• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #include "GLESv2Validate.h"
17 #include <string.h>
18 
19 #define LIST_VALID_TEXFORMATS(f) \
20     f(GL_DEPTH_COMPONENT) \
21     f(GL_DEPTH_STENCIL) \
22     f(GL_RED) \
23     f(GL_RED_INTEGER) \
24     f(GL_RG) \
25     f(GL_RGB) \
26     f(GL_RGBA) \
27     f(GL_RGBA_INTEGER) \
28     f(GL_RGB_INTEGER) \
29     f(GL_RG_INTEGER) \
30 
31 #define LIST_VALID_TEXTYPES(f) \
32     f(GL_BYTE) \
33     f(GL_FLOAT) \
34     f(GL_FLOAT_32_UNSIGNED_INT_24_8_REV) \
35     f(GL_HALF_FLOAT) \
36     f(GL_HALF_FLOAT_OES) \
37     f(GL_INT) \
38     f(GL_SHORT) \
39     f(GL_UNSIGNED_BYTE) \
40     f(GL_UNSIGNED_INT) \
41     f(GL_UNSIGNED_INT_10F_11F_11F_REV) \
42     f(GL_UNSIGNED_INT_2_10_10_10_REV) \
43     f(GL_UNSIGNED_INT_24_8) \
44     f(GL_UNSIGNED_INT_5_9_9_9_REV) \
45     f(GL_UNSIGNED_SHORT) \
46     f(GL_UNSIGNED_SHORT_4_4_4_4) \
47     f(GL_UNSIGNED_SHORT_5_5_5_1) \
48     f(GL_UNSIGNED_SHORT_5_6_5) \
49 
50 #define LIST_VALID_TEXFORMAT_COMBINATIONS(f) \
51     f(GL_BGRA8_EXT, GL_BGRA_EXT, GL_UNSIGNED_BYTE) \
52     f(GL_R8, GL_RED, GL_UNSIGNED_BYTE) \
53     f(GL_R8_SNORM, GL_RED, GL_BYTE) \
54     f(GL_R16F, GL_RED, GL_FLOAT) \
55     f(GL_R16F, GL_RED, GL_HALF_FLOAT) \
56     f(GL_R32F, GL_RED, GL_FLOAT) \
57     f(GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE) \
58     f(GL_R8I, GL_RED_INTEGER, GL_BYTE) \
59     f(GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT) \
60     f(GL_R16I, GL_RED_INTEGER, GL_SHORT) \
61     f(GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT) \
62     f(GL_R32I, GL_RED_INTEGER, GL_INT) \
63     f(GL_RG8, GL_RG, GL_UNSIGNED_BYTE) \
64     f(GL_RG8_SNORM, GL_RG, GL_BYTE) \
65     f(GL_RG16F, GL_RG, GL_HALF_FLOAT) \
66     f(GL_RG16F, GL_RG, GL_FLOAT) \
67     f(GL_RG32F, GL_RG, GL_FLOAT) \
68     f(GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_BYTE) \
69     f(GL_RG8I, GL_RG_INTEGER, GL_BYTE) \
70     f(GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT) \
71     f(GL_RG16I, GL_RG_INTEGER, GL_SHORT) \
72     f(GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT) \
73     f(GL_RG32I, GL_RG_INTEGER, GL_INT) \
74     f(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE) \
75     f(GL_SRGB8, GL_RGB, GL_UNSIGNED_BYTE) \
76     f(GL_RGB565, GL_RGB, GL_UNSIGNED_BYTE) \
77     f(GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5) \
78     f(GL_RGB8_SNORM, GL_RGB, GL_BYTE) \
79     f(GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV) \
80     f(GL_R11F_G11F_B10F, GL_RGB, GL_HALF_FLOAT) \
81     f(GL_R11F_G11F_B10F, GL_RGB, GL_FLOAT) \
82     f(GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV) \
83     f(GL_RGB9_E5, GL_RGB, GL_HALF_FLOAT) \
84     f(GL_RGB9_E5, GL_RGB, GL_FLOAT) \
85     f(GL_RGB16F, GL_RGB, GL_HALF_FLOAT) \
86     f(GL_RGB16F, GL_RGB, GL_FLOAT) \
87     f(GL_RGB32F, GL_RGB, GL_FLOAT) \
88     f(GL_RGB8UI, GL_RGB_INTEGER, GL_UNSIGNED_BYTE) \
89     f(GL_RGB8I, GL_RGB_INTEGER, GL_BYTE) \
90     f(GL_RGB16UI, GL_RGB_INTEGER, GL_UNSIGNED_SHORT) \
91     f(GL_RGB16I, GL_RGB_INTEGER, GL_SHORT) \
92     f(GL_RGB32UI, GL_RGB_INTEGER, GL_UNSIGNED_INT) \
93     f(GL_RGB32I, GL_RGB_INTEGER, GL_INT) \
94     f(GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE) \
95     f(GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE) \
96     f(GL_RGBA8_SNORM, GL_RGBA, GL_BYTE) \
97     f(GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_BYTE) \
98     f(GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1) \
99     f(GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV) \
100     f(GL_RGBA4, GL_RGBA, GL_UNSIGNED_BYTE) \
101     f(GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4) \
102     f(GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV) \
103     f(GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT) \
104     f(GL_RGBA16F, GL_RGBA, GL_FLOAT) \
105     f(GL_RGBA32F, GL_RGBA, GL_FLOAT) \
106     f(GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE) \
107     f(GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE) \
108     f(GL_RGB10_A2UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV) \
109     f(GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT) \
110     f(GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT) \
111     f(GL_RGBA32I, GL_RGBA_INTEGER, GL_INT) \
112     f(GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT) \
113     f(GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT) \
114     f(GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT) \
115     f(GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT) \
116     f(GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT) \
117     f(GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8) \
118     f(GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV) \
119     f(GL_COMPRESSED_R11_EAC, GL_RED, GL_FLOAT) \
120     f(GL_COMPRESSED_SIGNED_R11_EAC, GL_RED, GL_FLOAT) \
121     f(GL_COMPRESSED_RG11_EAC, GL_RG, GL_FLOAT) \
122     f(GL_COMPRESSED_SIGNED_RG11_EAC, GL_RG, GL_FLOAT) \
123     f(GL_COMPRESSED_RGB8_ETC2, GL_RGB, GL_UNSIGNED_BYTE) \
124     f(GL_COMPRESSED_SRGB8_ETC2, GL_RGB, GL_UNSIGNED_BYTE) \
125     f(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_RGBA, GL_UNSIGNED_BYTE) \
126     f(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_RGBA, GL_UNSIGNED_BYTE) \
127     f(GL_COMPRESSED_RGBA8_ETC2_EAC, GL_RGBA, GL_UNSIGNED_BYTE) \
128     f(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_RGBA, GL_UNSIGNED_BYTE) \
129     f(GL_COMPRESSED_RGBA_ASTC_4x4_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
130     f(GL_COMPRESSED_RGBA_ASTC_5x4_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
131     f(GL_COMPRESSED_RGBA_ASTC_5x5_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
132     f(GL_COMPRESSED_RGBA_ASTC_6x5_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
133     f(GL_COMPRESSED_RGBA_ASTC_6x6_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
134     f(GL_COMPRESSED_RGBA_ASTC_8x5_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
135     f(GL_COMPRESSED_RGBA_ASTC_8x6_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
136     f(GL_COMPRESSED_RGBA_ASTC_8x8_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
137     f(GL_COMPRESSED_RGBA_ASTC_10x5_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
138     f(GL_COMPRESSED_RGBA_ASTC_10x6_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
139     f(GL_COMPRESSED_RGBA_ASTC_10x8_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
140     f(GL_COMPRESSED_RGBA_ASTC_10x10_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
141     f(GL_COMPRESSED_RGBA_ASTC_12x10_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
142     f(GL_COMPRESSED_RGBA_ASTC_12x12_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
143     f(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
144     f(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
145     f(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
146     f(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
147     f(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
148     f(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
149     f(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
150     f(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
151     f(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
152     f(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
153     f(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
154     f(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
155     f(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
156     f(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, GL_RGBA, GL_UNSIGNED_BYTE) \
157 
158 
renderbufferParam(GLEScontext * ctx,GLenum pname)159 bool GLESv2Validate::renderbufferParam(GLEScontext* ctx, GLenum pname){
160     int glesMajorVersion = ctx->getMajorVersion();
161     switch(pname){
162     case GL_RENDERBUFFER_WIDTH:
163     case GL_RENDERBUFFER_HEIGHT:
164     case GL_RENDERBUFFER_INTERNAL_FORMAT:
165     case GL_RENDERBUFFER_RED_SIZE:
166     case GL_RENDERBUFFER_GREEN_SIZE:
167     case GL_RENDERBUFFER_BLUE_SIZE:
168     case GL_RENDERBUFFER_ALPHA_SIZE:
169     case GL_RENDERBUFFER_DEPTH_SIZE:
170     case GL_RENDERBUFFER_STENCIL_SIZE:
171         return true;
172     case GL_RENDERBUFFER_SAMPLES:
173         return glesMajorVersion >= 3;
174     }
175     return false;
176 }
177 
framebufferTarget(GLEScontext * ctx,GLenum target)178 bool GLESv2Validate::framebufferTarget(GLEScontext* ctx, GLenum target) {
179     int glesMajorVersion = ctx->getMajorVersion();
180     switch (target) {
181     case GL_FRAMEBUFFER:
182         return true;
183     case GL_DRAW_FRAMEBUFFER:
184     case GL_READ_FRAMEBUFFER:
185         return glesMajorVersion >= 3;
186     }
187     return false;
188 }
189 
framebufferAttachment(GLEScontext * ctx,GLenum attachment)190 bool GLESv2Validate::framebufferAttachment(GLEScontext* ctx, GLenum attachment) {
191     int glesMajorVersion = ctx->getMajorVersion();
192     switch (attachment) {
193     case GL_COLOR_ATTACHMENT0:
194     case GL_DEPTH_ATTACHMENT:
195     case GL_STENCIL_ATTACHMENT:
196         return true;
197     case GL_COLOR_ATTACHMENT1:
198     case GL_COLOR_ATTACHMENT2:
199     case GL_COLOR_ATTACHMENT3:
200     case GL_COLOR_ATTACHMENT4:
201     case GL_COLOR_ATTACHMENT5:
202     case GL_COLOR_ATTACHMENT6:
203     case GL_COLOR_ATTACHMENT7:
204     case GL_COLOR_ATTACHMENT8:
205     case GL_COLOR_ATTACHMENT9:
206     case GL_COLOR_ATTACHMENT10:
207     case GL_COLOR_ATTACHMENT11:
208     case GL_COLOR_ATTACHMENT12:
209     case GL_COLOR_ATTACHMENT13:
210     case GL_COLOR_ATTACHMENT14:
211     case GL_COLOR_ATTACHMENT15:
212     case GL_DEPTH_STENCIL_ATTACHMENT:
213         return glesMajorVersion >= 3;
214     }
215     return false;
216 }
217 
bufferTarget(GLEScontext * ctx,GLenum target)218 bool GLESv2Validate::bufferTarget(GLEScontext* ctx, GLenum target) {
219     int glesMajorVersion = ctx->getMajorVersion();
220     int glesMinorVersion = ctx->getMinorVersion();
221     switch (target) {
222     case GL_ARRAY_BUFFER: // Vertex attributes
223     case GL_ELEMENT_ARRAY_BUFFER: // Vertex array indices
224         return true;
225         // GLES 3.0 buffers
226     case GL_COPY_READ_BUFFER: // Buffer copy source
227     case GL_COPY_WRITE_BUFFER: // Buffer copy destination
228     case GL_PIXEL_PACK_BUFFER: // Pixel read target
229     case GL_PIXEL_UNPACK_BUFFER: // Texture data source
230     case GL_TRANSFORM_FEEDBACK_BUFFER: // Transform feedback buffer
231     case GL_UNIFORM_BUFFER: // Uniform block storage
232         return glesMajorVersion >= 3;
233         // GLES 3.1 buffers
234     case GL_ATOMIC_COUNTER_BUFFER: // Atomic counter storage
235     case GL_DISPATCH_INDIRECT_BUFFER: // Indirect compute dispatch commands
236     case GL_DRAW_INDIRECT_BUFFER: // Indirect command arguments
237     case GL_SHADER_STORAGE_BUFFER: // Read-write storage for shaders
238         return glesMajorVersion >= 3 && glesMinorVersion >= 1;
239     case GL_TEXTURE_BUFFER:
240         return glesMajorVersion >= 3 &&
241                ((glesMinorVersion == 1 && ctx->getCaps()->textureBufferAny()) ||
242                 glesMinorVersion > 1 );
243     default:
244         return false;
245     }
246 }
247 
bufferUsage(GLEScontext * ctx,GLenum usage)248 bool GLESv2Validate::bufferUsage(GLEScontext* ctx, GLenum usage) {
249     int glesMajorVersion = ctx->getMajorVersion();
250     switch(usage) {
251         case GL_STREAM_DRAW:
252         case GL_STATIC_DRAW:
253         case GL_DYNAMIC_DRAW:
254             return true;
255         case GL_STREAM_READ:
256         case GL_STATIC_READ:
257         case GL_DYNAMIC_READ:
258         case GL_STREAM_COPY:
259         case GL_STATIC_COPY:
260         case GL_DYNAMIC_COPY:
261             return glesMajorVersion >= 3;
262     }
263     return false;
264 
265 }
266 
267 
bufferParam(GLEScontext * ctx,GLenum pname)268 bool GLESv2Validate::bufferParam(GLEScontext* ctx, GLenum pname) {
269     int glesMajorVersion = ctx->getMajorVersion();
270     switch (pname) {
271     case GL_BUFFER_SIZE:
272     case GL_BUFFER_USAGE:
273         return true;
274     case GL_BUFFER_ACCESS_FLAGS:
275     case GL_BUFFER_MAPPED:
276     case GL_BUFFER_MAP_LENGTH:
277     case GL_BUFFER_MAP_OFFSET:
278         return glesMajorVersion >= 3;
279     default:
280         return false;
281     }
282 }
283 
284 
blendEquationMode(GLEScontext * ctx,GLenum mode)285 bool GLESv2Validate::blendEquationMode(GLEScontext* ctx, GLenum mode){
286     int glesMajorVersion = ctx->getMajorVersion();
287     switch (mode) {
288     case GL_FUNC_ADD:
289     case GL_FUNC_SUBTRACT:
290     case GL_FUNC_REVERSE_SUBTRACT:
291         return true;
292     case GL_MIN:
293     case GL_MAX:
294         return glesMajorVersion >= 3;
295     }
296     return false;
297 }
298 
blendSrc(GLenum s)299 bool GLESv2Validate::blendSrc(GLenum s) {
300    switch(s) {
301    case GL_ZERO:
302    case GL_ONE:
303    case GL_SRC_COLOR:
304    case GL_ONE_MINUS_SRC_COLOR:
305    case GL_DST_COLOR:
306    case GL_ONE_MINUS_DST_COLOR:
307    case GL_SRC_ALPHA:
308    case GL_ONE_MINUS_SRC_ALPHA:
309    case GL_DST_ALPHA:
310    case GL_ONE_MINUS_DST_ALPHA:
311    case GL_CONSTANT_COLOR:
312    case GL_ONE_MINUS_CONSTANT_COLOR:
313    case GL_CONSTANT_ALPHA:
314    case GL_ONE_MINUS_CONSTANT_ALPHA:
315    case GL_SRC_ALPHA_SATURATE:
316         return true;
317   }
318   return false;
319 }
320 
321 
blendDst(GLenum d)322 bool GLESv2Validate::blendDst(GLenum d) {
323    switch(d) {
324    case GL_ZERO:
325    case GL_ONE:
326    case GL_SRC_COLOR:
327    case GL_ONE_MINUS_SRC_COLOR:
328    case GL_DST_COLOR:
329    case GL_ONE_MINUS_DST_COLOR:
330    case GL_SRC_ALPHA:
331    case GL_ONE_MINUS_SRC_ALPHA:
332    case GL_DST_ALPHA:
333    case GL_ONE_MINUS_DST_ALPHA:
334    case GL_CONSTANT_COLOR:
335    case GL_ONE_MINUS_CONSTANT_COLOR:
336    case GL_CONSTANT_ALPHA:
337    case GL_ONE_MINUS_CONSTANT_ALPHA:
338    case GL_SRC_ALPHA_SATURATE:
339         return true;
340    }
341    return false;
342 }
343 
textureTarget(GLEScontext * ctx,GLenum target)344 bool GLESv2Validate::textureTarget(GLEScontext* ctx, GLenum target) {
345     int glesMajorVersion = ctx->getMajorVersion();
346     int glesMinorVersion = ctx->getMinorVersion();
347     switch (target) {
348     case GL_TEXTURE_2D:
349     case GL_TEXTURE_CUBE_MAP:
350         return true;
351     case GL_TEXTURE_2D_ARRAY:
352     case GL_TEXTURE_3D:
353         return glesMajorVersion >= 3;
354     case GL_TEXTURE_2D_MULTISAMPLE:
355         return glesMajorVersion >= 3 && glesMinorVersion >= 1;
356     case GL_TEXTURE_BUFFER:
357         return glesMajorVersion >= 3 && ( glesMinorVersion > 1 ||
358            (glesMinorVersion == 1 && ctx->getCaps()->textureBufferAny()));
359     default:
360         return false;
361     }
362 }
363 
textureParams(GLEScontext * ctx,GLenum param)364 bool GLESv2Validate::textureParams(GLEScontext* ctx, GLenum param) {
365     int glesMajorVersion = ctx->getMajorVersion();
366     int glesMinorVersion = ctx->getMinorVersion();
367     switch(param) {
368     case GL_TEXTURE_MIN_FILTER:
369     case GL_TEXTURE_MAG_FILTER:
370     case GL_TEXTURE_WRAP_S:
371     case GL_TEXTURE_WRAP_T:
372     case GL_TEXTURE_MAX_ANISOTROPY_EXT:
373         return true;
374     case GL_TEXTURE_SWIZZLE_R:
375     case GL_TEXTURE_SWIZZLE_G:
376     case GL_TEXTURE_SWIZZLE_B:
377     case GL_TEXTURE_SWIZZLE_A:
378     case GL_TEXTURE_MIN_LOD:
379     case GL_TEXTURE_MAX_LOD:
380     case GL_TEXTURE_BASE_LEVEL:
381     case GL_TEXTURE_MAX_LEVEL:
382     case GL_TEXTURE_COMPARE_MODE:
383     case GL_TEXTURE_COMPARE_FUNC:
384     case GL_TEXTURE_WRAP_R:
385     case GL_TEXTURE_IMMUTABLE_FORMAT:
386     case GL_TEXTURE_IMMUTABLE_LEVELS:
387         return glesMajorVersion >= 3;
388     case GL_DEPTH_STENCIL_TEXTURE_MODE:
389         return glesMajorVersion >= 3 && glesMinorVersion >= 1;
390     default:
391         return false;
392     }
393 }
394 
hintTargetMode(GLenum target,GLenum mode)395 bool GLESv2Validate::hintTargetMode(GLenum target,GLenum mode){
396 
397    switch(mode) {
398    case GL_FASTEST:
399    case GL_NICEST:
400    case GL_DONT_CARE:
401        break;
402    default: return false;
403    }
404    return target == GL_GENERATE_MIPMAP_HINT || target == GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES;
405 }
406 
capability(GLenum cap)407 bool GLESv2Validate::capability(GLenum cap){
408     switch(cap){
409     case GL_BLEND:
410     case GL_CULL_FACE:
411     case GL_DEPTH_TEST:
412     case GL_DITHER:
413     case GL_POLYGON_OFFSET_FILL:
414     case GL_SAMPLE_ALPHA_TO_COVERAGE:
415     case GL_SAMPLE_COVERAGE:
416     case GL_SCISSOR_TEST:
417     case GL_STENCIL_TEST:
418         return true;
419     }
420     return false;
421 }
422 
pixelStoreParam(GLEScontext * ctx,GLenum param)423 bool GLESv2Validate::pixelStoreParam(GLEScontext* ctx, GLenum param){
424     int glesMajorVersion = ctx->getMajorVersion();
425     switch(param) {
426     case GL_PACK_ALIGNMENT:
427     case GL_UNPACK_ALIGNMENT:
428         return true;
429     case GL_PACK_ROW_LENGTH:
430     case GL_PACK_SKIP_PIXELS:
431     case GL_PACK_SKIP_ROWS:
432     case GL_UNPACK_ROW_LENGTH:
433     case GL_UNPACK_IMAGE_HEIGHT:
434     case GL_UNPACK_SKIP_PIXELS:
435     case GL_UNPACK_SKIP_ROWS:
436     case GL_UNPACK_SKIP_IMAGES:
437         return glesMajorVersion >= 3;
438     default:
439         return false;
440     }
441 }
442 
readPixelFrmt(GLenum format)443 bool GLESv2Validate::readPixelFrmt(GLenum format){
444     switch(format) {
445     case GL_ALPHA:
446     case GL_LUMINANCE_ALPHA:
447     case GL_RGB:
448     case GL_RGBA:
449         return true;
450     }
451     return false;
452 }
453 
454 
shaderType(GLEScontext * ctx,GLenum type)455 bool GLESv2Validate::shaderType(GLEScontext* ctx, GLenum type){
456     int glesMajorVersion = ctx->getMajorVersion();
457     int glesMinorVersion = ctx->getMinorVersion();
458     switch (type) {
459     case GL_VERTEX_SHADER:
460     case GL_FRAGMENT_SHADER:
461         return true;
462     case GL_COMPUTE_SHADER:
463         return glesMajorVersion >= 3 && glesMinorVersion >= 1;
464     }
465     return false;
466 }
467 
precisionType(GLenum type)468 bool GLESv2Validate::precisionType(GLenum type){
469     switch(type){
470     case GL_LOW_FLOAT:
471     case GL_MEDIUM_FLOAT:
472     case GL_HIGH_FLOAT:
473     case GL_LOW_INT:
474     case GL_MEDIUM_INT:
475     case GL_HIGH_INT:
476         return true;
477     }
478     return false;
479 }
480 
arrayIndex(GLEScontext * ctx,GLuint index)481 bool GLESv2Validate::arrayIndex(GLEScontext * ctx,GLuint index) {
482     return index < (GLuint)ctx->getCaps()->maxVertexAttribs;
483 }
484 
485 #define GL_RED                              0x1903
486 #define GL_RG                               0x8227
487 #define GL_R8                               0x8229
488 #define GL_RG8                              0x822B
489 #define GL_R16F                             0x822D
490 #define GL_RG16F                            0x822F
491 #define GL_RGBA16F                          0x881A
492 #define GL_RGB16F                           0x881B
493 #define GL_R11F_G11F_B10F                   0x8C3A
494 #define GL_UNSIGNED_INT_10F_11F_11F_REV     0x8C3B
495 
pixelType(GLEScontext * ctx,GLenum type)496 bool GLESv2Validate::pixelType(GLEScontext * ctx,GLenum type) {
497     int glesMajorVersion = ctx->getMajorVersion();
498     if (glesMajorVersion < 3) {
499         if(type == GL_UNSIGNED_SHORT || type == GL_UNSIGNED_INT
500                 || type == GL_UNSIGNED_INT_10F_11F_11F_REV)
501             return true;
502 
503         return GLESvalidate::pixelType(ctx, type);
504     }
505 
506 #define GLES3_TYPE_CASE(type) \
507     case type: \
508 
509     switch (type) {
510         LIST_VALID_TEXTYPES(GLES3_TYPE_CASE)
511             return glesMajorVersion >= 3;
512         default:
513             break;
514     }
515 
516     return false;
517 }
518 
pixelFrmt(GLEScontext * ctx,GLenum format)519 bool GLESv2Validate::pixelFrmt(GLEScontext* ctx,GLenum format) {
520     int glesMajorVersion = ctx->getMajorVersion();
521     if (glesMajorVersion < 3) {
522         switch (format) {
523             case GL_DEPTH_COMPONENT:
524                 // GLES3 compatible
525                 // Required in dEQP
526             case GL_RED:
527             case GL_RG:
528                 return true;
529         }
530         return GLESvalidate::pixelFrmt(ctx, format);
531     }
532 
533 #define GLES3_FORMAT_CASE(format) \
534     case format:
535 
536     switch (format) {
537         LIST_VALID_TEXFORMATS(GLES3_FORMAT_CASE)
538             return glesMajorVersion >= 3;
539         default:
540             break;
541     }
542     return GLESvalidate::pixelFrmt(ctx, format);
543 }
544 
pixelItnlFrmt(GLEScontext * ctx,GLenum internalformat)545 bool GLESv2Validate::pixelItnlFrmt(GLEScontext* ctx ,GLenum internalformat) {
546     int glesMajorVersion = ctx->getMajorVersion();
547     switch (internalformat) {
548     case GL_R8:
549     case GL_RG8:
550     case GL_R16F:
551     case GL_RG16F:
552     case GL_RGBA16F:
553     case GL_RGB16F:
554     case GL_R11F_G11F_B10F:
555     case GL_RGB8:
556     case GL_RGBA8:
557         return true;
558     case GL_R8_SNORM:
559     case GL_R32F:
560     case GL_R8UI:
561     case GL_R8I:
562     case GL_R16UI:
563     case GL_R16I:
564     case GL_R32UI:
565     case GL_R32I:
566     case GL_RG8_SNORM:
567     case GL_RG32F:
568     case GL_RG8UI:
569     case GL_RG8I:
570     case GL_RG16UI:
571     case GL_RG16I:
572     case GL_RG32UI:
573     case GL_RG32I:
574     case GL_SRGB8:
575     case GL_RGB565:
576     case GL_RGB8_SNORM:
577     case GL_RGB9_E5:
578     case GL_RGB32F:
579     case GL_RGB8UI:
580     case GL_RGB8I:
581     case GL_RGB16UI:
582     case GL_RGB16I:
583     case GL_RGB32UI:
584     case GL_RGB32I:
585     case GL_SRGB8_ALPHA8:
586     case GL_RGBA8_SNORM:
587     case GL_RGB5_A1:
588     case GL_RGBA4:
589     case GL_RGB10_A2:
590     case GL_RGBA32F:
591     case GL_RGBA8UI:
592     case GL_RGBA8I:
593     case GL_RGB10_A2UI:
594     case GL_RGBA16UI:
595     case GL_RGBA16I:
596     case GL_RGBA32I:
597     case GL_RGBA32UI:
598     case GL_DEPTH_COMPONENT16:
599     case GL_DEPTH_COMPONENT24:
600     case GL_DEPTH_COMPONENT32F:
601     case GL_DEPTH24_STENCIL8:
602     case GL_DEPTH32F_STENCIL8:
603     case GL_COMPRESSED_R11_EAC:
604     case GL_COMPRESSED_SIGNED_R11_EAC:
605     case GL_COMPRESSED_RG11_EAC:
606     case GL_COMPRESSED_SIGNED_RG11_EAC:
607     case GL_COMPRESSED_RGB8_ETC2:
608     case GL_COMPRESSED_SRGB8_ETC2:
609     case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
610     case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
611     case GL_COMPRESSED_RGBA8_ETC2_EAC:
612     case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
613     case GL_COMPRESSED_RGBA_ASTC_4x4_KHR:
614     case GL_COMPRESSED_RGBA_ASTC_5x4_KHR:
615     case GL_COMPRESSED_RGBA_ASTC_5x5_KHR:
616     case GL_COMPRESSED_RGBA_ASTC_6x5_KHR:
617     case GL_COMPRESSED_RGBA_ASTC_6x6_KHR:
618     case GL_COMPRESSED_RGBA_ASTC_8x5_KHR:
619     case GL_COMPRESSED_RGBA_ASTC_8x6_KHR:
620     case GL_COMPRESSED_RGBA_ASTC_8x8_KHR:
621     case GL_COMPRESSED_RGBA_ASTC_10x5_KHR:
622     case GL_COMPRESSED_RGBA_ASTC_10x6_KHR:
623     case GL_COMPRESSED_RGBA_ASTC_10x8_KHR:
624     case GL_COMPRESSED_RGBA_ASTC_10x10_KHR:
625     case GL_COMPRESSED_RGBA_ASTC_12x10_KHR:
626     case GL_COMPRESSED_RGBA_ASTC_12x12_KHR:
627     case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:
628     case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:
629     case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:
630     case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:
631     case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:
632     case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:
633     case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:
634     case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:
635     case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:
636     case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:
637     case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:
638     case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:
639     case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:
640     case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:
641         if (glesMajorVersion >= 3) {
642             return true;
643         }
644         break;
645     }
646     return pixelFrmt(ctx, internalformat);
647 }
648 
pixelSizedFrmt(GLEScontext * ctx,GLenum internalformat,GLenum format,GLenum type)649 bool GLESv2Validate::pixelSizedFrmt(GLEScontext* ctx, GLenum internalformat,
650                                     GLenum format, GLenum type) {
651     int glesMajorVersion = ctx->getMajorVersion();
652     if (internalformat == format) {
653         return true;
654     }
655 
656     if (glesMajorVersion < 3) {
657         switch (format) {
658             case GL_RED:
659                 switch (type) {
660                     case GL_UNSIGNED_BYTE:
661                         return internalformat == GL_R8;
662                     case GL_HALF_FLOAT:
663                     case GL_FLOAT:
664                         return internalformat == GL_R16F;
665                     case GL_BYTE:
666                         return internalformat == GL_R8_SNORM;
667                     default:
668                         return false;
669                 }
670                 break;
671             case GL_RG:
672                 switch (type) {
673                     case GL_UNSIGNED_BYTE:
674                         return internalformat == GL_RG8;
675                     case GL_HALF_FLOAT:
676                     case GL_FLOAT:
677                         return internalformat == GL_RG16F;
678                     default:
679                         return false;
680                 }
681                 break;
682             case GL_RGB:
683                 switch (type) {
684                     case GL_HALF_FLOAT:
685                     case GL_FLOAT:
686                         return internalformat == GL_RGB16F
687                             || internalformat == GL_R11F_G11F_B10F;
688                     case GL_UNSIGNED_INT_10F_11F_11F_REV:
689                         return internalformat == GL_R11F_G11F_B10F;
690                     default:
691                         return internalformat == GL_RGB8 ||
692                                internalformat == GL_RGB;
693                 }
694                 break;
695             case GL_RGBA:
696                 switch (type) {
697                     case GL_HALF_FLOAT:
698                     case GL_FLOAT:
699                         return internalformat == GL_RGBA16F;
700                     default:
701                         return internalformat == GL_RGBA8 ||
702                                internalformat == GL_RGBA;
703                 }
704                 break;
705         }
706     }
707 
708 #define VALIDATE_FORMAT_COMBINATION(x, y, z) \
709     if (internalformat == x && format == y && type == z) return true; \
710 
711     LIST_VALID_TEXFORMAT_COMBINATIONS(VALIDATE_FORMAT_COMBINATION)
712 
713     return false;
714 }
715 
isCompressedFormat(GLenum format)716 bool GLESv2Validate::isCompressedFormat(GLenum format) {
717     switch (format) {
718         case GL_ETC1_RGB8_OES:
719         case GL_COMPRESSED_R11_EAC:
720         case GL_COMPRESSED_SIGNED_R11_EAC:
721         case GL_COMPRESSED_RG11_EAC:
722         case GL_COMPRESSED_SIGNED_RG11_EAC:
723         case GL_COMPRESSED_RGB8_ETC2:
724         case GL_COMPRESSED_SRGB8_ETC2:
725         case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
726         case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
727         case GL_COMPRESSED_RGBA8_ETC2_EAC:
728         case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
729         case GL_COMPRESSED_RGBA_ASTC_4x4_KHR:
730         case GL_COMPRESSED_RGBA_ASTC_5x4_KHR:
731         case GL_COMPRESSED_RGBA_ASTC_5x5_KHR:
732         case GL_COMPRESSED_RGBA_ASTC_6x5_KHR:
733         case GL_COMPRESSED_RGBA_ASTC_6x6_KHR:
734         case GL_COMPRESSED_RGBA_ASTC_8x5_KHR:
735         case GL_COMPRESSED_RGBA_ASTC_8x6_KHR:
736         case GL_COMPRESSED_RGBA_ASTC_8x8_KHR:
737         case GL_COMPRESSED_RGBA_ASTC_10x5_KHR:
738         case GL_COMPRESSED_RGBA_ASTC_10x6_KHR:
739         case GL_COMPRESSED_RGBA_ASTC_10x8_KHR:
740         case GL_COMPRESSED_RGBA_ASTC_10x10_KHR:
741         case GL_COMPRESSED_RGBA_ASTC_12x10_KHR:
742         case GL_COMPRESSED_RGBA_ASTC_12x12_KHR:
743         case GL_COMPRESSED_RGBA_BPTC_UNORM_EXT:
744         case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:
745         case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT:
746         case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT:
747         case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
748         case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
749         case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
750         case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
751         case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
752         case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
753         case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
754         case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
755         case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:
756         case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:
757         case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:
758         case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:
759         case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:
760         case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:
761         case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:
762         case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:
763         case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:
764         case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:
765         case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:
766         case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:
767         case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:
768         case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:
769         case GL_COMPRESSED_RED_RGTC1_EXT:
770         case GL_COMPRESSED_SIGNED_RED_RGTC1_EXT:
771         case GL_COMPRESSED_RED_GREEN_RGTC2_EXT:
772         case GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT:
773             return true;
774     }
775     return false;
776 }
777 
getCompatibleFormatTypeForInternalFormat(GLenum internalformat,GLenum * format_out,GLenum * type_out)778 void GLESv2Validate::getCompatibleFormatTypeForInternalFormat(GLenum internalformat, GLenum* format_out, GLenum* type_out) {
779 #define RETURN_COMPATIBLE_FORMAT(x, y, z) \
780     if (internalformat == x) { \
781         *format_out = y; \
782         *type_out = z; \
783         return; \
784     } \
785 
786     LIST_VALID_TEXFORMAT_COMBINATIONS(RETURN_COMPATIBLE_FORMAT)
787 }
attribName(const GLchar * name)788 bool GLESv2Validate::attribName(const GLchar* name){
789     const GLchar* found = strstr(name,"gl_");
790     return (!found) ||
791            (found != name) ; // attrib name does not start with gl_
792 }
793 
attribIndex(int index,int max)794 bool GLESv2Validate::attribIndex(int index, int max){
795     return index >=0 && index < max;
796 }
797 
programParam(GLEScontext * ctx,GLenum pname)798 bool GLESv2Validate::programParam(GLEScontext* ctx, GLenum pname){
799     int glesMajorVersion = ctx->getMajorVersion();
800     int glesMinorVersion = ctx->getMinorVersion();
801     switch(pname){
802         case GL_DELETE_STATUS:
803         case GL_LINK_STATUS:
804         case GL_VALIDATE_STATUS:
805         case GL_INFO_LOG_LENGTH:
806         case GL_ATTACHED_SHADERS:
807         case GL_ACTIVE_ATTRIBUTES:
808         case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
809         case GL_ACTIVE_UNIFORMS:
810         case GL_ACTIVE_UNIFORM_MAX_LENGTH:
811             return true;
812         case GL_ACTIVE_UNIFORM_BLOCKS:
813         case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
814         case GL_PROGRAM_BINARY_RETRIEVABLE_HINT:
815         case GL_PROGRAM_BINARY_LENGTH:
816         case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
817         case GL_TRANSFORM_FEEDBACK_VARYINGS:
818         case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
819         case GL_PROGRAM_SEPARABLE:
820             return glesMajorVersion >= 3;
821         case GL_ACTIVE_ATOMIC_COUNTER_BUFFERS:
822         case GL_COMPUTE_WORK_GROUP_SIZE:
823             return glesMajorVersion >= 3 && glesMinorVersion >= 1;
824     }
825     return false;
826 }
827 
textureIsCubeMap(GLenum target)828 bool GLESv2Validate::textureIsCubeMap(GLenum target){
829     switch(target){
830         case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
831         case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
832         case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
833         case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
834         case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
835         case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
836             return true;
837     }
838     return false;
839 }
840 
textureTargetEx(GLEScontext * ctx,GLenum textarget)841 bool GLESv2Validate::textureTargetEx(GLEScontext* ctx, GLenum textarget) {
842     int glesMajorVersion = ctx->getMajorVersion();
843     int glesMinorVersion = ctx->getMinorVersion();
844     switch (textarget) {
845     case GL_TEXTURE_2D_MULTISAMPLE:
846         return glesMajorVersion >= 3 && glesMinorVersion >= 1;
847     default:
848         return GLESvalidate::textureTargetEx(textarget);
849     }
850 }
851 
sizeOfType(GLenum type)852 int GLESv2Validate::sizeOfType(GLenum type) {
853     size_t retval = 0;
854     switch(type) {
855     case GL_BYTE:
856     case GL_UNSIGNED_BYTE:
857         retval = 1;
858         break;
859     case GL_SHORT:
860     case GL_UNSIGNED_SHORT:
861     case GL_HALF_FLOAT:
862     case GL_HALF_FLOAT_OES:
863         retval = 2;
864         break;
865     case GL_UNSIGNED_INT:
866     case GL_INT:
867     case GL_FLOAT:
868     case GL_FIXED:
869     case GL_BOOL:
870         retval =  4;
871         break;
872 #ifdef GL_DOUBLE
873     case GL_DOUBLE:
874         retval = 8;
875         break;
876 #endif
877     case GL_FLOAT_VEC2:
878     case GL_INT_VEC2:
879     case GL_UNSIGNED_INT_VEC2:
880     case GL_BOOL_VEC2:
881         retval = 8;
882         break;
883     case GL_INT_VEC3:
884     case GL_UNSIGNED_INT_VEC3:
885     case GL_BOOL_VEC3:
886     case GL_FLOAT_VEC3:
887         retval = 12;
888         break;
889     case GL_FLOAT_VEC4:
890     case GL_BOOL_VEC4:
891     case GL_INT_VEC4:
892     case GL_UNSIGNED_INT_VEC4:
893     case GL_FLOAT_MAT2:
894         retval = 16;
895         break;
896     case GL_FLOAT_MAT3:
897         retval = 36;
898         break;
899     case GL_FLOAT_MAT4:
900         retval = 64;
901         break;
902     case GL_FLOAT_MAT2x3:
903     case GL_FLOAT_MAT3x2:
904         retval = 4 * 6;
905         break;
906     case GL_FLOAT_MAT2x4:
907     case GL_FLOAT_MAT4x2:
908         retval = 4 * 8;
909         break;
910     case GL_FLOAT_MAT3x4:
911     case GL_FLOAT_MAT4x3:
912         retval = 4 * 12;
913         break;
914     case GL_SAMPLER_2D:
915     case GL_SAMPLER_CUBE:
916         retval = 4;
917         break;
918     case GL_UNSIGNED_SHORT_4_4_4_4:
919 	case GL_UNSIGNED_SHORT_5_5_5_1:
920 	case GL_UNSIGNED_SHORT_5_6_5:
921 	case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
922 	case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
923         retval = 2;
924         break;
925 	case GL_INT_2_10_10_10_REV:
926 	case GL_UNSIGNED_INT_10F_11F_11F_REV:
927 	case GL_UNSIGNED_INT_5_9_9_9_REV:
928 	case GL_UNSIGNED_INT_2_10_10_10_REV:
929 	case GL_UNSIGNED_INT_24_8_OES:;
930         retval = 4;
931         break;
932 	case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
933 		retval = 4 + 4;
934         break;
935     default:
936         fprintf(stderr, "%s: WARNING: unknown type 0x%x. assuming 32 bits.\n", __FUNCTION__, type);
937         retval = 4;
938     }
939     return retval;
940 }
941 
942