Move compatible stencil tracking from GrGLCaps::fConfigTable to ::fFormatTable.
Also adds the following to the format table:
*base internal format
*sized internal format
*compressed internal format
*the internal format to use with glTexImage
*the external type to use with glTexImage when there is no data to upload
(i.e., no GrColorType for data)
Bug: skia:6718
Change-Id: Ica51a8d4588bd24078c7d61805f6eef9c02ae14d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/226558
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 95f9d4a..828637d 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -1371,6 +1371,12 @@
return true;
}
+void GrGLCaps::setStencilFormatIndexForFormat(GrGLSizedInternalFormat format, int index) {
+ SkASSERT(!this->hasStencilFormatBeenDeterminedForFormat(format));
+ this->getFormatInfo(format).fStencilFormatIndex =
+ index < 0 ? FormatInfo::kUnsupported_StencilFormatIndex : index;
+}
+
void GrGLCaps::initFormatTable(const GrContextOptions& contextOptions,
const GrGLContextInfo& ctxInfo, const GrGLInterface* gli,
const FormatWorkarounds& formatWorkarounds) {
@@ -1406,6 +1412,11 @@
texStorageSupported = false;
#endif
+ // ES 2.0 requires that the internal/external formats match so we can't use sized internal
+ // formats for glTexImage until ES 3.0. TODO: Support sized internal formats in WebGL2.
+ bool texImageSupportsSizedInternalFormat =
+ (GR_IS_GR_GL(standard) || (GR_IS_GR_GL_ES(standard) && version >= GR_GL_VER(3,0)));
+
// This is set when we know we have both texture and render support for:
// R 8/16/16F
// RG 8/16/16F
@@ -1499,9 +1510,19 @@
///////////////////////////////////////////////////////////////////////////
+ GrGLenum halfFloatType = GR_GL_HALF_FLOAT;
+ if (GR_IS_GR_GL_ES(standard) && version < GR_GL_VER(3, 0)) {
+ halfFloatType = GR_GL_HALF_FLOAT_OES;
+ }
+
// RGBA8
{
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRGBA8);
+ info.fBaseInternalFormat = GR_GL_RGBA;
+ info.fSizedInternalFormat = GR_GL_RGBA8;
+ info.fInternalFormatForTexImage =
+ texImageSupportsSizedInternalFormat ? GR_GL_RGBA8 : GR_GL_RGBA;
+ info.fDefaultExternalType = GR_GL_UNSIGNED_BYTE;
info.fFlags = FormatInfo::kTextureable_Flag;
if (GR_IS_GR_GL(standard)) {
info.fFlags |= msaaRenderFlags;
@@ -1544,6 +1565,11 @@
// R8
{
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kR8);
+ info.fBaseInternalFormat = GR_GL_RED;
+ info.fSizedInternalFormat = GR_GL_R8;
+ info.fInternalFormatForTexImage =
+ texImageSupportsSizedInternalFormat ? GR_GL_R8 : GR_GL_RED;
+ info.fDefaultExternalType = GR_GL_UNSIGNED_BYTE;
if (textureRedSupport) {
info.fFlags |= FormatInfo::kTextureable_Flag | msaaRenderFlags;
}
@@ -1575,6 +1601,16 @@
bool alpha8IsValidForWebGL = GR_IS_GR_WEBGL(standard);
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kALPHA8);
+ info.fBaseInternalFormat = GR_GL_ALPHA;
+ info.fSizedInternalFormat = GR_GL_ALPHA8;
+ if (GR_IS_GR_GL_ES(standard) || !texImageSupportsSizedInternalFormat) {
+ // ES does not have sized internal format GL_ALPHA8.
+ info.fInternalFormatForTexImage = GR_GL_ALPHA;
+ } else {
+ info.fInternalFormatForTexImage = GR_GL_ALPHA8;
+ }
+
+ info.fDefaultExternalType = GR_GL_UNSIGNED_BYTE;
if (alpha8IsValidForGL || alpha8IsValidForGLES || alpha8IsValidForWebGL) {
info.fFlags = FormatInfo::kTextureable_Flag;
}
@@ -1601,6 +1637,11 @@
// LUMINANCE8
{
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kLUMINANCE8);
+ info.fBaseInternalFormat = GR_GL_LUMINANCE;
+ info.fSizedInternalFormat = GR_GL_LUMINANCE8;
+ info.fInternalFormatForTexImage =
+ texImageSupportsSizedInternalFormat ? GR_GL_LUMINANCE8 : GR_GL_LUMINANCE;
+ info.fDefaultExternalType = GR_GL_UNSIGNED_BYTE;
bool supportsLum = (GR_IS_GR_GL(standard) && version <= GR_GL_VER(3, 0)) ||
(GR_IS_GR_GL_ES(standard) && version < GR_GL_VER(3, 0)) ||
(GR_IS_GR_WEBGL(standard));
@@ -1634,6 +1675,25 @@
// BGRA8
{
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kBGRA8);
+ info.fBaseInternalFormat = GR_GL_BGRA;
+ info.fSizedInternalFormat = GR_GL_BGRA8;
+ // If BGRA is supported as an internal format it must always be specified to glTex[Sub]Image
+ // as a base format. Which base format depends on which extension is used.
+ if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) {
+ // GL_APPLE_texture_format_BGRA8888:
+ // ES 2.0: the extension makes BGRA an external format but not an internal format.
+ // ES 3.0: the extension explicitly states GL_BGRA8 is not a valid internal format
+ // for glTexImage (just for glTexStorage).
+ info.fInternalFormatForTexImage = GR_GL_RGBA;
+ } else {
+ // GL_EXT_texture_format_BGRA8888:
+ // This extension adds GL_BGRA as an unsized internal format. However, it is
+ // written against ES 2.0 and therefore doesn't define a GL_BGRA8 as ES 2.0 doesn't
+ // have sized internal formats.
+ info.fInternalFormatForTexImage = GR_GL_BGRA;
+ }
+
+ info.fDefaultExternalType = GR_GL_UNSIGNED_BYTE;
// TexStorage requires using a sized internal format and BGRA8 is only supported if we have
// the GL_APPLE_texture_format_BGRA8888 extension or if we have GL_EXT_texture_storage and
// GL_EXT_texture_format_BGRA8888.
@@ -1681,6 +1741,11 @@
// RGB565
{
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRGB565);
+ info.fBaseInternalFormat = GR_GL_RGB;
+ info.fSizedInternalFormat = GR_GL_RGB565;
+ info.fInternalFormatForTexImage =
+ texImageSupportsSizedInternalFormat ? GR_GL_RGB565 : GR_GL_RGB;
+ info.fDefaultExternalType = GR_GL_UNSIGNED_SHORT_5_6_5;
info.fFlags = FormatInfo::kTextureable_Flag;
if (GR_IS_GR_GL(standard)) {
if (version >= GR_GL_VER(4, 2) || ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) {
@@ -1712,6 +1777,11 @@
// RGBA16F
{
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRGBA16F);
+ info.fBaseInternalFormat = GR_GL_RGBA;
+ info.fSizedInternalFormat = GR_GL_RGBA16F;
+ info.fInternalFormatForTexImage =
+ texImageSupportsSizedInternalFormat ? GR_GL_RGBA16F : GR_GL_RGBA;
+ info.fDefaultExternalType = halfFloatType;
if (hasFP16Textures) {
info.fFlags = FormatInfo::kTextureable_Flag;
// ES requires 3.2 or EXT_color_buffer_half_float.
@@ -1742,6 +1812,11 @@
// R16F
{
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kR16F);
+ info.fBaseInternalFormat = GR_GL_RED;
+ info.fSizedInternalFormat = GR_GL_R16F;
+ info.fInternalFormatForTexImage =
+ texImageSupportsSizedInternalFormat ? GR_GL_R16F : GR_GL_RED;
+ info.fDefaultExternalType = halfFloatType;
if (textureRedSupport && hasFP16Textures) {
info.fFlags = FormatInfo::kTextureable_Flag;
if (halfFPRenderTargetSupport == HalfFPRenderTargetSupport::kAll) {
@@ -1765,6 +1840,11 @@
// RGB8
{
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRGB8);
+ info.fBaseInternalFormat = GR_GL_RGB;
+ info.fSizedInternalFormat = GR_GL_RGB8;
+ info.fInternalFormatForTexImage =
+ texImageSupportsSizedInternalFormat ? GR_GL_RGB8 : GR_GL_RGB;
+ info.fDefaultExternalType = GR_GL_UNSIGNED_BYTE;
info.fFlags = FormatInfo::kTextureable_Flag;
if (GR_IS_GR_GL(standard)) {
// Even in OpenGL 4.6 GL_RGB8 is required to be color renderable but not required to be
@@ -1801,6 +1881,11 @@
// RG8
{
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRG8);
+ info.fBaseInternalFormat = GR_GL_RG;
+ info.fSizedInternalFormat = GR_GL_RG8;
+ info.fInternalFormatForTexImage =
+ texImageSupportsSizedInternalFormat ? GR_GL_RG8 : GR_GL_RG;
+ info.fDefaultExternalType = GR_GL_UNSIGNED_BYTE;
if (textureRedSupport) {
info.fFlags |= FormatInfo::kTextureable_Flag | msaaRenderFlags;
if (texStorageSupported &&
@@ -1821,6 +1906,11 @@
// RGB10_A2
{
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRGB10_A2);
+ info.fBaseInternalFormat = GR_GL_RGBA;
+ info.fSizedInternalFormat = GR_GL_RGB10_A2;
+ info.fInternalFormatForTexImage =
+ texImageSupportsSizedInternalFormat ? GR_GL_RGB10_A2 : GR_GL_RGBA;
+ info.fDefaultExternalType = GR_GL_UNSIGNED_INT_2_10_10_10_REV;
if (GR_IS_GR_GL(standard) ||
(GR_IS_GR_GL_ES(standard) && version >= GR_GL_VER(3, 0))) {
info.fFlags = FormatInfo::kTextureable_Flag | msaaRenderFlags;
@@ -1844,6 +1934,11 @@
// RGBA4
{
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRGBA4);
+ info.fBaseInternalFormat = GR_GL_RGBA;
+ info.fSizedInternalFormat = GR_GL_RGBA4;
+ info.fInternalFormatForTexImage =
+ texImageSupportsSizedInternalFormat ? GR_GL_RGBA4 : GR_GL_RGBA;
+ info.fDefaultExternalType = GR_GL_UNSIGNED_SHORT_4_4_4_4;
info.fFlags = FormatInfo::kTextureable_Flag;
if (GR_IS_GR_GL(standard)) {
if (version >= GR_GL_VER(4, 2)) {
@@ -1874,6 +1969,11 @@
// SRGB8_ALPHA8
{
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kSRGB8_ALPHA8);
+ info.fBaseInternalFormat = GR_GL_RGBA;
+ info.fSizedInternalFormat = GR_GL_SRGB8_ALPHA8;
+ info.fInternalFormatForTexImage =
+ texImageSupportsSizedInternalFormat ? GR_GL_SRGB8_ALPHA8 : GR_GL_RGBA;
+ info.fDefaultExternalType = GR_GL_UNSIGNED_BYTE;
if (fSRGBSupport) {
uint32_t srgbRenderFlags =
formatWorkarounds.fDisableSRGBRenderWithMSAAForMacAMD ? nonMSAARenderFlags
@@ -1898,6 +1998,8 @@
// COMPRESSED_RGB8_ETC2
{
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kCOMPRESSED_RGB8_ETC2);
+ info.fBaseInternalFormat = GR_GL_RGB;
+ info.fCompressedInternalFormat = GR_GL_COMPRESSED_RGB8_ETC2;
if (GR_IS_GR_GL(standard)) {
if (version >= GR_GL_VER(4, 3) || ctxInfo.hasExtension("GL_ARB_ES3_compatibility")) {
info.fFlags = FormatInfo::kTextureable_Flag;
@@ -1915,6 +2017,8 @@
// COMPRESSED_ETC1_RGB8
{
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kCOMPRESSED_ETC1_RGB8);
+ info.fBaseInternalFormat = GR_GL_RGB;
+ info.fCompressedInternalFormat = GR_GL_COMPRESSED_ETC1_RGB8;
if (GR_IS_GR_GL_ES(standard)) {
if (ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture")) {
info.fFlags = FormatInfo::kTextureable_Flag;
@@ -1927,6 +2031,11 @@
// GR_GL_R16
{
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kR16);
+ info.fBaseInternalFormat = GR_GL_RED;
+ info.fSizedInternalFormat = GR_GL_R16;
+ info.fInternalFormatForTexImage =
+ texImageSupportsSizedInternalFormat ? GR_GL_R16 : GR_GL_RED;
+ info.fDefaultExternalType = GR_GL_UNSIGNED_SHORT;
if (r16AndRG1616Supported) {
info.fFlags = FormatInfo::kTextureable_Flag | msaaRenderFlags;
}
@@ -1943,6 +2052,11 @@
// GR_GL_RG16
{
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRG16);
+ info.fBaseInternalFormat = GR_GL_RG;
+ info.fSizedInternalFormat = GR_GL_RG16;
+ info.fInternalFormatForTexImage =
+ texImageSupportsSizedInternalFormat ? GR_GL_RG16 : GR_GL_RG;
+ info.fDefaultExternalType = GR_GL_UNSIGNED_SHORT;
if (r16AndRG1616Supported) {
info.fFlags = FormatInfo::kTextureable_Flag | msaaRenderFlags;
}
@@ -1978,6 +2092,11 @@
} // No WebGL support
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRGBA16);
+ info.fBaseInternalFormat = GR_GL_RGBA;
+ info.fSizedInternalFormat = GR_GL_RGBA16;
+ info.fInternalFormatForTexImage =
+ texImageSupportsSizedInternalFormat ? GR_GL_RGBA16 : GR_GL_RGBA;
+ info.fDefaultExternalType = GR_GL_UNSIGNED_SHORT;
if (rgba16161616Supported) {
info.fFlags = FormatInfo::kTextureable_Flag | msaaRenderFlags;
}
@@ -2017,6 +2136,11 @@
}
FormatInfo& info = this->getFormatInfo(GrGLSizedInternalFormat::kRG16F);
+ info.fBaseInternalFormat = GR_GL_RG;
+ info.fSizedInternalFormat = GR_GL_RG16F;
+ info.fInternalFormatForTexImage =
+ texImageSupportsSizedInternalFormat ? GR_GL_RG16F : GR_GL_RG;
+ info.fDefaultExternalType = halfFloatType;
if (rg16fTexturesSupported) {
info.fFlags |= FormatInfo::kTextureable_Flag;
}
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 6117293..77f6653 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -179,35 +179,51 @@
}
/**
- * Has a stencil format index been found for the config (or we've found that no format works).
+ * Gets the internal format to use with glTexImage...() and glTexStorage...(). May be sized or
+ * base depending upon the GL. Not applicable to compressed textures.
*/
- bool hasStencilFormatBeenDeterminedForConfig(GrPixelConfig config) const {
- return fConfigTable[config].fStencilFormatIndex != ConfigInfo::kUnknown_StencilIndex;
+ GrGLenum getTexImageInternalFormat(GrGLSizedInternalFormat format) const {
+ return this->getFormatInfo(format).fInternalFormatForTexImage;
+ }
+
+ GrGLenum getSizedInternalFormat(GrGLSizedInternalFormat format) const {
+ return this->getFormatInfo(format).fSizedInternalFormat;
+ }
+
+ GrGLenum getBaseInternalFormat(GrGLSizedInternalFormat format) const {
+ return this->getFormatInfo(format).fBaseInternalFormat;
}
/**
- * Gets the stencil format index for the config. This assumes
- * hasStencilFormatBeenDeterminedForConfig has already been checked. Returns a value < 0 if
- * no stencil format is supported with the config. Otherwise, returned index refers to the array
+ * Gets the default external type to use with glTex[Sub]Image... when the data pointer is null.
+ */
+ GrGLenum getFormatDefaultExternalType(GrGLSizedInternalFormat format) const {
+ return this->getFormatInfo(format).fDefaultExternalType;
+ }
+
+ /**
+ * Has a stencil format index been found for the format (or we've found that no format works).
+ */
+ bool hasStencilFormatBeenDeterminedForFormat(GrGLSizedInternalFormat format) const {
+ return this->getFormatInfo(format).fStencilFormatIndex != FormatInfo::kUnknown_StencilIndex;
+ }
+
+ /**
+ * Gets the stencil format index for the format. This assumes
+ * hasStencilFormatBeenDeterminedForFormat has already been checked. Returns a value < 0 if
+ * no stencil format is supported with the format. Otherwise, returned index refers to the array
* returned by stencilFormats().
*/
- int getStencilFormatIndexForConfig(GrPixelConfig config) const {
- SkASSERT(this->hasStencilFormatBeenDeterminedForConfig(config));
- return fConfigTable[config].fStencilFormatIndex;
+ int getStencilFormatIndexForFormat(GrGLSizedInternalFormat format) const {
+ SkASSERT(this->hasStencilFormatBeenDeterminedForFormat(format));
+ return this->getFormatInfo(format).fStencilFormatIndex;
}
/**
* If index is >= 0 this records an index into stencilFormats() as the best stencil format for
- * the config. If < 0 it records that the config has no supported stencil format index.
+ * the format. If < 0 it records that the format has no supported stencil format index.
*/
- void setStencilFormatIndexForConfig(GrPixelConfig config, int index) {
- SkASSERT(!this->hasStencilFormatBeenDeterminedForConfig(config));
- if (index < 0) {
- fConfigTable[config].fStencilFormatIndex = ConfigInfo::kUnsupported_StencilFormatIndex;
- } else {
- fConfigTable[config].fStencilFormatIndex = index;
- }
- }
+ void setStencilFormatIndexForFormat(GrGLSizedInternalFormat, int index);
/**
* Call to note that a color config has been verified as a valid color
@@ -569,8 +585,6 @@
};
struct ConfigInfo {
- ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex), fFlags(0) {}
-
ConfigFormats fFormats;
FormatType fFormatType;
@@ -580,15 +594,6 @@
// queryable. This stores the queried option (lazily).
ReadPixelsFormat fSecondReadPixelsFormat;
- enum {
- // This indicates that a stencil format has not yet been determined for the config.
- kUnknown_StencilIndex = -1,
- // This indicates that there is no supported stencil format for the config.
- kUnsupported_StencilFormatIndex = -2
- };
-
- // Index fStencilFormats.
- int fStencilFormatIndex;
// If data from a surface of this config is read back to a GrColorType with all four
// color channels this indicates how each channel should be interpreted. May contain
@@ -601,7 +606,7 @@
kRenderable_Flag = 0x1,
kRenderableWithMSAA_Flag = 0x2,
};
- uint32_t fFlags;
+ uint32_t fFlags = 0;
// verification of color attachment validity is done while flushing. Although only ever
// used in the (sole) rendering thread it can cause races if it is glommed into fFlags.
@@ -642,6 +647,34 @@
};
uint32_t fFlags = 0;
+ // Both compressed and uncompressed formats have base internal formats.
+ GrGLenum fBaseInternalFormat = 0;
+
+ // Not defined for compressed formats.
+ GrGLenum fSizedInternalFormat = 0;
+
+ // Not defined for uncompressed formats. Passed to glCompressedTexImage...
+ GrGLenum fCompressedInternalFormat = 0;
+
+ // Value to uses as the "internalformat" argument to glTexImage... Usually one of
+ // fBaseInternalFormat or fSizedInternalFormat but may vary depending on the particular
+ // format, GL version, extensions.
+ GrGLenum fInternalFormatForTexImage;
+
+ // Default value to use along with fBaseInternalFormat for functions such as glTexImage2D
+ // when not input providing data (passing nullptr). Not defined for compressed formats.
+ GrGLenum fDefaultExternalType = 0;
+
+ enum {
+ // This indicates that a stencil format has not yet been determined for the config.
+ kUnknown_StencilIndex = -1,
+ // This indicates that there is no supported stencil format for the config.
+ kUnsupported_StencilFormatIndex = -2
+ };
+
+ // Index fStencilFormats.
+ int fStencilFormatIndex = kUnknown_StencilIndex;
+
SkSTArray<1, ColorTypeInfo> fColorTypeInfos;
};
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index f7730c6..4e0ce88 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1591,10 +1591,11 @@
}
}
-int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) {
+int GrGLGpu::getCompatibleStencilIndex(GrGLSizedInternalFormat format) {
static const int kSize = 16;
- SkASSERT(this->caps()->isConfigRenderable(config));
- if (!this->glCaps().hasStencilFormatBeenDeterminedForConfig(config)) {
+ SkASSERT(this->glCaps().canFormatBeFBOColorAttachment(format));
+
+ if (!this->glCaps().hasStencilFormatBeenDeterminedForFormat(format)) {
// Default to unsupported, set this if we find a stencil format that works.
int firstWorkingStencilFormatIndex = -1;
@@ -1615,13 +1616,13 @@
GR_GL_TEXTURE_WRAP_T,
GR_GL_CLAMP_TO_EDGE));
- GrGLenum internalFormat;
- GrGLenum externalFormat;
- GrGLenum externalType;
- if (!this->glCaps().getTexImageFormats(config, config, &internalFormat, &externalFormat,
- &externalType)) {
- return false;
+ GrGLenum internalFormat = this->glCaps().getTexImageInternalFormat(format);
+ GrGLenum externalFormat = this->glCaps().getBaseInternalFormat(format);
+ GrGLenum externalType = this->glCaps().getFormatDefaultExternalType(format);
+ if (!externalFormat || !externalType || !externalType) {
+ return -1;
}
+
this->unbindCpuToGpuXferBuffer();
CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
GL_ALLOC_CALL(this->glInterface(), TexImage2D(GR_GL_TEXTURE_2D,
@@ -1698,9 +1699,9 @@
GL_CALL(DeleteTextures(1, &colorID));
this->bindFramebuffer(GR_GL_FRAMEBUFFER, 0);
this->deleteFramebuffer(fb);
- fGLContext->caps()->setStencilFormatIndexForConfig(config, firstWorkingStencilFormatIndex);
+ fGLContext->caps()->setStencilFormatIndexForFormat(format, firstWorkingStencilFormatIndex);
}
- return this->glCaps().getStencilFormatIndexForConfig(config);
+ return this->glCaps().getStencilFormatIndexForFormat(format);
}
bool GrGLGpu::createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info,
@@ -1768,7 +1769,8 @@
GrGLStencilAttachment::IDDesc sbDesc;
- int sIdx = this->getCompatibleStencilIndex(rt->config());
+ auto rtFormat = GrGLBackendFormatToSizedInternalFormat(rt->backendFormat());
+ int sIdx = this->getCompatibleStencilIndex(rtFormat);
if (sIdx < 0) {
return nullptr;
}
@@ -4059,7 +4061,9 @@
} else {
this->glCaps().getRenderbufferFormat(config, &colorBufferFormat);
}
- int sFormatIdx = this->getCompatibleStencilIndex(config);
+ auto format = GrGLBackendFormatToSizedInternalFormat(
+ this->caps()->getBackendFormatFromColorType(colorType));
+ int sFormatIdx = this->getCompatibleStencilIndex(format);
if (sFormatIdx < 0) {
return {};
}
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index abbcb2b..ea2dbe2 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -208,9 +208,9 @@
sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&,
int sampleCnt) override;
- // Given a GrPixelConfig return the index into the stencil format array on GrGLCaps to a
+ // Given a GL format return the index into the stencil format array on GrGLCaps to a
// compatible stencil format, or negative if there is no compatible stencil format.
- int getCompatibleStencilIndex(GrPixelConfig config);
+ int getCompatibleStencilIndex(GrGLSizedInternalFormat format);
void onFBOChanged();