47#include <initializer_list>
78 if (gsc.usesGLFBO0()) {
83 if (gsc.vulkanSecondaryCBCompatible()) {
87 if (gsc.vkRTSupportsInputAttachment()) {
126 : fBackend(rContext->
backend())
127 , fCanBeProtected(false)
137 , fIsTextureable(
true)
139 , fVkRTSupportsInputAttachment(false)
140 , fForVulkanSecondaryCommandBuffer(false) {
144 fCanBeProtected = vkCaps->supportsProtectedContent();
145 if (fCanBeProtected) {
146 fIsProtected = skgpu::Protected::kYes;
151 fShouldCreateMipMaps = skgpu::Mipmapped::kNo;
161 fIsTextureable =
false;
162 fShouldCreateMipMaps = skgpu::Mipmapped::kNo;
165 fShouldCreateMipMaps = shouldCreateMipMaps;
168 fVkRTSupportsInputAttachment = inputSupport;
171 fForVulkanSecondaryCommandBuffer = forVkSCB;
177 bool changed =
false;
178 auto set = [&changed](
auto& var,
auto value) {
204 set(fSampleCount, 4);
214 set(fShouldCreateMipMaps, skgpu::Mipmapped::kNo);
218 set(fUsesGLFBO0,
true);
219 set(fShouldCreateMipMaps,
220 skgpu::Mipmapped::kNo);
221 set(fIsTextureable,
false);
225 set(fShouldCreateMipMaps,
226 skgpu::Mipmapped::kNo);
227 set(fIsTextureable,
false);
230 if (fCanBeProtected) {
236 set(fForVulkanSecondaryCommandBuffer,
true);
237 set(fUsesGLFBO0,
false);
238 set(fShouldCreateMipMaps,
239 skgpu::Mipmapped::kNo);
240 set(fIsTextureable,
false);
241 set(fVkRTSupportsInputAttachment,
false);
261 if (!backendFormat.
isValid()) {
266 maxResourceBytes, ii, backendFormat, fSampleCount,
267 fOrigin, fSurfaceProps, fShouldCreateMipMaps,
268 fUsesGLFBO0, fIsTextureable, fIsProtected,
269 fVkRTSupportsInputAttachment,
270 fForVulkanSecondaryCommandBuffer);
303 static constexpr int kStencilBits = 8;
312 dContext, backendRT, fOrigin, fColorType, fColorSpace, &fSurfaceProps);
319 if (fForVulkanSecondaryCommandBuffer) {
324 if (fIsTextureable) {
331 fShouldCreateMipMaps,
336 SkASSERT(fShouldCreateMipMaps == skgpu::Mipmapped::kNo);
353 surface.get(), SkSurfaces::BackendHandleAccess::kFlushRead);
371 vkInfo.fColorAttachmentIndex = 0;
372 vkInfo.fCompatibleRenderPass = (VkRenderPass)1;
374 vkInfo.fDrawBounds =
nullptr;
382 bool fCanBeProtected;
395 bool fVkRTSupportsInputAttachment;
396 bool fForVulkanSecondaryCommandBuffer;
404 auto context = ctxInfo.directContext();
408 bool didModify1 = i >= 0 && params1.
modify(i);
417 bool didModify2 = j >= 0 && params2.
modify(j);
424 if (i == j || (!didModify1 && !didModify2)) {
454 bitmap.allocPixels(imageInfo);
462 params.setVkRTInputAttachmentSupport(
true);
464 ddl =
params.createDDL(dContext);
474 s->readPixels(imageInfo,
bitmap.getPixels(),
bitmap.rowBytes(), 0, 0);
492 "DDLSurfaceCharacterizationTest failed on parameter: %d\n", i);
511 context->setResourceCacheLimits(2*maxResourceCount, maxResourceBytes);
513 s->readPixels(imageInfo,
bitmap.getPixels(),
bitmap.rowBytes(), 0, 0);
515 context->setResourceCacheLimits(maxResourceCount, 2*maxResourceBytes);
517 s->readPixels(imageInfo,
bitmap.getPixels(),
bitmap.rowBytes(), 0, 0);
519 context->setResourceCacheLimits(maxResourceCount, maxResourceBytes);
521 s->readPixels(imageInfo,
bitmap.getPixels(),
bitmap.rowBytes(), 0, 0);
530 params.disableTextureability();
639 if (newBackendFormat.isValid()) {
658 params.disableTextureability();
697 auto context = ctxInfo.directContext();
698 const GrCaps* caps = context->priv().caps();
700 const size_t resourceCacheLimit = context->getResourceCacheLimit();
705 if (availableSamples <= 1) {
712 static constexpr int kStencilBits = 8;
713 static constexpr bool kNotTextureable =
false;
717 static const bool kExpectedCompatibility[4][4] = {
719 {
true,
false,
false,
false },
720 {
false,
true,
false,
true },
721 {
false,
false,
true,
false },
722 {
false,
false,
false,
true }
729 for (
bool isFBO0 : {
true,
false }) {
730 for (
int numSamples : { availableSamples, 1 }) {
731 characterizations[index] = proxy->createCharacterization(resourceCacheLimit,
737 skgpu::Mipmapped::kNo,
740 SkASSERT(characterizations[index].sampleCount() == numSamples);
741 SkASSERT(characterizations[index].usesGLFBO0() == isFBO0);
758 for (
int c = 0; c < 4; ++c) {
759 for (
int s = 0;
s < 4; ++
s) {
761 kExpectedCompatibility[c][
s] ==
762 surfaces[
s]->isCompatible(characterizations[c]));
773 auto dContext = ctxInfo.directContext();
786 scbDrawContext->releaseResources();
794 auto context = ctxInfo.directContext();
799#if defined(SK_VULKAN)
824 auto context = ctxInfo.directContext();
830 bitmap.allocPixels(imageInfo);
832 for (
bool textureability : {
true,
false }) {
839 params.disableTextureability();
841 params.setVkRTInputAttachmentSupport(
true);
844 ddl =
params.createDDL(context);
850 if (!textureability) {
851 params.disableTextureability();
854 params.setVkRTInputAttachmentSupport(
true);
863 s->readPixels(imageInfo,
bitmap.getPixels(),
bitmap.rowBytes(), 0, 0);
922 if (i >= 0 && !
params.modify(i)) {
934 auto context = ctxInfo.directContext();
939#if defined(SK_VULKAN)
974 auto dContext = ctxInfo.directContext();
976 auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(dContext,
980 skgpu::Mipmapped::kNo,
982 skgpu::Protected::kNo);
1016 sk_gpu_test::ManagedBackendTexture::ReleaseProc,
1027 auto dContext = ctxInfo.directContext();
1056 using namespace skgpu;
1058 auto dContext = ctxInfo.directContext();
1059 size_t maxResourceBytes = dContext->getResourceCacheLimit();
1060 auto proxy = dContext->threadSafeProxy().
get();
1062 Protected isProtected =
Protected(dContext->priv().caps()->supportsProtectedContent());
1064 auto check_create_fails = [proxy,
reporter, maxResourceBytes](
1072 bool vkRTSupportsInputAttachment,
1073 bool forVulkanSecondaryCommandBuffer) {
1080 proxy->createCharacterization(maxResourceBytes,
1090 vkRTSupportsInputAttachment,
1091 forVulkanSecondaryCommandBuffer);
1096 GrRenderable::kYes);
1105 static const bool kIsTextureable =
true;
1106 static const bool kIsNotTextureable =
false;
1108 static const bool kGoodUseFBO0 =
false;
1109 static const bool kBadUseFBO0 =
true;
1111 static const bool kGoodVkInputAttachment =
false;
1112 static const bool kBadVkInputAttachment =
true;
1114 static const bool kGoodForVkSCB =
false;
1115 static const bool kBadForVkSCB =
true;
1118 int goodHeight = 64;
1119 int badWidths[] = { 0, 1048576 };
1120 int badHeights[] = { 0, 1048576 };
1125 check_create_fails(goodBackendFormat, goodWidth, badHeights[0], kGoodCT, kGoodUseFBO0,
1126 kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
1127 check_create_fails(goodBackendFormat, goodWidth, badHeights[1], kGoodCT, kGoodUseFBO0,
1128 kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
1129 check_create_fails(goodBackendFormat, badWidths[0], goodHeight, kGoodCT, kGoodUseFBO0,
1130 kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
1131 check_create_fails(goodBackendFormat, badWidths[1], goodHeight, kGoodCT, kGoodUseFBO0,
1132 kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
1133 check_create_fails(badBackendFormat, goodWidth, goodHeight, kGoodCT, kGoodUseFBO0,
1134 kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
1135 check_create_fails(goodBackendFormat, goodWidth, goodHeight, kBadCT, kGoodUseFBO0,
1136 kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
1139 check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kBadUseFBO0,
1140 kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
1144 check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kGoodUseFBO0,
1145 kIsTextureable, isProtected, kGoodVkInputAttachment, kBadForVkSCB);
1148 check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kGoodUseFBO0,
1149 kIsNotTextureable, isProtected, kBadVkInputAttachment,
1153 check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kBadUseFBO0,
1154 kIsNotTextureable, isProtected, kGoodVkInputAttachment,
1158 check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kGoodUseFBO0,
1159 kIsTextureable, isProtected, kBadVkInputAttachment, kGoodForVkSCB);
1160 check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kGoodUseFBO0,
1161 kIsNotTextureable, isProtected, kGoodVkInputAttachment,
1190 using namespace skgpu;
1192 auto context = ctxInfo.directContext();
1194 Protected isProtected =
Protected(context->priv().caps()->supportsProtectedContent());
1202 auto mbet = sk_gpu_test::ManagedBackendTexture::MakeFromInfo(context, ii,
1229 skgpu::Mipmapped::kNo,
1243 context->flushAndSubmit();
1254 context->flush(
s.get());
1266 auto context = ctxInfo.directContext();
1307 s->readPixels(ii,
bitmap.getPixels(),
bitmap.rowBytes(), 0, 0);
1308 for (
int y = 0;
y < 32; ++
y) {
1309 for (
int x = 0;
x < 32; ++
x) {
1329 auto context = ctxInfo.directContext();
1340 for (
auto mipmapped : {skgpu::Mipmapped::kNo, skgpu::Mipmapped::kYes}) {
1344 recorder.getCanvas()->recordingContext()->threadSafeProxy(),
1359 if (!context->priv().caps()->isFormatTexturable(
format,
format.textureType())) {
1381 auto context = ctxInfo.directContext();
1388 params.setColorSpace(
nullptr);
static bool invalid(const SkISize &size)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static constexpr int kSize
static sk_sp< GrPromiseImageTexture > tracking_fulfill_proc(void *context)
static bool is_compatible(const GrSurfaceCharacterization &gsc, const GrBackendTexture &backendTex)
static void test_make_render_target(skiatest::Reporter *reporter, GrDirectContext *dContext, const SurfaceParameters ¶ms)
void DDLMakeRenderTargetTestImpl(GrDirectContext *dContext, skiatest::Reporter *reporter)
void DDLSurfaceCharacterizationTestImpl(GrDirectContext *dContext, skiatest::Reporter *reporter)
static void tracking_release_proc(void *context)
#define GR_GL_TEXTURE_RECTANGLE
#define GR_GL_TEXTURE_EXTERNAL
@ kBottomLeft_GrSurfaceOrigin
@ kTopLeft_GrSurfaceOrigin
skgpu::Protected Protected
@ kOpaque_SkAlphaType
pixel is opaque
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
#define SkAssertResult(cond)
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
@ kLastEnum_SkColorType
last valid value
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kUnknown_SkColorType
uninitialized
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorGREEN
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.
@ kUnknown_SkPixelGeometry
static constexpr bool SkToBool(const T &x)
#define DEF_GANESH_TEST_FOR_VULKAN_CONTEXT(name, reporter, context_info, ctsEnforcement)
#define DEF_GANESH_TEST(name, reporter, options, ctsEnforcement)
#define REPORTER_ASSERT(r, cond,...)
#define DEF_GANESH_TEST_FOR_GL_CONTEXT(name, reporter, context_info, ctsEnforcement)
#define DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(name, reporter, context_info, ctsEnforcement)
GrBackendFormat getBackendFormat() const
GrBackendApi backend() const
const GrCaps * caps() const
bool mipmapSupport() const
virtual int getRenderTargetSampleCount(int requestedCount, const GrBackendFormat &) const =0
GrSurfaceCharacterization createCharacterization(size_t cacheMaxResourceBytes, const SkImageInfo &ii, const GrBackendFormat &backendFormat, int sampleCount, GrSurfaceOrigin origin, const SkSurfaceProps &surfaceProps, skgpu::Mipmapped isMipmapped, bool willUseGLFBO0=false, bool isTextureable=true, skgpu::Protected isProtected=GrProtected::kNo, bool vkRTSupportsInputAttachment=false, bool forVulkanSecondaryCommandBuffer=false)
SK_API GrBackendApi backend() const
sk_sp< GrContextThreadSafeProxy > threadSafeProxy()
SK_API GrBackendFormat defaultBackendFormat(SkColorType, GrRenderable) const
const GrSurfaceCharacterization & characterization() const
sk_sp< GrDeferredDisplayList > detach()
SK_API bool colorTypeSupportedAsSurface(SkColorType colorType) const
size_t getResourceCacheLimit() const
GrSemaphoresSubmitted flush(const GrFlushInfo &info)
sk_sp< GrContextThreadSafeProxy > threadSafeProxy()
void setResourceCacheLimit(size_t maxResourceBytes)
static sk_sp< GrPromiseImageTexture > Make(const GrBackendTexture &backendTexture)
GrRecordingContextPriv priv()
GrSurfaceCharacterization createColorSpace(sk_sp< SkColorSpace >) const
GrSurfaceCharacterization createFBO0(bool usesGLFBO0) const
GrSurfaceCharacterization createResized(int width, int height) const
SkColorSpace * colorSpace() const
GrSurfaceCharacterization createBackendFormat(SkColorType colorType, const GrBackendFormat &backendFormat) const
bool hasRestrictedSampling() const
skgpu::Mipmapped mipmapped() const
static sk_sp< GrVkSecondaryCBDrawContext > Make(GrRecordingContext *, const SkImageInfo &, const GrVkDrawableInfo &, const SkSurfaceProps *props)
void drawRect(const SkRect &rect, const SkPaint &paint)
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
virtual GrRecordingContext * recordingContext() const
void clear(SkColor color)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
bool gammaIsLinear() const
static sk_sp< SkColorSpace > MakeRGB(const skcms_TransferFunction &transferFn, const skcms_Matrix3x3 &toXYZ)
static sk_sp< SkColorSpace > MakeSRGBLinear()
@ kUseDeviceIndependentFonts_Flag
sk_sp< GrDeferredDisplayList > createDDL(GrDirectContext *dContext) const
void setVkRTInputAttachmentSupport(bool inputSupport)
static const int kFBO0Count
void setColorType(SkColorType ct)
sk_sp< SkSurface > make(GrDirectContext *dContext) const
static const int kNumParams
void setColorSpace(sk_sp< SkColorSpace > cs)
void setForVulkanSecondaryCommandBuffer(bool forVkSCB)
GrSurfaceCharacterization createCharacterization(GrDirectContext *dContext) const
SkColorType colorType() const
SurfaceParameters(GrRecordingContext *rContext)
void disableTextureability()
void setShouldCreateMipMaps(skgpu::Mipmapped shouldCreateMipMaps)
static const int kVkSCBCount
void reset(T *ptr=nullptr)
const EmbeddedViewParams * params
uint32_t uint32_t * format
SK_API GrBackendRenderTarget MakeGL(int width, int height, int sampleCnt, int stencilBits, const GrGLFramebufferInfo &glInfo)
SK_API bool GetVkImageInfo(const GrBackendTexture &, GrVkImageInfo *)
SK_API sk_sp< SkImage > PromiseTextureFrom(skgpu::graphite::Recorder *, SkISize dimensions, const skgpu::graphite::TextureInfo &, const SkColorInfo &, skgpu::Origin origin, skgpu::graphite::Volatile, GraphitePromiseTextureFulfillProc, GraphitePromiseImageReleaseProc, GraphitePromiseTextureReleaseProc, GraphitePromiseImageContext)
SK_API sk_sp< SkImage > BorrowTextureFrom(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
static constexpr skcms_Matrix3x3 kAdobeRGB
static constexpr skcms_TransferFunction kSRGB
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SK_API sk_sp< SkSurface > WrapBackendRenderTarget(GrRecordingContext *context, const GrBackendRenderTarget &backendRenderTarget, GrSurfaceOrigin origin, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, RenderTargetReleaseProc releaseProc=nullptr, ReleaseContext releaseContext=nullptr)
@ kPresent
back-end surface will be used for presenting to screen
SK_API GrBackendTexture GetBackendTexture(SkSurface *, BackendHandleAccess)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
sk_sp< SkSurface > MakeBackendRenderTargetSurface(GrDirectContext *dContext, const SkImageInfo &ii, GrSurfaceOrigin origin, int sampleCnt, GrProtected isProtected, const SkSurfaceProps *props)
GrTextureProxy * GetTextureImageProxy(SkImage *image, GrRecordingContext *rContext)
sk_sp< SkSurface > MakeBackendTextureSurface(GrDirectContext *dContext, const SkImageInfo &ii, GrSurfaceOrigin origin, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected isProtected, const SkSurfaceProps *props)
SK_API bool DrawDDL(SkSurface *, sk_sp< const GrDeferredDisplayList > ddl)
sk_sp< GrPromiseImageTexture > fTex
skgpu::Protected fProtected
VkCommandBuffer fSecondaryCommandBuffer
VkImageUsageFlags fImageUsageFlags
static constexpr SkISize Make(int32_t w, int32_t h)
static SkImageInfo MakeN32Premul(int width, int height)
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
static constexpr SkRect MakeWH(float w, float h)
static void Release(void *self)
@ VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT
@ VK_FORMAT_R8G8B8A8_UNORM