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

Side by Side Diff: src/gpu/gl/GrGLUniformManager.h

Issue 62163004: Added support for Chrome's gpu command buffer extension BindUniformLocation. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fixed compile error on the bots + feedback. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGLShaderBuilder.cpp ('k') | src/gpu/gl/GrGLUniformManager.cpp » ('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 #ifndef GrGLUniformManager_DEFINED 8 #ifndef GrGLUniformManager_DEFINED
9 #define GrGLUniformManager_DEFINED 9 #define GrGLUniformManager_DEFINED
10 10
(...skipping 28 matching lines...) Expand all
39 : fValue(~value) { 39 : fValue(~value) {
40 SkASSERT(isValid()); 40 SkASSERT(isValid());
41 } 41 }
42 42
43 int toUniformIndex() const { SkASSERT(isValid()); return ~fValue; } 43 int toUniformIndex() const { SkASSERT(isValid()); return ~fValue; }
44 44
45 int fValue; 45 int fValue;
46 friend class GrGLUniformManager; // For accessing toUniformIndex(). 46 friend class GrGLUniformManager; // For accessing toUniformIndex().
47 }; 47 };
48 48
49 GrGLUniformManager(GrGpuGL* gpu) : fGpu(gpu) {} 49 GrGLUniformManager(GrGpuGL* gpu);
50 50
51 UniformHandle appendUniform(GrSLType type, int arrayCount = GrGLShaderVar::k NonArray); 51 UniformHandle appendUniform(GrSLType type, int arrayCount = GrGLShaderVar::k NonArray);
52 52
53 /** Functions for uploading uniform values. The varities ending in v can be used to upload to an 53 /** Functions for uploading uniform values. The varities ending in v can be used to upload to an
54 * array of uniforms. offset + arrayCount must be <= the array count of the uniform. 54 * array of uniforms. arrayCount must be <= the array count of the uniform.
55 */ 55 */
56 void setSampler(UniformHandle, GrGLint texUnit) const; 56 void setSampler(UniformHandle, GrGLint texUnit) const;
57 void set1f(UniformHandle, GrGLfloat v0) const; 57 void set1f(UniformHandle, GrGLfloat v0) const;
58 void set1fv(UniformHandle, int offset, int arrayCount, const GrGLfloat v[]) const; 58 void set1fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const;
59 void set2f(UniformHandle, GrGLfloat, GrGLfloat) const; 59 void set2f(UniformHandle, GrGLfloat, GrGLfloat) const;
60 void set2fv(UniformHandle, int offset, int arrayCount, const GrGLfloat v[]) const; 60 void set2fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const;
61 void set3f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat) const; 61 void set3f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat) const;
62 void set3fv(UniformHandle, int offset, int arrayCount, const GrGLfloat v[]) const; 62 void set3fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const;
63 void set4f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat, GrGLfloat) const; 63 void set4f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat, GrGLfloat) const;
64 void set4fv(UniformHandle, int offset, int arrayCount, const GrGLfloat v[]) const; 64 void set4fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const;
65 // matrices are column-major, the first three upload a single matrix, the la tter three upload 65 // matrices are column-major, the first three upload a single matrix, the la tter three upload
66 // arrayCount matrices into a uniform array. 66 // arrayCount matrices into a uniform array.
67 void setMatrix3f(UniformHandle, const GrGLfloat matrix[]) const; 67 void setMatrix3f(UniformHandle, const GrGLfloat matrix[]) const;
68 void setMatrix4f(UniformHandle, const GrGLfloat matrix[]) const; 68 void setMatrix4f(UniformHandle, const GrGLfloat matrix[]) const;
69 void setMatrix3fv(UniformHandle, int offset, int arrayCount, const GrGLfloat matrices[]) const; 69 void setMatrix3fv(UniformHandle, int arrayCount, const GrGLfloat matrices[]) const;
70 void setMatrix4fv(UniformHandle, int offset, int arrayCount, const GrGLfloat matrices[]) const; 70 void setMatrix4fv(UniformHandle, int arrayCount, const GrGLfloat matrices[]) const;
71 71
72 // convenience method for uploading a SkMatrix to a 3x3 matrix uniform 72 // convenience method for uploading a SkMatrix to a 3x3 matrix uniform
73 void setSkMatrix(UniformHandle, const SkMatrix&) const; 73 void setSkMatrix(UniformHandle, const SkMatrix&) const;
74 74
75 struct BuilderUniform { 75 struct BuilderUniform {
76 GrGLShaderVar fVariable; 76 GrGLShaderVar fVariable;
77 uint32_t fVisibility; 77 uint32_t fVisibility;
78 }; 78 };
79 // This uses an allocator rather than array so that the GrGLShaderVars don't move in memory 79 // This uses an allocator rather than array so that the GrGLShaderVars don't move in memory
80 // after they are inserted. Users of GrGLShaderBuilder get refs to the vars and ptrs to their 80 // after they are inserted. Users of GrGLShaderBuilder get refs to the vars and ptrs to their
81 // name strings. Otherwise, we'd have to hand out copies. 81 // name strings. Otherwise, we'd have to hand out copies.
82 typedef GrTAllocator<BuilderUniform> BuilderUniformArray; 82 typedef GrTAllocator<BuilderUniform> BuilderUniformArray;
83 83
84 /** 84 /**
85 * Called by the GrGLShaderBuilder to know if the manager is using
86 * BindUniformLocation. In that case getUniformLocations must be called
87 * before the program is linked.
88 */
89 bool isUsingBindUniform() const { return fUsingBindUniform; }
90
91 /**
85 * Called by the GrGLShaderBuilder to get GL locations for all uniforms. 92 * Called by the GrGLShaderBuilder to get GL locations for all uniforms.
86 */ 93 */
87 void getUniformLocations(GrGLuint programID, const BuilderUniformArray& unif orms); 94 void getUniformLocations(GrGLuint programID, const BuilderUniformArray& unif orms);
88 95
89 /** 96 /**
90 * Called by the GrGLShaderBuilder to access the array by the handle (index) . 97 * Called by the GrGLShaderBuilder to access the array by the handle (index) .
91 */ 98 */
92 const BuilderUniform& getBuilderUniform(const BuilderUniformArray&, GrGLUnif ormManager::UniformHandle) const; 99 const BuilderUniform& getBuilderUniform(const BuilderUniformArray&, GrGLUnif ormManager::UniformHandle) const;
93 100
94 private: 101 private:
95 enum { 102 enum {
96 kUnusedUniform = -1, 103 kUnusedUniform = -1,
97 }; 104 };
98 105
99 struct Uniform { 106 struct Uniform {
100 GrGLint fVSLocation; 107 GrGLint fVSLocation;
101 GrGLint fFSLocation; 108 GrGLint fFSLocation;
102 GrSLType fType; 109 GrSLType fType;
103 int fArrayCount; 110 int fArrayCount;
104 }; 111 };
105 112
113 bool fUsingBindUniform;
106 SkTArray<Uniform, true> fUniforms; 114 SkTArray<Uniform, true> fUniforms;
107 GrGpuGL* fGpu; 115 GrGpuGL* fGpu;
108 }; 116 };
109 117
110 #endif 118 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLShaderBuilder.cpp ('k') | src/gpu/gl/GrGLUniformManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698