[Mesa-dev] [PATCH 12/24] spirv_extensions: define spirv_extensions_supported

Ian Romanick idr at freedesktop.org
Mon Nov 27 22:09:02 UTC 2017


On 11/27/2017 01:25 PM, Ian Romanick wrote:
> On 11/15/2017 05:22 AM, Eduardo Lima Mitev wrote:
>> From: Alejandro PiƱeiro <apinheiro at igalia.com>
>>
>> Add a struct to maintain which SPIR-V extensions are supported, and an
>> utility method to initialize it based on
>> nir_spirv_supported_capabilities.
>> ---
>>  src/compiler/spirv/spirv_extensions.c | 29 +++++++++++++++++++++++++++++
>>  src/compiler/spirv/spirv_extensions.h | 12 ++++++++++++
>>  2 files changed, 41 insertions(+)
>>
>> diff --git a/src/compiler/spirv/spirv_extensions.c b/src/compiler/spirv/spirv_extensions.c
>> index 64d61c49d31..8263b693abd 100644
>> --- a/src/compiler/spirv/spirv_extensions.c
>> +++ b/src/compiler/spirv/spirv_extensions.c
>> @@ -59,3 +59,32 @@ spirv_extensions_to_string(SpvExtension ext)
>>  
>>     return "unknown";
>>  }
>> +
>> +/**
>> + * Sets the supported flags for known SPIR-V extensions based on the
>> + * capabilites supported (spirv capabilities based on the spirv to nir
>> + * support).
>> + *
>> + * One could argue that makes more sense in the other way around, as from the
>> + * spec pov capabilities are enable for a given extension. But from our pov,
>> + * we support or not (depending on the driver) some given capability, and
>> + * spirv_to_nir check for capabilities not extensions. Also we usually fill
>> + * first the supported capabilities, that are not always related to an
>> + * extension.
>> + */
>> +void
>> +fill_supported_spirv_extensions(struct spirv_supported_extensions *ext,
>> +                                const struct nir_spirv_supported_capabilities *cap)
> 
> Since this is exposed outside this file, this function should have some
> sort of a namespace prefix.  I'm not sure what it should be, though.
> 
>> +{
>> +   for (unsigned i = 0; i < SPV_EXTENSIONS_COUNT; i++)
>> +      ext->supported[i] = false;
>> +
>> +   ext->count = 0;
>> +
>> +   ext->supported[SPV_KHR_shader_draw_parameters] = cap->draw_parameters;
>> +   ext->supported[SPV_KHR_multiview] = cap->multiview;
>> +   ext->supported[SPV_KHR_variable_pointers] = cap->variable_pointers;
>> +
>> +   for (unsigned i = 0; i < SPV_EXTENSIONS_COUNT; i++)
>> +      if (ext->supported[i]) ext->count++;
> 
>    for (unsigned i = 0; i < SPV_EXTENSIONS_COUNT; i++) {
>       if (ext->supported[i])
>          ext->count++;
>    }
> 
>> +}
>> diff --git a/src/compiler/spirv/spirv_extensions.h b/src/compiler/spirv/spirv_extensions.h
>> index 54bc7f2dbe0..22238b727d7 100644
>> --- a/src/compiler/spirv/spirv_extensions.h
>> +++ b/src/compiler/spirv/spirv_extensions.h
>> @@ -25,6 +25,7 @@
>>  #define _SPIRV_EXTENSIONS_H_
>>  
>>  #include "compiler/nir/nir.h"
>> +#include "nir_spirv.h"
>>  
>>  #ifdef __cplusplus
>>  extern "C" {
>> @@ -60,8 +61,19 @@ typedef enum SpvExtension_ {
>>     SPV_EXTENSIONS_COUNT
>>  } SpvExtension;
>>  
>> +struct spirv_supported_extensions {
>> +   /** Flags the supported extensions. Array to make it easier to iterate. */
>> +   bool supported[SPV_EXTENSIONS_COUNT];
>> +
>> +   /** Number of supported extensions */
>> +   unsigned int count;
> 
> I see this is used by _mesa_get_spirv_extension_count, but I don't see
> where that is used.  Did I miss it?

Never mind.  Patch 10 showed up out-of-order, so I did miss it.

>> +};
>> +
>>  const char *spirv_extensions_to_string(SpvExtension ext);
>>  
>> +void fill_supported_spirv_extensions(struct spirv_supported_extensions *ext,
>> +                                     const struct nir_spirv_supported_capabilities *cap);
>> +
>>  #ifdef __cplusplus
>>  }
>>  #endif
>>


More information about the mesa-dev mailing list