be8013b62b24c288007305e7a94f20328a53f7b4
2 # Copyright (C) 2012 Intel Corporation
4 # Permission is hereby granted, free of charge, to any person obtaining a
5 # copy of this software and associated documentation files (the "Software"),
6 # to deal in the Software without restriction, including without limitation
7 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 # and/or sell copies of the Software, and to permit persons to whom the
9 # Software is furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice (including the next
12 # paragraph) shall be included in all copies or substantial portions of the
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23 # This script generates the file api_exec.c, which contains
24 # _mesa_initialize_exec_table(). It is responsible for populating all
25 # entries in the "exec" dispatch table that aren't dynamic.
44 * Initialize dispatch table.
48 #include "main/accum.h"
49 #include "main/api_loopback.h"
50 #include "main/api_exec.h"
51 #include "main/arbprogram.h"
52 #include "main/atifragshader.h"
53 #include "main/attrib.h"
54 #include "main/blend.h"
55 #include "main/blit.h"
56 #include "main/bufferobj.h"
57 #include "main/arrayobj.h"
58 #include "main/bbox.h"
59 #include "main/buffers.h"
60 #include "main/clear.h"
61 #include "main/clip.h"
62 #include "main/colortab.h"
63 #include "main/compute.h"
64 #include "main/condrender.h"
65 #include "main/conservativeraster.h"
66 #include "main/context.h"
67 #include "main/convolve.h"
68 #include "main/copyimage.h"
69 #include "main/depth.h"
70 #include "main/debug_output.h"
71 #include "main/dlist.h"
72 #include "main/drawpix.h"
73 #include "main/drawtex.h"
74 #include "main/rastpos.h"
75 #include "main/enable.h"
76 #include "main/errors.h"
77 #include "main/es1_conversion.h"
78 #include "main/eval.h"
79 #include "main/externalobjects.h"
81 #include "main/glspirv.h"
82 #include "main/feedback.h"
84 #include "main/fbobject.h"
85 #include "main/framebuffer.h"
86 #include "main/genmipmap.h"
87 #include "main/hint.h"
88 #include "main/histogram.h"
89 #include "main/imports.h"
90 #include "main/light.h"
91 #include "main/lines.h"
92 #include "main/matrix.h"
93 #include "main/multisample.h"
94 #include "main/objectlabel.h"
95 #include "main/objectpurge.h"
96 #include "main/performance_monitor.h"
97 #include "main/performance_query.h"
98 #include "main/pipelineobj.h"
99 #include "main/pixel.h"
100 #include "main/pixelstore.h"
101 #include "main/points.h"
102 #include "main/polygon.h"
103 #include "main/program_resource.h"
104 #include "main/querymatrix.h"
105 #include "main/queryobj.h"
106 #include "main/readpix.h"
107 #include "main/samplerobj.h"
108 #include "main/scissor.h"
109 #include "main/stencil.h"
110 #include "main/texenv.h"
111 #include "main/texgetimage.h"
112 #include "main/teximage.h"
113 #include "main/texgen.h"
114 #include "main/texobj.h"
115 #include "main/texparam.h"
116 #include "main/texstate.h"
117 #include "main/texstorage.h"
118 #include "main/barrier.h"
119 #include "main/texturebindless.h"
120 #include "main/textureview.h"
121 #include "main/transformfeedback.h"
122 #include "main/mtypes.h"
123 #include "main/varray.h"
124 #include "main/viewport.h"
125 #include "main/shaderapi.h"
126 #include "main/shaderimage.h"
127 #include "main/uniforms.h"
128 #include "main/syncobj.h"
129 #include "main/formatquery.h"
130 #include "main/dispatch.h"
131 #include "main/vdpau.h"
136 * Initialize a context's exec table with pointers to Mesa's supported
139 * This function depends on ctx->Version.
141 * \param ctx GL context to which \c exec belongs.
144 _mesa_initialize_exec_table(struct gl_context *ctx)
146 struct _glapi_table *exec;
149 assert(exec != NULL);
151 assert(ctx->Version > 0);
153 vbo_initialize_exec_dispatch(ctx, exec);
162 class PrintCode(gl_XML
.gl_print_base
):
165 gl_XML
.gl_print_base
.__init
__(self
)
167 self
.name
= 'gl_genexec.py'
168 self
.license
= license
.bsd_license_template
% (
169 'Copyright (C) 2012 Intel Corporation',
172 def printRealHeader(self
):
175 def printRealFooter(self
):
178 def printBody(self
, api
):
179 # Collect SET_* calls by the condition under which they should
181 settings_by_condition
= collections
.defaultdict(lambda: [])
182 for f
in api
.functionIterateAll():
183 if f
.exec_flavor
not in exec_flavor_map
:
185 'Unrecognized exec flavor {0!r}'.format(f
.exec_flavor
))
187 if f
.name
in apiexec
.functions
:
188 ex
= apiexec
.functions
[f
.name
]
189 unconditional_count
= 0
191 if ex
.compatibility
is not None:
192 condition_parts
.append('ctx->API == API_OPENGL_COMPAT')
193 unconditional_count
+= 1
195 if ex
.core
is not None:
196 condition_parts
.append('ctx->API == API_OPENGL_CORE')
197 unconditional_count
+= 1
199 if ex
.es1
is not None:
200 condition_parts
.append('ctx->API == API_OPENGLES')
201 unconditional_count
+= 1
203 if ex
.es2
is not None:
205 condition_parts
.append('(ctx->API == API_OPENGLES2 && ctx->Version >= {0})'.format(ex
.es2
))
207 condition_parts
.append('ctx->API == API_OPENGLES2')
208 unconditional_count
+= 1
210 # If the function is unconditionally available in all four
211 # APIs, then it is always available. Replace the complex
212 # tautology condition with "true" and let GCC do the right
214 if unconditional_count
== 4:
215 condition_parts
= ['true']
219 condition_parts
.append('ctx->API == API_OPENGL_COMPAT')
221 condition_parts
.append('_mesa_is_desktop_gl(ctx)')
222 if 'es1' in f
.api_map
:
223 condition_parts
.append('ctx->API == API_OPENGLES')
224 if 'es2' in f
.api_map
:
225 if f
.api_map
['es2'] > 2.0:
226 condition_parts
.append('(ctx->API == API_OPENGLES2 && ctx->Version >= {0})'.format(int(f
.api_map
['es2'] * 10)))
228 condition_parts
.append('ctx->API == API_OPENGLES2')
230 if not condition_parts
:
231 # This function does not exist in any API.
233 condition
= ' || '.join(condition_parts
)
234 prefix
= exec_flavor_map
[f
.exec_flavor
]
236 # This function is not implemented, or is dispatched
239 if f
.has_no_error_variant
:
240 no_error_condition
= '_mesa_is_no_error_enabled(ctx) && ({0})'.format(condition
)
241 error_condition
= '!_mesa_is_no_error_enabled(ctx) && ({0})'.format(condition
)
242 settings_by_condition
[no_error_condition
].append(
243 'SET_{0}(exec, {1}{0}_no_error);'.format(f
.name
, prefix
, f
.name
))
244 settings_by_condition
[error_condition
].append(
245 'SET_{0}(exec, {1}{0});'.format(f
.name
, prefix
, f
.name
))
247 settings_by_condition
[condition
].append(
248 'SET_{0}(exec, {1}{0});'.format(f
.name
, prefix
, f
.name
))
249 # Print out an if statement for each unique condition, with
250 # the SET_* calls nested inside it.
251 for condition
in sorted(settings_by_condition
.keys()):
252 print ' if ({0}) {{'.format(condition
)
253 for setting
in sorted(settings_by_condition
[condition
]):
254 print ' {0}'.format(setting
)
259 """Parse arguments and return namespace."""
260 parser
= argparse
.ArgumentParser()
261 parser
.add_argument('-f',
263 default
='gl_and_es_API.xml',
264 help='an xml file describing an API')
265 return parser
.parse_args()
271 printer
= PrintCode()
272 api
= gl_XML
.parse_GL_API(args
.filename
)
276 if __name__
== '__main__':