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) {
146 if (fCanBeProtected) {
162 fIsTextureable =
false;
166 fShouldCreateMipMaps = shouldCreateMipMaps;
169 fVkRTSupportsInputAttachment = inputSupport;
172 fForVulkanSecondaryCommandBuffer = forVkSCB;
178 bool changed =
false;
179 auto set = [&changed](
auto& var,
auto value) {
205 set(fSampleCount, 4);
219 set(fUsesGLFBO0,
true);
220 set(fShouldCreateMipMaps,
222 set(fIsTextureable,
false);
226 set(fShouldCreateMipMaps,
228 set(fIsTextureable,
false);
232 set(fForVulkanSecondaryCommandBuffer,
true);
233 set(fUsesGLFBO0,
false);
234 set(fShouldCreateMipMaps,
236 set(fIsTextureable,
false);
237 set(fVkRTSupportsInputAttachment,
false);
257 if (!backendFormat.
isValid()) {
262 maxResourceBytes, ii, backendFormat, fSampleCount,
263 fOrigin, fSurfaceProps, fShouldCreateMipMaps,
264 fUsesGLFBO0, fIsTextureable, fIsProtected,
265 fVkRTSupportsInputAttachment,
266 fForVulkanSecondaryCommandBuffer);
299 static constexpr int kStencilBits = 8;
308 dContext, backendRT, fOrigin, fColorType, fColorSpace, &fSurfaceProps);
315 if (fForVulkanSecondaryCommandBuffer) {
320 if (fIsTextureable) {
327 fShouldCreateMipMaps,
367 vkInfo.fColorAttachmentIndex = 0;
368 vkInfo.fCompatibleRenderPass = (VkRenderPass)1;
370 vkInfo.fDrawBounds =
nullptr;
378 bool fCanBeProtected;
391 bool fVkRTSupportsInputAttachment;
392 bool fForVulkanSecondaryCommandBuffer;
400 auto context = ctxInfo.directContext();
404 bool didModify1 =
i >= 0 && params1.
modify(
i);
413 bool didModify2 = j >= 0 && params2.
modify(j);
420 if (
i == j || (!didModify1 && !didModify2)) {
450 bitmap.allocPixels(imageInfo);
458 params.setVkRTInputAttachmentSupport(
true);
460 ddl =
params.createDDL(dContext);
470 s->readPixels(imageInfo,
bitmap.getPixels(),
bitmap.rowBytes(), 0, 0);
488 "DDLSurfaceCharacterizationTest failed on parameter: %d\n",
i);
507 context->setResourceCacheLimits(2*maxResourceCount, maxResourceBytes);
509 s->readPixels(imageInfo,
bitmap.getPixels(),
bitmap.rowBytes(), 0, 0);
511 context->setResourceCacheLimits(maxResourceCount, 2*maxResourceBytes);
513 s->readPixels(imageInfo,
bitmap.getPixels(),
bitmap.rowBytes(), 0, 0);
515 context->setResourceCacheLimits(maxResourceCount, maxResourceBytes);
517 s->readPixels(imageInfo,
bitmap.getPixels(),
bitmap.rowBytes(), 0, 0);
526 params.disableTextureability();
635 if (newBackendFormat.isValid()) {
654 params.disableTextureability();
693 auto context = ctxInfo.directContext();
694 const GrCaps* caps = context->priv().caps();
696 const size_t resourceCacheLimit = context->getResourceCacheLimit();
701 if (availableSamples <= 1) {
708 static constexpr int kStencilBits = 8;
709 static constexpr bool kNotTextureable =
false;
713 static const bool kExpectedCompatibility[4][4] = {
715 {
true,
false,
false,
false },
716 {
false,
true,
false,
true },
717 {
false,
false,
true,
false },
718 {
false,
false,
false,
true }
725 for (
bool isFBO0 : {
true,
false }) {
726 for (
int numSamples : { availableSamples, 1 }) {
736 SkASSERT(characterizations[index].sampleCount() == numSamples);
737 SkASSERT(characterizations[index].usesGLFBO0() == isFBO0);
754 for (
int c = 0; c < 4; ++c) {
755 for (
int s = 0;
s < 4; ++
s) {
757 kExpectedCompatibility[c][
s] ==
758 surfaces[
s]->isCompatible(characterizations[c]));
769 auto dContext = ctxInfo.directContext();
782 scbDrawContext->releaseResources();
790 auto context = ctxInfo.directContext();
795#if defined(SK_VULKAN)
820 auto context = ctxInfo.directContext();
826 bitmap.allocPixels(imageInfo);
828 for (
bool textureability : {
true,
false }) {
835 params.disableTextureability();
837 params.setVkRTInputAttachmentSupport(
true);
840 ddl =
params.createDDL(context);
846 if (!textureability) {
847 params.disableTextureability();
850 params.setVkRTInputAttachmentSupport(
true);
859 s->readPixels(imageInfo,
bitmap.getPixels(),
bitmap.rowBytes(), 0, 0);
930 auto context = ctxInfo.directContext();
935#if defined(SK_VULKAN)
970 auto dContext = ctxInfo.directContext();
972 auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(dContext,
1012 sk_gpu_test::ManagedBackendTexture::ReleaseProc,
1023 auto dContext = ctxInfo.directContext();
1052 using namespace skgpu;
1054 auto dContext = ctxInfo.directContext();
1055 size_t maxResourceBytes = dContext->getResourceCacheLimit();
1056 auto proxy = dContext->threadSafeProxy().get();
1058 Protected isProtected =
Protected(dContext->priv().caps()->supportsProtectedContent());
1060 auto check_create_fails = [proxy,
reporter, maxResourceBytes](
1068 bool vkRTSupportsInputAttachment,
1069 bool forVulkanSecondaryCommandBuffer) {
1086 vkRTSupportsInputAttachment,
1087 forVulkanSecondaryCommandBuffer);
1101 static const bool kIsTextureable =
true;
1102 static const bool kIsNotTextureable =
false;
1104 static const bool kGoodUseFBO0 =
false;
1105 static const bool kBadUseFBO0 =
true;
1107 static const bool kGoodVkInputAttachment =
false;
1108 static const bool kBadVkInputAttachment =
true;
1110 static const bool kGoodForVkSCB =
false;
1111 static const bool kBadForVkSCB =
true;
1114 int goodHeight = 64;
1115 int badWidths[] = { 0, 1048576 };
1116 int badHeights[] = { 0, 1048576 };
1121 check_create_fails(goodBackendFormat, goodWidth, badHeights[0], kGoodCT, kGoodUseFBO0,
1122 kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
1123 check_create_fails(goodBackendFormat, goodWidth, badHeights[1], kGoodCT, kGoodUseFBO0,
1124 kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
1125 check_create_fails(goodBackendFormat, badWidths[0], goodHeight, kGoodCT, kGoodUseFBO0,
1126 kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
1127 check_create_fails(goodBackendFormat, badWidths[1], goodHeight, kGoodCT, kGoodUseFBO0,
1128 kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
1129 check_create_fails(badBackendFormat, goodWidth, goodHeight, kGoodCT, kGoodUseFBO0,
1130 kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
1131 check_create_fails(goodBackendFormat, goodWidth, goodHeight, kBadCT, kGoodUseFBO0,
1132 kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
1135 check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kBadUseFBO0,
1136 kIsTextureable, isProtected, kGoodVkInputAttachment, kGoodForVkSCB);
1140 check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kGoodUseFBO0,
1141 kIsTextureable, isProtected, kGoodVkInputAttachment, kBadForVkSCB);
1144 check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kGoodUseFBO0,
1145 kIsNotTextureable, isProtected, kBadVkInputAttachment,
1149 check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kBadUseFBO0,
1150 kIsNotTextureable, isProtected, kGoodVkInputAttachment,
1154 check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kGoodUseFBO0,
1155 kIsTextureable, isProtected, kBadVkInputAttachment, kGoodForVkSCB);
1156 check_create_fails(goodBackendFormat, goodWidth, goodHeight, kGoodCT, kGoodUseFBO0,
1157 kIsNotTextureable, isProtected, kGoodVkInputAttachment,
1173 info->fFulfilled =
true;
1179 info->fReleased =
true;
1186 using namespace skgpu;
1188 auto context = ctxInfo.directContext();
1190 Protected isProtected =
Protected(context->priv().caps()->supportsProtectedContent());
1198 auto mbet = sk_gpu_test::ManagedBackendTexture::MakeFromInfo(context, ii,
1239 context->flushAndSubmit();
1250 context->flush(
s.get());
1262 auto context = ctxInfo.directContext();
1303 s->readPixels(ii,
bitmap.getPixels(),
bitmap.rowBytes(), 0, 0);
1304 for (
int y = 0;
y < 32; ++
y) {
1305 for (
int x = 0;
x < 32; ++
x) {
1325 auto context = ctxInfo.directContext();
1340 recorder.getCanvas()->recordingContext()->threadSafeProxy(),
1355 if (!context->priv().caps()->isFormatTexturable(
format,
format.textureType())) {
1377 auto context = ctxInfo.directContext();
1384 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)
DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(DDLOperatorEqTest, reporter, ctxInfo, CtsEnforcement::kNever)
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)
DEF_GANESH_TEST_FOR_GL_CONTEXT(DDLCompatibilityTest, reporter, ctxInfo, CtsEnforcement::kNever)
static void tracking_release_proc(void *context)
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
#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
@ 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,...)
GrBackendFormat getBackendFormat() const
GrBackendApi backend() const
const GrCaps * caps() const
bool mipmapSupport() const
bool supportsProtectedContent() 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 GrDeferredDisplayList::LazyProxyData * lazyProxyData() const
const GrSurfaceCharacterization & characterization() const
sk_sp< GrDeferredDisplayList > detach()
GrDeferredDisplayListPriv priv()
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
bool characterize(GrSurfaceCharacterization *characterization) const
@ kFlushRead
back-end object is readable
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, std::string_view label={})
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)
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
static constexpr skcms_Matrix3x3 kAdobeRGB
static constexpr skcms_TransferFunction kSRGB
sk_sp< const SkImage > image
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)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
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