Mesa (master): mapi/glapi: Generate sizeof() helpers instead of fixed sizes.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Nov 22 03:58:28 UTC 2019
Module: Mesa
Branch: master
Commit: b1156ecdf2f3a0488db6fbcb5e352634ebeece00
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b1156ecdf2f3a0488db6fbcb5e352634ebeece00
Author: Markus Wick <markus at selfnet.de>
Date: Sun Nov 17 19:12:04 2019 +0100
mapi/glapi: Generate sizeof() helpers instead of fixed sizes.
Generating a source code with a fixed size leads to issues with plattform dependent types.
We either hard code 4 or 8 bytes there, and both are wrong on the other plattform.
So this patch solves this issue by generating eg sizeof(GLsizeiptr), which is valid both
on 32 and on 64 bit plattforms.
Signed-off-by: Marek Olšák <marek.olsak at amd.com>
---
src/mapi/glapi/gen/gl_XML.py | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py
index 2854a9a5688..5b5f6e23b0a 100644
--- a/src/mapi/glapi/gen/gl_XML.py
+++ b/src/mapi/glapi/gen/gl_XML.py
@@ -565,7 +565,14 @@ class gl_parameter(object):
def size_string(self, use_parens = 1):
- s = self.size()
+ base_size_str = ""
+
+ count = self.get_element_count()
+ if count:
+ base_size_str = "%d * " % count
+
+ base_size_str += "sizeof(%s)" % ( self.get_base_type_string() )
+
if self.counter or self.count_parameter_list:
list = [ "compsize" ]
@@ -574,8 +581,8 @@ class gl_parameter(object):
elif self.counter:
list = [ self.counter ]
- if s > 1:
- list.append( str(s) )
+ if self.size() > 1:
+ list.append( base_size_str )
if len(list) > 1 and use_parens :
return "safe_mul(%s)" % ", ".join(list)
@@ -585,7 +592,7 @@ class gl_parameter(object):
elif self.is_image():
return "compsize"
else:
- return str(s)
+ return base_size_str
def format_string(self):
More information about the mesa-commit
mailing list