Reduce usage of GrGLShaderBuilder::SamplerMode
authortomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 2 Aug 2012 20:13:12 +0000 (20:13 +0000)
committertomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 2 Aug 2012 20:13:12 +0000 (20:13 +0000)
http://codereview.appspot.com/6453080/

git-svn-id: http://skia.googlecode.com/svn/trunk@4940 2bbb7eff-a529-9590-31e7-b0007b416f81

src/gpu/gl/GrGLProgram.cpp
src/gpu/gl/GrGLShaderBuilder.cpp
src/gpu/gl/GrGLShaderBuilder.h

index 3590428..ebbd267 100644 (file)
@@ -1068,15 +1068,7 @@ void GrGLProgram::genStageCode(int stageNum,
 
     builder->fSampleCoords = varyingFSName;
 
-    GrGLShaderBuilder::SamplerMode sampleMode =
-        GrGLShaderBuilder::kExplicitDivide_SamplerMode;
-    if (desc.fOptFlags & (StageDesc::kIdentityMatrix_OptFlagBit |
-                          StageDesc::kNoPerspective_OptFlagBit)) {
-        sampleMode = GrGLShaderBuilder::kDefault_SamplerMode;
-    } else if (NULL == customStage) {
-        sampleMode = GrGLShaderBuilder::kProj_SamplerMode;
-    }
-    builder->setupTextureAccess(sampleMode, stageNum);
+    builder->setupTextureAccess(stageNum);
 
     builder->computeSwizzle(desc.fInConfigFlags);
     builder->computeModulate(fsInColor);
index 7171029..fb70556 100644 (file)
@@ -31,7 +31,6 @@ static SkString build_sampler_string(GrGLShaderBuilder::SamplerMode samplerMode)
           sampler.append("Proj");
           break;
       case GrGLShaderBuilder::kExplicitDivide_SamplerMode:
-          GrAssert(false);  // Not Implemented
           break;
     }
 
@@ -120,18 +119,22 @@ void GrGLShaderBuilder::computeModulate(const char* fsInColor) {
     }
 }
 
-void GrGLShaderBuilder::setupTextureAccess(SamplerMode samplerMode,
-                                           int stageNum) {
+void GrGLShaderBuilder::setupTextureAccess(int stageNum) {
     SkString retval;
 
-    fTexFunc = "texture2D";
-    switch (samplerMode) {
+    SamplerMode mode = kDefault_SamplerMode;
+    // FIXME: we aren't currently using Proj.
+    if (fVaryingDims != fCoordDims) {
+        mode = kExplicitDivide_SamplerMode;
+    }
+
+    switch (mode) {
         case kDefault_SamplerMode:
             GrAssert(fVaryingDims == fCoordDims);
             // Do nothing
             break;
         case kProj_SamplerMode:
-            fTexFunc.append("Proj");
+            // Do nothing
             break;
         case kExplicitDivide_SamplerMode:
             retval = "inCoord";
@@ -147,6 +150,7 @@ void GrGLShaderBuilder::setupTextureAccess(SamplerMode samplerMode,
             fSampleCoords = retval;
             break;
     }
+    fTexFunc = build_sampler_string(mode);
     fComplexCoord = false;
 }
 
index 16a11e2..ab0792b 100644 (file)
@@ -45,7 +45,7 @@ public:
     /** Determines whether we should use texture2D() or texture2Dproj(), and if an explicit divide
         is required for the sample coordinates, creates the new variable and emits the code to
         initialize it. */
-    void setupTextureAccess(SamplerMode samplerMode, int stageNum);
+    void setupTextureAccess(int stageNum);
 
     /** texture2D(samplerName, coordName), with projection if necessary; if coordName is not
         specified, uses fSampleCoords. */