Plumb OptDrawState down to VertexShaderBuilder
BUG=skia: Review URL: https://codereview.chromium.org/628293002
This commit is contained in:
parent
1564dde11a
commit
307796bc2e
@ -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());
|
||||
|
@ -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[],
|
||||
|
@ -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[]);
|
||||
|
@ -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()));
|
||||
|
@ -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);
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
class GrGLFragmentOnlyProgramBuilder : public GrGLProgramBuilder {
|
||||
public:
|
||||
GrGLFragmentOnlyProgramBuilder(GrGpuGL*, const GrGLProgramDesc&);
|
||||
GrGLFragmentOnlyProgramBuilder(GrGpuGL*, const GrOptDrawState&, const GrGLProgramDesc&);
|
||||
|
||||
int addTexCoordSets(int count);
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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++) {
|
||||
|
@ -332,7 +332,9 @@ bool GrGpuGL::programUnitTest(int maxStages) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SkAutoTUnref<GrOptDrawState> optState(this->getDrawState().createOptState(*this->caps()));
|
||||
SkAutoTUnref<GrGLProgram> program(GrGLProgram::Create(this,
|
||||
*optState.get(),
|
||||
pdesc,
|
||||
geometryProcessor.get(),
|
||||
stages,
|
||||
|
Loading…
Reference in New Issue
Block a user