[Mesa-dev] [PATCH v2 13/25] spirv_extensions: add list of extensions and to_string method

Alejandro Piñeiro apinheiro at igalia.com
Tue Dec 12 11:26:58 UTC 2017


On 12/12/17 01:20, Timothy Arceri wrote:
> I might be blind but in which patch does this end up being used?

On the patch "spirv_extensions: add spirv_supported_extensions on
gl_constants" is used. That patch adds spirv_supported_extensions on
gl_constants, and as the commit message says, uses it at the
implementation of _mesa_get_spirv_extension_count and
_mesa_get_enabled_spirv_extension to get real values. The patch
"spirv_extensions: i965: initialize SPIR-V extensions" fill it up for i965.

>
> Also this and the following patches seem to reinvent a system for
> exposing extension support. Is there a good reason for not simply
> expanding extensions_table.h to support tracking the spriv extensions?

They are a different set of extensions that are enabled or not in a
different way. On the case of opengl extensions they are enabled
individually by each driver. spirv extensions are enabled based on spirv
capabilities. And spirv extensions tracking doesn't need so many
features as tracking opengl extensions. We could make it more similar to
extensions_table.h, but at the end of the day, it would be two different
implementations with different needs. I just focused in keeping it simple.

BR
>
> On 01/12/17 04:28, Eduardo Lima Mitev wrote:
>> From: Alejandro Piñeiro <apinheiro at igalia.com>
>>
>> Ideally this should be generated somehow. One option would be gather
>> all the extension dependencies listed on the core grammar, but there
>> would be the possibility of not including some of the extensions.
>>
>> Note that spirv-tools is doing it just slightly better, as it has a
>> hardcoded list of extensions manually took from the registry, that
>> they parse to get the enum and the to_string method (see
>> generate_grammar_tables.py).
>>
>> v2:
>>    * Use a macro to improve readability. (Tapani Pälli)
>>    * Add unreachable on the switch, no default (Eric Engestrom)
>>    * No typedef enum (Ian Romanick)
>>    * Sort extensions names (Ian Romanick)
>>    * Don't add extensions unlikely to be supported by Mesa at any point
>>      (Ian Romanick)
>> ---
>>   src/compiler/Makefile.sources         |  2 ++
>>   src/compiler/spirv/spirv_extensions.c | 46
>> +++++++++++++++++++++++++++++++
>>   src/compiler/spirv/spirv_extensions.h | 51
>> +++++++++++++++++++++++++++++++++++
>>   3 files changed, 99 insertions(+)
>>   create mode 100644 src/compiler/spirv/spirv_extensions.c
>>   create mode 100644 src/compiler/spirv/spirv_extensions.h
>>
>> diff --git a/src/compiler/Makefile.sources
>> b/src/compiler/Makefile.sources
>> index 2ab8e163a26..f198456c751 100644
>> --- a/src/compiler/Makefile.sources
>> +++ b/src/compiler/Makefile.sources
>> @@ -293,6 +293,8 @@ SPIRV_FILES = \
>>       spirv/GLSL.std.450.h \
>>       spirv/nir_spirv.h \
>>       spirv/spirv.h \
>> +    spirv/spirv_extensions.c \
>> +    spirv/spirv_extensions.h \
>>       spirv/spirv_info.h \
>>       spirv/spirv_to_nir.c \
>>       spirv/vtn_alu.c \
>> diff --git a/src/compiler/spirv/spirv_extensions.c
>> b/src/compiler/spirv/spirv_extensions.c
>> new file mode 100644
>> index 00000000000..f50f87b52e1
>> --- /dev/null
>> +++ b/src/compiler/spirv/spirv_extensions.c
>> @@ -0,0 +1,46 @@
>> +/*
>> + * 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
>> + * the rights to use, copy, modify, merge, publish, distribute,
>> sublicense,
>> + * 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 NONINFRINGEMENT.  IN NO
>> EVENT SHALL
>> + * THE AUTHORS OR COPYRIGHT HOLDERS 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.
>> + */
>> +
>> +#include "spirv.h"
>> +#include "spirv_extensions.h"
>> +
>> +const char *
>> +spirv_extensions_to_string(enum SpvExtension ext)
>> +{
>> +#define STR(x) case x: return #x;
>> +   switch (ext) {
>> +   STR(SPV_KHR_16bit_storage);
>> +   STR(SPV_KHR_device_group);
>> +   STR(SPV_KHR_multiview);
>> +   STR(SPV_KHR_shader_ballot);
>> +   STR(SPV_KHR_shader_draw_parameters);
>> +   STR(SPV_KHR_storage_buffer_storage_class);
>> +   STR(SPV_KHR_subgroup_vote);
>> +   STR(SPV_KHR_variable_pointers);
>> +   case SPV_EXTENSIONS_COUNT:
>> +      unreachable("Unknown SPIR-V extension");
>> +   }
>> +#undef STR
>> +
>> +   return "unknown";
>> +}
>> diff --git a/src/compiler/spirv/spirv_extensions.h
>> b/src/compiler/spirv/spirv_extensions.h
>> new file mode 100644
>> index 00000000000..0568132a517
>> --- /dev/null
>> +++ b/src/compiler/spirv/spirv_extensions.h
>> @@ -0,0 +1,51 @@
>> +/*
>> + * 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
>> + * the rights to use, copy, modify, merge, publish, distribute,
>> sublicense,
>> + * 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 NONINFRINGEMENT.  IN NO
>> EVENT SHALL
>> + * THE AUTHORS OR COPYRIGHT HOLDERS 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.
>> + */
>> +
>> +#ifndef _SPIRV_EXTENSIONS_H_
>> +#define _SPIRV_EXTENSIONS_H_
>> +
>> +#include "compiler/nir/nir.h"
>> +
>> +#ifdef __cplusplus
>> +extern "C" {
>> +#endif
>> +
>> +enum SpvExtension {
>> +   SPV_KHR_16bit_storage = 0,
>> +   SPV_KHR_device_group,
>> +   SPV_KHR_multiview,
>> +   SPV_KHR_shader_ballot,
>> +   SPV_KHR_shader_draw_parameters,
>> +   SPV_KHR_storage_buffer_storage_class,
>> +   SPV_KHR_subgroup_vote,
>> +   SPV_KHR_variable_pointers,
>> +   SPV_EXTENSIONS_COUNT
>> +};
>> +
>> +const char *spirv_extensions_to_string(enum SpvExtension ext);
>> +
>> +#ifdef __cplusplus
>> +}
>> +#endif
>> +
>> +#endif /* SPIRV_EXTENSIONS */
>>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev




More information about the mesa-dev mailing list