Change GrGLProgramDesc header to have DoPathRendering flag instead of RequiresVertexShader
Also update GLProgramTests to fix bug where it would incorrectly try to PathRendering when we did
not want to.
BUG=skia:
R=bsalomon@google.com, joshualitt@chromium.org
Author: egdaniel@google.com
Review URL: https://codereview.chromium.org/586793002
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index dccd4bb..a695173 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -29,9 +29,10 @@
const GrEffectStage* colorStages[],
const GrEffectStage* coverageStages[]) {
SkAutoTDelete<GrGLProgramBuilder> builder;
- if (!desc.getHeader().fRequiresVertexShader &&
- gpu->glCaps().pathRenderingSupport() &&
- gpu->glPathRendering()->texturingMode() == GrGLPathRendering::FixedFunction_TexturingMode) {
+ if (desc.getHeader().fUseFragShaderOnly) {
+ SkASSERT(gpu->glCaps().pathRenderingSupport());
+ SkASSERT(gpu->glPathRendering()->texturingMode() ==
+ GrGLPathRendering::FixedFunction_TexturingMode);
SkASSERT(NULL == geometryProcessor);
builder.reset(SkNEW_ARGS(GrGLFragmentOnlyProgramBuilder, (gpu, desc)));
} else {
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index c6560be..c0a9e13 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -163,7 +163,7 @@
GrGpu::DrawType drawType,
GrBlendCoeff srcCoeff,
GrBlendCoeff dstCoeff,
- const GrGpuGL* gpu,
+ GrGpuGL* gpu,
const GrDeviceCoordTexture* dstCopy,
const GrEffectStage** geometryProcessor,
SkTArray<const GrEffectStage*, true>* colorStages,
@@ -260,12 +260,11 @@
// Because header is a pointer into the dynamic array, we can't push any new data into the key
// below here.
- // We will only require a vertex shader if we have more than just the position VA attrib.
- // If we have a geom processor we must us a vertex shader and we should not have a geometry
- // processor if we are doing path rendering.
- SkASSERT(!GrGpu::IsPathRenderingDrawType(drawType) || !optState.requiresVertexShader());
- header->fRequiresVertexShader = optState.requiresVertexShader() ||
- !GrGpu::IsPathRenderingDrawType(drawType);
+ header->fUseFragShaderOnly = gpu->caps()->pathRenderingSupport() &&
+ GrGpu::IsPathRenderingDrawType(drawType) &&
+ gpu->glPathRendering()->texturingMode() == GrGLPathRendering::FixedFunction_TexturingMode;
+ SkASSERT(!header->fUseFragShaderOnly || !optState.hasGeometryProcessor());
+
header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType;
// Currently the experimental GS will only work with triangle prims (and it doesn't do anything
@@ -277,7 +276,7 @@
header->fExperimentalGS = false;
#endif
#endif
- bool defaultToUniformInputs = GR_GL_NO_CONSTANT_ATTRIBUTES || gpu->caps()->pathRenderingSupport();
+ bool defaultToUniformInputs = GR_GL_NO_CONSTANT_ATTRIBUTES || header->fUseFragShaderOnly;
if (!inputColorIsUsed) {
header->fColorInput = kAllOnes_ColorInput;
@@ -285,7 +284,7 @@
header->fColorInput = kUniform_ColorInput;
} else {
header->fColorInput = kAttribute_ColorInput;
- header->fRequiresVertexShader = true;
+ header->fUseFragShaderOnly = false;
}
bool covIsSolidWhite = !requiresCoverageAttrib && 0xffffffff == optState.getCoverageColor();
@@ -296,7 +295,7 @@
header->fCoverageInput = kUniform_ColorInput;
} else {
header->fCoverageInput = kAttribute_ColorInput;
- header->fRequiresVertexShader = true;
+ header->fUseFragShaderOnly = false;
}
if (optState.readsDst()) {
diff --git a/src/gpu/gl/GrGLProgramDesc.h b/src/gpu/gl/GrGLProgramDesc.h
index 8cee707..c9bdac5 100644
--- a/src/gpu/gl/GrGLProgramDesc.h
+++ b/src/gpu/gl/GrGLProgramDesc.h
@@ -45,14 +45,15 @@
// For unit testing.
bool setRandom(SkRandom*,
- const GrGpuGL* gpu,
+ GrGpuGL* gpu,
const GrRenderTarget* dummyDstRenderTarget,
const GrTexture* dummyDstCopyTexture,
const GrEffectStage* geometryProcessor,
const GrEffectStage* stages[],
int numColorStages,
int numCoverageStages,
- int currAttribIndex);
+ int currAttribIndex,
+ GrGpu::DrawType);
/**
* Builds a program descriptor from a GrOptDrawState. Whether the primitive type is points, and
@@ -64,7 +65,7 @@
GrGpu::DrawType drawType,
GrBlendCoeff srcCoeff,
GrBlendCoeff dstCoeff,
- const GrGpuGL* gpu,
+ GrGpuGL* gpu,
const GrDeviceCoordTexture* dstCopy,
const GrEffectStage** outGeometryProcessor,
SkTArray<const GrEffectStage*, true>* outColorStages,
@@ -151,7 +152,7 @@
ColorInput fCoverageInput : 8;
CoverageOutput fCoverageOutput : 8;
- SkBool8 fRequiresVertexShader;
+ SkBool8 fUseFragShaderOnly;
SkBool8 fEmitsPointSize;
// To enable experimental geometry shader code (not for use in
diff --git a/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp b/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp
index 16def63..9c32433 100644
--- a/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp
@@ -11,7 +11,7 @@
GrGLFragmentOnlyProgramBuilder::GrGLFragmentOnlyProgramBuilder(GrGpuGL* gpu,
const GrGLProgramDesc& desc)
: INHERITED(gpu, desc) {
- SkASSERT(!desc.getHeader().fRequiresVertexShader);
+ SkASSERT(desc.getHeader().fUseFragShaderOnly);
SkASSERT(gpu->glCaps().pathRenderingSupport());
SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fColorInput);
SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fCoverageInput);
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index a0dd555..328243d 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -84,9 +84,7 @@
GrGLProgramBuilder::GrGLProgramBuilder(GrGpuGL* gpu,
const GrGLProgramDesc& desc)
- : fFragOnly(!desc.getHeader().fRequiresVertexShader &&
- gpu->glCaps().pathRenderingSupport() &&
- gpu->glPathRendering()->texturingMode() == GrGLPathRendering::FixedFunction_TexturingMode)
+ : fFragOnly(SkToBool(desc.getHeader().fUseFragShaderOnly))
, fTexCoordSetCnt(0)
, fProgramID(0)
, fFS(this, desc)