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

Side by Side Diff: include/gpu/GrTypesPriv.h

Issue 1785873003: Implement GL support for buffer textures (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_glTexBuffer
Patch Set: rebase Created 4 years, 9 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 | « include/gpu/GrTextureAccess.h ('k') | src/gpu/GrTextureAccess.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 2013 Google Inc. 2 * Copyright 2013 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 GrTypesPriv_DEFINED 8 #ifndef GrTypesPriv_DEFINED
9 #define GrTypesPriv_DEFINED 9 #define GrTypesPriv_DEFINED
10 10
11 #include "GrTypes.h" 11 #include "GrTypes.h"
12 #include "SkRect.h" 12 #include "SkRect.h"
13 13
14 /** 14 /**
15 * Types of shader-language-specific boxed variables we can create. (Currently only GrGLShaderVars, 15 * Types of shader-language-specific boxed variables we can create. (Currently only GrGLShaderVars,
16 * but should be applicable to other shader languages.) 16 * but should be applicable to other shader languages.)
17 */ 17 */
18 enum GrSLType { 18 enum GrSLType {
19 kVoid_GrSLType, 19 kVoid_GrSLType,
20 kFloat_GrSLType, 20 kFloat_GrSLType,
21 kVec2f_GrSLType, 21 kVec2f_GrSLType,
22 kVec3f_GrSLType, 22 kVec3f_GrSLType,
23 kVec4f_GrSLType, 23 kVec4f_GrSLType,
24 kMat22f_GrSLType, 24 kMat22f_GrSLType,
25 kMat33f_GrSLType, 25 kMat33f_GrSLType,
26 kMat44f_GrSLType, 26 kMat44f_GrSLType,
27 kSampler2D_GrSLType, 27 kSampler2D_GrSLType,
28 kSamplerExternal_GrSLType, 28 kSamplerExternal_GrSLType,
29 kSampler2DRect_GrSLType, 29 kSampler2DRect_GrSLType,
30 kSamplerBuffer_GrSLType,
30 kBool_GrSLType, 31 kBool_GrSLType,
31 kInt_GrSLType, 32 kInt_GrSLType,
32 kUint_GrSLType, 33 kUint_GrSLType,
33 34
34 kLast_GrSLType = kUint_GrSLType 35 kLast_GrSLType = kUint_GrSLType
35 }; 36 };
36 static const int kGrSLTypeCount = kLast_GrSLType + 1; 37 static const int kGrSLTypeCount = kLast_GrSLType + 1;
37 38
38 enum GrShaderType { 39 enum GrShaderType {
39 kVertex_GrShaderType, 40 kVertex_GrShaderType,
(...skipping 29 matching lines...) Expand all
69 kLast_GrSLPrecision = kHigh_GrSLPrecision 70 kLast_GrSLPrecision = kHigh_GrSLPrecision
70 }; 71 };
71 72
72 static const int kGrSLPrecisionCount = kLast_GrSLPrecision + 1; 73 static const int kGrSLPrecisionCount = kLast_GrSLPrecision + 1;
73 74
74 /** 75 /**
75 * Gets the vector size of the SLType. Returns -1 for void, matrices, and sample rs. 76 * Gets the vector size of the SLType. Returns -1 for void, matrices, and sample rs.
76 */ 77 */
77 static inline int GrSLTypeVectorCount(GrSLType type) { 78 static inline int GrSLTypeVectorCount(GrSLType type) {
78 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); 79 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
79 static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1, -1, -1, 1, 1, 1 }; 80 static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1, -1, -1, -1, 1 , 1, 1 };
80 return kCounts[type]; 81 return kCounts[type];
81 82
82 GR_STATIC_ASSERT(0 == kVoid_GrSLType); 83 GR_STATIC_ASSERT(0 == kVoid_GrSLType);
83 GR_STATIC_ASSERT(1 == kFloat_GrSLType); 84 GR_STATIC_ASSERT(1 == kFloat_GrSLType);
84 GR_STATIC_ASSERT(2 == kVec2f_GrSLType); 85 GR_STATIC_ASSERT(2 == kVec2f_GrSLType);
85 GR_STATIC_ASSERT(3 == kVec3f_GrSLType); 86 GR_STATIC_ASSERT(3 == kVec3f_GrSLType);
86 GR_STATIC_ASSERT(4 == kVec4f_GrSLType); 87 GR_STATIC_ASSERT(4 == kVec4f_GrSLType);
87 GR_STATIC_ASSERT(5 == kMat22f_GrSLType); 88 GR_STATIC_ASSERT(5 == kMat22f_GrSLType);
88 GR_STATIC_ASSERT(6 == kMat33f_GrSLType); 89 GR_STATIC_ASSERT(6 == kMat33f_GrSLType);
89 GR_STATIC_ASSERT(7 == kMat44f_GrSLType); 90 GR_STATIC_ASSERT(7 == kMat44f_GrSLType);
90 GR_STATIC_ASSERT(8 == kSampler2D_GrSLType); 91 GR_STATIC_ASSERT(8 == kSampler2D_GrSLType);
91 GR_STATIC_ASSERT(9 == kSamplerExternal_GrSLType); 92 GR_STATIC_ASSERT(9 == kSamplerExternal_GrSLType);
92 GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType); 93 GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType);
93 GR_STATIC_ASSERT(11 == kBool_GrSLType); 94 GR_STATIC_ASSERT(11 == kSamplerBuffer_GrSLType);
94 GR_STATIC_ASSERT(12 == kInt_GrSLType); 95 GR_STATIC_ASSERT(12 == kBool_GrSLType);
95 GR_STATIC_ASSERT(13 == kUint_GrSLType); 96 GR_STATIC_ASSERT(13 == kInt_GrSLType);
97 GR_STATIC_ASSERT(14 == kUint_GrSLType);
96 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrSLTypeCount); 98 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrSLTypeCount);
97 } 99 }
98 100
99 /** Return the type enum for a vector of floats of length n (1..4), 101 /** Return the type enum for a vector of floats of length n (1..4),
100 e.g. 1 -> kFloat_GrSLType, 2 -> kVec2_GrSLType, ... */ 102 e.g. 1 -> kFloat_GrSLType, 2 -> kVec2_GrSLType, ... */
101 static inline GrSLType GrSLFloatVectorType(int count) { 103 static inline GrSLType GrSLFloatVectorType(int count) {
102 SkASSERT(count > 0 && count <= 4); 104 SkASSERT(count > 0 && count <= 4);
103 return (GrSLType)(count); 105 return (GrSLType)(count);
104 106
105 GR_STATIC_ASSERT(kFloat_GrSLType == 1); 107 GR_STATIC_ASSERT(kFloat_GrSLType == 1);
(...skipping 11 matching lines...) Expand all
117 GR_STATIC_ASSERT(1 == kFloat_GrSLType); 119 GR_STATIC_ASSERT(1 == kFloat_GrSLType);
118 GR_STATIC_ASSERT(2 == kVec2f_GrSLType); 120 GR_STATIC_ASSERT(2 == kVec2f_GrSLType);
119 GR_STATIC_ASSERT(3 == kVec3f_GrSLType); 121 GR_STATIC_ASSERT(3 == kVec3f_GrSLType);
120 GR_STATIC_ASSERT(4 == kVec4f_GrSLType); 122 GR_STATIC_ASSERT(4 == kVec4f_GrSLType);
121 GR_STATIC_ASSERT(5 == kMat22f_GrSLType); 123 GR_STATIC_ASSERT(5 == kMat22f_GrSLType);
122 GR_STATIC_ASSERT(6 == kMat33f_GrSLType); 124 GR_STATIC_ASSERT(6 == kMat33f_GrSLType);
123 GR_STATIC_ASSERT(7 == kMat44f_GrSLType); 125 GR_STATIC_ASSERT(7 == kMat44f_GrSLType);
124 GR_STATIC_ASSERT(8 == kSampler2D_GrSLType); 126 GR_STATIC_ASSERT(8 == kSampler2D_GrSLType);
125 GR_STATIC_ASSERT(9 == kSamplerExternal_GrSLType); 127 GR_STATIC_ASSERT(9 == kSamplerExternal_GrSLType);
126 GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType); 128 GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType);
127 GR_STATIC_ASSERT(11 == kBool_GrSLType); 129 GR_STATIC_ASSERT(11 == kSamplerBuffer_GrSLType);
128 GR_STATIC_ASSERT(12 == kInt_GrSLType); 130 GR_STATIC_ASSERT(12 == kBool_GrSLType);
129 GR_STATIC_ASSERT(13 == kUint_GrSLType); 131 GR_STATIC_ASSERT(13 == kInt_GrSLType);
130 GR_STATIC_ASSERT(14 == kGrSLTypeCount); 132 GR_STATIC_ASSERT(14 == kUint_GrSLType);
133 GR_STATIC_ASSERT(15 == kGrSLTypeCount);
131 } 134 }
132 135
133 /** Is the shading language type integral (including vectors/matrices)? */ 136 /** Is the shading language type integral (including vectors/matrices)? */
134 static inline bool GrSLTypeIsIntType(GrSLType type) { 137 static inline bool GrSLTypeIsIntType(GrSLType type) {
135 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); 138 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
136 return type >= kInt_GrSLType; 139 return type >= kInt_GrSLType;
137 140
138 GR_STATIC_ASSERT(0 == kVoid_GrSLType); 141 GR_STATIC_ASSERT(0 == kVoid_GrSLType);
139 GR_STATIC_ASSERT(1 == kFloat_GrSLType); 142 GR_STATIC_ASSERT(1 == kFloat_GrSLType);
140 GR_STATIC_ASSERT(2 == kVec2f_GrSLType); 143 GR_STATIC_ASSERT(2 == kVec2f_GrSLType);
141 GR_STATIC_ASSERT(3 == kVec3f_GrSLType); 144 GR_STATIC_ASSERT(3 == kVec3f_GrSLType);
142 GR_STATIC_ASSERT(4 == kVec4f_GrSLType); 145 GR_STATIC_ASSERT(4 == kVec4f_GrSLType);
143 GR_STATIC_ASSERT(5 == kMat22f_GrSLType); 146 GR_STATIC_ASSERT(5 == kMat22f_GrSLType);
144 GR_STATIC_ASSERT(6 == kMat33f_GrSLType); 147 GR_STATIC_ASSERT(6 == kMat33f_GrSLType);
145 GR_STATIC_ASSERT(7 == kMat44f_GrSLType); 148 GR_STATIC_ASSERT(7 == kMat44f_GrSLType);
146 GR_STATIC_ASSERT(8 == kSampler2D_GrSLType); 149 GR_STATIC_ASSERT(8 == kSampler2D_GrSLType);
147 GR_STATIC_ASSERT(9 == kSamplerExternal_GrSLType); 150 GR_STATIC_ASSERT(9 == kSamplerExternal_GrSLType);
148 GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType); 151 GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType);
149 GR_STATIC_ASSERT(11 == kBool_GrSLType); 152 GR_STATIC_ASSERT(11 == kSamplerBuffer_GrSLType);
150 GR_STATIC_ASSERT(12 == kInt_GrSLType); 153 GR_STATIC_ASSERT(12 == kBool_GrSLType);
151 GR_STATIC_ASSERT(13 == kUint_GrSLType); 154 GR_STATIC_ASSERT(13 == kInt_GrSLType);
152 GR_STATIC_ASSERT(14 == kGrSLTypeCount); 155 GR_STATIC_ASSERT(14 == kUint_GrSLType);
156 GR_STATIC_ASSERT(15 == kGrSLTypeCount);
153 } 157 }
154 158
155 /** Is the shading language type numeric (including vectors/matrices)? */ 159 /** Is the shading language type numeric (including vectors/matrices)? */
156 static inline bool GrSLTypeIsNumeric(GrSLType type) { 160 static inline bool GrSLTypeIsNumeric(GrSLType type) {
157 return GrSLTypeIsFloatType(type) || GrSLTypeIsIntType(type); 161 return GrSLTypeIsFloatType(type) || GrSLTypeIsIntType(type);
158 } 162 }
159 163
160 /** Returns the size in bytes for floating point GrSLTypes. For non floating poi nt type returns 0 */ 164 /** Returns the size in bytes for floating point GrSLTypes. For non floating poi nt type returns 0 */
161 static inline size_t GrSLTypeSize(GrSLType type) { 165 static inline size_t GrSLTypeSize(GrSLType type) {
162 SkASSERT(GrSLTypeIsFloatType(type)); 166 SkASSERT(GrSLTypeIsFloatType(type));
163 static const size_t kSizes[] = { 167 static const size_t kSizes[] = {
164 0, // kVoid_GrSLType 168 0, // kVoid_GrSLType
165 sizeof(float), // kFloat_GrSLType 169 sizeof(float), // kFloat_GrSLType
166 2 * sizeof(float), // kVec2f_GrSLType 170 2 * sizeof(float), // kVec2f_GrSLType
167 3 * sizeof(float), // kVec3f_GrSLType 171 3 * sizeof(float), // kVec3f_GrSLType
168 4 * sizeof(float), // kVec4f_GrSLType 172 4 * sizeof(float), // kVec4f_GrSLType
169 2 * 2 * sizeof(float), // kMat22f_GrSLType 173 2 * 2 * sizeof(float), // kMat22f_GrSLType
170 3 * 3 * sizeof(float), // kMat33f_GrSLType 174 3 * 3 * sizeof(float), // kMat33f_GrSLType
171 4 * 4 * sizeof(float), // kMat44f_GrSLType 175 4 * 4 * sizeof(float), // kMat44f_GrSLType
172 0, // kSampler2D_GrSLType 176 0, // kSampler2D_GrSLType
173 0, // kSamplerExternal_GrSLType 177 0, // kSamplerExternal_GrSLType
174 0, // kSampler2DRect_GrSLType 178 0, // kSampler2DRect_GrSLType
179 0, // kSamplerBuffer_GrSLType
175 0, // kBool_GrSLType 180 0, // kBool_GrSLType
176 0, // kInt_GrSLType 181 0, // kInt_GrSLType
177 0, // kUint_GrSLType 182 0, // kUint_GrSLType
178 }; 183 };
179 return kSizes[type]; 184 return kSizes[type];
180 185
181 GR_STATIC_ASSERT(0 == kVoid_GrSLType); 186 GR_STATIC_ASSERT(0 == kVoid_GrSLType);
182 GR_STATIC_ASSERT(1 == kFloat_GrSLType); 187 GR_STATIC_ASSERT(1 == kFloat_GrSLType);
183 GR_STATIC_ASSERT(2 == kVec2f_GrSLType); 188 GR_STATIC_ASSERT(2 == kVec2f_GrSLType);
184 GR_STATIC_ASSERT(3 == kVec3f_GrSLType); 189 GR_STATIC_ASSERT(3 == kVec3f_GrSLType);
185 GR_STATIC_ASSERT(4 == kVec4f_GrSLType); 190 GR_STATIC_ASSERT(4 == kVec4f_GrSLType);
186 GR_STATIC_ASSERT(5 == kMat22f_GrSLType); 191 GR_STATIC_ASSERT(5 == kMat22f_GrSLType);
187 GR_STATIC_ASSERT(6 == kMat33f_GrSLType); 192 GR_STATIC_ASSERT(6 == kMat33f_GrSLType);
188 GR_STATIC_ASSERT(7 == kMat44f_GrSLType); 193 GR_STATIC_ASSERT(7 == kMat44f_GrSLType);
189 GR_STATIC_ASSERT(8 == kSampler2D_GrSLType); 194 GR_STATIC_ASSERT(8 == kSampler2D_GrSLType);
190 GR_STATIC_ASSERT(9 == kSamplerExternal_GrSLType); 195 GR_STATIC_ASSERT(9 == kSamplerExternal_GrSLType);
191 GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType); 196 GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType);
192 GR_STATIC_ASSERT(11 == kBool_GrSLType); 197 GR_STATIC_ASSERT(11 == kSamplerBuffer_GrSLType);
193 GR_STATIC_ASSERT(12 == kInt_GrSLType); 198 GR_STATIC_ASSERT(12 == kBool_GrSLType);
194 GR_STATIC_ASSERT(13 == kUint_GrSLType); 199 GR_STATIC_ASSERT(13 == kInt_GrSLType);
195 GR_STATIC_ASSERT(14 == kGrSLTypeCount); 200 GR_STATIC_ASSERT(14 == kUint_GrSLType);
201 GR_STATIC_ASSERT(15 == kGrSLTypeCount);
196 } 202 }
197 203
198 static inline bool GrSLTypeIsSamplerType(GrSLType type) { 204 static inline bool GrSLTypeIsSamplerType(GrSLType type) {
199 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); 205 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
200 return type >= kSampler2D_GrSLType && type <= kSampler2DRect_GrSLType; 206 return type >= kSampler2D_GrSLType && type <= kSamplerBuffer_GrSLType;
201 207
202 GR_STATIC_ASSERT(8 == kSampler2D_GrSLType); 208 GR_STATIC_ASSERT(8 == kSampler2D_GrSLType);
203 GR_STATIC_ASSERT(9 == kSamplerExternal_GrSLType); 209 GR_STATIC_ASSERT(9 == kSamplerExternal_GrSLType);
204 GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType); 210 GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType);
211 GR_STATIC_ASSERT(11 == kSamplerBuffer_GrSLType);
205 } 212 }
206 213
207 static inline bool GrSLTypeAcceptsPrecision(GrSLType type) { 214 static inline bool GrSLTypeAcceptsPrecision(GrSLType type) {
208 return GrSLTypeIsNumeric(type) || GrSLTypeIsSamplerType(type); 215 return GrSLTypeIsNumeric(type) || GrSLTypeIsSamplerType(type);
209 } 216 }
210 217
211 ////////////////////////////////////////////////////////////////////////////// 218 //////////////////////////////////////////////////////////////////////////////
212 219
213 /** 220 /**
214 * Types used to describe format of vertices in arrays. 221 * Types used to describe format of vertices in arrays.
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 // Takes a pointer to a GrCaps, and will suppress prints if required 422 // Takes a pointer to a GrCaps, and will suppress prints if required
416 #define GrCapsDebugf(caps, ...) \ 423 #define GrCapsDebugf(caps, ...) \
417 if (!caps->suppressPrints()) { \ 424 if (!caps->suppressPrints()) { \
418 SkDebugf(__VA_ARGS__); \ 425 SkDebugf(__VA_ARGS__); \
419 } 426 }
420 #else 427 #else
421 #define GrCapsDebugf(caps, ...) 428 #define GrCapsDebugf(caps, ...)
422 #endif 429 #endif
423 430
424 #endif 431 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrTextureAccess.h ('k') | src/gpu/GrTextureAccess.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698