diff options
author | jvanverth@google.com <jvanverth@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-02-28 16:28:34 +0000 |
---|---|---|
committer | jvanverth@google.com <jvanverth@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-02-28 16:28:34 +0000 |
commit | b8b705b1b983a2ee3a254bed4dd03f926101e4e7 (patch) | |
tree | 700a965273fff93e1cc821bfdbcc22028e138d46 /tests/GLProgramsTest.cpp | |
parent | 4aaaaeace7e617ddc473645756fb7c20790bc270 (diff) |
Add new vertex attribute array specification.
This changes the old method of setting vertex layout to a new one where we
specify vertex attribute data separately from attribute bindings (i.e. program
functionality). Attribute data is now set up via an array of generic attribute
types and offsets, and this is mapped to the old program functionality by
setting specific attribute indices. This allows us to create more general
inputs to shaders.
git-svn-id: http://skia.googlecode.com/svn/trunk@7899 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/GLProgramsTest.cpp')
-rw-r--r-- | tests/GLProgramsTest.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index 0c660d9e3d..3c9af5c98f 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -23,7 +23,7 @@ void GrGLProgram::Desc::setRandom(SkMWCRandom* random, const GrGpuGL* gpu, const GrEffectStage stages[GrDrawState::kNumStages]) { - fVertexLayout = 0; + fAttribBindings = 0; fEmitsPointSize = random->nextBool(); fColorInput = random->nextULessThan(kColorInputCnt); fCoverageInput = random->nextULessThan(kColorInputCnt); @@ -32,7 +32,7 @@ void GrGLProgram::Desc::setRandom(SkMWCRandom* random, fFirstCoverageStage = random->nextULessThan(GrDrawState::kNumStages); - fVertexLayout |= random->nextBool() ? GrDrawState::kCoverage_VertexLayoutBit : 0; + fAttribBindings |= random->nextBool() ? GrDrawState::kCoverage_AttribBindingsBit : 0; #if GR_GL_EXPERIMENTAL_GS fExperimentalGS = gpu->getCaps().geometryShaderSupport() && random->nextBool(); @@ -40,7 +40,7 @@ void GrGLProgram::Desc::setRandom(SkMWCRandom* random, bool edgeAA = random->nextBool(); if (edgeAA) { - fVertexLayout |= GrDrawState::kEdge_VertexLayoutBit; + fAttribBindings |= GrDrawState::kEdge_AttribBindingsBit; if (gpu->getCaps().shaderDerivativeSupport()) { fVertexEdgeType = (GrDrawState::VertexEdgeType) random->nextULessThan(GrDrawState::kVertexEdgeTypeCnt); @@ -64,11 +64,31 @@ void GrGLProgram::Desc::setRandom(SkMWCRandom* random, fEffectKeys[s] = factory.glEffectKey(stages[s], gpu->glCaps()); // use separate tex coords? if (!useOnce && random->nextBool()) { - fVertexLayout |= GrDrawState::StageTexCoordVertexLayoutBit(s); + fAttribBindings |= GrDrawState::ExplicitTexCoordAttribBindingsBit(s); useOnce = true; } } } + + 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::kEdge_AttribBindingsBit) { + fEdgeAttributeIndex = attributeIndex; + ++attributeIndex; + } + if (GrDrawState::AttributesBindExplicitTexCoords(fAttribBindings)) { + fTexCoordAttributeIndex = attributeIndex; + ++attributeIndex; + } } bool GrGpuGL::programUnitTest(int maxStages) { |