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

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

Issue 1336763003: remove path specific program building classes (Closed) Base URL: https://skia.googlesource.com/skia.git@pathgp
Patch Set: a few more tidys Created 5 years, 3 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/builders/GrGLPathProgramBuilder.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 && GrGLShaderVar::kNonArray == uni.fArrayCoun t)) 14 (1 == arrayCount && GrGLShaderVar::kNonArray == uni.fArrayCoun t))
15 15
16 GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, const UniformInfoAr ray& uniforms) 16 GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID,
17 : fGpu(gpu) { 17 const UniformInfoArray& uniforms,
18 const SeparableVaryingInfoArray& separableVaryings)
19 : fGpu(gpu)
20 , fProgramID(programID) {
18 int count = uniforms.count(); 21 int count = uniforms.count();
19 fUniforms.push_back_n(count); 22 fUniforms.push_back_n(count);
20 for (int i = 0; i < count; i++) { 23 for (int i = 0; i < count; i++) {
21 Uniform& uniform = fUniforms[i]; 24 Uniform& uniform = fUniforms[i];
22 const UniformInfo& builderUniform = uniforms[i]; 25 const UniformInfo& builderUniform = uniforms[i];
23 SkASSERT(GrGLShaderVar::kNonArray == builderUniform.fVariable.getArrayCo unt() || 26 SkASSERT(GrGLShaderVar::kNonArray == builderUniform.fVariable.getArrayCo unt() ||
24 builderUniform.fVariable.getArrayCount() > 0); 27 builderUniform.fVariable.getArrayCount() > 0);
25 SkDEBUGCODE( 28 SkDEBUGCODE(
26 uniform.fArrayCount = builderUniform.fVariable.getArrayCount(); 29 uniform.fArrayCount = builderUniform.fVariable.getArrayCount();
27 uniform.fType = builderUniform.fVariable.getType(); 30 uniform.fType = builderUniform.fVariable.getType();
28 ); 31 );
29 // 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.
30 33
31 if (GrGLProgramBuilder::kVertex_Visibility & builderUniform.fVisibility) { 34 if (GrGLProgramBuilder::kVertex_Visibility & builderUniform.fVisibility) {
32 uniform.fVSLocation = builderUniform.fLocation; 35 uniform.fVSLocation = builderUniform.fLocation;
33 } else { 36 } else {
34 uniform.fVSLocation = kUnusedUniform; 37 uniform.fVSLocation = kUnusedUniform;
35 } 38 }
36 if (GrGLProgramBuilder::kFragment_Visibility & builderUniform.fVisibilit y) { 39 if (GrGLProgramBuilder::kFragment_Visibility & builderUniform.fVisibilit y) {
37 uniform.fFSLocation = builderUniform.fLocation; 40 uniform.fFSLocation = builderUniform.fLocation;
38 } else { 41 } else {
39 uniform.fFSLocation = kUnusedUniform; 42 uniform.fFSLocation = kUnusedUniform;
40 } 43 }
41 } 44 }
45
46 // NVPR programs have separable varyings
47 count = separableVaryings.count();
48 fSeparableVaryings.push_back_n(count);
49 for (int i = 0; i < count; i++) {
50 SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport());
51 SeparableVarying& separableVarying = fSeparableVaryings[i];
52 const SeparableVaryingInfo& builderSeparableVarying = separableVaryings[ i];
53 SkASSERT(GrGLShaderVar::kNonArray == builderSeparableVarying.fVariable.g etArrayCount() ||
54 builderSeparableVarying.fVariable.getArrayCount() > 0);
55 SkDEBUGCODE(
56 separableVarying.fArrayCount = builderSeparableVarying.fVariable.get ArrayCount();
57 separableVarying.fType = builderSeparableVarying.fVariable.getType() ;
58 );
59 separableVarying.fLocation = builderSeparableVarying.fLocation;
60 }
42 } 61 }
43 62
44 void GrGLProgramDataManager::setSampler(UniformHandle u, GrGLint texUnit) const { 63 void GrGLProgramDataManager::setSampler(UniformHandle u, GrGLint texUnit) const {
45 const Uniform& uni = fUniforms[u.toIndex()]; 64 const Uniform& uni = fUniforms[u.toIndex()];
46 SkASSERT(uni.fType == kSampler2D_GrSLType); 65 SkASSERT(uni.fType == kSampler2D_GrSLType);
47 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount); 66 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
48 // 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
49 // 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
50 // once stages insert their own samplers. 69 // once stages insert their own samplers.
51 // this->printUnused(uni); 70 // this->printUnused(uni);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 matrix.get(SkMatrix::kMSkewX), 269 matrix.get(SkMatrix::kMSkewX),
251 matrix.get(SkMatrix::kMScaleY), 270 matrix.get(SkMatrix::kMScaleY),
252 matrix.get(SkMatrix::kMPersp1), 271 matrix.get(SkMatrix::kMPersp1),
253 matrix.get(SkMatrix::kMTransX), 272 matrix.get(SkMatrix::kMTransX),
254 matrix.get(SkMatrix::kMTransY), 273 matrix.get(SkMatrix::kMTransY),
255 matrix.get(SkMatrix::kMPersp2), 274 matrix.get(SkMatrix::kMPersp2),
256 }; 275 };
257 this->setMatrix3f(u, mt); 276 this->setMatrix3f(u, mt);
258 } 277 }
259 278
279 void GrGLProgramDataManager::setPathFragmentInputTransform(SeparableVaryingHandl e u,
280 int components,
281 const SkMatrix& matri x) const {
282 SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport());
283 const SeparableVarying& fragmentInput = fSeparableVaryings[u.toIndex()];
284
285 SkASSERT((components == 2 && fragmentInput.fType == kVec2f_GrSLType) ||
286 (components == 3 && fragmentInput.fType == kVec3f_GrSLType));
287
288 fGpu->glPathRendering()->setProgramPathFragmentInputTransform(fProgramID,
289 fragmentInput. fLocation,
290 GR_GL_OBJECT_L INEAR,
291 components,
292 matrix);
293 }
294
260 #ifdef SK_DEBUG 295 #ifdef SK_DEBUG
261 void GrGLProgramDataManager::printUnused(const Uniform& uni) const { 296 void GrGLProgramDataManager::printUnused(const Uniform& uni) const {
262 if (kUnusedUniform == uni.fFSLocation && kUnusedUniform == uni.fVSLocation) { 297 if (kUnusedUniform == uni.fFSLocation && kUnusedUniform == uni.fVSLocation) {
263 GrCapsDebugf(fGpu->caps(), "Unused uniform in shader\n"); 298 GrCapsDebugf(fGpu->caps(), "Unused uniform in shader\n");
264 } 299 }
265 } 300 }
266 #endif 301 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgramDataManager.h ('k') | src/gpu/gl/builders/GrGLPathProgramBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698