~ubuntu-branches/ubuntu/natty/mesa/natty-proposed

« back to all changes in this revision

Viewing changes to src/mesa/glapi/gen/remap_helper.py

  • Committer: Bazaar Package Importer
  • Author(s): Robert Hooker, Robert Hooker, Christopher James Halse Rogers
  • Date: 2010-09-14 08:55:40 UTC
  • mfrom: (1.2.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100914085540-m4fpl0hdjlfd4jgz
Tags: 7.9~git20100909-0ubuntu1
[ Robert Hooker ]
* New upstream git snapshot up to commit 94118fe2d4b1e5 (LP: #631413)
* New features include ATI HD5xxx series support in r600, and a vastly
  improved glsl compiler.
* Remove pre-generated .pc's, use the ones generated at build time
  instead.
* Remove all references to mesa-utils now that its no longer shipped
  with the mesa source.
* Disable the experimental ARB_fragment_shader option by default on
  i915, it exposes incomplete functionality that breaks KDE compositing
  among other things. It can be enabled via driconf still. (LP: #628930).

[ Christopher James Halse Rogers ]
* debian/patches/04_osmesa_version.diff:
  - Refresh for new upstream
* Bugs fixed in this release:
  - Fixes severe rendering corruption in Unity on radeon (LP: #628727,
    LP: #596292, LP: #599741, LP: #630315, LP: #613694, LP: #599741).
  - Also fixes rendering in gnome-shell (LP: #578619).
  - Flickering in OpenGL apps on radeon (LP: #626943, LP: #610541).
  - Provides preliminary support for new intel chips (LP: #601052).
* debian/rules:
  - Update configure flags to match upstream reshuffling.
  - Explicitly remove gallium DRI drivers that we don't want to ship.
* Update debian/gbp.conf for this Maverick-specific packaging
* libegl1-mesa-dri-x11,kms: There are no longer separate kms or x11 drivers
  for EGL, libegl1-mesa-drivers now contains a single driver that provides
  both backends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
 
3
 
# Copyright (C) 2009 Chia-I Wu <olv@0xlab.org>
4
 
# All Rights Reserved.
5
 
#
6
 
# This is based on extension_helper.py by Ian Romanick.
7
 
#
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
 
# on the rights to use, copy, modify, merge, publish, distribute, sub
12
 
# license, and/or sell copies of the Software, and to permit persons to whom
13
 
# the Software is furnished to do so, subject to the following conditions:
14
 
#
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
17
 
# Software.
18
 
#
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
22
 
# IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
 
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25
 
# IN THE SOFTWARE.
26
 
 
27
 
import gl_XML
28
 
import license
29
 
import sys, getopt, string
30
 
 
31
 
def get_function_spec(func):
32
 
        sig = ""
33
 
        # derive parameter signature
34
 
        for p in func.parameterIterator():
35
 
                if p.is_padding:
36
 
                        continue
37
 
                # FIXME: This is a *really* ugly hack. :(
38
 
                tn = p.type_expr.get_base_type_node()
39
 
                if p.is_pointer():
40
 
                        sig += 'p'
41
 
                elif tn.integer:
42
 
                        sig += 'i'
43
 
                elif tn.size == 4:
44
 
                        sig += 'f'
45
 
                else:
46
 
                        sig += 'd'
47
 
 
48
 
        spec = [sig]
49
 
        for ent in func.entry_points:
50
 
                spec.append("gl" + ent)
51
 
 
52
 
        # spec is terminated by an empty string
53
 
        spec.append('')
54
 
 
55
 
        return spec
56
 
 
57
 
class PrintGlRemap(gl_XML.gl_print_base):
58
 
        def __init__(self):
59
 
                gl_XML.gl_print_base.__init__(self)
60
 
 
61
 
                self.name = "remap_helper.py (from Mesa)"
62
 
                self.license = license.bsd_license_template % ("Copyright (C) 2009 Chia-I Wu <olv@0xlab.org>", "Chia-I Wu")
63
 
                return
64
 
 
65
 
 
66
 
        def printRealHeader(self):
67
 
                print '#include "main/dispatch.h"'
68
 
                print ''
69
 
                return
70
 
 
71
 
 
72
 
        def printBody(self, api):
73
 
                print 'struct gl_function_remap {'
74
 
                print '   GLint func_index;'
75
 
                print '   GLint dispatch_offset; /* for sanity check */'
76
 
                print '};'
77
 
                print ''
78
 
 
79
 
                pool_indices = {}
80
 
 
81
 
                print '/* this is internal to remap.c */'
82
 
                print '#ifdef need_MESA_remap_table'
83
 
                print ''
84
 
                print 'static const char _mesa_function_pool[] ='
85
 
 
86
 
                # output string pool
87
 
                index = 0;
88
 
                for f in api.functionIterateAll():
89
 
                        pool_indices[f] = index
90
 
 
91
 
                        spec = get_function_spec(f)
92
 
 
93
 
                        # a function has either assigned offset, fixed offset,
94
 
                        # or no offset
95
 
                        if f.assign_offset:
96
 
                                comments = "will be remapped"
97
 
                        elif f.offset > 0:
98
 
                                comments = "offset %d" % f.offset
99
 
                        else:
100
 
                                comments = "dynamic"
101
 
 
102
 
                        print '   /* _mesa_function_pool[%d]: %s (%s) */' \
103
 
                                        % (index, f.name, comments)
104
 
                        for line in spec:
105
 
                                print '   "%s\\0"' % line
106
 
                                index += len(line) + 1
107
 
                print '   ;'
108
 
                print ''
109
 
 
110
 
                print '/* these functions need to be remapped */'
111
 
                print 'static const struct {'
112
 
                print '   GLint pool_index;'
113
 
                print '   GLint remap_index;'
114
 
                print '} MESA_remap_table_functions[] = {'
115
 
                # output all functions that need to be remapped
116
 
                # iterate by offsets so that they are sorted by remap indices
117
 
                for f in api.functionIterateByOffset():
118
 
                        if not f.assign_offset:
119
 
                                continue
120
 
                        print '   { %5d, %s_remap_index },' \
121
 
                                        % (pool_indices[f], f.name)
122
 
                print '   {    -1, -1 }'
123
 
                print '};'
124
 
                print ''
125
 
 
126
 
                # collect functions by versions/extensions
127
 
                extension_functions = {}
128
 
                abi_extensions = []
129
 
                for f in api.functionIterateAll():
130
 
                        for n in f.entry_points:
131
 
                                category, num = api.get_category_for_name(n)
132
 
                                # consider only GL_VERSION_X_Y or extensions
133
 
                                c = gl_XML.real_category_name(category)
134
 
                                if c.startswith("GL_"):
135
 
                                        if not extension_functions.has_key(c):
136
 
                                                extension_functions[c] = []
137
 
                                        extension_functions[c].append(f)
138
 
                                        # remember the ext names of the ABI
139
 
                                        if (f.is_abi() and n == f.name and
140
 
                                                c not in abi_extensions):
141
 
                                                abi_extensions.append(c)
142
 
                # ignore the ABI itself
143
 
                for ext in abi_extensions:
144
 
                        extension_functions.pop(ext)
145
 
 
146
 
                extensions = extension_functions.keys()
147
 
                extensions.sort()
148
 
 
149
 
                # output ABI functions that have alternative names (with ext suffix)
150
 
                print '/* these functions are in the ABI, but have alternative names */'
151
 
                print 'static const struct gl_function_remap MESA_alt_functions[] = {'
152
 
                for ext in extensions:
153
 
                        funcs = []
154
 
                        for f in extension_functions[ext]:
155
 
                                # test if the function is in the ABI and has alt names
156
 
                                if f.is_abi() and len(f.entry_points) > 1:
157
 
                                        funcs.append(f)
158
 
                        if not funcs:
159
 
                                continue
160
 
                        print '   /* from %s */' % ext
161
 
                        for f in funcs:
162
 
                                print '   { %5d, _gloffset_%s },' \
163
 
                                                % (pool_indices[f], f.name)
164
 
                print '   {    -1, -1 }'
165
 
                print '};'
166
 
                print ''
167
 
 
168
 
                print '#endif /* need_MESA_remap_table */'
169
 
                print ''
170
 
 
171
 
                # output remap helpers for DRI drivers
172
 
 
173
 
                for ext in extensions:
174
 
                        funcs = []
175
 
                        remapped = []
176
 
                        for f in extension_functions[ext]:
177
 
                                if f.assign_offset:
178
 
                                        # these are handled above
179
 
                                        remapped.append(f)
180
 
                                else:
181
 
                                        # these functions are either in the
182
 
                                        # abi, or have offset -1
183
 
                                        funcs.append(f)
184
 
 
185
 
                        print '#if defined(need_%s)' % (ext)
186
 
                        if remapped:
187
 
                                print '/* functions defined in MESA_remap_table_functions are excluded */'
188
 
 
189
 
                        # output extension functions that need to be mapped
190
 
                        print 'static const struct gl_function_remap %s_functions[] = {' % (ext)
191
 
                        for f in funcs:
192
 
                                if f.offset >= 0:
193
 
                                        print '   { %5d, _gloffset_%s },' \
194
 
                                                        % (pool_indices[f], f.name)
195
 
                                else:
196
 
                                        print '   { %5d, -1 }, /* %s */' % \
197
 
                                                        (pool_indices[f], f.name)
198
 
                        print '   {    -1, -1 }'
199
 
                        print '};'
200
 
 
201
 
                        print '#endif'
202
 
                        print ''
203
 
 
204
 
                return
205
 
 
206
 
 
207
 
def show_usage():
208
 
        print "Usage: %s [-f input_file_name]" % sys.argv[0]
209
 
        sys.exit(1)
210
 
 
211
 
if __name__ == '__main__':
212
 
        file_name = "gl_API.xml"
213
 
 
214
 
        try:
215
 
                (args, trail) = getopt.getopt(sys.argv[1:], "f:")
216
 
        except Exception,e:
217
 
                show_usage()
218
 
 
219
 
        for (arg,val) in args:
220
 
                if arg == "-f":
221
 
                        file_name = val
222
 
 
223
 
        api = gl_XML.parse_GL_API( file_name )
224
 
 
225
 
        printer = PrintGlRemap()
226
 
        printer.Print( api )