glapi/glx: call __glEmptyImage if USE_XCB, not memcpy directly
authorJulien Cristau <julien.cristau@logilab.fr>
Fri, 20 Jul 2012 09:09:19 +0000 (11:09 +0200)
committerBrian Paul <brianp@vmware.com>
Mon, 27 Aug 2012 19:32:53 +0000 (13:32 -0600)
We were stomping on the caller's buffer by ignoring their alignment
requests and other pixel store modes.  This patch makes the USE_XCB path match
the older one more closely.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=52059

Signed-off-by: Julien Cristau <julien.cristau@logilab.fr>
Signed-off-by: Brian Paul <brianp@vmware.com>
src/mapi/glapi/gen/glX_proto_send.py

index ca3a790560590c1b30220ac2ae7095f6f4cd7111..c53359240cfd7b48515afa14dfdf1e2db22305b4 100644 (file)
@@ -681,16 +681,31 @@ generic_%u_byte( GLint rop, const void * ptr )
 
                        if f.needs_reply():
                                print '        %s_reply_t *reply = %s_reply(c, %s, NULL);' % (xcb_name, xcb_name, xcb_request)
-                               if output and f.reply_always_array:
-                                       print '        (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string())
-
-                               elif output and not f.reply_always_array:
-                                       if not output.is_image():
-                                               print '        if (%s_data_length(reply) == 0)' % (xcb_name)
-                                               print '            (void)memcpy(%s, &reply->datum, sizeof(reply->datum));' % (output.name)
-                                               print '        else'
-                                       print '        (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string())
-
+                               if output:
+                                       if output.is_image():
+                                               [dim, w, h, d, junk] = output.get_dimensions()
+                                               if f.dimensions_in_reply:
+                                                       w = "reply->width"
+                                                       h = "reply->height"
+                                                       d = "reply->depth"
+                                                       if dim < 2:
+                                                               h = "1"
+                                                       else:
+                                                               print '        if (%s == 0) { %s = 1; }' % (h, h)
+                                                       if dim < 3:
+                                                               d = "1"
+                                                       else:
+                                                               print '        if (%s == 0) { %s = 1; }' % (d, d)
+
+                                               print '        __glEmptyImage(gc, 3, %s, %s, %s, %s, %s, %s_data(reply), %s);' % (w, h, d, output.img_format, output.img_type, xcb_name, output.name)
+                                       else:
+                                               if f.reply_always_array:
+                                                       print '        (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string())
+                                               else:
+                                                       print '        if (%s_data_length(reply) == 0)' % (xcb_name)
+                                                       print '            (void)memcpy(%s, &reply->datum, sizeof(reply->datum));' % (output.name)
+                                                       print '        else'
+                                                       print '            (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string())
 
                                if f.return_type != 'void':
                                        print '        retval = reply->ret_val;'