aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/builders
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2014-10-28 17:59:26 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-28 17:59:26 -0700
commit79f8faeea2692d2948c0f634e956d1e7fc8333e0 (patch)
treea4de457cd96b8b8ada35fa277e79fd7fb47f2e4b /src/gpu/gl/builders
parent7a5693178414e133426f99b45d703ee2b0078af4 (diff)
OptState owns program descriptor
Diffstat (limited to 'src/gpu/gl/builders')
-rw-r--r--src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp14
-rw-r--r--src/gpu/gl/builders/GrGLFragmentShaderBuilder.h2
-rw-r--r--src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp2
-rw-r--r--src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.cpp7
-rw-r--r--src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.h2
-rw-r--r--src/gpu/gl/builders/GrGLNvprProgramBuilder.cpp5
-rw-r--r--src/gpu/gl/builders/GrGLNvprProgramBuilder.h2
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.cpp56
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.h20
-rw-r--r--src/gpu/gl/builders/GrGLShaderBuilder.h1
-rw-r--r--src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp2
11 files changed, 54 insertions, 59 deletions
diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
index ff3989bf63..6aeba7a9ee 100644
--- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
@@ -69,12 +69,12 @@ GrGLFragmentShaderBuilder::KeyForFragmentPosition(const GrRenderTarget* dst, con
}
GrGLFragmentShaderBuilder::GrGLFragmentShaderBuilder(GrGLProgramBuilder* program,
- const GrGLProgramDesc& desc)
+ uint8_t fragPosKey)
: INHERITED(program)
, fHasCustomColorOutput(false)
, fHasSecondaryOutput(false)
, fSetupFragPosition(false)
- , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == desc.getHeader().fFragPosKey)
+ , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == fragPosKey)
, fCustomColorOutputIndex(-1)
, fHasReadDstColor(false)
, fHasReadFragmentPosition(false) {
@@ -262,13 +262,13 @@ void GrGLFragmentShaderBuilder::enableSecondaryOutput(const GrGLSLExpr4& inputCo
const char* secondaryOutputName = this->getSecondaryColorOutputName();
GrGLSLExpr4 coeff(1);
switch (fProgramBuilder->header().fSecondaryOutputType) {
- case GrOptDrawState::kCoverage_SecondaryOutputType:
+ case GrProgramDesc::kCoverage_SecondaryOutputType:
break;
- case GrOptDrawState::kCoverageISA_SecondaryOutputType:
+ case GrProgramDesc::kCoverageISA_SecondaryOutputType:
// Get (1-A) into coeff
coeff = GrGLSLExpr4::VectorCast(GrGLSLExpr1(1) - inputColor.a());
break;
- case GrOptDrawState::kCoverageISC_SecondaryOutputType:
+ case GrProgramDesc::kCoverageISC_SecondaryOutputType:
// Get (1-RGBA) into coeff
coeff = GrGLSLExpr4(1) - inputColor;
break;
@@ -283,9 +283,9 @@ void GrGLFragmentShaderBuilder::combineColorAndCoverage(const GrGLSLExpr4& input
const GrGLSLExpr4& inputCoverage) {
GrGLSLExpr4 fragColor = inputColor * inputCoverage;
switch (fProgramBuilder->header().fPrimaryOutputType) {
- case GrOptDrawState::kModulate_PrimaryOutputType:
+ case GrProgramDesc::kModulate_PrimaryOutputType:
break;
- case GrOptDrawState::kCombineWithDst_PrimaryOutputType:
+ case GrProgramDesc::kCombineWithDst_PrimaryOutputType:
{
// Tack on "+(1-coverage)dst onto the frag color.
GrGLSLExpr4 dstCoeff = GrGLSLExpr4(1) - inputCoverage;
diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
index b5f83d46db..226be518c3 100644
--- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
+++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
@@ -84,7 +84,7 @@ public:
the key is 0. */
static FragPosKey KeyForFragmentPosition(const GrRenderTarget* dst, const GrGLCaps&);
- GrGLFragmentShaderBuilder(GrGLProgramBuilder* program, const GrGLProgramDesc& desc);
+ GrGLFragmentShaderBuilder(GrGLProgramBuilder* program, uint8_t fragPosKey);
// true public interface, defined explicitly in the abstract interfaces above
virtual bool enableFeature(GLSLFeature) SK_OVERRIDE;
diff --git a/src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp b/src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp
index af95f564cf..f35c9ba910 100644
--- a/src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp
@@ -48,7 +48,7 @@ bool GrGLGeometryBuilder::compileAndAttachShaders(GrGLuint programId,
geomShaderSrc.append("void main() {\n");
geomShaderSrc.append("\tfor (int i = 0; i < 3; ++i) {\n"
"\t\tgl_Position = gl_in[i].gl_Position;\n");
- if (fProgramBuilder->desc().getHeader().fEmitsPointSize) {
+ if (fProgramBuilder->desc().header().fEmitsPointSize) {
geomShaderSrc.append("\t\tgl_PointSize = 1.0;\n");
}
SkASSERT(fInputs.count() == fOutputs.count());
diff --git a/src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.cpp b/src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.cpp
index 1c1cb42122..c0c4fbb46e 100644
--- a/src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.cpp
@@ -9,12 +9,9 @@
#include "../GrGpuGL.h"
GrGLLegacyNvprProgramBuilder::GrGLLegacyNvprProgramBuilder(GrGpuGL* gpu,
- const GrOptDrawState& optState,
- const GrGLProgramDesc& desc)
- : INHERITED(gpu, optState, desc)
+ const GrOptDrawState& optState)
+ : INHERITED(gpu, optState)
, fTexCoordSetCnt(0) {
- SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fColorInput);
- SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fCoverageInput);
}
int GrGLLegacyNvprProgramBuilder::addTexCoordSets(int count) {
diff --git a/src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.h b/src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.h
index dabec081b4..cd2cfb7453 100644
--- a/src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.h
@@ -12,7 +12,7 @@
class GrGLLegacyNvprProgramBuilder : public GrGLProgramBuilder {
public:
- GrGLLegacyNvprProgramBuilder(GrGpuGL*, const GrOptDrawState&, const GrGLProgramDesc&);
+ GrGLLegacyNvprProgramBuilder(GrGpuGL*, const GrOptDrawState&);
virtual GrGLProgram* createProgram(GrGLuint programID);
diff --git a/src/gpu/gl/builders/GrGLNvprProgramBuilder.cpp b/src/gpu/gl/builders/GrGLNvprProgramBuilder.cpp
index 3d991a2e2c..5488252b28 100644
--- a/src/gpu/gl/builders/GrGLNvprProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLNvprProgramBuilder.cpp
@@ -12,9 +12,8 @@
#define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X)
GrGLNvprProgramBuilder::GrGLNvprProgramBuilder(GrGpuGL* gpu,
- const GrOptDrawState& optState,
- const GrGLProgramDesc& desc)
- : INHERITED(gpu, optState, desc)
+ const GrOptDrawState& optState)
+ : INHERITED(gpu, optState)
, fSeparableVaryingInfos(kVarsPerBlock) {
}
diff --git a/src/gpu/gl/builders/GrGLNvprProgramBuilder.h b/src/gpu/gl/builders/GrGLNvprProgramBuilder.h
index 008aff74d7..e9f6b3b872 100644
--- a/src/gpu/gl/builders/GrGLNvprProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLNvprProgramBuilder.h
@@ -12,7 +12,7 @@
class GrGLNvprProgramBuilder : public GrGLProgramBuilder {
public:
- GrGLNvprProgramBuilder(GrGpuGL*, const GrOptDrawState&, const GrGLProgramDesc&);
+ GrGLNvprProgramBuilder(GrGpuGL*, const GrOptDrawState&);
/*
* The separable varying info must be passed to GrGLProgram so this must
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 65a7cdaa63..6df086c1a1 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -29,19 +29,17 @@ static const GrGLShaderVar::Precision kDefaultFragmentPrecision = GrGLShaderVar:
const int GrGLProgramBuilder::kVarsPerBlock = 8;
GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState,
- const GrGLProgramDesc& desc,
GrGpu::DrawType drawType,
GrGpuGL* gpu) {
// create a builder. This will be handed off to effects so they can use it to add
// uniforms, varyings, textures, etc
- SkAutoTDelete<GrGLProgramBuilder> builder(CreateProgramBuilder(desc,
- optState,
+ SkAutoTDelete<GrGLProgramBuilder> builder(CreateProgramBuilder(optState,
drawType,
optState.hasGeometryProcessor(),
gpu));
GrGLProgramBuilder* pb = builder.get();
- const GrGLProgramDesc::KeyHeader& header = pb->header();
+ const GrGLProgramDescBuilder::GLKeyHeader& header = GrGLProgramDescBuilder::GetHeader(pb->desc());
// emit code to read the dst copy texture, if necessary
if (GrGLFragmentShaderBuilder::kNoDstRead_DstReadKey != header.fDstReadKey
@@ -64,10 +62,10 @@ GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState,
if (header.fEmitsPointSize) {
pb->fVS.codeAppend("gl_PointSize = 1.0;");
}
- if (GrGLProgramDesc::kAttribute_ColorInput == header.fColorInput) {
+ if (GrProgramDesc::kAttribute_ColorInput == header.fColorInput) {
pb->fVS.setupBuiltinVertexAttribute("Color", &inputColor);
}
- if (GrGLProgramDesc::kAttribute_ColorInput == header.fCoverageInput) {
+ if (GrProgramDesc::kAttribute_ColorInput == header.fCoverageInput) {
pb->fVS.setupBuiltinVertexAttribute("Coverage", &inputCoverage);
}
}
@@ -79,7 +77,7 @@ GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState,
}
// write the secondary color output if necessary
- if (GrOptDrawState::kNone_SecondaryOutputType != header.fSecondaryOutputType) {
+ if (GrProgramDesc::kNone_SecondaryOutputType != header.fSecondaryOutputType) {
pb->fFS.enableSecondaryOutput(inputColor, inputCoverage);
}
@@ -89,38 +87,38 @@ GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState,
}
GrGLProgramBuilder*
-GrGLProgramBuilder::CreateProgramBuilder(const GrGLProgramDesc& desc,
- const GrOptDrawState& optState,
+GrGLProgramBuilder::CreateProgramBuilder(const GrOptDrawState& optState,
GrGpu::DrawType drawType,
bool hasGeometryProcessor,
GrGpuGL* gpu) {
- if (desc.getHeader().fUseNvpr) {
+ const GrProgramDesc& desc = optState.programDesc();
+ if (GrGLProgramDescBuilder::GetHeader(desc).fUseNvpr) {
SkASSERT(gpu->glCaps().pathRenderingSupport());
+ SkASSERT(GrProgramDesc::kAttribute_ColorInput != desc.header().fColorInput);
+ SkASSERT(GrProgramDesc::kAttribute_ColorInput != desc.header().fCoverageInput);
SkASSERT(!hasGeometryProcessor);
if (gpu->glPathRendering()->texturingMode() ==
GrGLPathRendering::FixedFunction_TexturingMode) {
- return SkNEW_ARGS(GrGLLegacyNvprProgramBuilder, (gpu, optState, desc));
+ return SkNEW_ARGS(GrGLLegacyNvprProgramBuilder, (gpu, optState));
} else {
- return SkNEW_ARGS(GrGLNvprProgramBuilder, (gpu, optState, desc));
+ return SkNEW_ARGS(GrGLNvprProgramBuilder, (gpu, optState));
}
} else {
- return SkNEW_ARGS(GrGLProgramBuilder, (gpu, optState, desc));
+ return SkNEW_ARGS(GrGLProgramBuilder, (gpu, optState));
}
}
/////////////////////////////////////////////////////////////////////////////
-GrGLProgramBuilder::GrGLProgramBuilder(GrGpuGL* gpu,
- const GrOptDrawState& optState,
- const GrGLProgramDesc& desc)
+GrGLProgramBuilder::GrGLProgramBuilder(GrGpuGL* gpu, const GrOptDrawState& optState)
: fVS(this)
, fGS(this)
- , fFS(this, desc)
+ , fFS(this, optState.programDesc().header().fFragPosKey)
, fOutOfStage(true)
, fStageIndex(-1)
, fGeometryProcessor(NULL)
, fOptState(optState)
- , fDesc(desc)
+ , fDesc(optState.programDesc())
, fGpu(gpu)
, fUniforms(kVarsPerBlock) {
}
@@ -202,8 +200,8 @@ const GrGLContextInfo& GrGLProgramBuilder::ctxInfo() const {
void GrGLProgramBuilder::setupUniformColorAndCoverageIfNeeded(GrGLSLExpr4* inputColor,
GrGLSLExpr4* inputCoverage) {
- const GrGLProgramDesc::KeyHeader& header = this->header();
- if (GrGLProgramDesc::kUniform_ColorInput == header.fColorInput) {
+ const GrProgramDesc::KeyHeader& header = this->header();
+ if (GrProgramDesc::kUniform_ColorInput == header.fColorInput) {
const char* name;
fUniformHandles.fColorUni =
this->addUniform(GrGLProgramBuilder::kFragment_Visibility,
@@ -211,10 +209,10 @@ void GrGLProgramBuilder::setupUniformColorAndCoverageIfNeeded(GrGLSLExpr4* input
"Color",
&name);
*inputColor = GrGLSLExpr4(name);
- } else if (GrGLProgramDesc::kAllOnes_ColorInput == header.fColorInput) {
+ } else if (GrProgramDesc::kAllOnes_ColorInput == header.fColorInput) {
*inputColor = GrGLSLExpr4(1);
}
- if (GrGLProgramDesc::kUniform_ColorInput == header.fCoverageInput) {
+ if (GrProgramDesc::kUniform_ColorInput == header.fCoverageInput) {
const char* name;
fUniformHandles.fCoverageUni =
this->addUniform(GrGLProgramBuilder::kFragment_Visibility,
@@ -222,7 +220,7 @@ void GrGLProgramBuilder::setupUniformColorAndCoverageIfNeeded(GrGLSLExpr4* input
"Coverage",
&name);
*inputCoverage = GrGLSLExpr4(name);
- } else if (GrGLProgramDesc::kAllOnes_ColorInput == header.fCoverageInput) {
+ } else if (GrProgramDesc::kAllOnes_ColorInput == header.fCoverageInput) {
*inputCoverage = GrGLSLExpr4(1);
}
}
@@ -236,7 +234,9 @@ void GrGLProgramBuilder::emitAndInstallProcs(const GrOptDrawState& optState,
if (optState.hasGeometryProcessor()) {
const GrGeometryProcessor& gp = *optState.getGeometryProcessor();
fVS.emitAttributes(gp);
- ProcKeyProvider keyProvider(&fDesc, ProcKeyProvider::kGeometry_ProcessorType);
+ ProcKeyProvider keyProvider(&fDesc,
+ ProcKeyProvider::kGeometry_ProcessorType,
+ GrGLProgramDescBuilder::kProcessorKeyOffsetsAndLengthOffset);
GrGLSLExpr4 output;
this->emitAndInstallProc<GrGeometryProcessor>(gp, 0, keyProvider, *inputCoverage, &output);
*inputCoverage = output;
@@ -245,7 +245,9 @@ void GrGLProgramBuilder::emitAndInstallProcs(const GrOptDrawState& optState,
}
void GrGLProgramBuilder::emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOut) {
- ProcKeyProvider keyProvider(&fDesc, ProcKeyProvider::kFragment_ProcessorType);
+ ProcKeyProvider keyProvider(&fDesc,
+ ProcKeyProvider::kFragment_ProcessorType,
+ GrGLProgramDescBuilder::kProcessorKeyOffsetsAndLengthOffset);
for (int e = procOffset; e < numProcs; ++e) {
GrGLSLExpr4 output;
const GrFragmentStage& stage = fOptState.getFragmentStage(e);
@@ -259,7 +261,7 @@ void GrGLProgramBuilder::emitAndInstallFragProcs(int procOffset, int numProcs, G
template <class Proc>
void GrGLProgramBuilder::emitAndInstallProc(const Proc& proc,
int index,
- const ProcKeyProvider keyProvider,
+ const ProcKeyProvider& keyProvider,
const GrGLSLExpr4& input,
GrGLSLExpr4* output) {
// Program builders have a bit of state we need to clear with each effect
@@ -419,7 +421,7 @@ GrGLProgram* GrGLProgramBuilder::finalize() {
this->cleanupProgram(programID, shadersToDelete);
return NULL;
}
- if (!(this->header().fUseNvpr &&
+ if (!(GrGLProgramDescBuilder::GetHeader(fDesc).fUseNvpr &&
fGpu->glPathRendering()->texturingMode() ==
GrGLPathRendering::FixedFunction_TexturingMode)) {
if (!fVS.compileAndAttachShaders(programID, &shadersToDelete)) {
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h
index 9d8e7e0ac9..0abdf0a122 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.h
@@ -169,10 +169,7 @@ public:
* to be used.
* @return true if generation was successful.
*/
- static GrGLProgram* CreateProgram(const GrOptDrawState&,
- const GrGLProgramDesc&,
- GrGpu::DrawType,
- GrGpuGL* gpu);
+ static GrGLProgram* CreateProgram(const GrOptDrawState&, GrGpu::DrawType, GrGpuGL*);
virtual UniformHandle addUniform(uint32_t visibility,
GrSLType type,
@@ -224,21 +221,20 @@ public:
};
protected:
- typedef GrGLProgramDesc::ProcKeyProvider ProcKeyProvider;
+ typedef GrProgramDesc::ProcKeyProvider ProcKeyProvider;
typedef GrGLProgramDataManager::UniformInfo UniformInfo;
typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray;
- static GrGLProgramBuilder* CreateProgramBuilder(const GrGLProgramDesc&,
- const GrOptDrawState&,
+ static GrGLProgramBuilder* CreateProgramBuilder(const GrOptDrawState&,
GrGpu::DrawType,
bool hasGeometryProcessor,
GrGpuGL*);
- GrGLProgramBuilder(GrGpuGL*, const GrOptDrawState&, const GrGLProgramDesc&);
+ GrGLProgramBuilder(GrGpuGL*, const GrOptDrawState&);
const GrOptDrawState& optState() const { return fOptState; }
- const GrGLProgramDesc& desc() const { return fDesc; }
- const GrGLProgramDesc::KeyHeader& header() const { return fDesc.getHeader(); }
+ const GrProgramDesc& desc() const { return fDesc; }
+ const GrProgramDesc::KeyHeader& header() const { return fDesc.header(); }
// Generates a name for a variable. The generated string will be name prefixed by the prefix
// char (unless the prefix is '\0'). It also mangles the name to be stage-specific if we're
@@ -252,7 +248,7 @@ protected:
template <class Proc>
void emitAndInstallProc(const Proc&,
int index,
- const ProcKeyProvider,
+ const ProcKeyProvider&,
const GrGLSLExpr4& input,
GrGLSLExpr4* output);
@@ -332,7 +328,7 @@ protected:
SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors;
const GrOptDrawState& fOptState;
- const GrGLProgramDesc& fDesc;
+ const GrProgramDesc& fDesc;
GrGpuGL* fGpu;
UniformInfoArray fUniforms;
diff --git a/src/gpu/gl/builders/GrGLShaderBuilder.h b/src/gpu/gl/builders/GrGLShaderBuilder.h
index cf7ae9b53d..8b7b9f9974 100644
--- a/src/gpu/gl/builders/GrGLShaderBuilder.h
+++ b/src/gpu/gl/builders/GrGLShaderBuilder.h
@@ -8,6 +8,7 @@
#ifndef GrGLShaderBuilder_DEFINED
#define GrGLShaderBuilder_DEFINED
+#include "gl/GrGLProcessor.h"
#include "gl/GrGLProgramDesc.h"
#include "gl/GrGLProgramDataManager.h"
diff --git a/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp b/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
index 1fa946793c..5a65f71fcc 100644
--- a/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
@@ -93,7 +93,7 @@ void GrGLVertexBuilder::transformSkiaToGLCoords() {
void GrGLVertexBuilder::bindVertexAttributes(GrGLuint programID) {
// Bind the attrib locations to same values for all shaders
- const GrGLProgramDesc::KeyHeader& header = fProgramBuilder->header();
+ const GrProgramDesc::KeyHeader& header = fProgramBuilder->header();
SkASSERT(-1 != header.fPositionAttributeIndex);
GL_CALL(BindAttribLocation(programID,
header.fPositionAttributeIndex,