Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Unified Diff: tests/GLProgramsTest.cpp

Issue 13296005: Revise attribute binding interface (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Fix fExperimentalGS in GrGLProgramDesc Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gr_unittests.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/GLProgramsTest.cpp
===================================================================
--- tests/GLProgramsTest.cpp (revision 8462)
+++ tests/GLProgramsTest.cpp (working copy)
@@ -24,18 +24,30 @@
void GrGLProgramDesc::setRandom(SkMWCRandom* random,
const GrGpuGL* gpu,
const GrTexture* dstTexture,
- const GrEffectStage stages[GrDrawState::kNumStages]) {
- fAttribBindings = 0;
+ const GrEffectStage stages[GrDrawState::kNumStages],
+ int currAttribIndex) {
fEmitsPointSize = random->nextBool();
- fColorInput = random->nextULessThan(kColorInputCnt);
- fCoverageInput = random->nextULessThan(kColorInputCnt);
+ 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;
+
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
@@ -48,18 +60,14 @@
fDualSrcOutput = kNone_DualSrcOutput;
}
- // use separate tex coords?
- if (random->nextBool()) {
- fAttribBindings |= GrDrawState::kLocalCoords_AttribBindingsBit;
- }
+ bool useLocalCoords = random->nextBool() && currAttribIndex < GrDrawState::kMaxVertexAttribCnt;
+ fLocalCoordAttributeIndex = useLocalCoords ? currAttribIndex++ : -1;
bool dstRead = false;
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
if (NULL != stages[s].getEffect()) {
const GrBackendEffectFactory& factory = (*stages[s].getEffect())->getFactory();
- bool explicitLocalCoords = (fAttribBindings &
- GrDrawState::kLocalCoords_AttribBindingsBit);
- GrDrawEffect drawEffect(stages[s], explicitLocalCoords);
+ GrDrawEffect drawEffect(stages[s], useLocalCoords);
fEffectKeys[s] = factory.glEffectKey(drawEffect, gpu->glCaps());
if ((*stages[s].getEffect())->willReadDst()) {
dstRead = true;
@@ -70,22 +78,6 @@
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) {
@@ -118,7 +110,7 @@
GrGLProgramDesc pdesc;
GrEffectStage stages[GrDrawState::kNumStages];
- int currAttribIndex = GrDrawState::kAttribIndexCount;
+ int currAttribIndex = 1; // we need to always leave room for position
int attribIndices[2];
GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()};
for (int s = 0; s < maxStages; ++s) {
@@ -131,10 +123,9 @@
dummyTextures));
int numAttribs = (*effect)->numVertexAttribs();
- // 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) {
+ // If adding this effect would exceed the max attrib count then generate a
+ // new random effect.
+ if (currAttribIndex + numAttribs > GrDrawState::kMaxVertexAttribCnt) {
--s;
continue;
}
@@ -145,8 +136,8 @@
}
}
const GrTexture* dstTexture = random.nextBool() ? dummyTextures[0] : dummyTextures[1];
- pdesc.setRandom(&random, this, dstTexture, stages);
-
+ pdesc.setRandom(&random, this, dstTexture, stages, currAttribIndex);
+
const GrEffectStage* stagePtrs[GrDrawState::kNumStages];
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
stagePtrs[s] = &stages[s];
« no previous file with comments | « src/gpu/gr_unittests.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698