Bug 898129 - Only set the texture transform for shaders where it will be used. r=nrc
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 01 Aug 2013 21:12:15 -0400
changeset 153452 8808316e03bb383df4caa77a01130a532ebc95bc
parent 153451 4aec4fb6cb96f8c642161c5d8ad38ddaf94c96c8
child 153453 c242c3498ff1fdaeae4f98d823621b3291a439b1
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnrc
bugs898129
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 898129 - Only set the texture transform for shaders where it will be used. r=nrc
gfx/layers/opengl/ColorLayerOGL.cpp
gfx/layers/opengl/CompositorOGL.cpp
gfx/layers/opengl/LayerManagerOGLProgram.cpp
--- a/gfx/layers/opengl/ColorLayerOGL.cpp
+++ b/gfx/layers/opengl/ColorLayerOGL.cpp
@@ -32,17 +32,16 @@ RenderColorLayer(ColorLayer* aLayer, Lay
   color.b *= opacity;
   color.a = opacity;
 
   ShaderProgramOGL *program = aManager->GetProgram(ColorLayerProgramType,
                                                    aLayer->GetMaskLayer());
   program->Activate();
   program->SetLayerQuadRect(aLayer->GetBounds());
   program->SetLayerTransform(aLayer->GetEffectiveTransform());
-  program->SetTextureTransform(gfx3DMatrix());
   program->SetRenderOffset(aOffset);
   program->SetRenderColor(color);
   program->LoadMask(aLayer->GetMaskLayer());
 
   aManager->BindAndDrawQuad(program);
 }
 
 void
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -1033,17 +1033,16 @@ CompositorOGL::DrawQuad(const Rect& aRec
     TexturedEffect* texturedEffect =
         static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
     TextureSourceOGL* source = texturedEffect->mTexture->AsSourceOGL();
     // This is used by IOSurface that use 0,0...w,h coordinate rather then 0,0..1,1.
     program->SetTexCoordMultiplier(source->GetSize().width, source->GetSize().height);
   }
   program->SetLayerQuadRect(aRect);
   program->SetLayerTransform(aTransform);
