aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-11 20:47:39 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-11 20:47:39 +0000
commit341767c9fc6577fbd6b7ed57a12f03f565788025 (patch)
tree67a3bf5e3cffc4e489581a5043e8489da9544139 /src/gpu
parentf9ad8867f2bcd8563862b0a5a90b473ad020d465 (diff)
Remove support for vertex attribute matrices
Review URL: http://codereview.appspot.com/6200065/ git-svn-id: http://skia.googlecode.com/svn/trunk@3917 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/gl/GrGLProgram.cpp41
-rw-r--r--src/gpu/gl/GrGLProgram.h1
-rw-r--r--src/gpu/gl/GrGpuGLShaders.cpp78
-rw-r--r--src/gpu/gl/GrGpuGLShaders.h6
4 files changed, 13 insertions, 113 deletions
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 7ffb4d4da4..91167d6a66 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -30,11 +30,7 @@ enum {
typedef GrGLProgram::ProgramDesc::StageDesc StageDesc;
-#if GR_GL_ATTRIBUTE_MATRICES
- #define VIEW_MATRIX_NAME "aViewM"
-#else
- #define VIEW_MATRIX_NAME "uViewM"
-#endif
+#define VIEW_MATRIX_NAME "uViewM"
#define POS_ATTR_NAME "aPosition"
#define COL_ATTR_NAME "aColor"
@@ -81,11 +77,7 @@ inline const char* declared_color_output_name() { return "fsColorOut"; }
inline const char* dual_source_output_name() { return "dualSourceOut"; }
inline void tex_matrix_name(int stage, GrStringBuilder* s) {
-#if GR_GL_ATTRIBUTE_MATRICES
- *s = "aTexM";
-#else
*s = "uTexM";
-#endif
s->appendS32(stage);
}
@@ -562,15 +554,10 @@ bool GrGLProgram::genProgram(const GrGLContextInfo& gl,
segments.fFSOutputs.push_back(colorOutput);
}
-#if GR_GL_ATTRIBUTE_MATRICES
- segments.fVSAttrs.push_back().set(kMat33f_GrSLType,
- GrGLShaderVar::kAttribute_TypeModifier, VIEW_MATRIX_NAME);
- programData->fUniLocations.fViewMatrixUni = kSetAsAttribute;
-#else
segments.fVSUnis.push_back().set(kMat33f_GrSLType,
GrGLShaderVar::kUniform_TypeModifier, VIEW_MATRIX_NAME);
programData->fUniLocations.fViewMatrixUni = kUseUniform;
-#endif
+
segments.fVSAttrs.push_back().set(kVec2f_GrSLType,
GrGLShaderVar::kAttribute_TypeModifier, POS_ATTR_NAME);
@@ -1097,23 +1084,6 @@ bool GrGLProgram::bindOutputsAttribsAndLinkProgram(
}
}
- if (kSetAsAttribute == programData->fUniLocations.fViewMatrixUni) {
- GL_CALL(BindAttribLocation(progID,
- ViewMatrixAttributeIdx(),
- VIEW_MATRIX_NAME));
- }
-
- for (int s = 0; s < GrDrawState::kNumStages; ++s) {
- const StageUniLocations& unis = programData->fUniLocations.fStages[s];
- if (kSetAsAttribute == unis.fTextureMatrixUni) {
- GrStringBuilder matName;
- tex_matrix_name(s, &matName);
- GL_CALL(BindAttribLocation(progID,
- TextureMatrixAttributeIdx(s),
- matName.c_str()));
- }
- }
-
GL_CALL(BindAttribLocation(progID, ColorAttributeIdx(), COL_ATTR_NAME));
GL_CALL(BindAttribLocation(progID, CoverageAttributeIdx(), COV_ATTR_NAME));
GL_CALL(BindAttribLocation(progID, EdgeAttributeIdx(), EDGE_ATTR_NAME));
@@ -1569,15 +1539,10 @@ void GrGLProgram::genStageCode(const GrGLContextInfo& gl,
varyingDims = coordDims;
} else {
GrGLShaderVar* mat;
- #if GR_GL_ATTRIBUTE_MATRICES
- mat = &segments->fVSAttrs.push_back();
- mat->setTypeModifier(GrGLShaderVar::kAttribute_TypeModifier);
- locations->fTextureMatrixUni = kSetAsAttribute;
- #else
mat = &segments->fVSUnis.push_back();
mat->setTypeModifier(GrGLShaderVar::kUniform_TypeModifier);
locations->fTextureMatrixUni = kUseUniform;
- #endif
+
tex_matrix_name(stageNum, mat->accessName());
mat->setType(kMat33f_GrSLType);
matName = mat->getName().c_str();
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index c4aebf66ac..991f86f21e 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -260,7 +260,6 @@ private:
public:
enum {
kUnusedUniform = -1,
- kSetAsAttribute = 1000,
};
struct StageUniLocations {
diff --git a/src/gpu/gl/GrGpuGLShaders.cpp b/src/gpu/gl/GrGpuGLShaders.cpp
index 49aa87c3e6..177f48a1a8 100644
--- a/src/gpu/gl/GrGpuGLShaders.cpp
+++ b/src/gpu/gl/GrGpuGLShaders.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "GrGpuGLShaders.h"
#include "GrBinHashKey.h"
#include "effects/GrConvolutionEffect.h"
@@ -12,7 +13,6 @@
#include "GrGLProgram.h"
#include "GrGLProgramStage.h"
#include "GrGLSL.h"
-#include "GrGpuGLShaders.h"
#include "GrGpuVertex.h"
#include "GrNoncopyable.h"
#include "GrProgramStageFactory.h"
@@ -356,48 +356,6 @@ GrGpuGLShaders::~GrGpuGLShaders() {
delete fProgramCache;
}
-const GrMatrix& GrGpuGLShaders::getHWViewMatrix() {
- GrAssert(fProgramData);
-
- if (GrGLProgram::kSetAsAttribute ==
- fProgramData->fUniLocations.fViewMatrixUni) {
- return fHWDrawState.getViewMatrix();
- } else {
- return fProgramData->fViewMatrix;
- }
-}
-
-void GrGpuGLShaders::recordHWViewMatrix(const GrMatrix& matrix) {
- GrAssert(fProgramData);
- if (GrGLProgram::kSetAsAttribute ==
- fProgramData->fUniLocations.fViewMatrixUni) {
- fHWDrawState.setViewMatrix(matrix);
- } else {
- fProgramData->fViewMatrix = matrix;
- }
-}
-
-const GrMatrix& GrGpuGLShaders::getHWSamplerMatrix(int stage) {
- GrAssert(fProgramData);
-
- if (GrGLProgram::kSetAsAttribute ==
- fProgramData->fUniLocations.fStages[stage].fTextureMatrixUni) {
- return fHWDrawState.getSampler(stage).getMatrix();
- } else {
- return fProgramData->fTextureMatrices[stage];
- }
-}
-
-void GrGpuGLShaders::recordHWSamplerMatrix(int stage, const GrMatrix& matrix) {
- GrAssert(fProgramData);
- if (GrGLProgram::kSetAsAttribute ==
- fProgramData->fUniLocations.fStages[stage].fTextureMatrixUni) {
- *fHWDrawState.sampler(stage)->matrix() = matrix;
- } else {
- fProgramData->fTextureMatrices[stage] = matrix;
- }
-}
-
void GrGpuGLShaders::onResetContext() {
INHERITED::onResetContext();
@@ -428,7 +386,7 @@ void GrGpuGLShaders::onResetContext() {
void GrGpuGLShaders::flushViewMatrix() {
const GrMatrix& vm = this->getDrawState().getViewMatrix();
- if (!GrGpuGLShaders::getHWViewMatrix().cheapEqualTo(vm)) {
+ if (!fProgramData->fViewMatrix.cheapEqualTo(vm)) {
const GrRenderTarget* rt = this->getDrawState().getRenderTarget();
GrAssert(NULL != rt);
@@ -453,19 +411,11 @@ void GrGpuGLShaders::flushViewMatrix() {
GrScalarToFloat(m[GrMatrix::kMPersp2])
};
- if (GrGLProgram::kSetAsAttribute ==
- fProgramData->fUniLocations.fViewMatrixUni) {
- int baseIdx = GrGLProgram::ViewMatrixAttributeIdx();
- GL_CALL(VertexAttrib4fv(baseIdx + 0, mt+0));
- GL_CALL(VertexAttrib4fv(baseIdx + 1, mt+3));
- GL_CALL(VertexAttrib4fv(baseIdx + 2, mt+6));
- } else {
- GrAssert(GrGLProgram::kUnusedUniform !=
- fProgramData->fUniLocations.fViewMatrixUni);
- GL_CALL(UniformMatrix3fv(fProgramData->fUniLocations.fViewMatrixUni,
- 1, false, mt));
- }
- this->recordHWViewMatrix(vm);
+ GrAssert(GrGLProgram::kUnusedUniform !=
+ fProgramData->fUniLocations.fViewMatrixUni);
+ GL_CALL(UniformMatrix3fv(fProgramData->fUniLocations.fViewMatrixUni,
+ 1, false, mt));
+ fProgramData->fViewMatrix = vm;
}
}
@@ -511,7 +461,7 @@ void GrGpuGLShaders::flushTextureMatrix(int s) {
const GrGLTexture* texture =
static_cast<const GrGLTexture*>(drawState.getTexture(s));
if (NULL != texture) {
- const GrMatrix& hwMatrix = this->getHWSamplerMatrix(s);
+ const GrMatrix& hwMatrix = fProgramData->fTextureMatrices[s];
const GrMatrix& samplerMatrix = drawState.getSampler(s).getMatrix();
if (GrGLProgram::kUnusedUniform != uni &&
(((1 << s) & fDirtyFlags.fTextureChangedMask) ||
@@ -536,16 +486,8 @@ void GrGpuGLShaders::flushTextureMatrix(int s) {
GrScalarToFloat(m[GrMatrix::kMPersp2])
};
- if (GrGLProgram::kSetAsAttribute ==
- fProgramData->fUniLocations.fStages[s].fTextureMatrixUni) {
- int baseIdx = GrGLProgram::TextureMatrixAttributeIdx(s);
- GL_CALL(VertexAttrib4fv(baseIdx + 0, mt+0));
- GL_CALL(VertexAttrib4fv(baseIdx + 1, mt+3));
- GL_CALL(VertexAttrib4fv(baseIdx + 2, mt+6));
- } else {
- GL_CALL(UniformMatrix3fv(uni, 1, false, mt));
- }
- this->recordHWSamplerMatrix(s, drawState.getSampler(s).getMatrix());
+ GL_CALL(UniformMatrix3fv(uni, 1, false, mt));
+ fProgramData->fTextureMatrices[s] = samplerMatrix;
}
}
}
diff --git a/src/gpu/gl/GrGpuGLShaders.h b/src/gpu/gl/GrGpuGLShaders.h
index b983389aa7..bd6ccd3b53 100644
--- a/src/gpu/gl/GrGpuGLShaders.h
+++ b/src/gpu/gl/GrGpuGLShaders.h
@@ -45,12 +45,6 @@ private:
class ProgramCache;
- // Helpers to make code more readable
- const GrMatrix& getHWViewMatrix();
- void recordHWViewMatrix(const GrMatrix& matrix);
- const GrMatrix& getHWSamplerMatrix(int stage);
- void recordHWSamplerMatrix(int stage, const GrMatrix& matrix);
-
// sets the texture matrix uniform for currently bound program
void flushTextureMatrix(int stage);