[Mesa-dev] [PATCH 2/2] glapi/glx: call __glEmptyImage if USE_XCB, not memcpy directly (#52059)

2012-07-19 Thread Julien Cristau
From: Julien Cristau julien.cris...@logilab.fr

We were stomping on the caller's buffer by ignoring their alignment
requests.  This patch makes the USE_XCB path match the older one more
closely.

Signed-off-by: Julien Cristau julien.cris...@logilab.fr
---
 src/mapi/glapi/gen/glX_proto_send.py |   36 -
 1 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/src/mapi/glapi/gen/glX_proto_send.py 
b/src/mapi/glapi/gen/glX_proto_send.py
index 9068a61..40cb05d 100644
--- a/src/mapi/glapi/gen/glX_proto_send.py
+++ b/src/mapi/glapi/gen/glX_proto_send.py
@@ -673,16 +673,32 @@ 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:
+   s = output.size() / 
output.get_element_count()
+   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;'
-- 
1.7.2.5

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] glapi/glx: call __glEmptyImage if USE_XCB, not memcpy directly (#52059)

2012-07-19 Thread Ian Romanick

On 07/19/2012 07:46 AM, Julien Cristau wrote:

From: Julien Cristau julien.cris...@logilab.fr

We were stomping on the caller's buffer by ignoring their alignment
requests.  This patch makes the USE_XCB path match the older one more
closely.

Signed-off-by: Julien Cristau julien.cris...@logilab.fr


Say

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

here instead of mentioning the bug in the subject.


---
  src/mapi/glapi/gen/glX_proto_send.py |   36 -
  1 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/src/mapi/glapi/gen/glX_proto_send.py 
b/src/mapi/glapi/gen/glX_proto_send.py
index 9068a61..40cb05d 100644
--- a/src/mapi/glapi/gen/glX_proto_send.py
+++ b/src/mapi/glapi/gen/glX_proto_send.py
@@ -673,16 +673,32 @@ 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)


I was going to comment that 'dim' should be the second parameter to 
__glEmptyImage instead of hardcoding 3, but it looks like the dim 
parameter isn't used in __glEmptyImage.  I think I can recommend a 
follow-on patch. :)



+   else:
+   s = output.size() / 
output.get_element_count()


I don't see where this variable is used.


+   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;'


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] glapi/glx: call __glEmptyImage if USE_XCB, not memcpy directly (#52059)

2012-07-19 Thread Julien Cristau
On Thu, Jul 19, 2012 at 09:39:09 -0700, Ian Romanick wrote:

 On 07/19/2012 07:46 AM, Julien Cristau wrote:
 From: Julien Cristau julien.cris...@logilab.fr
 
 We were stomping on the caller's buffer by ignoring their alignment
 requests.  This patch makes the USE_XCB path match the older one more
 closely.
 
 Signed-off-by: Julien Cristau julien.cris...@logilab.fr
 
 Say
 
 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=52059
 
 here instead of mentioning the bug in the subject.
 
Will do.

[...]
 +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)
 
 I was going to comment that 'dim' should be the second parameter to
 __glEmptyImage instead of hardcoding 3, but it looks like the dim
 parameter isn't used in __glEmptyImage.  I think I can recommend a
 follow-on patch. :)
 
Ack.

 +else:
 +s = output.size() / 
 output.get_element_count()
 
 I don't see where this variable is used.
 
Right, I'll drop it.

Thanks!

Cheers,
Julien
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev