Fix GrProgramsTest to not generate tests with too many TexCoord references
Make GrProgramsTest check how many texture coordinate sets are
available and select random effects up until the amount runs out.
Otherwise, following effect sequence would fail the shader compilation
when Skia is compiled with nv_path_rendering on (eg. when fixed
function codepath is used):
* Stage 0: TextureDomain (1 texcoord)
* Stage 1: Convolution (1 texcoord)
* Stage 2: Bitmap Alpha Threshold (2 texcoords)
* Stage 3: DisplacementMap (2 texcoords)
* Stage 4: Config Conversion (1 texcoords)
* Stage 5: Two-Point Conical Gradient (2 texcoords)
This would use more texture coordinate sets than 8, which is fairly
common amount currently.
R=bsalomon@google.com, cdalton@nvidia.com
Author: kkinnunen@nvidia.com
Review URL: https://codereview.chromium.org/32403002
git-svn-id: http://skia.googlecode.com/svn/trunk@11881 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 13d0d2e..12107f4 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -158,6 +158,7 @@
GrGLProgramDesc pdesc;
int currAttribIndex = 1; // we need to always leave room for position
+ int currTextureCoordSet = 0;
int attribIndices[2];
GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()};
@@ -167,7 +168,9 @@
SkAutoSTMalloc<8, const GrEffectStage*> stages(numStages);
- for (int s = 0; s < numStages; ++s) {
+ bool useFixedFunctionTexturing = this->shouldUseFixedFunctionTexturing();
+
+ for (int s = 0; s < numStages;) {
SkAutoTUnref<const GrEffectRef> effect(GrEffectTestFactory::CreateStage(
&random,
this->getContext(),
@@ -178,15 +181,29 @@
// If adding this effect would exceed the max attrib count then generate a
// new random effect.
if (currAttribIndex + numAttribs > GrDrawState::kMaxVertexAttribCnt) {
- --s;
continue;
}
+
+
+ // If adding this effect would exceed the max texture coord set count then generate a
+ // new random effect.
+ if (useFixedFunctionTexturing && !(*effect)->hasVertexCode()) {
+ int numTransforms = (*effect)->numTransforms();
+ if (currTextureCoordSet + numTransforms > this->glCaps().maxFixedFunctionTextureCoords()) {
+ continue;
+ }
+ currTextureCoordSet += numTransforms;
+ }
+
+ useFixedFunctionTexturing = useFixedFunctionTexturing && !(*effect)->hasVertexCode();
+
for (int i = 0; i < numAttribs; ++i) {
attribIndices[i] = currAttribIndex++;
}
GrEffectStage* stage = SkNEW_ARGS(GrEffectStage,
(effect.get(), attribIndices[0], attribIndices[1]));
stages[s] = stage;
+ ++s;
}
const GrTexture* dstTexture = random.nextBool() ? dummyTextures[0] : dummyTextures[1];
pdesc.setRandom(&random,