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

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

Issue 1462123003: Create GrGLSLVaryingHandler class for program building (Closed) Base URL: https://skia.googlesource.com/skia.git@putCapsOnArgs
Patch Set: fix release builder Created 5 years, 1 month 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/GrGLVaryingHandler.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 "SkMatrix.h" 8 #include "SkMatrix.h"
9 #include "gl/GrGLProgramDataManager.h" 9 #include "gl/GrGLProgramDataManager.h"
10 #include "gl/GrGLGpu.h" 10 #include "gl/GrGLGpu.h"
11 11
12 #define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, COUNT) \ 12 #define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, COUNT) \
13 SkASSERT(arrayCount <= uni.fArrayCount || \ 13 SkASSERT(arrayCount <= uni.fArrayCount || \
14 (1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCo unt)) 14 (1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCo unt))
15 15
16 GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID, 16 GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID,
17 const UniformInfoArray& uniforms, 17 const UniformInfoArray& uniforms,
18 const SeparableVaryingInfoArray& separableVaryings) 18 const VaryingInfoArray& pathProcV aryings)
19 : fGpu(gpu) 19 : fGpu(gpu)
20 , fProgramID(programID) { 20 , fProgramID(programID) {
21 int count = uniforms.count(); 21 int count = uniforms.count();
22 fUniforms.push_back_n(count); 22 fUniforms.push_back_n(count);
23 for (int i = 0; i < count; i++) { 23 for (int i = 0; i < count; i++) {
24 Uniform& uniform = fUniforms[i]; 24 Uniform& uniform = fUniforms[i];
25 const UniformInfo& builderUniform = uniforms[i]; 25 const UniformInfo& builderUniform = uniforms[i];
26 SkASSERT(GrGLSLShaderVar::kNonArray == builderUniform.fVariable.getArray Count() || 26 SkASSERT(GrGLSLShaderVar::kNonArray == builderUniform.fVariable.getArray Count() ||
27 builderUniform.fVariable.getArrayCount() > 0); 27 builderUniform.fVariable.getArrayCount() > 0);
28 SkDEBUGCODE( 28 SkDEBUGCODE(
29 uniform.fArrayCount = builderUniform.fVariable.getArrayCount(); 29 uniform.fArrayCount = builderUniform.fVariable.getArrayCount();
30 uniform.fType = builderUniform.fVariable.getType(); 30 uniform.fType = builderUniform.fVariable.getType();
31 ); 31 );
32 // TODO: Move the Xoom uniform array in both FS and VS bug workaround he re. 32 // TODO: Move the Xoom uniform array in both FS and VS bug workaround he re.
33 33
34 if (GrGLProgramBuilder::kVertex_Visibility & builderUniform.fVisibility) { 34 if (GrGLProgramBuilder::kVertex_Visibility & builderUniform.fVisibility) {
35 uniform.fVSLocation = builderUniform.fLocation; 35 uniform.fVSLocation = builderUniform.fLocation;
36 } else { 36 } else {
37 uniform.fVSLocation = kUnusedUniform; 37 uniform.fVSLocation = kUnusedUniform;
38 } 38 }
39 if (GrGLProgramBuilder::kFragment_Visibility & builderUniform.fVisibilit y) { 39 if (GrGLProgramBuilder::kFragment_Visibility & builderUniform.fVisibilit y) {
40 uniform.fFSLocation = builderUniform.fLocation; 40 uniform.fFSLocation = builderUniform.fLocation;
41 } else { 41 } else {
42 uniform.fFSLocation = kUnusedUniform; 42 uniform.fFSLocation = kUnusedUniform;
43 } 43 }
44 } 44 }
45 45
46 // NVPR programs have separable varyings 46 // NVPR programs have separable varyings
47 count = separableVaryings.count(); 47 count = pathProcVaryings.count();
48 fSeparableVaryings.push_back_n(count); 48 fPathProcVaryings.push_back_n(count);
49 for (int i = 0; i < count; i++) { 49 for (int i = 0; i < count; i++) {
50 SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport()); 50 SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport());
51 SeparableVarying& separableVarying = fSeparableVaryings[i]; 51 PathProcVarying& pathProcVarying = fPathProcVaryings[i];
52 const SeparableVaryingInfo& builderSeparableVarying = separableVaryings[ i]; 52 const VaryingInfo& builderPathProcVarying = pathProcVaryings[i];
53 SkASSERT(GrGLSLShaderVar::kNonArray == builderSeparableVarying.fVariable .getArrayCount() || 53 SkASSERT(GrGLSLShaderVar::kNonArray == builderPathProcVarying.fVariable. getArrayCount() ||
54 builderSeparableVarying.fVariable.getArrayCount() > 0); 54 builderPathProcVarying.fVariable.getArrayCount() > 0);
55 SkDEBUGCODE( 55 SkDEBUGCODE(
56 separableVarying.fArrayCount = builderSeparableVarying.fVariable.get ArrayCount(); 56 pathProcVarying.fArrayCount = builderPathProcVarying.fVariable.getAr rayCount();
57 separableVarying.fType = builderSeparableVarying.fVariable.getType() ; 57 pathProcVarying.fType = builderPathProcVarying.fVariable.getType();
58 ); 58 );
59 separableVarying.fLocation = builderSeparableVarying.fLocation; 59 pathProcVarying.fLocation = builderPathProcVarying.fLocation;
60 } 60 }
61 } 61 }
62 62
63 void GrGLProgramDataManager::setSampler(UniformHandle u, int texUnit) const { 63 void GrGLProgramDataManager::setSampler(UniformHandle u, int texUnit) const {
64 const Uniform& uni = fUniforms[u.toIndex()]; 64 const Uniform& uni = fUniforms[u.toIndex()];
65 SkASSERT(uni.fType == kSampler2D_GrSLType); 65 SkASSERT(uni.fType == kSampler2D_GrSLType);
66 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); 66 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
67 // FIXME: We still insert a single sampler uniform for every stage. If the s hader does not 67 // 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 68 // reference the sampler then the compiler may have optimized it out. Uncomm ent this assert
69 // once stages insert their own samplers. 69 // once stages insert their own samplers.
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 matrix.get(SkMatrix::kMSkewX), 269 matrix.get(SkMatrix::kMSkewX),
270 matrix.get(SkMatrix::kMScaleY), 270 matrix.get(SkMatrix::kMScaleY),
271 matrix.get(SkMatrix::kMPersp1), 271 matrix.get(SkMatrix::kMPersp1),
272 matrix.get(SkMatrix::kMTransX), 272 matrix.get(SkMatrix::kMTransX),
273 matrix.get(SkMatrix::kMTransY), 273 matrix.get(SkMatrix::kMTransY),
274 matrix.get(SkMatrix::kMPersp2), 274 matrix.get(SkMatrix::kMPersp2),
275 }; 275 };
276 this->setMatrix3f(u, mt); 276 this->setMatrix3f(u, mt);
277 } 277 }
278 278
279 void GrGLProgramDataManager::setPathFragmentInputTransform(SeparableVaryingHandl e u, 279 void GrGLProgramDataManager::setPathFragmentInputTransform(VaryingHandle u,
280 int components, 280 int components,
281 const SkMatrix& matri x) const { 281 const SkMatrix& matri x) const {
282 SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport()); 282 SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport());
283 const SeparableVarying& fragmentInput = fSeparableVaryings[u.toIndex()]; 283 const PathProcVarying& fragmentInput = fPathProcVaryings[u.toIndex()];
284 284
285 SkASSERT((components == 2 && fragmentInput.fType == kVec2f_GrSLType) || 285 SkASSERT((components == 2 && fragmentInput.fType == kVec2f_GrSLType) ||
286 (components == 3 && fragmentInput.fType == kVec3f_GrSLType)); 286 (components == 3 && fragmentInput.fType == kVec3f_GrSLType));
287 287
288 fGpu->glPathRendering()->setProgramPathFragmentInputTransform(fProgramID, 288 fGpu->glPathRendering()->setProgramPathFragmentInputTransform(fProgramID,
289 fragmentInput. fLocation, 289 fragmentInput. fLocation,
290 GR_GL_OBJECT_L INEAR, 290 GR_GL_OBJECT_L INEAR,
291 components, 291 components,
292 matrix); 292 matrix);
293 } 293 }
294 294
295 #ifdef SK_DEBUG 295 #ifdef SK_DEBUG
296 void GrGLProgramDataManager::printUnused(const Uniform& uni) const { 296 void GrGLProgramDataManager::printUnused(const Uniform& uni) const {
297 if (kUnusedUniform == uni.fFSLocation && kUnusedUniform == uni.fVSLocation) { 297 if (kUnusedUniform == uni.fFSLocation && kUnusedUniform == uni.fVSLocation) {
298 GrCapsDebugf(fGpu->caps(), "Unused uniform in shader\n"); 298 GrCapsDebugf(fGpu->caps(), "Unused uniform in shader\n");
299 } 299 }
300 } 300 }
301 #endif 301 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgramDataManager.h ('k') | src/gpu/gl/GrGLVaryingHandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698