1 /**************************************************************************
3 * Copyright 2011 Jose Fonseca
4 * Copyright 2010 VMware, Inc.
5 * Copyright 2004 IBM Corporation
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sub license,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice (including the next
16 * paragraph) shall be included in all copies or substantial portions of the
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
23 * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
25 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 **************************************************************************/
31 * Auxiliary functions to compute the size of array/blob arguments, depending.
43 #include "glimports.hpp"
47 _gl_type_size(GLenum type)
52 case GL_UNSIGNED_BYTE:
55 case GL_UNSIGNED_SHORT:
70 os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, type);
76 _gl_uniform_size(GLenum type, GLenum &elemType, GLint &numCols, GLint &numRows) {
100 elemType = GL_DOUBLE;
104 elemType = GL_DOUBLE;
108 elemType = GL_DOUBLE;
126 case GL_UNSIGNED_INT:
127 elemType = GL_UNSIGNED_INT;
129 case GL_UNSIGNED_INT_VEC2:
130 elemType = GL_UNSIGNED_INT;
133 case GL_UNSIGNED_INT_VEC3:
134 elemType = GL_UNSIGNED_INT;
137 case GL_UNSIGNED_INT_VEC4:
138 elemType = GL_UNSIGNED_INT;
171 case GL_FLOAT_MAT2x3:
176 case GL_FLOAT_MAT2x4:
181 case GL_FLOAT_MAT3x2:
186 case GL_FLOAT_MAT3x4:
191 case GL_FLOAT_MAT4x2:
196 case GL_FLOAT_MAT4x3:
202 elemType = GL_DOUBLE;
207 elemType = GL_DOUBLE;
212 elemType = GL_DOUBLE;
216 case GL_DOUBLE_MAT2x3:
217 elemType = GL_DOUBLE;
221 case GL_DOUBLE_MAT2x4:
222 elemType = GL_DOUBLE;
226 case GL_DOUBLE_MAT3x2:
227 elemType = GL_DOUBLE;
231 case GL_DOUBLE_MAT3x4:
232 elemType = GL_DOUBLE;
236 case GL_DOUBLE_MAT4x2:
237 elemType = GL_DOUBLE;
241 case GL_DOUBLE_MAT4x3:
242 elemType = GL_DOUBLE;
249 case GL_SAMPLER_CUBE:
250 case GL_SAMPLER_1D_SHADOW:
251 case GL_SAMPLER_2D_SHADOW:
252 case GL_SAMPLER_1D_ARRAY:
253 case GL_SAMPLER_2D_ARRAY:
254 case GL_SAMPLER_CUBE_MAP_ARRAY:
255 case GL_SAMPLER_1D_ARRAY_SHADOW:
256 case GL_SAMPLER_2D_ARRAY_SHADOW:
257 case GL_SAMPLER_2D_MULTISAMPLE:
258 case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
259 case GL_SAMPLER_CUBE_SHADOW:
260 case GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW:
261 case GL_SAMPLER_BUFFER:
262 case GL_SAMPLER_2D_RECT:
263 case GL_SAMPLER_2D_RECT_SHADOW:
264 case GL_INT_SAMPLER_1D:
265 case GL_INT_SAMPLER_2D:
266 case GL_INT_SAMPLER_3D:
267 case GL_INT_SAMPLER_CUBE:
268 case GL_INT_SAMPLER_1D_ARRAY:
269 case GL_INT_SAMPLER_2D_ARRAY:
270 case GL_INT_SAMPLER_CUBE_MAP_ARRAY:
271 case GL_INT_SAMPLER_2D_MULTISAMPLE:
272 case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
273 case GL_INT_SAMPLER_BUFFER:
274 case GL_INT_SAMPLER_2D_RECT:
275 case GL_UNSIGNED_INT_SAMPLER_1D:
276 case GL_UNSIGNED_INT_SAMPLER_2D:
277 case GL_UNSIGNED_INT_SAMPLER_3D:
278 case GL_UNSIGNED_INT_SAMPLER_CUBE:
279 case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
280 case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
281 case GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY:
282 case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
283 case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
284 case GL_UNSIGNED_INT_SAMPLER_BUFFER:
285 case GL_UNSIGNED_INT_SAMPLER_2D_RECT:
289 os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, type);
298 _glArrayPointer_size(GLint size, GLenum type, GLsizei stride, GLsizei count)
304 if (size == GL_BGRA) {
309 os::log("apitrace: warning: %s: unexpected size 0x%04X\n", __FUNCTION__, size);
312 size_t elementSize = size*_gl_type_size(type);
314 stride = (GLsizei)elementSize;
317 return stride*(count - 1) + elementSize;
320 #define _glVertexPointer_size(size, type, stride, count) _glArrayPointer_size(size, type, stride, count)
321 #define _glNormalPointer_size(type, stride, count) _glArrayPointer_size(3, type, stride, count)
322 #define _glColorPointer_size(size, type, stride, count) _glArrayPointer_size(size, type, stride, count)
323 #define _glIndexPointer_size(type, stride, count) _glArrayPointer_size(1, type, stride, count)
324 #define _glTexCoordPointer_size(size, type, stride, count) _glArrayPointer_size(size, type, stride, count)
325 #define _glEdgeFlagPointer_size(stride, count) _glArrayPointer_size(1, GL_BOOL, stride, count)
326 #define _glFogCoordPointer_size(type, stride, count) _glArrayPointer_size(1, type, stride, count)
327 #define _glSecondaryColorPointer_size(size, type, stride, count) _glArrayPointer_size(size, type, stride, count)
328 #define _glVertexAttribPointer_size(size, type, normalized, stride, count) _glArrayPointer_size(size, type, stride, count)
329 #define _glVertexAttribPointerARB_size(size, type, normalized, stride, count) _glArrayPointer_size(size, type, stride, count)
330 #define _glVertexAttribPointerNV_size(size, type, stride, count) _glArrayPointer_size(size, type, stride, count)
333 * Same as glGetIntegerv, but passing the result in the return value.
336 _glGetInteger(GLenum pname) {
338 _glGetIntegerv(pname, ¶m);
343 _element_array_buffer_binding(void) {
344 return _glGetInteger(GL_ELEMENT_ARRAY_BUFFER_BINDING);
348 _glDrawArrays_count(GLint first, GLsizei count)
353 return first + count;
356 #define _glDrawArraysEXT_count _glDrawArrays_count
358 /* Forward declaration for definition in gltrace.py */
360 _shadow_glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size,
364 _glDrawElementsBaseVertex_count(GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex)
372 GLint element_array_buffer = _element_array_buffer_binding();
373 if (element_array_buffer) {
374 // Read indices from index buffer object
375 GLintptr offset = (GLintptr)indices;
376 GLsizeiptr size = count*_gl_type_size(type);
377 GLvoid *temp = malloc(size);
381 memset(temp, 0, size);
382 _shadow_glGetBufferSubData(GL_ELEMENT_ARRAY_BUFFER, offset, size, temp);
392 if (type == GL_UNSIGNED_BYTE) {
393 const GLubyte *p = (const GLubyte *)indices;
394 for (i = 0; i < count; ++i) {
395 if (p[i] > maxindex) {
399 } else if (type == GL_UNSIGNED_SHORT) {
400 const GLushort *p = (const GLushort *)indices;
401 for (i = 0; i < count; ++i) {
402 if (p[i] > maxindex) {
406 } else if (type == GL_UNSIGNED_INT) {
407 const GLuint *p = (const GLuint *)indices;
408 for (i = 0; i < count; ++i) {
409 if (p[i] > maxindex) {
414 os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, type);
417 if (element_array_buffer) {
421 maxindex += basevertex;
426 #define _glDrawRangeElementsBaseVertex_count(start, end, count, type, indices, basevertex) _glDrawElementsBaseVertex_count(count, type, indices, basevertex)
428 #define _glDrawElements_count(count, type, indices) _glDrawElementsBaseVertex_count(count, type, indices, 0);
429 #define _glDrawRangeElements_count(start, end, count, type, indices) _glDrawElements_count(count, type, indices)
430 #define _glDrawRangeElementsEXT_count _glDrawRangeElements_count
432 /* FIXME take in consideration instancing */
433 #define _glDrawArraysInstanced_count(first, count, primcount) _glDrawArrays_count(first, count)
434 #define _glDrawElementsInstanced_count(count, type, indices, primcount) _glDrawElements_count(count, type, indices)
435 #define _glDrawElementsInstancedBaseVertex_count(count, type, indices, primcount, basevertex) _glDrawElementsBaseVertex_count(count, type, indices, basevertex)
436 #define _glDrawRangeElementsInstanced_count(start, end, count, type, indices, primcount) _glDrawRangeElements_count(start, end, count, type, indices)
437 #define _glDrawRangeElementsInstancedBaseVertex_count(start, end, count, type, indices, primcount, basevertex) _glDrawRangeElementsBaseVertex_count(start, end, count, type, indices, basevertex)
439 #define _glDrawArraysInstancedBaseInstance_count(first, count, primcount, baseinstance) _glDrawArrays_count(first, count)
440 #define _glDrawElementsInstancedBaseInstance_count(count, type, indices, primcount, baseinstance) _glDrawElements_count(count, type, indices)
441 #define _glDrawElementsInstancedBaseVertexBaseInstance_count(count, type, indices, primcount, basevertex, baseinstance) _glDrawElementsBaseVertex_count(count, type, indices, basevertex)
443 #define _glDrawArraysInstancedARB_count _glDrawArraysInstanced_count
444 #define _glDrawElementsInstancedARB_count _glDrawElementsInstanced_count
445 #define _glDrawArraysInstancedEXT_count _glDrawArraysInstanced_count
446 #define _glDrawElementsInstancedEXT_count _glDrawElementsInstanced_count
453 } DrawArraysIndirectCommand;
456 _glMultiDrawArraysIndirect_count(const GLvoid *indirect, GLsizei drawcount, GLsizei stride) {
457 const DrawArraysIndirectCommand *cmd;
460 if (drawcount <= 0) {
465 stride = sizeof *cmd;
468 GLint draw_indirect_buffer = _glGetInteger(GL_DRAW_INDIRECT_BUFFER_BINDING);
469 if (draw_indirect_buffer) {
470 // Read commands from indirect buffer object
471 GLintptr offset = (GLintptr)indirect;
472 GLsizeiptr size = sizeof *cmd + (drawcount - 1) * stride;
473 GLvoid *temp = malloc(size);
477 memset(temp, 0, size);
478 _glGetBufferSubData(GL_DRAW_INDIRECT_BUFFER, offset, size, temp);
487 for (GLsizei i = 0; i < drawcount; ++i) {
488 cmd = (const DrawArraysIndirectCommand *)((const GLbyte *)indirect + i * stride);
490 GLuint count_i = _glDrawArraysInstancedBaseInstance_count(
497 count = std::max(count, count_i);
500 if (draw_indirect_buffer) {
508 _glDrawArraysIndirect_count(const GLvoid *indirect) {
509 return _glMultiDrawArraysIndirect_count(indirect, 1, 0);
518 } DrawElementsIndirectCommand;
521 _glMultiDrawElementsIndirect_count(GLenum type, const GLvoid *indirect, GLsizei drawcount, GLsizei stride) {
522 const DrawElementsIndirectCommand *cmd;
525 if (drawcount <= 0) {
530 stride = sizeof *cmd;
533 GLint draw_indirect_buffer = _glGetInteger(GL_DRAW_INDIRECT_BUFFER_BINDING);
534 if (draw_indirect_buffer) {
535 // Read commands from indirect buffer object
536 GLintptr offset = (GLintptr)indirect;
537 GLsizeiptr size = sizeof *cmd + (drawcount - 1) * stride;
538 GLvoid *temp = malloc(size);
542 memset(temp, 0, size);
543 _glGetBufferSubData(GL_DRAW_INDIRECT_BUFFER, offset, size, temp);
551 cmd = (const DrawElementsIndirectCommand *)indirect;
554 for (GLsizei i = 0; i < drawcount; ++i) {
555 cmd = (const DrawElementsIndirectCommand *)((const GLbyte *)indirect + i * stride);
557 GLuint count_i = _glDrawElementsInstancedBaseVertexBaseInstance_count(
560 (GLvoid *)(uintptr_t)(cmd->firstIndex * _gl_type_size(type)),
566 count = std::max(count, count_i);
569 if (draw_indirect_buffer) {
577 _glDrawElementsIndirect_count(GLenum type, const GLvoid *indirect) {
578 return _glMultiDrawElementsIndirect_count(type, indirect, 1, 0);
581 #define _glMultiDrawArraysIndirectAMD_count _glMultiDrawArraysIndirect_count
582 #define _glMultiDrawElementsIndirectAMD_count _glMultiDrawElementsIndirect_count
585 _glMultiDrawArrays_count(const GLint *first, const GLsizei *count, GLsizei drawcount) {
587 for (GLsizei draw = 0; draw < drawcount; ++draw) {
588 GLuint _count_draw = _glDrawArrays_count(first[draw], count[draw]);
589 _count = std::max(_count, _count_draw);
595 _glMultiDrawElements_count(const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount) {
597 for (GLsizei draw = 0; draw < drawcount; ++draw) {
598 GLuint _count_draw = _glDrawElements_count(count[draw], type, indices[draw]);
599 _count = std::max(_count, _count_draw);
605 _glMultiDrawElementsBaseVertex_count(const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount, const GLint * basevertex) {
607 for (GLsizei draw = 0; draw < drawcount; ++draw) {
608 GLuint _count_draw = _glDrawElementsBaseVertex_count(count[draw], type, indices[draw], basevertex[draw]);
609 _count = std::max(_count, _count_draw);
614 #define _glMultiDrawArraysEXT_count _glMultiDrawArrays_count
615 #define _glMultiDrawElementsEXT_count _glMultiDrawElements_count
617 #define _glMultiModeDrawArraysIBM_count(first, count, drawcount, modestride) _glMultiDrawArrays_count(first, count, drawcount)
618 #define _glMultiModeDrawElementsIBM_count(count, type, indices, drawcount, modestride) _glMultiDrawElements_count(count, type, (const GLvoid **)indices, drawcount)
622 _glCallLists_size(GLsizei n, GLenum type)
624 return n*_gl_type_size(type);
628 _glMap1d_size(GLenum target, GLint stride, GLint order)
637 case GL_MAP1_TEXTURE_COORD_1:
640 case GL_MAP1_TEXTURE_COORD_2:
644 case GL_MAP1_TEXTURE_COORD_3:
645 case GL_MAP1_VERTEX_3:
648 case GL_MAP1_COLOR_4:
649 case GL_MAP1_TEXTURE_COORD_4:
650 case GL_MAP1_VERTEX_4:
654 os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, target);
658 if (stride < channels) {
662 return channels + stride * (order - 1);
665 #define _glMap1f_size _glMap1d_size
668 _glMap2d_size(GLenum target, GLint ustride, GLint uorder, GLint vstride, GLint vorder)
670 if (uorder < 1 || vorder < 1) {
677 case GL_MAP2_TEXTURE_COORD_1:
680 case GL_MAP2_TEXTURE_COORD_2:
684 case GL_MAP2_TEXTURE_COORD_3:
685 case GL_MAP2_VERTEX_3:
688 case GL_MAP2_COLOR_4:
689 case GL_MAP2_TEXTURE_COORD_4:
690 case GL_MAP2_VERTEX_4:
694 os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, target);
698 if (ustride < channels || vstride < channels) {
703 ustride * (uorder - 1) +
704 vstride * (vorder - 1);
707 #define _glMap2f_size _glMap2d_size
710 * Number of channels in this format.
712 * That is, the number of elements per pixel when this format is passed with a
713 * to DrawPixels, ReadPixels, TexImage*, TexSubImage*, GetTexImage, etc.
715 static inline unsigned
716 _gl_format_channels(GLenum format) {
722 case GL_GREEN_INTEGER:
724 case GL_BLUE_INTEGER:
726 case GL_ALPHA_INTEGER:
729 case GL_LUMINANCE_INTEGER_EXT:
730 case GL_DEPTH_COMPONENT:
731 case GL_STENCIL_INDEX:
733 case GL_DEPTH_STENCIL:
734 case GL_LUMINANCE_ALPHA:
735 case GL_LUMINANCE_ALPHA_INTEGER_EXT:
738 case GL_422_EXT: // (luminance, chrominance)
739 case GL_422_REV_EXT: // (luminance, chrominance)
740 case GL_422_AVERAGE_EXT: // (luminance, chrominance)
741 case GL_422_REV_AVERAGE_EXT: // (luminance, chrominance)
742 case GL_HILO_NV: // (hi, lo)
743 case GL_DSDT_NV: // (ds, dt)
744 case GL_YCBCR_422_APPLE: // (luminance, chroma)
745 case GL_RGB_422_APPLE: // (G, B) on even pixels, (G, R) on odd pixels
746 case GL_YCRCB_422_SGIX: // (Y, [Cb,Cr])
752 case GL_DSDT_MAG_NV: // (ds, dt, magnitude)
753 case GL_YCRCB_444_SGIX: // (Cb, Y, Cr)
756 case GL_RGBA_INTEGER:
758 case GL_BGRA_INTEGER:
761 case GL_DSDT_MAG_VIB_NV: // (ds, dt, magnitude, vibrance)
765 case GL_FORMAT_SUBSAMPLE_24_24_OML:
766 case GL_FORMAT_SUBSAMPLE_244_244_OML:
767 // requires UNSIGNED_INT_10_10_10_2, so this value will be ignored
770 os::log("apitrace: warning: %s: unexpected format GLenum 0x%04X\n", __FUNCTION__, format);
778 return (x & (x - 1)) == 0;
781 template<class X, class Y>
784 return (x + (y - 1)) & ~(y - 1);
788 _gl_format_size(GLenum format, GLenum type,
789 unsigned & bits_per_element, unsigned & bits_per_pixel)
791 unsigned num_channels = _gl_format_channels(format);
795 bits_per_pixel = bits_per_element = 1;
798 case GL_UNSIGNED_BYTE:
799 bits_per_element = 8;
800 bits_per_pixel = bits_per_element * num_channels;
803 case GL_UNSIGNED_SHORT:
805 bits_per_element = 16;
806 bits_per_pixel = bits_per_element * num_channels;
809 case GL_UNSIGNED_INT:
811 bits_per_element = 32;
812 bits_per_pixel = bits_per_element * num_channels;
814 case GL_UNSIGNED_BYTE_3_3_2:
815 case GL_UNSIGNED_BYTE_2_3_3_REV:
816 bits_per_pixel = bits_per_element = 8;
818 case GL_UNSIGNED_SHORT_4_4_4_4:
819 case GL_UNSIGNED_SHORT_4_4_4_4_REV:
820 case GL_UNSIGNED_SHORT_5_5_5_1:
821 case GL_UNSIGNED_SHORT_1_5_5_5_REV:
822 case GL_UNSIGNED_SHORT_5_6_5:
823 case GL_UNSIGNED_SHORT_5_6_5_REV:
824 case GL_UNSIGNED_SHORT_8_8_MESA:
825 case GL_UNSIGNED_SHORT_8_8_REV_MESA:
826 bits_per_pixel = bits_per_element = 16;
828 case GL_UNSIGNED_INT_8_8_8_8:
829 case GL_UNSIGNED_INT_8_8_8_8_REV:
830 case GL_UNSIGNED_INT_10_10_10_2:
831 case GL_UNSIGNED_INT_2_10_10_10_REV:
832 case GL_UNSIGNED_INT_24_8:
833 case GL_UNSIGNED_INT_10F_11F_11F_REV:
834 case GL_UNSIGNED_INT_5_9_9_9_REV:
835 case GL_UNSIGNED_INT_S8_S8_8_8_NV:
836 case GL_UNSIGNED_INT_8_8_S8_S8_REV_NV:
837 bits_per_pixel = bits_per_element = 32;
839 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
840 bits_per_pixel = bits_per_element = 64;
843 os::log("apitrace: warning: %s: unexpected type GLenum 0x%04X\n", __FUNCTION__, type);
844 bits_per_pixel = bits_per_element = 0;
850 _glClearBufferData_size(GLenum format, GLenum type) {
851 unsigned bits_per_element;
852 unsigned bits_per_pixel;
853 _gl_format_size(format, type, bits_per_element, bits_per_pixel);
854 return (bits_per_pixel + 7)/8;
858 _gl_image_size(GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth, GLboolean has_unpack_subimage) {
860 unsigned bits_per_element;
861 unsigned bits_per_pixel;
862 _gl_format_size(format, type, bits_per_element, bits_per_pixel);
865 GLint row_length = 0;
866 GLint image_height = 0;
868 GLint skip_pixels = 0;
869 GLint skip_images = 0;
871 _glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
872 if (has_unpack_subimage) {
873 _glGetIntegerv(GL_UNPACK_ROW_LENGTH, &row_length);
874 _glGetIntegerv(GL_UNPACK_IMAGE_HEIGHT, &image_height);
875 _glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skip_rows);
876 _glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skip_pixels);
877 _glGetIntegerv(GL_UNPACK_SKIP_IMAGES, &skip_images);
880 if (row_length <= 0) {
884 size_t row_stride = (row_length*bits_per_pixel + 7)/8;
886 if ((bits_per_element == 1*8 ||
887 bits_per_element == 2*8 ||
888 bits_per_element == 4*8 ||
889 bits_per_element == 8*8) &&
890 (GLint)bits_per_element < alignment*8) {
891 row_stride = _align(row_stride, alignment);
894 if (image_height <= 0) {
895 image_height = height;
898 /* XXX: GL_UNPACK_IMAGE_HEIGHT and GL_UNPACK_SKIP_IMAGES should probably
899 * not be considered for pixel rectangles. */
901 size_t image_stride = image_height*row_stride;
903 size_t size = depth*image_stride;
905 size += (skip_pixels*bits_per_pixel + 7)/8;
906 size += skip_rows*row_stride;
907 size += skip_images*image_stride;
912 // note that can_unpack_subimage() is generated by gltrace.py
913 #define _glTexImage3D_size(format, type, width, height, depth) _gl_image_size(format, type, width, height, depth, can_unpack_subimage())
914 #define _glTexImage2D_size(format, type, width, height) _gl_image_size(format, type, width, height, 1, can_unpack_subimage())
915 #define _glTexImage1D_size(format, type, width) _gl_image_size(format, type, width, 1, 1, can_unpack_subimage())
917 #define _glTexSubImage3D_size(format, type, width, height, depth) _glTexImage3D_size(format, type, width, height, depth)
918 #define _glTexSubImage2D_size(format, type, width, height) _glTexImage2D_size(format, type, width, height)
919 #define _glTexSubImage1D_size(format, type, width) _glTexImage1D_size(format, type, width)
921 #define _glTexImage3DEXT_size _glTexImage3D_size
922 #define _glTexImage2DEXT_size _glTexImage2D_size
923 #define _glTexImage1DEXT_size _glTexImage1D_size
924 #define _glTexSubImage3DEXT_size _glTexSubImage3D_size
925 #define _glTexSubImage2DEXT_size _glTexSubImage2D_size
926 #define _glTexSubImage1DEXT_size _glTexSubImage1D_size
928 #define _glTextureImage3DEXT_size _glTexImage3D_size
929 #define _glTextureImage2DEXT_size _glTexImage2D_size
930 #define _glTextureImage1DEXT_size _glTexImage1D_size
931 #define _glTextureSubImage3DEXT_size _glTexSubImage3D_size
932 #define _glTextureSubImage2DEXT_size _glTexSubImage2D_size
933 #define _glTextureSubImage1DEXT_size _glTexSubImage1D_size
935 #define _glMultiTexImage3DEXT_size _glTexImage3D_size
936 #define _glMultiTexImage2DEXT_size _glTexImage2D_size
937 #define _glMultiTexImage1DEXT_size _glTexImage1D_size
938 #define _glMultiTexSubImage3DEXT_size _glTexSubImage3D_size
939 #define _glMultiTexSubImage2DEXT_size _glTexSubImage2D_size
940 #define _glMultiTexSubImage1DEXT_size _glTexSubImage1D_size
942 #define _glDrawPixels_size(format, type, width, height) _glTexImage2D_size(format, type, width, height)
943 #define _glConvolutionFilter1D_size(format, type, width) _glTexImage1D_size(format, type, width)
944 #define _glConvolutionFilter2D_size(format, type, width, height) _glTexImage2D_size(format, type, width, height)
945 #define _glColorTable_size(format, type, width) _glTexImage1D_size(format, type, width)
946 #define _glColorSubTable_size(format, type, count) _glColorTable_size(format, type, count)
948 #define _glBitmap_size(width, height) _glTexImage2D_size(GL_COLOR_INDEX, GL_BITMAP, width, height)
949 #define _glPolygonStipple_size() _glBitmap_size(32, 32)
952 _glClearBuffer_size(GLenum buffer)
960 case GL_FRONT_AND_BACK:
966 os::log("apitrace: warning: %s: unexpected buffer GLenum 0x%04X\n", __FUNCTION__, buffer);
973 * Helper function for determining the string lengths for glShaderSource and
974 * glShaderSourceARB, which is a tad too complex to inline in the specs.
978 _glShaderSource_length(const Char * const * string, const GLint *length, GLsizei index)
980 if (length != NULL && length[index] >= 0) {
981 return (size_t)length[index];
983 return strlen(string[index]);
988 * Helper function for determining the string lengths for glGetDebugMessageLog*.
992 _glGetDebugMessageLog_length(const Char * string, const GLsizei *lengths, GLuint count)
997 for (index = 0; index < count; ++index) {
998 size += lengths[index];
1001 for (index = 0; index < count; ++index) {
1002 size += strlen(&string[size]) + 1;
1006 // Remove the last null terminator
1013 * attribute list, terminated by the given terminator.
1016 static inline size_t
1017 _AttribList_size(const T *pAttribList, const T terminator = static_cast<T>(0))
1024 } while (*pAttribList++ != terminator);
1032 * (key, value) attribute list, terminated by the given terminator.
1035 static inline size_t
1036 _AttribPairList_size(const T *pAttribList, const T terminator = static_cast<T>(0))
1041 while (pAttribList[size] != terminator) {
1044 // terminator also counts
1052 #endif /* _GL_SIZE_HPP_ */