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

Unified Diff: src/gpu/gl/GrGpuGL_program.cpp

Issue 761563002: First step to moving vertex attributes to the geometryProcessor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: adding test to ignore Created 6 years 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/gl/GrGpuGL.cpp ('k') | src/gpu/gl/builders/GrGLProgramBuilder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGpuGL_program.cpp
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index e2c59b927fe6a5019fe59040193f9535a5cefd97..cb8810cc79600450945d8db98f2c11079ff5710f 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -250,16 +250,11 @@ bool GrGpuGL::flushGraphicsState(const GrOptDrawState& optState, DrawType type)
void GrGpuGL::setupGeometry(const GrOptDrawState& optState,
const GrDrawTarget::DrawInfo& info,
size_t* indexOffsetInBytes) {
- GrGLsizei stride = static_cast<GrGLsizei>(optState.getVertexStride());
-
- size_t vertexOffsetInBytes = stride * info.startVertex();
-
GrGLVertexBuffer* vbuf;
vbuf = (GrGLVertexBuffer*) info.vertexBuffer();
SkASSERT(vbuf);
SkASSERT(!vbuf->isMapped());
- vertexOffsetInBytes += vbuf->baseOffset();
GrGLIndexBuffer* ibuf = NULL;
if (info.isIndexed()) {
@@ -276,23 +271,31 @@ void GrGpuGL::setupGeometry(const GrOptDrawState& optState,
fHWGeometryState.bindArrayAndBuffersToDraw(this, vbuf, ibuf);
if (fCurrentProgram->hasVertexShader()) {
- int vertexAttribCount = optState.getVertexAttribCount();
+ const GrGeometryProcessor* gp = optState.getGeometryProcessor();
+
+ GrGLsizei stride = static_cast<GrGLsizei>(gp->getVertexStride());
+
+ size_t vertexOffsetInBytes = stride * info.startVertex();
+
+ vertexOffsetInBytes += vbuf->baseOffset();
+
+ const SkTArray<GrGeometryProcessor::GrAttribute, true>& attribs = gp->getAttribs();
+ int vaCount = attribs.count();
uint32_t usedAttribArraysMask = 0;
- const GrVertexAttrib* vertexAttrib = optState.getVertexAttribs();
+ size_t offset = 0;
- for (int vertexAttribIndex = 0; vertexAttribIndex < vertexAttribCount;
- ++vertexAttribIndex, ++vertexAttrib) {
- usedAttribArraysMask |= (1 << vertexAttribIndex);
- GrVertexAttribType attribType = vertexAttrib->fType;
+ for (int attribIndex = 0; attribIndex < vaCount; attribIndex++) {
+ usedAttribArraysMask |= (1 << attribIndex);
+ GrVertexAttribType attribType = attribs[attribIndex].fType;
attribState->set(this,
- vertexAttribIndex,
+ attribIndex,
vbuf,
GrGLAttribTypeToLayout(attribType).fCount,
GrGLAttribTypeToLayout(attribType).fType,
GrGLAttribTypeToLayout(attribType).fNormalized,
stride,
- reinterpret_cast<GrGLvoid*>(
- vertexOffsetInBytes + vertexAttrib->fOffset));
+ reinterpret_cast<GrGLvoid*>(vertexOffsetInBytes + offset));
+ offset += attribs[attribIndex].fOffset;
}
attribState->disableUnusedArrays(this, usedAttribArraysMask);
}
« no previous file with comments | « src/gpu/gl/GrGpuGL.cpp ('k') | src/gpu/gl/builders/GrGLProgramBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698