]> git.cworth.org Git - apitrace/commitdiff
gles: Prepare __gl_image_size for GLES
authorChia-I Wu <olvaffe@gmail.com>
Wed, 2 Nov 2011 17:59:22 +0000 (01:59 +0800)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Thu, 17 Nov 2011 15:50:26 +0000 (15:50 +0000)
__gl_image_size queries several GL states that are not available in GLES
contexts.  The defaults work for GLES so those queries can be safely skipped.

glsize.hpp
gltrace.py

index 76da8fa0af73448305fc3e2c3b8efc6f5d680fe8..1d1ce45178126ea94964069fab1279eab88d5d06 100644 (file)
@@ -582,7 +582,7 @@ _align(X x, Y y) {
 }
 
 static inline size_t
-__gl_image_size(GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth) {
+__gl_image_size(GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth, GLboolean has_unpack_subimage) {
     unsigned num_channels = __gl_format_channels(format);
 
     unsigned bits_per_pixel;
@@ -645,12 +645,14 @@ __gl_image_size(GLenum format, GLenum type, GLsizei width, GLsizei height, GLsiz
     GLint skip_pixels = 0;
     GLint skip_images = 0;
 
-    __glGetIntegerv(GL_UNPACK_ALIGNMENT,    &alignment);
-    __glGetIntegerv(GL_UNPACK_ROW_LENGTH,   &row_length);
-    __glGetIntegerv(GL_UNPACK_IMAGE_HEIGHT, &image_height);
-    __glGetIntegerv(GL_UNPACK_SKIP_ROWS,    &skip_rows);
-    __glGetIntegerv(GL_UNPACK_SKIP_PIXELS,  &skip_pixels);
-    __glGetIntegerv(GL_UNPACK_SKIP_IMAGES,  &skip_images);
+    __glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
+    if (has_unpack_subimage) {
+        __glGetIntegerv(GL_UNPACK_ROW_LENGTH,   &row_length);
+        __glGetIntegerv(GL_UNPACK_IMAGE_HEIGHT, &image_height);
+        __glGetIntegerv(GL_UNPACK_SKIP_ROWS,    &skip_rows);
+        __glGetIntegerv(GL_UNPACK_SKIP_PIXELS,  &skip_pixels);
+        __glGetIntegerv(GL_UNPACK_SKIP_IMAGES,  &skip_images);
+    }
 
     if (row_length <= 0) {
         row_length = width;
@@ -682,9 +684,10 @@ __gl_image_size(GLenum format, GLenum type, GLsizei width, GLsizei height, GLsiz
     return size;
 }
 
-#define __glTexImage3D_size(format, type, width, height, depth) __gl_image_size(format, type, width, height, depth)
-#define __glTexImage2D_size(format, type, width, height)        __gl_image_size(format, type, width, height, 1)
-#define __glTexImage1D_size(format, type, width)                __gl_image_size(format, type, width, 1, 1)
+// note that can_unpack_subimage() is generated by gltrace.py
+#define __glTexImage3D_size(format, type, width, height, depth) __gl_image_size(format, type, width, height, depth, can_unpack_subimage())
+#define __glTexImage2D_size(format, type, width, height)        __gl_image_size(format, type, width, height, 1, can_unpack_subimage())
+#define __glTexImage1D_size(format, type, width)                __gl_image_size(format, type, width, 1, 1, can_unpack_subimage())
 
 #define __glTexSubImage3D_size(format, type, width, height, depth) __glTexImage3D_size(format, type, width, height, depth)
 #define __glTexSubImage2D_size(format, type, width, height)        __glTexImage2D_size(format, type, width, height)
index 8043e80544ea1d4ead9964ada0b2c13fee367299..c75ac8053487286e272ae77718e4b9e364ca89d6 100644 (file)
@@ -319,6 +319,14 @@ class GlTracer(Tracer):
         print '}'
         print
 
+        # states such as GL_UNPACK_ROW_LENGTH are not available in GLES
+        print 'static inline bool'
+        print 'can_unpack_subimage(void) {'
+        print '    tracer_context *ctx = __get_context();'
+        print '    return (ctx->profile == PROFILE_COMPAT);'
+        print '}'
+        print
+
     array_pointer_function_names = set((
         "glVertexPointer",
         "glNormalPointer",