From a9e795eab5f59a52d96b8fdc39351452835f5eb9 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Tue, 23 May 2017 19:02:57 +0000 Subject: Revert "Add a flag to GrSurfaceFlags that requires the texture to be cleared upon creation. " This reverts commit 45e5068a6d10f4e4fd4658824310f8871f02ccf7. Reason for revert: :'( Original change's description: > Add a flag to GrSurfaceFlags that requires the texture to be cleared upon creation. > > Bug: chromium:656320 > > Change-Id: I940bfa24540516ab83a2ed52f761b96eb6ad19f1 > Reviewed-on: https://skia-review.googlesource.com/17391 > Reviewed-by: Greg Daniel > Commit-Queue: Brian Salomon > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Bug: chromium:656320 Change-Id: I8a4f71537e45f3c4cf37b10b2dc8ee38fe6959ba Reviewed-on: https://skia-review.googlesource.com/17765 Reviewed-by: Brian Salomon Commit-Queue: Brian Salomon --- src/gpu/gl/GrGLAssembleInterface.cpp | 8 ------- src/gpu/gl/GrGLCaps.cpp | 9 -------- src/gpu/gl/GrGLCaps.h | 4 ---- src/gpu/gl/GrGLGpu.cpp | 45 +++--------------------------------- src/gpu/gl/GrGLGpu.h | 6 ++--- 5 files changed, 6 insertions(+), 66 deletions(-) (limited to 'src/gpu/gl') diff --git a/src/gpu/gl/GrGLAssembleInterface.cpp b/src/gpu/gl/GrGLAssembleInterface.cpp index 7305696567..7914934eac 100644 --- a/src/gpu/gl/GrGLAssembleInterface.cpp +++ b/src/gpu/gl/GrGLAssembleInterface.cpp @@ -105,10 +105,6 @@ const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) { GET_PROC(Clear); GET_PROC(ClearColor); GET_PROC(ClearStencil); - if (glVer >= GR_GL_VER(4,4) || extensions.has("GL_ARB_clear_texture")) { - GET_PROC(ClearTexImage); - GET_PROC(ClearTexSubImage); - } GET_PROC(ColorMask); GET_PROC(CompileShader); GET_PROC(CompressedTexImage2D); @@ -588,10 +584,6 @@ const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) { GET_PROC(Clear); GET_PROC(ClearColor); GET_PROC(ClearStencil); - if (extensions.has("GL_EXT_clear_texture")) { - GET_PROC_SUFFIX(ClearTexImage, EXT); - GET_PROC_SUFFIX(ClearTexSubImage, EXT); - } GET_PROC(ColorMask); GET_PROC(CompileShader); GET_PROC(CompressedTexImage2D); diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 0d84a72121..b9eee088e0 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -54,7 +54,6 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, fSRGBDecodeDisableSupport = false; fSRGBDecodeDisableAffectsMipmaps = false; fClearToBoundaryValuesIsBroken = false; - fClearTextureSupport = false; fDrawArraysBaseVertexIsBroken = false; fBlitFramebufferFlags = kNoSupport_BlitFramebufferFlag; @@ -253,14 +252,6 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, // vis-versa. fRGBAToBGRAReadbackConversionsAreSlow = isMESA || isMAC; - if (kGL_GrGLStandard == standard) { - if (version >= GR_GL_VER(4,4) || ctxInfo.hasExtension("GL_ARB_clear_texture")) { - fClearTextureSupport = true; - } - } else if (ctxInfo.hasExtension("GL_EXT_clear_texture")) { - fClearTextureSupport = true; - } - /************************************************************************** * GrShaderCaps fields **************************************************************************/ diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index b7273a08b1..3059ea7149 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -360,9 +360,6 @@ public: // Certain Intel GPUs on Mac fail to clear if the glClearColor is made up of only 1s and 0s. bool clearToBoundaryValuesIsBroken() const { return fClearToBoundaryValuesIsBroken; } - /// glClearTex(Sub)Image support - bool clearTextureSupport() const { return fClearTextureSupport; } - // Adreno/MSAA drops a draw on the imagefiltersbase GM if the base vertex param to // glDrawArrays is nonzero. // https://bugs.chromium.org/p/skia/issues/detail?id=6650 @@ -440,7 +437,6 @@ private: bool fSRGBDecodeDisableSupport : 1; bool fSRGBDecodeDisableAffectsMipmaps : 1; bool fClearToBoundaryValuesIsBroken : 1; - bool fClearTextureSupport : 1; bool fDrawArraysBaseVertexIsBroken : 1; uint32_t fBlitFramebufferFlags; diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 81ee87c5e0..565e60a220 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -1320,44 +1320,24 @@ static void set_initial_texture_params(const GrGLInterface* interface, GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, - const SkTArray& origTexels) { + const SkTArray& texels) { // We fail if the MSAA was requested and is not available. if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleCnt) { //SkDebugf("MSAA RT requested but not supported on this platform."); return return_null_texture(); } - bool performClear = (desc.fFlags & kPerformInitialClear_GrSurfaceFlag); - const SkTArray* texels = &origTexels; - - SkTArray zeroLevels; - std::unique_ptr zeros; - // TODO: remove the GrPixelConfigIsSint test. This is here because we have yet to add support - // for glClearBuffer* which must be used instead of glClearColor/glClear for integer FBO - // attachments. - if (performClear && !this->glCaps().clearTextureSupport() && - (!this->glCaps().canConfigBeFBOColorAttachment(desc.fConfig) || - GrPixelConfigIsSint(desc.fConfig))) { - size_t rowSize = GrBytesPerPixel(desc.fConfig) * desc.fWidth; - size_t size = rowSize * desc.fHeight; - zeros.reset(new uint8_t[size]); - memset(zeros.get(), 0, size); - zeroLevels.push_back(GrMipLevel{zeros.get(), 0}); - texels = &zeroLevels; - performClear = false; - } - bool isRenderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag); GrGLTexture::IDDesc idDesc; idDesc.fOwnership = GrBackendObjectOwnership::kOwned; GrGLTexture::TexParams initialTexParams; - if (!this->createTextureImpl(desc, &idDesc.fInfo, isRenderTarget, &initialTexParams, *texels)) { + if (!this->createTextureImpl(desc, &idDesc.fInfo, isRenderTarget, &initialTexParams, texels)) { return return_null_texture(); } bool wasMipMapDataProvided = false; - if (texels->count() > 1) { + if (texels.count() > 1) { wasMipMapDataProvided = true; } @@ -1381,25 +1361,6 @@ GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc, SkDebugf("--- new texture [%d] size=(%d %d) config=%d\n", idDesc.fInfo.fID, desc.fWidth, desc.fHeight, desc.fConfig); #endif - if (tex && performClear) { - if (this->glCaps().clearTextureSupport()) { - GrGLenum format = GrPixelConfigIsSint(tex->config()) ? GR_GL_RGBA_INTEGER : GR_GL_RGBA; - static constexpr uint32_t kZero = 0; - GL_CALL(ClearTexImage(tex->textureID(), 0, format, GR_GL_UNSIGNED_BYTE, &kZero)); - } else { - SkASSERT(!GrPixelConfigIsSint(desc.fConfig)); - GrGLIRect viewport; - this->bindSurfaceFBOForPixelOps(tex, GR_GL_FRAMEBUFFER, &viewport, kDst_TempFBOTarget); - this->disableScissor(); - this->disableWindowRectangles(); - GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); - fHWWriteToColor = kYes_TriState; - GL_CALL(ClearColor(0, 0, 0, 0)); - GL_CALL(Clear(GR_GL_COLOR_BUFFER_BIT)); - this->unbindTextureFBOForPixelOps(GR_GL_FRAMEBUFFER, tex); - fHWBoundRenderTargetUniqueID.makeInvalid(); - } - } return tex; } diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index d19f2ef6ee..a4706c79ed 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -371,9 +371,9 @@ private: kDst_TempFBOTarget }; - // Binds a surface as a FBO for copying, reading, or clearing. If the surface already owns an - // FBO ID then that ID is bound. If not the surface is temporarily bound to a FBO and that FBO - // is bound. This must be paired with a call to unbindSurfaceFBOForPixelOps(). + // Binds a surface as a FBO for copying or reading. If the surface already owns an FBO ID then + // that ID is bound. If not the surface is temporarily bound to a FBO and that FBO is bound. + // This must be paired with a call to unbindSurfaceFBOForPixelOps(). void bindSurfaceFBOForPixelOps(GrSurface* surface, GrGLenum fboTarget, GrGLIRect* viewport, TempFBOTarget tempFBOTarget); -- cgit v1.2.3