Use vertex buffer objects instead of client side arrays in fixed-function codepaths
Pass vertices to the fixed-function shaders in vertex buffer object
stored at attribute 0. This is specified in OpenGL Compatibility
Profile Section 10.8.2 (Transferring Vertices With Vertex Attribute
Zero).
This makes future integration to Chromium command buffer better, since
the command buffer already has code for vertex buffer objects but not
vertex arrays.
Delete unused function pointers related to fixed-function codepaths.
R=bsalomon@google.com
Author: kkinnunen@nvidia.com
Review URL: https://codereview.chromium.org/130423013
git-svn-id: http://skia.googlecode.com/svn/trunk@13557 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index a3beab1..50ecf0b 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -344,22 +344,29 @@
if (!fCurrentProgram->hasVertexShader()) {
int posIdx = this->getDrawState().positionAttributeIndex();
- const GrVertexAttrib* vertexArray = this->getDrawState().getVertexAttribs() + posIdx;
- GrVertexAttribType vertexArrayType = vertexArray->fType;
- SkASSERT(!GrGLAttribTypeToLayout(vertexArrayType).fNormalized);
- SkASSERT(GrGLAttribTypeToLayout(vertexArrayType).fCount == 2);
- attribState->setFixedFunctionVertexArray(this,
- vbuf,
- 2,
- GrGLAttribTypeToLayout(vertexArrayType).fType,
- stride,
- reinterpret_cast<GrGLvoid*>(
- vertexOffsetInBytes + vertexArray->fOffset));
- attribState->disableUnusedArrays(this, 0, true);
+ const GrVertexAttrib* vertexAttrib = this->getDrawState().getVertexAttribs() + posIdx;
+ GrVertexAttribType attribType = vertexAttrib->fType;
+ SkASSERT(!GrGLAttribTypeToLayout(attribType).fNormalized);
+ SkASSERT(GrGLAttribTypeToLayout(attribType).fCount == 2);
+
+ // Attrib at location 0 is defined to be bound to vertex in fixed-function pipe. Asserts
+ // above should make sure position attribute goes to location 0 when below code is executed.
+
+ attribState->set(this,
+ 0,
+ vbuf,
+ GrGLAttribTypeToLayout(attribType).fCount,
+ GrGLAttribTypeToLayout(attribType).fType,
+ GrGLAttribTypeToLayout(attribType).fNormalized,
+ stride,
+ reinterpret_cast<GrGLvoid*>(
+ vertexOffsetInBytes + vertexAttrib->fOffset));
+ attribState->disableUnusedArrays(this, 1);
} else {
+ int vertexAttribCount = this->getDrawState().getVertexAttribCount();
uint32_t usedAttribArraysMask = 0;
const GrVertexAttrib* vertexAttrib = this->getDrawState().getVertexAttribs();
- int vertexAttribCount = this->getDrawState().getVertexAttribCount();
+
for (int vertexAttribIndex = 0; vertexAttribIndex < vertexAttribCount;
++vertexAttribIndex, ++vertexAttrib) {
@@ -373,9 +380,8 @@
GrGLAttribTypeToLayout(attribType).fNormalized,
stride,
reinterpret_cast<GrGLvoid*>(
- vertexOffsetInBytes + vertexAttrib->fOffset));
+ vertexOffsetInBytes + vertexAttrib->fOffset));
}
-
- attribState->disableUnusedArrays(this, usedAttribArraysMask, false);
+ attribState->disableUnusedArrays(this, usedAttribArraysMask);
}
}