From 0ae2ca2830231d074ac6fc61bf5550e85d12ed53 Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Mon, 4 Jun 2012 13:31:48 +0000 Subject: [PATCH] Revert r4134 due to bot failures git-svn-id: http://skia.googlecode.com/svn/trunk@4136 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/gl/GrGpuGL.cpp | 162 +++++++++++++++++---------------- src/gpu/gl/GrGpuGL.h | 3 - src/gpu/gl/GrGpuGL_program.cpp | 15 --- 3 files changed, 86 insertions(+), 94 deletions(-) diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index c390191c30..90fb2a69b3 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -2109,82 +2109,6 @@ void set_tex_swizzle(GrGLenum swizzle[4], const GrGLInterface* gl) { } } -void GrGpuGL::flushBoundTextureAndParams(int stage) { - GrDrawState* drawState = this->drawState(); - - GrGLTexture* nextTexture = - static_cast(drawState->getTexture(stage)); - - // true for now, but maybe not with GrEffect. - GrAssert(NULL != nextTexture); - // if we created a rt/tex and rendered to it without using a - // texture and now we're texturing from the rt it will still be - // the last bound texture, but it needs resolving. So keep this - // out of the "last != next" check. - GrGLRenderTarget* texRT = - static_cast(nextTexture->asRenderTarget()); - if (NULL != texRT) { - this->onResolveRenderTarget(texRT); - } - - if (fHWBoundTextures[stage] != nextTexture) { - this->setTextureUnit(stage); - GL_CALL(BindTexture(GR_GL_TEXTURE_2D, nextTexture->textureID())); - #if GR_COLLECT_STATS - ++fStats.fTextureChngCnt; - #endif - //GrPrintf("---- bindtexture %d\n", nextTexture->textureID()); - fHWBoundTextures[stage] = nextTexture; - } - - const GrSamplerState& sampler = drawState->getSampler(stage); - ResetTimestamp timestamp; - const GrGLTexture::TexParams& oldTexParams = - nextTexture->getCachedTexParams(×tamp); - bool setAll = timestamp < this->getResetTimestamp(); - GrGLTexture::TexParams newTexParams; - - newTexParams.fFilter = gr_to_gl_filter(sampler.getFilter()); - - const GrGLenum* wraps = GrGLTexture::WrapMode2GLWrap(); - newTexParams.fWrapS = wraps[sampler.getWrapX()]; - newTexParams.fWrapT = wraps[sampler.getWrapY()]; - memcpy(newTexParams.fSwizzleRGBA, - get_swizzle(nextTexture->config(), sampler, this->glCaps()), - sizeof(newTexParams.fSwizzleRGBA)); - if (setAll || newTexParams.fFilter != oldTexParams.fFilter) { - this->setTextureUnit(stage); - GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, - GR_GL_TEXTURE_MAG_FILTER, - newTexParams.fFilter)); - GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, - GR_GL_TEXTURE_MIN_FILTER, - newTexParams.fFilter)); - } - if (setAll || newTexParams.fWrapS != oldTexParams.fWrapS) { - this->setTextureUnit(stage); - GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, - GR_GL_TEXTURE_WRAP_S, - newTexParams.fWrapS)); - } - if (setAll || newTexParams.fWrapT != oldTexParams.fWrapT) { - this->setTextureUnit(stage); - GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, - GR_GL_TEXTURE_WRAP_T, - newTexParams.fWrapT)); - } - if (this->glCaps().textureSwizzleSupport() && - (setAll || memcmp(newTexParams.fSwizzleRGBA, - oldTexParams.fSwizzleRGBA, - sizeof(newTexParams.fSwizzleRGBA)))) { - this->setTextureUnit(stage); - set_tex_swizzle(newTexParams.fSwizzleRGBA, - this->glInterface()); - } - nextTexture->setCachedTexParams(newTexParams, - this->getResetTimestamp()); -} - bool GrGpuGL::flushGLStateCommon(GrPrimitiveType type) { GrDrawState* drawState = this->drawState(); @@ -2192,6 +2116,92 @@ bool GrGpuGL::flushGLStateCommon(GrPrimitiveType type) { // and bailed if not true. GrAssert(NULL != drawState->getRenderTarget()); + for (int s = 0; s < GrDrawState::kNumStages; ++s) { + // bind texture and set sampler state + if (this->isStageEnabled(s)) { + GrGLTexture* nextTexture = + static_cast(drawState->getTexture(s)); + + // true for now, but maybe not with GrEffect. + GrAssert(NULL != nextTexture); + // if we created a rt/tex and rendered to it without using a + // texture and now we're texturing from the rt it will still be + // the last bound texture, but it needs resolving. So keep this + // out of the "last != next" check. + GrGLRenderTarget* texRT = + static_cast(nextTexture->asRenderTarget()); + if (NULL != texRT) { + this->onResolveRenderTarget(texRT); + } + + if (fHWBoundTextures[s] != nextTexture) { + this->setTextureUnit(s); + GL_CALL(BindTexture(GR_GL_TEXTURE_2D, nextTexture->textureID())); + #if GR_COLLECT_STATS + ++fStats.fTextureChngCnt; + #endif + //GrPrintf("---- bindtexture %d\n", nextTexture->textureID()); + fHWBoundTextures[s] = nextTexture; + } + + const GrSamplerState& sampler = drawState->getSampler(s); + ResetTimestamp timestamp; + const GrGLTexture::TexParams& oldTexParams = + nextTexture->getCachedTexParams(×tamp); + bool setAll = timestamp < this->getResetTimestamp(); + GrGLTexture::TexParams newTexParams; + + newTexParams.fFilter = gr_to_gl_filter(sampler.getFilter()); + + const GrGLenum* wraps = GrGLTexture::WrapMode2GLWrap(); + newTexParams.fWrapS = wraps[sampler.getWrapX()]; + newTexParams.fWrapT = wraps[sampler.getWrapY()]; + memcpy(newTexParams.fSwizzleRGBA, + get_swizzle(nextTexture->config(), sampler, this->glCaps()), + sizeof(newTexParams.fSwizzleRGBA)); + if (setAll || newTexParams.fFilter != oldTexParams.fFilter) { + this->setTextureUnit(s); + GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, + GR_GL_TEXTURE_MAG_FILTER, + newTexParams.fFilter)); + GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, + GR_GL_TEXTURE_MIN_FILTER, + newTexParams.fFilter)); + } + if (setAll || newTexParams.fWrapS != oldTexParams.fWrapS) { + this->setTextureUnit(s); + GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, + GR_GL_TEXTURE_WRAP_S, + newTexParams.fWrapS)); + } + if (setAll || newTexParams.fWrapT != oldTexParams.fWrapT) { + this->setTextureUnit(s); + GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, + GR_GL_TEXTURE_WRAP_T, + newTexParams.fWrapT)); + } + if (this->glCaps().textureSwizzleSupport() && + (setAll || + memcmp(newTexParams.fSwizzleRGBA, + oldTexParams.fSwizzleRGBA, + sizeof(newTexParams.fSwizzleRGBA)))) { + this->setTextureUnit(s); + set_tex_swizzle(newTexParams.fSwizzleRGBA, + this->glInterface()); + } + nextTexture->setCachedTexParams(newTexParams, + this->getResetTimestamp()); + } + } + + GrIRect* rect = NULL; + GrIRect clipBounds; + if (drawState->isClipState() && + fClip.hasConservativeBounds()) { + fClip.getConservativeBounds().roundOut(&clipBounds); + rect = &clipBounds; + } + this->flushRenderTarget(rect); this->flushAAState(type); if (drawState->isDitherState()) { diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h index b997c169fa..b0a7bdc653 100644 --- a/src/gpu/gl/GrGpuGL.h +++ b/src/gpu/gl/GrGpuGL.h @@ -239,9 +239,6 @@ private: const GrGLContextInfo& fGL; }; - // binds the texture and sets its texture params - void flushBoundTextureAndParams(int stage); - // sets the texture matrix and domain for the currently bound program void flushTextureMatrixAndDomain(int stage); diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp index 9826a5180b..e79afe15e2 100644 --- a/src/gpu/gl/GrGpuGL_program.cpp +++ b/src/gpu/gl/GrGpuGL_program.cpp @@ -438,9 +438,6 @@ bool GrGpuGL::flushGraphicsState(GrPrimitiveType type) { for (int s = 0; s < GrDrawState::kNumStages; ++s) { if (this->isStageEnabled(s)) { - - this->flushBoundTextureAndParams(s); - this->flushTextureMatrixAndDomain(s); this->flushTexelSize(s); @@ -458,18 +455,6 @@ bool GrGpuGL::flushGraphicsState(GrPrimitiveType type) { } } this->flushColorMatrix(); - - GrIRect* rect = NULL; - GrIRect clipBounds; - if (drawState.isClipState() && - fClip.hasConservativeBounds()) { - fClip.getConservativeBounds().roundOut(&clipBounds); - rect = &clipBounds; - } - // This must come after textures are flushed because a texture may need - // to be msaa-resolved (which will modify bound FBO state). - this->flushRenderTarget(rect); - return true; }