OLD | NEW |
---|---|
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 GrGLProgramDataManager_DEFINED | 8 #ifndef GrGLProgramDataManager_DEFINED |
9 #define GrGLProgramDataManager_DEFINED | 9 #define GrGLProgramDataManager_DEFINED |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 }; | 46 }; |
47 | 47 |
48 typedef ShaderResourceHandle UniformHandle; | 48 typedef ShaderResourceHandle UniformHandle; |
49 | 49 |
50 struct UniformInfo { | 50 struct UniformInfo { |
51 GrGLShaderVar fVariable; | 51 GrGLShaderVar fVariable; |
52 uint32_t fVisibility; | 52 uint32_t fVisibility; |
53 GrGLint fLocation; | 53 GrGLint fLocation; |
54 }; | 54 }; |
55 | 55 |
56 | |
bsalomon
2015/09/11 18:32:23
extra \n
| |
57 struct SeparableVaryingInfo { | |
58 GrGLShaderVar fVariable; | |
59 GrGLint fLocation; | |
60 }; | |
61 | |
56 // This uses an allocator rather than array so that the GrGLShaderVars don't move in memory | 62 // This uses an allocator rather than array so that the GrGLShaderVars don't move in memory |
57 // after they are inserted. Users of GrGLShaderBuilder get refs to the vars and ptrs to their | 63 // after they are inserted. Users of GrGLShaderBuilder get refs to the vars and ptrs to their |
58 // name strings. Otherwise, we'd have to hand out copies. | 64 // name strings. Otherwise, we'd have to hand out copies. |
59 typedef GrTAllocator<UniformInfo> UniformInfoArray; | 65 typedef GrTAllocator<UniformInfo> UniformInfoArray; |
66 typedef GrTAllocator<SeparableVaryingInfo> SeparableVaryingInfoArray; | |
60 | 67 |
61 GrGLProgramDataManager(GrGLGpu*, const UniformInfoArray&); | 68 GrGLProgramDataManager(GrGLGpu*, GrGLuint programID, const UniformInfoArray& , |
69 const SeparableVaryingInfoArray&); | |
62 | 70 |
63 /** Functions for uploading uniform values. The varities ending in v can be used to upload to an | 71 /** Functions for uploading uniform values. The varities ending in v can be used to upload to an |
64 * array of uniforms. arrayCount must be <= the array count of the uniform. | 72 * array of uniforms. arrayCount must be <= the array count of the uniform. |
65 */ | 73 */ |
66 void setSampler(UniformHandle, GrGLint texUnit) const; | 74 void setSampler(UniformHandle, GrGLint texUnit) const; |
67 void set1f(UniformHandle, GrGLfloat v0) const; | 75 void set1f(UniformHandle, GrGLfloat v0) const; |
68 void set1fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; | 76 void set1fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; |
69 void set2f(UniformHandle, GrGLfloat, GrGLfloat) const; | 77 void set2f(UniformHandle, GrGLfloat, GrGLfloat) const; |
70 void set2fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; | 78 void set2fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; |
71 void set3f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat) const; | 79 void set3f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat) const; |
72 void set3fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; | 80 void set3fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; |
73 void set4f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat, GrGLfloat) const; | 81 void set4f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat, GrGLfloat) const; |
74 void set4fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; | 82 void set4fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; |
75 // matrices are column-major, the first three upload a single matrix, the la tter three upload | 83 // matrices are column-major, the first three upload a single matrix, the la tter three upload |
76 // arrayCount matrices into a uniform array. | 84 // arrayCount matrices into a uniform array. |
77 void setMatrix3f(UniformHandle, const GrGLfloat matrix[]) const; | 85 void setMatrix3f(UniformHandle, const GrGLfloat matrix[]) const; |
78 void setMatrix4f(UniformHandle, const GrGLfloat matrix[]) const; | 86 void setMatrix4f(UniformHandle, const GrGLfloat matrix[]) const; |
79 void setMatrix3fv(UniformHandle, int arrayCount, const GrGLfloat matrices[]) const; | 87 void setMatrix3fv(UniformHandle, int arrayCount, const GrGLfloat matrices[]) const; |
80 void setMatrix4fv(UniformHandle, int arrayCount, const GrGLfloat matrices[]) const; | 88 void setMatrix4fv(UniformHandle, int arrayCount, const GrGLfloat matrices[]) const; |
81 | 89 |
82 // convenience method for uploading a SkMatrix to a 3x3 matrix uniform | 90 // convenience method for uploading a SkMatrix to a 3x3 matrix uniform |
83 void setSkMatrix(UniformHandle, const SkMatrix&) const; | 91 void setSkMatrix(UniformHandle, const SkMatrix&) const; |
84 | 92 |
93 // for nvpr only | |
94 typedef GrGLProgramDataManager::ShaderResourceHandle SeparableVaryingHandle; | |
95 void setPathFragmentInputTransform(SeparableVaryingHandle u, int components, | |
96 const SkMatrix& matrix) const; | |
97 | |
85 private: | 98 private: |
86 enum { | 99 enum { |
87 kUnusedUniform = -1, | 100 kUnusedUniform = -1, |
88 }; | 101 }; |
89 | 102 |
90 struct Uniform { | 103 struct Uniform { |
91 GrGLint fVSLocation; | 104 GrGLint fVSLocation; |
92 GrGLint fFSLocation; | 105 GrGLint fFSLocation; |
93 SkDEBUGCODE( | 106 SkDEBUGCODE( |
94 GrSLType fType; | 107 GrSLType fType; |
95 int fArrayCount; | 108 int fArrayCount; |
96 ); | 109 ); |
97 }; | 110 }; |
98 | 111 |
112 enum { | |
113 kUnusedSeparableVarying = -1, | |
114 }; | |
115 struct SeparableVarying { | |
116 GrGLint fLocation; | |
117 SkDEBUGCODE( | |
118 GrSLType fType; | |
119 int fArrayCount; | |
120 ); | |
121 }; | |
122 | |
99 SkDEBUGCODE(void printUnused(const Uniform&) const;) | 123 SkDEBUGCODE(void printUnused(const Uniform&) const;) |
100 | 124 |
101 SkTArray<Uniform, true> fUniforms; | 125 SkTArray<Uniform, true> fUniforms; |
126 SkTArray<SeparableVarying, true> fSeparableVaryings; | |
102 GrGLGpu* fGpu; | 127 GrGLGpu* fGpu; |
128 GrGLuint fProgramID; | |
103 | 129 |
104 typedef SkNoncopyable INHERITED; | 130 typedef SkNoncopyable INHERITED; |
105 }; | 131 }; |
106 | 132 |
107 #endif | 133 #endif |
OLD | NEW |