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_init.c, which contains
24 # _mesa_initialize_exec_table(). It is responsible for populating all
25 # entries in the "OutsideBeginEnd" dispatch table.
44 * \\file api_exec_init.c
45 * Initialize dispatch table.
49 #include "api_exec_decl.h"
50 #include "glapi/glapi.h"
51 #include "main/context.h"
52 #include "main/dispatch.h"
56 * Initialize a context's OutsideBeginEnd table with pointers to Mesa's supported
59 * This function depends on ctx->Version.
61 * \param ctx GL context
64 _mesa_initialize_exec_table(struct gl_context *ctx)
66 struct _glapi_table *table = ctx->OutsideBeginEnd;
68 assert(table != NULL);
69 assert(ctx->Version > 0);
78 class PrintCode(gl_XML.gl_print_base):
81 gl_XML.gl_print_base.__init__(self)
83 self.name = 'api_exec_init.py'
84 self.license = license.bsd_license_template % (
85 'Copyright (C) 2012 Intel Corporation',
88 def printRealHeader(self):
91 def printRealFooter(self):
94 def printBody(self, api):
95 # Collect SET_* calls by the condition under which they should
97 settings_by_condition = collections.defaultdict(lambda: [])
98 for f in api.functionIterateAll():
99 if f.exec_flavor not in exec_flavor_map:
101 'Unrecognized exec flavor {0!r}'.format(f.exec_flavor))
102 condition = apiexec.get_api_condition(f)
105 prefix = exec_flavor_map[f.exec_flavor]
107 # This function is not implemented, or is dispatched
110 if f.has_no_error_variant:
111 no_error_condition = '_mesa_is_no_error_enabled(ctx) && ({0})'.format(condition)
112 error_condition = '!_mesa_is_no_error_enabled(ctx) && ({0})'.format(condition)
113 settings_by_condition[no_error_condition].append(
114 'SET_{0}(table, {1}{0}_no_error);'.format(f.name, prefix, f.name))
115 settings_by_condition[error_condition].append(
116 'SET_{0}(table, {1}{0});'.format(f.name, prefix, f.name))
118 settings_by_condition[condition].append(
119 'SET_{0}(table, {1}{0});'.format(f.name, prefix, f.name))
120 # Print out an if statement for each unique condition, with
121 # the SET_* calls nested inside it.
122 for condition in sorted(settings_by_condition.keys()):
123 print(' if ({0}) {{'.format(condition))
124 for setting in sorted(settings_by_condition[condition]):
125 print(' {0}'.format(setting))
129 if __name__ == '__main__':
130 apiexec.print_glapi_file(PrintCode())