-  program->SetTextureTransform(gfx3DMatrix());
   program->SetRenderOffset(aOffset.x, aOffset.y);
 
   switch (aEffectChain.mPrimaryEffect->mType) {
     case EFFECT_SOLID_COLOR: {
       EffectSolidColor* effectSolidColor =
         static_cast<EffectSolidColor*>(aEffectChain.mPrimaryEffect.get());
 
       Color color = effectSolidColor->mColor;
@@ -1131,16 +1130,17 @@ CompositorOGL::DrawQuad(const Rect& aRec
       mGLContext->ApplyFilterToBoundTexture(filter);
       AutoBindTexture bindCb(sourceCb, LOCAL_GL_TEXTURE1);
       mGLContext->ApplyFilterToBoundTexture(filter);
       AutoBindTexture bindCr(sourceCr, LOCAL_GL_TEXTURE2);
       mGLContext->ApplyFilterToBoundTexture(filter);
 
       program->SetYCbCrTextureUnits(Y, Cb, Cr);
       program->SetLayerOpacity(aOpacity);
+      program->SetTextureTransform(gfx3DMatrix());
 
       AutoBindTexture bindMask;
       if (maskType != MaskNone) {
         bindMask.Bind(sourceMask, LOCAL_GL_TEXTURE3);
         program->SetMaskTextureUnit(3);
         program->SetMaskLayerTransform(maskQuadTransform);
       }
       BindAndDrawQuadWithTextureRect(program, effectYCbCr->mTextureCoords, sourceYCbCr->GetSubSource(Y));
@@ -1154,16 +1154,17 @@ CompositorOGL::DrawQuad(const Rect& aRec
 
       ShaderProgramOGL *program = GetProgram(GetFBOLayerProgramType(), maskType);
 
       surface->BindTexture(LOCAL_GL_TEXTURE0, mFBOTextureTarget);
 
       program->Activate();
       program->SetTextureUnit(0);
       program->SetLayerOpacity(aOpacity);
+      program->SetTextureTransform(gfx3DMatrix());
 
       AutoBindTexture bindMask;
       if (maskType != MaskNone) {
         bindMask.Bind(sourceMask, LOCAL_GL_TEXTURE1);
         program->SetMaskTextureUnit(1);
         program->SetMaskLayerTransform(maskQuadTransform);
       }
 
--- a/gfx/layers/opengl/LayerManagerOGLProgram.cpp
+++ b/gfx/layers/opengl/LayerManagerOGLProgram.cpp
@@ -17,27 +17,27 @@ namespace layers {
 typedef ProgramProfileOGL::Argument Argument;
 
 // helper methods for GetProfileFor
 void
 AddCommonArgs(ProgramProfileOGL& aProfile)
 {
   aProfile.mUniforms.AppendElement(Argument("uLayerTransform"));
   aProfile.mUniforms.AppendElement(Argument("uLayerQuadTransform"));
-  aProfile.mUniforms.AppendElement(Argument("uTextureTransform"));
   aProfile.mUniforms.AppendElement(Argument("uMatrixProj"));
   aProfile.mHasMatrixProj = true;
   aProfile.mUniforms.AppendElement(Argument("uRenderTargetOffset"));
   aProfile.mAttributes.AppendElement(Argument("aVertexCoord"));
 }
 void
 AddCommonTextureArgs(ProgramProfileOGL& aProfile)
 {
   aProfile.mUniforms.AppendElement(Argument("uLayerOpacity"));
   aProfile.mUniforms.AppendElement(Argument("uTexture"));
+  aProfile.mUniforms.AppendElement(Argument("uTextureTransform"));
   aProfile.mAttributes.AppendElement(Argument("aTexCoord"));
 }
 
 /* static */ ProgramProfileOGL
 ProgramProfileOGL::GetProfileFor(ShaderProgramType aType,
                                  MaskType aMask)
 {
   NS_ASSERTION(ProgramExists(aType, aMask), "Invalid program type.");
@@ -167,93 +167,100 @@ ProgramProfileOGL::GetProfileFor(ShaderP
       result.mVertexShaderString = sLayerVS;
       result.mFragmentShaderString = sYCbCrTextureLayerFS;
     }
     AddCommonArgs(result);
     result.mUniforms.AppendElement(Argument("uLayerOpacity"));
     result.mUniforms.AppendElement(Argument("uYTexture"));
     result.mUniforms.AppendElement(Argument("uCbTexture"));
     result.mUniforms.AppendElement(Argument("uCrTexture"));
+    result.mUniforms.AppendElement(Argument("uTextureTransform"));
     result.mAttributes.AppendElement(Argument("aTexCoord"));
     result.mTextureCount = 3;
     break;
   case ComponentAlphaPass1ProgramType:
     if (aMask == Mask2d) {
       result.mVertexShaderString = sLayerMaskVS;
       result.mFragmentShaderString = sComponentPassMask1FS;
     } else {
       result.mVertexShaderString = sLayerVS;
       result.mFragmentShaderString = sComponentPass1FS;
     }
     AddCommonArgs(result);
     result.mUniforms.AppendElement(Argument("uLayerOpacity"));
     result.mUniforms.AppendElement(Argument("uBlackTexture"));
     result.mUniforms.AppendElement(Argument("uWhiteTexture"));
+    result.mUniforms.AppendElement(Argument("uTextureTransform"));
     result.mAttributes.AppendElement(Argument("aTexCoord"));
     result.mTextureCount = 2;
     break;
   case ComponentAlphaPass1RGBProgramType:
     if (aMask == Mask2d) {
       result.mVertexShaderString = sLayerMaskVS;
       result.mFragmentShaderString = sComponentPassMask1RGBFS;
     } else {
       result.mVertexShaderString = sLayerVS;
       result.mFragmentShaderString = sComponentPass1RGBFS;
     }
     AddCommonArgs(result);
     result.mUniforms.AppendElement(Argument("uLayerOpacity"));
     result.mUniforms.AppendElement(Argument("uBlackTexture"));
     result.mUniforms.AppendElement(Argument("uWhiteTexture"));
+    result.mUniforms.AppendElement(Argument("uTextureTransform"));
     result.mAttributes.AppendElement(Argument("aTexCoord"));
     result.mTextureCount = 2;
     break;
   case ComponentAlphaPass2ProgramType:
     if (aMask == Mask2d) {
       result.mVertexShaderString = sLayerMaskVS;
       result.mFragmentShaderString = sComponentPassMask2FS;
     } else {
       result.mVertexShaderString = sLayerVS;
       result.mFragmentShaderString = sComponentPass2FS;
     }
     AddCommonArgs(result);
     result.mUniforms.AppendElement(Argument("uLayerOpacity"));
     result.mUniforms.AppendElement(Argument("uBlackTexture"));
     result.mUniforms.AppendElement(Argument("uWhiteTexture"));
+    result.mUniforms.AppendElement(Argument("uTextureTransform"));
     result.mAttributes.AppendElement(Argument("aTexCoord"));
     result.mTextureCount = 2;
     break;
   case ComponentAlphaPass2RGBProgramType:
     if (aMask == Mask2d) {
       result.mVertexShaderString = sLayerMaskVS;
       result.mFragmentShaderString = sComponentPassMask2RGBFS;
     } else {
       result.mVertexShaderString = sLayerVS;
       result.mFragmentShaderString = sComponentPass2RGBFS;
     }
     AddCommonArgs(result);
     result.mUniforms.AppendElement(Argument("uLayerOpacity"));
     result.mUniforms.AppendElement(Argument("uBlackTexture"));
     result.mUniforms.AppendElement(Argument("uWhiteTexture"));
+    result.mUniforms.AppendElement(Argument("uTextureTransform"));
     result.mAttributes.AppendElement(Argument("aTexCoord"));
     result.mTextureCount = 2;
     break;
   case Copy2DProgramType:
     NS_ASSERTION(!aMask, "Program does not have masked variant.");
     result.mVertexShaderString = sCopyVS;
     result.mFragmentShaderString = sCopy2DFS;
     result.mUniforms.AppendElement(Argument("uTexture"));
+    result.mUniforms.AppendElement(Argument("uTextureTransform"));
     result.mAttributes.AppendElement(Argument("aVertexCoord"));
     result.mAttributes.AppendElement(Argument("aTexCoord"));
     result.mTextureCount = 1;
     break;
   case Copy2DRectProgramType:
     NS_ASSERTION(!aMask, "Program does not have masked variant.");
     result.mVertexShaderString = sCopyVS;
     result.mFragmentShaderString = sCopy2DRectFS;
     result.mUniforms.AppendElement(Argument("uTexture"));
+    result.mUniforms.AppendElement(Argument("uTextureTransform"));
     result.mAttributes.AppendElement(Argument("aVertexCoord"));
     result.mAttributes.AppendElement(Argument("aTexCoord"));
     result.mTextureCount = 1;
     break;
   default:
     NS_NOTREACHED("Unknown shader program type.");
   }