diff options
author | Marek Olšák <marek.olsak@amd.com> | 2021-11-28 19:28:57 -0500 |
---|---|---|
committer | Marek Olšák <marek.olsak@amd.com> | 2021-12-14 12:00:10 -0500 |
commit | 1aa0b587cd0db0ba9a74f53c54b0c136ce8d8e52 (patch) | |
tree | f1c7bebc297db806b4bd445fd7f2c3fba3f65861 | |
parent | 6e4238f99acef72e3d38b39cff33e5ea4fa496ae (diff) |
glapi: move apiexec API condition determination to common code
it will be used elsewhere
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14000>
-rw-r--r-- | src/mapi/glapi/gen/api_exec_init.py | 49 | ||||
-rw-r--r-- | src/mapi/glapi/gen/apiexec.py | 50 |
2 files changed, 52 insertions, 47 deletions
diff --git a/src/mapi/glapi/gen/api_exec_init.py b/src/mapi/glapi/gen/api_exec_init.py index 3166c0fae8f..7c729a2a2f8 100644 --- a/src/mapi/glapi/gen/api_exec_init.py +++ b/src/mapi/glapi/gen/api_exec_init.py @@ -179,54 +179,9 @@ class PrintCode(gl_XML.gl_print_base): if f.exec_flavor not in exec_flavor_map: raise Exception( 'Unrecognized exec flavor {0!r}'.format(f.exec_flavor)) - condition_parts = [] - if f.name in apiexec.functions: - ex = apiexec.functions[f.name] - unconditional_count = 0 - - if ex.compatibility is not None: - condition_parts.append('ctx->API == API_OPENGL_COMPAT') - unconditional_count += 1 - - if ex.core is not None: - condition_parts.append('ctx->API == API_OPENGL_CORE') - unconditional_count += 1 - - if ex.es1 is not None: - condition_parts.append('ctx->API == API_OPENGLES') - unconditional_count += 1 - - if ex.es2 is not None: - if ex.es2 > 20: - condition_parts.append('(ctx->API == API_OPENGLES2 && ctx->Version >= {0})'.format(ex.es2)) - else: - condition_parts.append('ctx->API == API_OPENGLES2') - unconditional_count += 1 - - # If the function is unconditionally available in all four - # APIs, then it is always available. Replace the complex - # tautology condition with "true" and let GCC do the right - # thing. - if unconditional_count == 4: - condition_parts = ['true'] - else: - if f.desktop: - if f.deprecated: - condition_parts.append('ctx->API == API_OPENGL_COMPAT') - else: - condition_parts.append('_mesa_is_desktop_gl(ctx)') - if 'es1' in f.api_map: - condition_parts.append('ctx->API == API_OPENGLES') - if 'es2' in f.api_map: - if f.api_map['es2'] > 2.0: - condition_parts.append('(ctx->API == API_OPENGLES2 && ctx->Version >= {0})'.format(int(f.api_map['es2'] * 10))) - else: - condition_parts.append('ctx->API == API_OPENGLES2') - - if not condition_parts: - # This function does not exist in any API. + condition = apiexec.get_api_condition(f) + if not condition: continue - condition = ' || '.join(condition_parts) prefix = exec_flavor_map[f.exec_flavor] if prefix is None: # This function is not implemented, or is dispatched diff --git a/src/mapi/glapi/gen/apiexec.py b/src/mapi/glapi/gen/apiexec.py index 966e66a6c02..8920748e3a2 100644 --- a/src/mapi/glapi/gen/apiexec.py +++ b/src/mapi/glapi/gen/apiexec.py @@ -295,3 +295,53 @@ functions = { # GL_ARB_bindless_texture "GetVertexAttribLui64vARB": exec_info(compatibility=30, core=31), } + +def get_api_condition(f): + condition_parts = [] + if f.name in functions: + ex = functions[f.name] + unconditional_count = 0 + + if ex.compatibility is not None: + condition_parts.append('ctx->API == API_OPENGL_COMPAT') + unconditional_count += 1 + + if ex.core is not None: + condition_parts.append('ctx->API == API_OPENGL_CORE') + unconditional_count += 1 + + if ex.es1 is not None: + condition_parts.append('ctx->API == API_OPENGLES') + unconditional_count += 1 + + if ex.es2 is not None: + if ex.es2 > 20: + condition_parts.append('(ctx->API == API_OPENGLES2 && ctx->Version >= {0})'.format(ex.es2)) + else: + condition_parts.append('ctx->API == API_OPENGLES2') + unconditional_count += 1 + + # If the function is unconditionally available in all four + # APIs, then it is always available. Replace the complex + # tautology condition with "true" and let GCC do the right + # thing. + if unconditional_count == 4: + condition_parts = ['true'] + else: + if f.desktop: + if f.deprecated: + condition_parts.append('ctx->API == API_OPENGL_COMPAT') + else: + condition_parts.append('_mesa_is_desktop_gl(ctx)') + if 'es1' in f.api_map: + condition_parts.append('ctx->API == API_OPENGLES') + if 'es2' in f.api_map: + if f.api_map['es2'] > 2.0: + condition_parts.append('(ctx->API == API_OPENGLES2 && ctx->Version >= {0})'.format(int(f.api_map['es2'] * 10))) + else: + condition_parts.append('ctx->API == API_OPENGLES2') + + if not condition_parts: + # This function does not exist in any API. + return None + return ' || '.join(condition_parts) |