Add spvc_type_get_base_type_id.

Wraps SPIRType::self which is necessary for advanced reflection.
This commit is contained in:
Hans-Kristian Arntzen 2019-11-04 10:53:09 +01:00
parent e9ad6398de
commit e8ed10d445
2 changed files with 11 additions and 0 deletions

View File

@ -1663,6 +1663,11 @@ spvc_type spvc_compiler_get_type_handle(spvc_compiler compiler, spvc_type_id id)
SPVC_END_SAFE_SCOPE(compiler->context, nullptr)
}
spvc_type_id spvc_type_get_base_type_id(spvc_type type)
{
return type->self;
}
static spvc_basetype convert_basetype(SPIRType::BaseType type)
{
// For now the enums match up.

View File

@ -719,6 +719,12 @@ SPVC_PUBLIC_API SpvExecutionModel spvc_compiler_get_execution_model(spvc_compile
*/
SPVC_PUBLIC_API spvc_type spvc_compiler_get_type_handle(spvc_compiler compiler, spvc_type_id id);
/* Pulls out SPIRType::self. This effectively gives the type ID without array or pointer qualifiers.
* This is necessary when reflecting decoration/name information on members of a struct,
* which are placed in the base type, not the qualified type.
* This is similar to spvc_reflected_resource::base_type_id. */
SPVC_PUBLIC_API spvc_type_id spvc_type_get_base_type_id(spvc_type type);
SPVC_PUBLIC_API spvc_basetype spvc_type_get_basetype(spvc_type type);
SPVC_PUBLIC_API unsigned spvc_type_get_bit_width(spvc_type type);
SPVC_PUBLIC_API unsigned spvc_type_get_vector_size(spvc_type type);