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

Side by Side Diff: src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp

Issue 628293002: Plumb OptDrawState down to VertexShaderBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean up Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrGLVertexShaderBuilder.h" 8 #include "GrGLVertexShaderBuilder.h"
9 #include "GrGLFullProgramBuilder.h" 9 #include "GrGLFullProgramBuilder.h"
10 #include "GrGLShaderStringBuilder.h" 10 #include "GrGLShaderStringBuilder.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 fOutputs.back().setType(type); 50 fOutputs.back().setType(type);
51 fOutputs.back().setTypeModifier(GrGLShaderVar::kVaryingOut_TypeModifier); 51 fOutputs.back().setTypeModifier(GrGLShaderVar::kVaryingOut_TypeModifier);
52 fProgramBuilder->nameVariable(fOutputs.back().accessName(), 'v', name); 52 fProgramBuilder->nameVariable(fOutputs.back().accessName(), 'v', name);
53 53
54 if (vsOutName) { 54 if (vsOutName) {
55 *vsOutName = fOutputs.back().getName().c_str(); 55 *vsOutName = fOutputs.back().getName().c_str();
56 } 56 }
57 } 57 }
58 58
59 59
60 void GrGLVertexShaderBuilder::bindProgramLocations(GrGLuint programId) { 60 void GrGLVertexShaderBuilder::bindProgramLocations(const GrOptDrawState& optStat e,
61 GrGLuint programId) {
61 const GrGLProgramDesc::KeyHeader& header = fProgramBuilder->desc().getHeader (); 62 const GrGLProgramDesc::KeyHeader& header = fProgramBuilder->desc().getHeader ();
62 GrGpuGL* gpu = fProgramBuilder->gpu(); 63 GrGpuGL* gpu = fProgramBuilder->gpu();
63 64
64 // Bind the attrib locations to same values for all shaders 65 // Bind the attrib locations to same values for all shaders
65 SkASSERT(-1 != header.fPositionAttributeIndex); 66 SkASSERT(-1 != header.fPositionAttributeIndex);
66 GL_CALL(BindAttribLocation(programId, 67 GL_CALL(BindAttribLocation(programId,
67 header.fPositionAttributeIndex, 68 header.fPositionAttributeIndex,
68 fPositionVar->c_str())); 69 fPositionVar->c_str()));
69 if (-1 != header.fLocalCoordAttributeIndex) { 70 if (-1 != header.fLocalCoordAttributeIndex) {
70 GL_CALL(BindAttribLocation(programId, 71 GL_CALL(BindAttribLocation(programId,
71 header.fLocalCoordAttributeIndex, 72 header.fLocalCoordAttributeIndex,
72 fLocalCoordsVar->c_str())); 73 fLocalCoordsVar->c_str()));
73 } 74 }
74 if (-1 != header.fColorAttributeIndex) { 75 if (-1 != header.fColorAttributeIndex) {
75 GL_CALL(BindAttribLocation(programId, 76 GL_CALL(BindAttribLocation(programId,
76 header.fColorAttributeIndex, 77 header.fColorAttributeIndex,
77 color_attribute_name())); 78 color_attribute_name()));
78 } 79 }
79 if (-1 != header.fCoverageAttributeIndex) { 80 if (-1 != header.fCoverageAttributeIndex) {
80 GL_CALL(BindAttribLocation(programId, 81 GL_CALL(BindAttribLocation(programId,
81 header.fCoverageAttributeIndex, 82 header.fCoverageAttributeIndex,
82 coverage_attribute_name())); 83 coverage_attribute_name()));
83 } 84 }
84 85
85 // We pull the current state of attributes off of drawstate's optimized stat e and bind them in 86 const GrVertexAttrib* vaPtr = optState.getVertexAttribs();
86 // order. This assumes that the drawState has not changed since we called fl ushGraphicsState() 87 const int vaCount = optState.getVertexAttribCount();
87 // higher up in the stack.
88 const GrDrawTargetCaps* caps = fProgramBuilder->gpu()->caps();
89 const GrDrawState& drawState = *fProgramBuilder->gpu()->drawState();
90 SkAutoTUnref<GrOptDrawState> optState(drawState.createOptState(*caps));
91 const GrVertexAttrib* vaPtr = optState->getVertexAttribs();
92 const int vaCount = optState->getVertexAttribCount();
93 88
94 int i = fEffectAttribOffset; 89 int i = fEffectAttribOffset;
95 for (int index = 0; index < vaCount; index++) { 90 for (int index = 0; index < vaCount; index++) {
96 if (kGeometryProcessor_GrVertexAttribBinding != vaPtr[index].fBinding) { 91 if (kGeometryProcessor_GrVertexAttribBinding != vaPtr[index].fBinding) {
97 continue; 92 continue;
98 } 93 }
99 SkASSERT(index != header.fPositionAttributeIndex && 94 SkASSERT(index != header.fPositionAttributeIndex &&
100 index != header.fLocalCoordAttributeIndex && 95 index != header.fLocalCoordAttributeIndex &&
101 index != header.fColorAttributeIndex && 96 index != header.fColorAttributeIndex &&
102 index != header.fCoverageAttributeIndex); 97 index != header.fCoverageAttributeIndex);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 this->addAttribute(GrShaderVar(coverage_attribute_name(), 188 this->addAttribute(GrShaderVar(coverage_attribute_name(),
194 kVec4f_GrSLType, 189 kVec4f_GrSLType,
195 GrShaderVar::kAttribute_TypeModifier)); 190 GrShaderVar::kAttribute_TypeModifier));
196 const char *vsName, *fsName; 191 const char *vsName, *fsName;
197 fFullProgramBuilder->addVarying(kVec4f_GrSLType, "Coverage", &vsName, &f sName); 192 fFullProgramBuilder->addVarying(kVec4f_GrSLType, "Coverage", &vsName, &f sName);
198 this->codeAppendf("%s = %s;", vsName, coverage_attribute_name()); 193 this->codeAppendf("%s = %s;", vsName, coverage_attribute_name());
199 *coverage = fsName; 194 *coverage = fsName;
200 } 195 }
201 fEffectAttribOffset = fInputs.count(); 196 fEffectAttribOffset = fInputs.count();
202 } 197 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698