aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLProgramDesc.cpp
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2014-09-04 08:56:46 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-09-04 08:56:46 -0700
commitbd769d0f1c8cf6ccbb2738dfad1624a4c828e4eb (patch)
tree1fb4cd896c5d63bf3eb0dddbbd7259edab8703e3 /src/gpu/gl/GrGLProgramDesc.cpp
parentc5ba71d2e5cd426def66fa49dcf003e5b2c98dc7 (diff)
Initial change to create GeometryProcessor
BUG=skia: R=bsalomon@google.com, robertphillips@google.com, egdaniel@google.com, jvanverth@google.com Author: joshualitt@chromium.org Review URL: https://codereview.chromium.org/509153002
Diffstat (limited to 'src/gpu/gl/GrGLProgramDesc.cpp')
-rw-r--r--src/gpu/gl/GrGLProgramDesc.cpp53
1 files changed, 45 insertions, 8 deletions
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 545ed2114c..8d0ea3d6b3 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -53,6 +53,7 @@ bool GrGLProgramDesc::Build(const GrDrawState& drawState,
GrBlendCoeff dstCoeff,
const GrGpuGL* gpu,
const GrDeviceCoordTexture* dstCopy,
+ const GrEffectStage** geometryProcessor,
SkTArray<const GrEffectStage*, true>* colorStages,
SkTArray<const GrEffectStage*, true>* coverageStages,
GrGLProgramDesc* desc) {
@@ -69,6 +70,7 @@ bool GrGLProgramDesc::Build(const GrDrawState& drawState,
int firstEffectiveColorStage = 0;
bool inputColorIsUsed = true;
+
if (!skipColor) {
firstEffectiveColorStage = drawState.numColorStages();
while (firstEffectiveColorStage > 0 && inputColorIsUsed) {
@@ -107,6 +109,9 @@ bool GrGLProgramDesc::Build(const GrDrawState& drawState,
bool requiresVertexShader = !GrGpu::IsPathRenderingDrawType(drawType);
int numStages = 0;
+ if (drawState.hasGeometryProcessor()) {
+ numStages++;
+ }
if (!skipColor) {
numStages += drawState.numColorStages() - firstEffectiveColorStage;
}
@@ -120,12 +125,42 @@ bool GrGLProgramDesc::Build(const GrDrawState& drawState,
int offsetAndSizeIndex = 0;
bool effectKeySuccess = true;
+
+ KeyHeader* header = desc->header();
+ // make sure any padding in the header is zeroed.
+ memset(desc->header(), 0, kHeaderSize);
+
+ // We can only have one effect which touches the vertex shader
+ if (drawState.hasGeometryProcessor()) {
+ uint16_t* offsetAndSize =
+ reinterpret_cast<uint16_t*>(desc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset +
+ offsetAndSizeIndex * 2 * sizeof(uint16_t));
+
+ GrEffectKeyBuilder b(&desc->fKey);
+ uint16_t effectKeySize;
+ uint32_t effectOffset = desc->fKey.count();
+ effectKeySuccess |= GetEffectKeyAndUpdateStats(
+ *drawState.getGeometryProcessor(), gpu->glCaps(),
+ requiresLocalCoordAttrib, &b,
+ &effectKeySize, &readsDst,
+ &readFragPosition, &requiresVertexShader);
+ effectKeySuccess |= (effectOffset <= SK_MaxU16);
+
+ offsetAndSize[0] = SkToU16(effectOffset);
+ offsetAndSize[1] = effectKeySize;
+ ++offsetAndSizeIndex;
+ *geometryProcessor = drawState.getGeometryProcessor();
+ SkASSERT(requiresVertexShader);
+ header->fHasGeometryProcessor = true;
+ }
+
if (!skipColor) {
for (int s = firstEffectiveColorStage; s < drawState.numColorStages(); ++s) {
uint16_t* offsetAndSize =
reinterpret_cast<uint16_t*>(desc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset +
offsetAndSizeIndex * 2 * sizeof(uint16_t));
+ bool effectRequiresVertexShader = false;
GrEffectKeyBuilder b(&desc->fKey);
uint16_t effectKeySize;
uint32_t effectOffset = desc->fKey.count();
@@ -133,12 +168,13 @@ bool GrGLProgramDesc::Build(const GrDrawState& drawState,
drawState.getColorStage(s), gpu->glCaps(),
requiresLocalCoordAttrib, &b,
&effectKeySize, &readsDst,
- &readFragPosition, &requiresVertexShader);
+ &readFragPosition, &effectRequiresVertexShader);
effectKeySuccess |= (effectOffset <= SK_MaxU16);
offsetAndSize[0] = SkToU16(effectOffset);
offsetAndSize[1] = effectKeySize;
++offsetAndSizeIndex;
+ SkASSERT(!effectRequiresVertexShader);
}
}
if (!skipCoverage) {
@@ -147,6 +183,7 @@ bool GrGLProgramDesc::Build(const GrDrawState& drawState,
reinterpret_cast<uint16_t*>(desc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset +
offsetAndSizeIndex * 2 * sizeof(uint16_t));
+ bool effectRequiresVertexShader = false;
GrEffectKeyBuilder b(&desc->fKey);
uint16_t effectKeySize;
uint32_t effectOffset = desc->fKey.count();
@@ -154,12 +191,13 @@ bool GrGLProgramDesc::Build(const GrDrawState& drawState,
drawState.getCoverageStage(s), gpu->glCaps(),
requiresLocalCoordAttrib, &b,
&effectKeySize, &readsDst,
- &readFragPosition, &requiresVertexShader);
+ &readFragPosition, &effectRequiresVertexShader);
effectKeySuccess |= (effectOffset <= SK_MaxU16);
offsetAndSize[0] = SkToU16(effectOffset);
offsetAndSize[1] = effectKeySize;
++offsetAndSizeIndex;
+ SkASSERT(!effectRequiresVertexShader);
}
}
if (!effectKeySuccess) {
@@ -167,10 +205,6 @@ bool GrGLProgramDesc::Build(const GrDrawState& drawState,
return false;
}
- KeyHeader* header = desc->header();
- // make sure any padding in the header is zeroed.
- memset(desc->header(), 0, kHeaderSize);
-
// Because header is a pointer into the dynamic array, we can't push any new data into the key
// below here.
@@ -259,9 +293,11 @@ bool GrGLProgramDesc::Build(const GrDrawState& drawState,
header->fCoverageOutput = kModulate_CoverageOutput;
// If we do have coverage determine whether it matters.
- bool separateCoverageFromColor = false;
+ bool separateCoverageFromColor = drawState.hasGeometryProcessor();
if (!drawState.isCoverageDrawing() && !skipCoverage &&
- (drawState.numCoverageStages() > 0 || requiresCoverageAttrib)) {
+ (drawState.numCoverageStages() > 0 ||
+ drawState.hasGeometryProcessor() ||
+ requiresCoverageAttrib)) {
if (gpu->caps()->dualSourceBlendingSupport() &&
!(blendOpts & (GrDrawState::kEmitCoverage_BlendOptFlag |
@@ -286,6 +322,7 @@ bool GrGLProgramDesc::Build(const GrDrawState& drawState,
separateCoverageFromColor = true;
}
}
+
if (!skipColor) {
for (int s = firstEffectiveColorStage; s < drawState.numColorStages(); ++s) {
colorStages->push_back(&drawState.getColorStage(s));