aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2014-10-06 12:13:54 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-06 12:13:54 -0700
commit307796bc2e3731099d96773db7385fe70cb94f7d (patch)
treed76c7887045df86f570a09470ac9095dbbbbf723 /src/gpu/gl
parent1564dde11af9f8ab1e4394af1599c5772accf710 (diff)
Plumb OptDrawState down to VertexShaderBuilder
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/GrGLProgram.cpp5
-rw-r--r--src/gpu/gl/GrGLProgram.h1
-rw-r--r--src/gpu/gl/GrGpuGL.h3
-rw-r--r--src/gpu/gl/GrGpuGL_program.cpp10
-rw-r--r--src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp3
-rw-r--r--src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.h2
-rw-r--r--src/gpu/gl/builders/GrGLFullProgramBuilder.cpp4
-rw-r--r--src/gpu/gl/builders/GrGLFullProgramBuilder.h2
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.cpp3
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.h4
-rw-r--r--src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp11
11 files changed, 26 insertions, 22 deletions
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index aae9bd8ce1..480e1b7735 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -24,6 +24,7 @@
#define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X)
GrGLProgram* GrGLProgram::Create(GrGpuGL* gpu,
+ const GrOptDrawState& optState,
const GrGLProgramDesc& desc,
const GrGeometryStage* geometryProcessor,
const GrFragmentStage* colorStages[],
@@ -34,9 +35,9 @@ GrGLProgram* GrGLProgram::Create(GrGpuGL* gpu,
SkASSERT(gpu->glPathRendering()->texturingMode() ==
GrGLPathRendering::FixedFunction_TexturingMode);
SkASSERT(NULL == geometryProcessor);
- builder.reset(SkNEW_ARGS(GrGLFragmentOnlyProgramBuilder, (gpu, desc)));
+ builder.reset(SkNEW_ARGS(GrGLFragmentOnlyProgramBuilder, (gpu, optState, desc)));
} else {
- builder.reset(SkNEW_ARGS(GrGLFullProgramBuilder, (gpu, desc)));
+ builder.reset(SkNEW_ARGS(GrGLFullProgramBuilder, (gpu, optState, desc)));
}
if (builder->genProgram(geometryProcessor, colorStages, coverageStages)) {
SkASSERT(0 != builder->getProgramID());
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index ce7e6b0987..21593e351f 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -40,6 +40,7 @@ public:
typedef GrGLProgramBuilder::BuiltinUniformHandles BuiltinUniformHandles;
static GrGLProgram* Create(GrGpuGL* gpu,
+ const GrOptDrawState& optState,
const GrGLProgramDesc& desc,
const GrGeometryStage* geometryProcessor,
const GrFragmentStage* colorStages[],
diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h
index e5f2915a24..7ace6788d1 100644
--- a/src/gpu/gl/GrGpuGL.h
+++ b/src/gpu/gl/GrGpuGL.h
@@ -179,7 +179,8 @@ private:
~ProgramCache();
void abandon();
- GrGLProgram* getProgram(const GrGLProgramDesc& desc,
+ GrGLProgram* getProgram(const GrOptDrawState& optState,
+ const GrGLProgramDesc& desc,
const GrGeometryStage* geometryProcessor,
const GrFragmentStage* colorStages[],
const GrFragmentStage* coverageStages[]);
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index 2e6bfc4f92..363d87fbfb 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -90,7 +90,8 @@ int GrGpuGL::ProgramCache::search(const GrGLProgramDesc& desc) const {
return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less);
}
-GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrGLProgramDesc& desc,
+GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState,
+ const GrGLProgramDesc& desc,
const GrGeometryStage* geometryProcessor,
const GrFragmentStage* colorStages[],
const GrFragmentStage* coverageStages[]) {
@@ -128,8 +129,8 @@ GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrGLProgramDesc& desc,
#ifdef PROGRAM_CACHE_STATS
++fCacheMisses;
#endif
- GrGLProgram* program = GrGLProgram::Create(fGpu, desc, geometryProcessor,
- colorStages, coverageStages);
+ GrGLProgram* program = GrGLProgram::Create(fGpu, optState, desc, geometryProcessor,
+ colorStages, coverageStages);
if (NULL == program) {
return NULL;
}
@@ -245,7 +246,8 @@ bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC
return false;
}
- fCurrentProgram.reset(fProgramCache->getProgram(desc,
+ fCurrentProgram.reset(fProgramCache->getProgram(*optState.get(),
+ desc,
geometryProcessor,
colorStages.begin(),
coverageStages.begin()));
diff --git a/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp b/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp
index 2c70a75ca9..d5bccd7025 100644
--- a/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp
@@ -9,8 +9,9 @@
#include "../GrGpuGL.h"
GrGLFragmentOnlyProgramBuilder::GrGLFragmentOnlyProgramBuilder(GrGpuGL* gpu,
+ const GrOptDrawState& optState,
const GrGLProgramDesc& desc)
- : INHERITED(gpu, desc) {
+ : INHERITED(gpu, optState, desc) {
SkASSERT(desc.getHeader().fUseFragShaderOnly);
SkASSERT(gpu->glCaps().pathRenderingSupport());
SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fColorInput);
diff --git a/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.h b/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.h
index b1fb88d954..06c15fdfe1 100644
--- a/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.h
@@ -12,7 +12,7 @@
class GrGLFragmentOnlyProgramBuilder : public GrGLProgramBuilder {
public:
- GrGLFragmentOnlyProgramBuilder(GrGpuGL*, const GrGLProgramDesc&);
+ GrGLFragmentOnlyProgramBuilder(GrGpuGL*, const GrOptDrawState&, const GrGLProgramDesc&);
int addTexCoordSets(int count);
diff --git a/src/gpu/gl/builders/GrGLFullProgramBuilder.cpp b/src/gpu/gl/builders/GrGLFullProgramBuilder.cpp
index 46db712a96..d309b27583 100644
--- a/src/gpu/gl/builders/GrGLFullProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLFullProgramBuilder.cpp
@@ -9,9 +9,9 @@
#include "../GrGLGeometryProcessor.h"
#include "../GrGpuGL.h"
-GrGLFullProgramBuilder::GrGLFullProgramBuilder(GrGpuGL* gpu,
+GrGLFullProgramBuilder::GrGLFullProgramBuilder(GrGpuGL* gpu, const GrOptDrawState& optState,
const GrGLProgramDesc& desc)
- : INHERITED(gpu, desc)
+ : INHERITED(gpu, optState, desc)
, fGLGeometryProcessorEmitter(this)
, fGS(this)
, fVS(this) {
diff --git a/src/gpu/gl/builders/GrGLFullProgramBuilder.h b/src/gpu/gl/builders/GrGLFullProgramBuilder.h
index 41da17ff9e..0f3834187b 100644
--- a/src/gpu/gl/builders/GrGLFullProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLFullProgramBuilder.h
@@ -15,7 +15,7 @@ class GrGLVertexProgramEffects;
class GrGLFullProgramBuilder : public GrGLProgramBuilder {
public:
- GrGLFullProgramBuilder(GrGpuGL*, const GrGLProgramDesc&);
+ GrGLFullProgramBuilder(GrGpuGL*, const GrOptDrawState&, const GrGLProgramDesc&);
/** Add a varying variable to the current program to pass values between vertex and fragment
shaders. If the last two parameters are non-NULL, they are filled in with the name
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 909ac76d62..de08ec4ad0 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -82,7 +82,7 @@ bool GrGLProgramBuilder::genProgram(const GrGeometryStage* geometryProcessor,
//////////////////////////////////////////////////////////////////////////////
-GrGLProgramBuilder::GrGLProgramBuilder(GrGpuGL* gpu,
+GrGLProgramBuilder::GrGLProgramBuilder(GrGpuGL* gpu, const GrOptDrawState& optState,
const GrGLProgramDesc& desc)
: fEffectEmitter(NULL)
, fFragOnly(SkToBool(desc.getHeader().fUseFragShaderOnly))
@@ -91,6 +91,7 @@ GrGLProgramBuilder::GrGLProgramBuilder(GrGpuGL* gpu,
, fFS(this, desc)
, fSeparableVaryingInfos(kVarsPerBlock)
, fGrProcessorEmitter(this)
+ , fOptState(optState)
, fDesc(desc)
, fGpu(gpu)
, fUniforms(kVarsPerBlock) {
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h
index f6397d8871..7fa8ba266c 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.h
@@ -145,8 +145,9 @@ public:
protected:
typedef GrTAllocator<GrGLShaderVar> VarArray;
- GrGLProgramBuilder(GrGpuGL*, const GrGLProgramDesc&);
+ GrGLProgramBuilder(GrGpuGL*, const GrOptDrawState&, const GrGLProgramDesc&);
+ const GrOptDrawState& optState() const { return fOptState; }
const GrGLProgramDesc& desc() const { return fDesc; }
// Helper for emitEffects().
@@ -326,6 +327,7 @@ private:
GrGLFragmentProcessorEmitter fGrProcessorEmitter;
+ const GrOptDrawState& fOptState;
const GrGLProgramDesc& fDesc;
GrGpuGL* fGpu;
UniformInfoArray fUniforms;
diff --git a/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp b/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
index 4877071d77..55ce7d1458 100644
--- a/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
@@ -82,14 +82,9 @@ void GrGLVertexShaderBuilder::bindProgramLocations(GrGLuint programId) {
coverage_attribute_name()));
}
- // We pull the current state of attributes off of drawstate's optimized state and bind them in
- // order. This assumes that the drawState has not changed since we called flushGraphicsState()
- // higher up in the stack.
- const GrDrawTargetCaps* caps = fProgramBuilder->gpu()->caps();
- const GrDrawState& drawState = *fProgramBuilder->gpu()->drawState();
- SkAutoTUnref<GrOptDrawState> optState(drawState.createOptState(*caps));
- const GrVertexAttrib* vaPtr = optState->getVertexAttribs();
- const int vaCount = optState->getVertexAttribCount();
+ const GrOptDrawState& optState = fProgramBuilder->optState();
+ const GrVertexAttrib* vaPtr = optState.getVertexAttribs();
+ const int vaCount = optState.getVertexAttribCount();
int i = fEffectAttribOffset;
for (int index = 0; index < vaCount; index++) {