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

Side by Side Diff: src/gpu/gl/GrGLProgramDataManager.cpp

Issue 611653002: Cleanup of shader building system (Closed) Base URL: https://skia.googlesource.com/skia.git@solo_gp
Patch Set: 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
« no previous file with comments | « src/gpu/gl/GrGLProgramDataManager.h ('k') | src/gpu/gl/GrGLProgramDesc.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "gl/builders/GrGLProgramBuilder.h"
9 #include "gl/GrGLPathRendering.h" 8 #include "gl/GrGLPathRendering.h"
10 #include "gl/GrGLProgram.h"
11 #include "gl/GrGLUniformHandle.h" 9 #include "gl/GrGLUniformHandle.h"
12 #include "gl/GrGpuGL.h" 10 #include "gl/GrGpuGL.h"
13 #include "SkMatrix.h" 11 #include "SkMatrix.h"
14 12
15 #define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, COUNT) \ 13 #define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, COUNT) \
16 SkASSERT(arrayCount <= uni.fArrayCount || \ 14 SkASSERT(arrayCount <= uni.fArrayCount || \
17 (1 == arrayCount && GrGLShaderVar::kNonArray == uni.fArrayCoun t)) 15 (1 == arrayCount && GrGLShaderVar::kNonArray == uni.fArrayCoun t))
18 16
19 GrGLProgramDataManager::GrGLProgramDataManager(GrGpuGL* gpu, 17 GrGLProgramDataManager::GrGLProgramDataManager(GrGpuGL* gpu, const UniformInfoAr ray& uniforms)
20 GrGLProgram* program, 18 : fGpu(gpu) {
21 const GrGLProgramBuilder& builder ) 19 int count = uniforms.count();
22 : fGpu(gpu),
23 fProgram(program) {
24 int count = builder.getUniformInfos().count();
25 fUniforms.push_back_n(count); 20 fUniforms.push_back_n(count);
26 for (int i = 0; i < count; i++) { 21 for (int i = 0; i < count; i++) {
27 Uniform& uniform = fUniforms[i]; 22 Uniform& uniform = fUniforms[i];
28 const GrGLProgramBuilder::UniformInfo& builderUniform = builder.getUnifo rmInfos()[i]; 23 const UniformInfo& builderUniform = uniforms[i];
29 SkASSERT(GrGLShaderVar::kNonArray == builderUniform.fVariable.getArrayCo unt() || 24 SkASSERT(GrGLShaderVar::kNonArray == builderUniform.fVariable.getArrayCo unt() ||
30 builderUniform.fVariable.getArrayCount() > 0); 25 builderUniform.fVariable.getArrayCount() > 0);
31 SkDEBUGCODE( 26 SkDEBUGCODE(
32 uniform.fArrayCount = builderUniform.fVariable.getArrayCount(); 27 uniform.fArrayCount = builderUniform.fVariable.getArrayCount();
33 uniform.fType = builderUniform.fVariable.getType(); 28 uniform.fType = builderUniform.fVariable.getType();
34 ); 29 );
35 // TODO: Move the Xoom uniform array in both FS and VS bug workaround he re. 30 // TODO: Move the Xoom uniform array in both FS and VS bug workaround he re.
36 31
37 if (GrGLProgramBuilder::kVertex_Visibility & builderUniform.fVisibility) { 32 if (GrGLProgramBuilder::kVertex_Visibility & builderUniform.fVisibility) {
38 uniform.fVSLocation = builderUniform.fLocation; 33 uniform.fVSLocation = builderUniform.fLocation;
39 } else { 34 } else {
40 uniform.fVSLocation = kUnusedUniform; 35 uniform.fVSLocation = kUnusedUniform;
41 } 36 }
42 if (GrGLProgramBuilder::kFragment_Visibility & builderUniform.fVisibilit y) { 37 if (GrGLProgramBuilder::kFragment_Visibility & builderUniform.fVisibilit y) {
43 uniform.fFSLocation = builderUniform.fLocation; 38 uniform.fFSLocation = builderUniform.fLocation;
44 } else { 39 } else {
45 uniform.fFSLocation = kUnusedUniform; 40 uniform.fFSLocation = kUnusedUniform;
46 } 41 }
47 } 42 }
48
49 count = builder.getSeparableVaryingInfos().count();
50 fVaryings.push_back_n(count);
51 for (int i = 0; i < count; i++) {
52 Varying& varying = fVaryings[i];
53 const GrGLProgramBuilder::SeparableVaryingInfo& builderVarying =
54 builder.getSeparableVaryingInfos()[i];
55 SkASSERT(GrGLShaderVar::kNonArray == builderVarying.fVariable.getArrayCo unt());
56 SkDEBUGCODE(
57 varying.fType = builderVarying.fVariable.getType();
58 );
59 varying.fLocation = builderVarying.fLocation;
60 }
61 } 43 }
62 44
63 void GrGLProgramDataManager::setSampler(UniformHandle u, GrGLint texUnit) const { 45 void GrGLProgramDataManager::setSampler(UniformHandle u, GrGLint texUnit) const {
64 const Uniform& uni = fUniforms[u.toProgramDataIndex()]; 46 const Uniform& uni = fUniforms[u.toProgramDataIndex()];
65 SkASSERT(uni.fType == kSampler2D_GrSLType); 47 SkASSERT(uni.fType == kSampler2D_GrSLType);
66 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount); 48 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
67 // FIXME: We still insert a single sampler uniform for every stage. If the s hader does not 49 // FIXME: We still insert a single sampler uniform for every stage. If the s hader does not
68 // reference the sampler then the compiler may have optimized it out. Uncomm ent this assert 50 // reference the sampler then the compiler may have optimized it out. Uncomm ent this assert
69 // once stages insert their own samplers. 51 // once stages insert their own samplers.
70 // SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLo cation); 52 // SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLo cation);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 matrix.get(SkMatrix::kMPersp0), 251 matrix.get(SkMatrix::kMPersp0),
270 matrix.get(SkMatrix::kMSkewX), 252 matrix.get(SkMatrix::kMSkewX),
271 matrix.get(SkMatrix::kMScaleY), 253 matrix.get(SkMatrix::kMScaleY),
272 matrix.get(SkMatrix::kMPersp1), 254 matrix.get(SkMatrix::kMPersp1),
273 matrix.get(SkMatrix::kMTransX), 255 matrix.get(SkMatrix::kMTransX),
274 matrix.get(SkMatrix::kMTransY), 256 matrix.get(SkMatrix::kMTransY),
275 matrix.get(SkMatrix::kMPersp2), 257 matrix.get(SkMatrix::kMPersp2),
276 }; 258 };
277 this->setMatrix3f(u, mt); 259 this->setMatrix3f(u, mt);
278 } 260 }
279
280 void GrGLProgramDataManager::setProgramPathFragmentInputTransform(VaryingHandle i,
281 unsigned compo nents,
282 const SkMatrix & matrix) const {
283 const Varying& fragmentInput = fVaryings[i.toProgramDataIndex()];
284 fGpu->glPathRendering()->setProgramPathFragmentInputTransform(fProgram->prog ramID(),
285 fragmentInput. fLocation,
286 GR_GL_OBJECT_L INEAR,
287 components,
288 matrix);
289 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgramDataManager.h ('k') | src/gpu/gl/GrGLProgramDesc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698