From a622aad869abe0413cb034a39b464a3c76b332d1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alejandro=20Pi=C3=B1eiro?= Date: Tue, 10 Oct 2017 16:09:25 +0200 Subject: [PATCH] spirv_extensions: add GL_ARB_spirv_extensions boilerplate MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit v2: * Mention extension gap at gl_API.xml (Emil Velikov) * Bail with INVALID_ENUM if extension not available on getStringi (Emil Velikov) * Use EXTRA_EXT macro when defining the extension at get.c/get_hash_params.py (Emil Velikov) * Rename source files (spirvextensions.[ch] -> spirv_extensions.[ch]) (Ian) v3: * Fix GL_PROGRAM_BINARY_FORMATS glGet query, broken by error on a previous rebase v4: * Fix rebase conflicts on getstring.c after GL_SHADING_LANGUAGE_VERSION query was added v5: * Remove src/mapi/glapi/gen/Makefile.am as it no longer exists in master Signed-off-by: Alejandro Piñeiro Signed-off-by: Arcady Goldmints-Orlov Reviewed-by: Caio Marcelo de Oliveira Filho --- src/mapi/glapi/gen/ARB_spirv_extensions.xml | 13 ++++++ src/mapi/glapi/gen/gl_API.xml | 4 ++ src/mapi/glapi/gen/meson.build | 1 + src/mesa/Makefile.sources | 2 + src/mesa/main/extensions_table.h | 1 + src/mesa/main/get.c | 6 +++ src/mesa/main/get_hash_params.py | 3 ++ src/mesa/main/getstring.c | 13 ++++++ src/mesa/main/mtypes.h | 1 + src/mesa/main/spirv_extensions.c | 42 ++++++++++++++++++ src/mesa/main/spirv_extensions.h | 49 +++++++++++++++++++++ src/mesa/meson.build | 2 + 12 files changed, 137 insertions(+) create mode 100644 src/mapi/glapi/gen/ARB_spirv_extensions.xml create mode 100644 src/mesa/main/spirv_extensions.c create mode 100644 src/mesa/main/spirv_extensions.h diff --git a/src/mapi/glapi/gen/ARB_spirv_extensions.xml b/src/mapi/glapi/gen/ARB_spirv_extensions.xml new file mode 100644 index 00000000000..103393104c2 --- /dev/null +++ b/src/mapi/glapi/gen/ARB_spirv_extensions.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index 60ae1aaa0db..f6128f1a36e 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -8424,6 +8424,10 @@ + + + + diff --git a/src/mapi/glapi/gen/meson.build b/src/mapi/glapi/gen/meson.build index d58c4cec60e..c36e49fbf94 100644 --- a/src/mapi/glapi/gen/meson.build +++ b/src/mapi/glapi/gen/meson.build @@ -82,6 +82,7 @@ api_xml_files = files( 'ARB_shader_subroutine.xml', 'ARB_shader_storage_buffer_object.xml', 'ARB_sparse_buffer.xml', + 'ARB_spirv_extensions.xml', 'ARB_sync.xml', 'ARB_tessellation_shader.xml', 'ARB_texture_barrier.xml', diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources index 89bcfe40bb5..b0b43a78ce9 100644 --- a/src/mesa/Makefile.sources +++ b/src/mesa/Makefile.sources @@ -209,6 +209,8 @@ MAIN_FILES = \ main/shader_query.cpp \ main/shared.c \ main/shared.h \ + main/spirv_extensions.c \ + main/spirv_extensions.h \ main/state.c \ main/state.h \ main/stencil.c \ diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index 332a75e6c73..02f36887bca 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -140,6 +140,7 @@ EXT(ARB_shading_language_420pack , ARB_shading_language_420pack EXT(ARB_shading_language_packing , ARB_shading_language_packing , GLL, GLC, x , x , 2011) EXT(ARB_shadow , ARB_shadow , GLL, x , x , x , 2001) EXT(ARB_sparse_buffer , ARB_sparse_buffer , GLL, GLC, x , x , 2014) +EXT(ARB_spirv_extensions , ARB_spirv_extensions , x, GLC, x , x , 2016) EXT(ARB_stencil_texturing , ARB_stencil_texturing , GLL, GLC, x , x , 2012) EXT(ARB_sync , ARB_sync , GLL, GLC, x , x , 2003) EXT(ARB_tessellation_shader , ARB_tessellation_shader , GLL, GLC, x , x , 2009) diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 8a7b1e42906..3fbacb3d735 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -34,6 +34,7 @@ #include "get.h" #include "macros.h" #include "mtypes.h" +#include "spirv_extensions.h" #include "state.h" #include "texcompress.h" #include "texstate.h" @@ -521,6 +522,7 @@ EXTRA_EXT(NV_conservative_raster_dilate); EXTRA_EXT(NV_conservative_raster_pre_snap_triangles); EXTRA_EXT(ARB_sample_locations); EXTRA_EXT(AMD_framebuffer_multisample_advanced); +EXTRA_EXT(ARB_spirv_extensions); static const int extra_ARB_color_buffer_float_or_glcore[] = { @@ -1235,6 +1237,10 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu v->value_int_n.ints[0] = GL_PROGRAM_BINARY_FORMAT_MESA; } break; + /* ARB_spirv_extensions */ + case GL_NUM_SPIR_V_EXTENSIONS: + v->value_int = _mesa_get_spirv_extension_count(ctx); + break; /* GL_EXT_disjoint_timer_query */ case GL_GPU_DISJOINT_EXT: { diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py index 33d3d39d503..3e67a5adf11 100644 --- a/src/mesa/main/get_hash_params.py +++ b/src/mesa/main/get_hash_params.py @@ -415,6 +415,9 @@ descriptor=[ # GL_ARB_sampler_objects / GL 3.3 / GLES 3.0 [ "SAMPLER_BINDING", "LOC_CUSTOM, TYPE_INT, GL_SAMPLER_BINDING, NO_EXTRA" ], +# GL_ARB_spirv_extensions + [ "NUM_SPIR_V_EXTENSIONS", "LOC_CUSTOM, TYPE_INT, 0, extra_ARB_spirv_extensions" ], + # GL_ARB_sync [ "MAX_SERVER_WAIT_TIMEOUT", "CONTEXT_INT64(Const.MaxServerWaitTimeout), extra_ARB_sync" ], diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c index 3d5ae0b694b..e2f5af29b37 100644 --- a/src/mesa/main/getstring.c +++ b/src/mesa/main/getstring.c @@ -33,6 +33,7 @@ #include "mtypes.h" #include "macros.h" #include "version.h" +#include "spirv_extensions.h" /** * Return the string for a glGetString(GL_SHADING_LANGUAGE_VERSION) query. @@ -206,6 +207,18 @@ _mesa_GetStringi(GLenum name, GLuint index) } return (const GLubyte *) version; } + case GL_SPIR_V_EXTENSIONS: + if (!ctx->Extensions.ARB_spirv_extensions) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetStringi"); + return (const GLubyte *) 0; + } + + if (index >= _mesa_get_spirv_extension_count(ctx)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetStringi(index=%u)", index); + return (const GLubyte *) 0; + } + return _mesa_get_enabled_spirv_extension(ctx, index); + default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetStringi"); return (const GLubyte *) 0; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 2b87c701116..745b243254a 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -4220,6 +4220,7 @@ struct gl_extensions GLboolean ARB_shadow; GLboolean ARB_sparse_buffer; GLboolean ARB_stencil_texturing; + GLboolean ARB_spirv_extensions; GLboolean ARB_sync; GLboolean ARB_tessellation_shader; GLboolean ARB_texture_border_clamp; diff --git a/src/mesa/main/spirv_extensions.c b/src/mesa/main/spirv_extensions.c new file mode 100644 index 00000000000..40a89c133aa --- /dev/null +++ b/src/mesa/main/spirv_extensions.c @@ -0,0 +1,42 @@ +/* + * Copyright © 2017 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file + * \brief SPIRV-V extension handling. See ARB_spirv_extensions + */ + +#include "spirv_extensions.h" + +GLuint +_mesa_get_spirv_extension_count(struct gl_context *ctx) +{ + return 0; +} + +const GLubyte * +_mesa_get_enabled_spirv_extension(struct gl_context *ctx, + GLuint index) +{ + return (const GLubyte *) 0; +} diff --git a/src/mesa/main/spirv_extensions.h b/src/mesa/main/spirv_extensions.h new file mode 100644 index 00000000000..35754f7e53b --- /dev/null +++ b/src/mesa/main/spirv_extensions.h @@ -0,0 +1,49 @@ +/* + * Copyright 2017 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file + * \brief SPIRV-V extension handling. See ARB_spirv_extensions + */ + +#ifndef _SPIRVEXTENSIONS_H_ +#define _SPIRVEXTENSIONS_H_ + +#include "mtypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern GLuint +_mesa_get_spirv_extension_count(struct gl_context *ctx); + +extern const GLubyte * +_mesa_get_enabled_spirv_extension(struct gl_context *ctx, + GLuint index); + +#ifdef __cplusplus +} +#endif + +#endif /* SPIRVEXTENSIONS_H */ diff --git a/src/mesa/meson.build b/src/mesa/meson.build index baf5c6b11c1..4a89358a267 100644 --- a/src/mesa/meson.build +++ b/src/mesa/meson.build @@ -249,6 +249,8 @@ files_libmesa_common = files( 'main/shader_query.cpp', 'main/shared.c', 'main/shared.h', + 'main/spirv_extensions.c', + 'main/spirv_extensions.h', 'main/state.c', 'main/state.h', 'main/stencil.c', -- 2.30.2