diff options
| author | jvanverth@google.com <jvanverth@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-01 19:29:32 +0000 |
|---|---|---|
| committer | jvanverth@google.com <jvanverth@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-01 19:29:32 +0000 |
| commit | c7bf2963f00a29bd28e5e2a446da79f93c1d9383 (patch) | |
| tree | 065de5e21129c28201547891d806bff2f60bb646 /tests/GLProgramsTest.cpp | |
| parent | fb495b537f5ddd6966f02cfe38f6b106a4869934 (diff) | |
Rolling back r8466.
Not reviewed.
git-svn-id: http://skia.googlecode.com/svn/trunk@8467 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/GLProgramsTest.cpp')
| -rw-r--r-- | tests/GLProgramsTest.cpp | 63 |
1 files changed, 36 insertions, 27 deletions
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index 675d0c1cb4..512f89ecf2 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -24,30 +24,18 @@ void GrGLProgramDesc::setRandom(SkMWCRandom* random, const GrGpuGL* gpu, const GrTexture* dstTexture, - const GrEffectStage stages[GrDrawState::kNumStages], - int currAttribIndex) { + const GrEffectStage stages[GrDrawState::kNumStages]) { + fAttribBindings = 0; fEmitsPointSize = random->nextBool(); - - fPositionAttributeIndex = 0; - - // if the effects have used up all off the available attributes, - // don't try to use color or coverage attributes as input - do { - fColorInput = random->nextULessThan(kColorInputCnt); - } while (GrDrawState::kMaxVertexAttribCnt <= currAttribIndex && - kAttribute_ColorInput == fColorInput); - fColorAttributeIndex = (fColorInput == kAttribute_ColorInput) ? currAttribIndex++ : -1; - - do { - fCoverageInput = random->nextULessThan(kColorInputCnt); - } while (GrDrawState::kMaxVertexAttribCnt <= currAttribIndex && - kAttribute_ColorInput == fCoverageInput); - fCoverageAttributeIndex = (fCoverageInput == kAttribute_ColorInput) ? currAttribIndex++ : -1; + fColorInput = random->nextULessThan(kColorInputCnt); + fCoverageInput = random->nextULessThan(kColorInputCnt); fColorFilterXfermode = random->nextULessThan(SkXfermode::kCoeffModesCnt); fFirstCoverageStage = random->nextULessThan(GrDrawState::kNumStages); + fAttribBindings |= random->nextBool() ? GrDrawState::kCoverage_AttribBindingsBit : 0; + #if GR_GL_EXPERIMENTAL_GS fExperimentalGS = gpu->caps()->geometryShaderSupport() && random->nextBool(); #endif @@ -60,14 +48,18 @@ void GrGLProgramDesc::setRandom(SkMWCRandom* random, fDualSrcOutput = kNone_DualSrcOutput; } - bool useLocalCoords = random->nextBool() && currAttribIndex < GrDrawState::kMaxVertexAttribCnt; - fLocalCoordAttributeIndex = useLocalCoords ? currAttribIndex++ : -1; + // use separate tex coords? + if (random->nextBool()) { + fAttribBindings |= GrDrawState::kLocalCoords_AttribBindingsBit; + } bool dstRead = false; for (int s = 0; s < GrDrawState::kNumStages; ++s) { if (NULL != stages[s].getEffect()) { const GrBackendEffectFactory& factory = (*stages[s].getEffect())->getFactory(); - GrDrawEffect drawEffect(stages[s], useLocalCoords); + bool explicitLocalCoords = (fAttribBindings & + GrDrawState::kLocalCoords_AttribBindingsBit); + GrDrawEffect drawEffect(stages[s], explicitLocalCoords); fEffectKeys[s] = factory.glEffectKey(drawEffect, gpu->glCaps()); if ((*stages[s].getEffect())->willReadDst()) { dstRead = true; @@ -78,6 +70,22 @@ void GrGLProgramDesc::setRandom(SkMWCRandom* random, if (dstRead) { this->fDstRead = GrGLShaderBuilder::KeyForDstRead(dstTexture, gpu->glCaps()); } + + int attributeIndex = 0; + fPositionAttributeIndex = attributeIndex; + ++attributeIndex; + if (fColorInput || (fAttribBindings & GrDrawState::kColor_AttribBindingsBit)) { + fColorAttributeIndex = attributeIndex; + ++attributeIndex; + } + if (fCoverageInput || (fAttribBindings & GrDrawState::kCoverage_AttribBindingsBit)) { + fCoverageAttributeIndex = attributeIndex; + ++attributeIndex; + } + if (fAttribBindings & GrDrawState::kLocalCoords_AttribBindingsBit) { + fLocalCoordsAttributeIndex = attributeIndex; + ++attributeIndex; + } } bool GrGpuGL::programUnitTest(int maxStages) { @@ -110,7 +118,7 @@ bool GrGpuGL::programUnitTest(int maxStages) { GrGLProgramDesc pdesc; GrEffectStage stages[GrDrawState::kNumStages]; - int currAttribIndex = 1; // we need to always leave room for position + int currAttribIndex = GrDrawState::kAttribIndexCount; int attribIndices[2]; GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()}; for (int s = 0; s < maxStages; ++s) { @@ -123,9 +131,10 @@ bool GrGpuGL::programUnitTest(int maxStages) { dummyTextures)); int numAttribs = (*effect)->numVertexAttribs(); - // If adding this effect would exceed the max attrib count then generate a - // new random effect. - if (currAttribIndex + numAttribs > GrDrawState::kMaxVertexAttribCnt) { + // If adding this effect would cause to exceed the max attrib count then generate a + // new random effect. The explanation for why this check is correct is a bit + // convoluted and this code will be removed soon. + if (currAttribIndex + numAttribs > GrDrawState::kCoverageOverrideAttribIndexValue) { --s; continue; } @@ -136,8 +145,8 @@ bool GrGpuGL::programUnitTest(int maxStages) { } } const GrTexture* dstTexture = random.nextBool() ? dummyTextures[0] : dummyTextures[1]; - pdesc.setRandom(&random, this, dstTexture, stages, currAttribIndex); - + pdesc.setRandom(&random, this, dstTexture, stages); + const GrEffectStage* stagePtrs[GrDrawState::kNumStages]; for (int s = 0; s < GrDrawState::kNumStages; ++s) { stagePtrs[s] = &stages[s]; |
