Add fixes & test for isConfigTexturable and isConfigRenderable
This CL fixes: isConfigTexturable was returning true for: kRG_float for ANGLE ES2 configs isConfigRenderable was returning true for: kAlpha_8 for ANGLE ES2 configs isConfigTexturable and isConfigRenderable were returning true for: SBGRA on ES2 The NexusPlayer was marking RGBA & RG float configs as renderable but not textureable Bug: 720325 Change-Id: If21361870dbdde8f3e09bc9dff3a394f2a329157 Reviewed-on: https://skia-review.googlesource.com/17387 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
e2fc563234
commit
b7b7e5fba0
@ -159,7 +159,7 @@ public:
|
||||
|
||||
int maxWindowRectangles() const { return fMaxWindowRectangles; }
|
||||
|
||||
virtual bool isConfigTexturable(GrPixelConfig config) const = 0;
|
||||
virtual bool isConfigTexturable(GrPixelConfig) const = 0;
|
||||
virtual bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const = 0;
|
||||
virtual bool canConfigBeImageStorage(GrPixelConfig config) const = 0;
|
||||
|
||||
|
@ -378,6 +378,7 @@ bool GrGpu::writePixels(GrSurface* surface,
|
||||
int left, int top, int width, int height,
|
||||
GrPixelConfig config, const SkTArray<GrMipLevel>& texels) {
|
||||
SkASSERT(surface);
|
||||
|
||||
for (int currentMipLevel = 0; currentMipLevel < texels.count(); currentMipLevel++) {
|
||||
if (!texels[currentMipLevel].fPixels ) {
|
||||
return false;
|
||||
|
@ -986,9 +986,10 @@ void GrGLCaps::initFSAASupport(const GrContextOptions& contextOptions, const GrG
|
||||
} else if (fUsesMixedSamples) {
|
||||
fMSFBOType = kMixedSamples_MSFBOType;
|
||||
} else if (ctxInfo.version() >= GR_GL_VER(3,0) ||
|
||||
ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample") ||
|
||||
ctxInfo.hasExtension("GL_ANGLE_framebuffer_multisample")) {
|
||||
ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) {
|
||||
fMSFBOType = kStandard_MSFBOType;
|
||||
} else if (ctxInfo.hasExtension("GL_ANGLE_framebuffer_multisample")) {
|
||||
fMSFBOType = kEXT_MSFBOType;
|
||||
} else if (ctxInfo.hasExtension("GL_APPLE_framebuffer_multisample")) {
|
||||
fMSFBOType = kES_Apple_MSFBOType;
|
||||
}
|
||||
@ -1637,7 +1638,6 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
|
||||
fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
|
||||
}
|
||||
fConfigTable[kSRGBA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
|
||||
|
||||
// sBGRA is not a "real" thing in OpenGL, but GPUs support it, and on platforms where
|
||||
// kN32 == BGRA, we need some way to work with it. (The default framebuffer on Windows
|
||||
// is in this format, for example).
|
||||
@ -1649,10 +1649,11 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
|
||||
GR_GL_BGRA;
|
||||
fConfigTable[kSBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
|
||||
fConfigTable[kSBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
||||
if (fSRGBSupport) {
|
||||
if (fSRGBSupport && kGL_GrGLStandard == standard) {
|
||||
fConfigTable[kSBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag |
|
||||
allRenderFlags;
|
||||
}
|
||||
|
||||
if (texStorageSupported) {
|
||||
fConfigTable[kSBGRA_8888_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
|
||||
}
|
||||
@ -1803,6 +1804,7 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
|
||||
// [half] floating point textures became part of the standard in ES3.1 / OGL 3.0.
|
||||
bool hasFPTextures = false;
|
||||
bool hasHalfFPTextures = false;
|
||||
bool rgIsTexturable = false;
|
||||
// for now we don't support floating point MSAA on ES
|
||||
uint32_t fpRenderFlags = (kGL_GrGLStandard == standard) ? allRenderFlags : nonMSAARenderFlags;
|
||||
|
||||
@ -1810,11 +1812,13 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
|
||||
if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_texture_float")) {
|
||||
hasFPTextures = true;
|
||||
hasHalfFPTextures = true;
|
||||
rgIsTexturable = true;
|
||||
}
|
||||
} else {
|
||||
if (version >= GR_GL_VER(3, 1)) {
|
||||
hasFPTextures = true;
|
||||
hasHalfFPTextures = true;
|
||||
rgIsTexturable = true;
|
||||
} else {
|
||||
if (ctxInfo.hasExtension("GL_OES_texture_float_linear") &&
|
||||
ctxInfo.hasExtension("GL_OES_texture_float")) {
|
||||
@ -1836,7 +1840,7 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
|
||||
fConfigTable[fpconfig].fFormats.fExternalType = GR_GL_FLOAT;
|
||||
fConfigTable[fpconfig].fFormatType = kFloat_FormatType;
|
||||
if (hasFPTextures) {
|
||||
fConfigTable[fpconfig].fFlags = ConfigInfo::kTextureable_Flag;
|
||||
fConfigTable[fpconfig].fFlags = rgIsTexturable ? ConfigInfo::kTextureable_Flag : 0;
|
||||
// For now we only enable rendering to float on desktop, because on ES we'd have to
|
||||
// solve many precision issues and no clients actually want this yet.
|
||||
if (kGL_GrGLStandard == standard /* || version >= GR_GL_VER(3,2) ||
|
||||
|
@ -318,10 +318,11 @@ void GrVkCaps::ConfigInfo::InitConfigFlags(VkFormatFeatureFlags vkFlags, uint16_
|
||||
if (SkToBool(VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT & vkFlags) &&
|
||||
SkToBool(VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT & vkFlags)) {
|
||||
*flags = *flags | kTextureable_Flag;
|
||||
}
|
||||
|
||||
if (SkToBool(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT & vkFlags)) {
|
||||
*flags = *flags | kRenderable_Flag;
|
||||
// Ganesh assumes that all renderable surfaces are also texturable
|
||||
if (SkToBool(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT & vkFlags)) {
|
||||
*flags = *flags | kRenderable_Flag;
|
||||
}
|
||||
}
|
||||
|
||||
if (SkToBool(VK_FORMAT_FEATURE_BLIT_SRC_BIT & vkFlags)) {
|
||||
|
@ -70,4 +70,57 @@ DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrSurface, reporter, ctxInfo) {
|
||||
context->getGpu()->deleteTestingOnlyBackendTexture(backendTexHandle);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// This test checks that the isConfigTexturable and isConfigRenderable are
|
||||
// consistent with createTexture's result.
|
||||
DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
|
||||
GrContext* context = ctxInfo.grContext();
|
||||
const GrCaps* caps = context->caps();
|
||||
|
||||
GrPixelConfig configs[] = {
|
||||
kUnknown_GrPixelConfig,
|
||||
kAlpha_8_GrPixelConfig,
|
||||
kGray_8_GrPixelConfig,
|
||||
kRGB_565_GrPixelConfig,
|
||||
kRGBA_4444_GrPixelConfig,
|
||||
kRGBA_8888_GrPixelConfig,
|
||||
kBGRA_8888_GrPixelConfig,
|
||||
kSRGBA_8888_GrPixelConfig,
|
||||
kSBGRA_8888_GrPixelConfig,
|
||||
kRGBA_8888_sint_GrPixelConfig,
|
||||
kETC1_GrPixelConfig,
|
||||
kRGBA_float_GrPixelConfig,
|
||||
kRG_float_GrPixelConfig,
|
||||
kAlpha_half_GrPixelConfig,
|
||||
kRGBA_half_GrPixelConfig,
|
||||
};
|
||||
SkASSERT(kGrPixelConfigCnt == SK_ARRAY_COUNT(configs));
|
||||
|
||||
GrSurfaceDesc desc;
|
||||
desc.fWidth = 64;
|
||||
desc.fHeight = 64;
|
||||
|
||||
for (GrPixelConfig config : configs) {
|
||||
for (GrSurfaceOrigin origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
|
||||
desc.fFlags = kNone_GrSurfaceFlags;
|
||||
desc.fOrigin = origin;
|
||||
desc.fSampleCnt = 0;
|
||||
desc.fConfig = config;
|
||||
|
||||
sk_sp<GrSurface> tex = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo);
|
||||
REPORTER_ASSERT(reporter, SkToBool(tex.get()) == caps->isConfigTexturable(desc.fConfig,
|
||||
desc.fOrigin));
|
||||
|
||||
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||
tex = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo);
|
||||
REPORTER_ASSERT(reporter, SkToBool(tex.get()) == caps->isConfigRenderable(config, false));
|
||||
|
||||
desc.fSampleCnt = 4;
|
||||
tex = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo);
|
||||
REPORTER_ASSERT(reporter, SkToBool(tex.get()) == caps->isConfigRenderable(config, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -42,6 +42,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) {
|
||||
static const size_t kRowBytes = kS * sizeof(int32_t);
|
||||
|
||||
GrSurfaceDesc desc;
|
||||
desc.fOrigin = kTopLeft_GrSurfaceOrigin;
|
||||
desc.fConfig = kRGBA_8888_sint_GrPixelConfig;
|
||||
desc.fWidth = kS;
|
||||
desc.fHeight = kS;
|
||||
|
@ -297,7 +297,7 @@ class GrPipeline;
|
||||
class MockCaps : public GrCaps {
|
||||
public:
|
||||
explicit MockCaps(const GrContextOptions& options) : INHERITED(options) {}
|
||||
bool isConfigTexturable(GrPixelConfig config) const override { return false; }
|
||||
bool isConfigTexturable(GrPixelConfig) const override { return false; }
|
||||
bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override { return false; }
|
||||
bool canConfigBeImageStorage(GrPixelConfig) const override { return false; }
|
||||
bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc,
|
||||
|
Loading…
Reference in New Issue
Block a user