Modify workaround to never set base or max texture level for GL_TEXTURE_EXTERNAL_OES
Bug: https://github.com/flutter/flutter/issues/23900 Bug: https://github.com/flutter/flutter/issues/24402 Bug: https://github.com/flutter/flutter/issues/24391 Change-Id: I8b24a62618ecd19387bcb8a827030d0c6d5b5362 Reviewed-on: https://skia-review.googlesource.com/c/173363 Commit-Queue: Brian Salomon <bsalomon@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com> Auto-Submit: Brian Salomon <bsalomon@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
8222f3be41
commit
f3841931ef
@ -62,7 +62,7 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions,
|
||||
fUseDrawInsteadOfAllRenderTargetWrites = false;
|
||||
fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines = false;
|
||||
fDetachStencilFromMSAABuffersBeforeReadPixels = false;
|
||||
fClampMaxTextureLevelToOne = false;
|
||||
fDontSetBaseOrMaxLevelForExternalTextures = false;
|
||||
fProgramBinarySupport = false;
|
||||
fSamplerObjectSupport = false;
|
||||
|
||||
@ -2726,12 +2726,10 @@ void GrGLCaps::applyDriverCorrectnessWorkarounds(const GrGLContextInfo& ctxInfo,
|
||||
}
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
// Older versions of Android have problems with setting GL_TEXTURE_MAX_LEVEL to 0 for
|
||||
// EGL images (or possibly just GL_TEXTURE_EXTERNAL_OES).
|
||||
// If the texture is not MIP mapped (only has level 0) then it should be harmless to use a
|
||||
// GL_TEXTURE_MAX_LEVEL of 1. Such textures are never used with GL_*_MIPMAP_* set for
|
||||
// GL_TEXTURE_MIN_FILTER.
|
||||
fClampMaxTextureLevelToOne = true;
|
||||
// Older versions of Android have problems with setting GL_TEXTURE_BASE_LEVEL or
|
||||
// GL_TEXTURE_MAX_LEVEL on GL_TEXTURE_EXTERTNAL_OES textures. We just leave them as is and hope
|
||||
// the client never changes them either.
|
||||
fDontSetBaseOrMaxLevelForExternalTextures = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -390,9 +390,11 @@ public:
|
||||
return fDetachStencilFromMSAABuffersBeforeReadPixels;
|
||||
}
|
||||
|
||||
// Older Android versions seem to have an issue with setting GL_TEXTURE_MAX_LEVEL to 0
|
||||
// on EGLImage/GL_TEXTURE_EXTERNAL_OES textures.
|
||||
bool clampMaxTextureLevelToOne() const { return fClampMaxTextureLevelToOne; }
|
||||
// Older Android versions seem to have an issue with setting GL_TEXTURE_BASE_LEVEL or
|
||||
// GL_TEXTURE_MAX_LEVEL for GL_TEXTURE_EXTERNAL_OES textures.
|
||||
bool dontSetBaseOrMaxLevelForExternalTextures() const {
|
||||
return fDontSetBaseOrMaxLevelForExternalTextures;
|
||||
}
|
||||
|
||||
// Returns the observed maximum number of instances the driver can handle in a single draw call
|
||||
// without crashing, or 'pendingInstanceCount' if this workaround is not necessary.
|
||||
@ -530,7 +532,7 @@ private:
|
||||
bool fUseDrawInsteadOfAllRenderTargetWrites : 1;
|
||||
bool fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines : 1;
|
||||
bool fDetachStencilFromMSAABuffersBeforeReadPixels : 1;
|
||||
bool fClampMaxTextureLevelToOne : 1;
|
||||
bool fDontSetBaseOrMaxLevelForExternalTextures : 1;
|
||||
int fMaxInstancesPerDrawWithoutCrashing;
|
||||
|
||||
uint32_t fBlitFramebufferFlags;
|
||||
|
@ -2902,9 +2902,6 @@ void GrGLGpu::bindTexture(int unitIdx, GrSamplerState samplerState, GrGLTexture*
|
||||
GrGLTexture::NonSamplerParams newNonSamplerParams;
|
||||
newNonSamplerParams.fBaseMipMapLevel = 0;
|
||||
newNonSamplerParams.fMaxMipMapLevel = texture->texturePriv().maxMipMapLevel();
|
||||
if (this->glCaps().clampMaxTextureLevelToOne()) {
|
||||
newNonSamplerParams.fMaxMipMapLevel = SkTMax(newNonSamplerParams.fMaxMipMapLevel, 1);
|
||||
}
|
||||
|
||||
const GrGLTexture::NonSamplerParams& oldNonSamplerParams = texture->getCachedNonSamplerParams();
|
||||
if (this->glCaps().textureSwizzleSupport()) {
|
||||
@ -2928,7 +2925,9 @@ void GrGLGpu::bindTexture(int unitIdx, GrSamplerState samplerState, GrGLTexture*
|
||||
}
|
||||
}
|
||||
// These are not supported in ES2 contexts
|
||||
if (this->glCaps().mipMapLevelAndLodControlSupport()) {
|
||||
if (this->glCaps().mipMapLevelAndLodControlSupport() &&
|
||||
(texture->texturePriv().textureType() != GrTextureType::kExternal ||
|
||||
!this->glCaps().dontSetBaseOrMaxLevelForExternalTextures())) {
|
||||
if (newNonSamplerParams.fBaseMipMapLevel != oldNonSamplerParams.fBaseMipMapLevel) {
|
||||
this->setTextureUnit(unitIdx);
|
||||
GL_CALL(TexParameteri(target, GR_GL_TEXTURE_BASE_LEVEL,
|
||||
|
Loading…
Reference in New Issue
Block a user