diff options
author | Hans-Kristian Arntzen <post@arntzen-software.no> | 2022-10-03 13:20:08 +0300 |
---|---|---|
committer | Hans-Kristian Arntzen <post@arntzen-software.no> | 2022-10-03 13:20:08 +0300 |
commit | f3b1375b133b1c34b6f529cf953ce68db4238010 (patch) | |
tree | d29f1970278ecc09e2ab07d039eb1ebd742c071a | |
parent | c821207ae29a6157e84594adc0e2753fc90f4985 (diff) |
Add reflection support for shader record buffers.
Reflect naming scheme in a context sensitive way that matches the
frontend.
GLSL -> use block name
HLSL (DXC) -> use instance name.
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | main.cpp | 1 | ||||
-rw-r--r-- | spirv_cross.cpp | 4 | ||||
-rw-r--r-- | spirv_cross.hpp | 2 | ||||
-rw-r--r-- | spirv_cross_c.cpp | 7 | ||||
-rw-r--r-- | spirv_cross_c.h | 3 |
6 files changed, 17 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d8ea49a6..cf14c8d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -332,7 +332,7 @@ if (SPIRV_CROSS_STATIC) endif() set(spirv-cross-abi-major 0) -set(spirv-cross-abi-minor 49) +set(spirv-cross-abi-minor 50) set(spirv-cross-abi-patch 0) if (SPIRV_CROSS_SHARED) @@ -536,6 +536,7 @@ static void print_resources(const Compiler &compiler, const ShaderResources &res print_resources(compiler, "push", res.push_constant_buffers); print_resources(compiler, "counters", res.atomic_counters); print_resources(compiler, "acceleration structures", res.acceleration_structures); + print_resources(compiler, "record buffers", res.shader_record_buffers); print_resources(compiler, spv::StorageClassInput, res.builtin_inputs); print_resources(compiler, spv::StorageClassOutput, res.builtin_outputs); } diff --git a/spirv_cross.cpp b/spirv_cross.cpp index 3f30ee93..e8c57720 100644 --- a/spirv_cross.cpp +++ b/spirv_cross.cpp @@ -991,6 +991,10 @@ ShaderResources Compiler::get_shader_resources(const unordered_set<VariableID> * // in the future. res.push_constant_buffers.push_back({ var.self, var.basetype, type.self, get_name(var.self) }); } + else if (type.storage == StorageClassShaderRecordBufferKHR) + { + res.shader_record_buffers.push_back({ var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self, ssbo_instance_name) }); + } // Images else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::Image && type.image.sampled == 2) diff --git a/spirv_cross.hpp b/spirv_cross.hpp index f1c347dd..53c8b653 100644 --- a/spirv_cross.hpp +++ b/spirv_cross.hpp @@ -99,6 +99,8 @@ struct ShaderResources // but keep the vector in case this restriction is lifted in the future. SmallVector<Resource> push_constant_buffers; + SmallVector<Resource> shader_record_buffers; + // For Vulkan GLSL and HLSL source, // these correspond to separate texture2D and samplers respectively. SmallVector<Resource> separate_images; diff --git a/spirv_cross_c.cpp b/spirv_cross_c.cpp index 2d9401b8..011d127a 100644 --- a/spirv_cross_c.cpp +++ b/spirv_cross_c.cpp @@ -194,6 +194,7 @@ struct spvc_resources_s : ScratchMemoryAllocation SmallVector<spvc_reflected_resource> sampled_images; SmallVector<spvc_reflected_resource> atomic_counters; SmallVector<spvc_reflected_resource> push_constant_buffers; + SmallVector<spvc_reflected_resource> shader_record_buffers; SmallVector<spvc_reflected_resource> separate_images; SmallVector<spvc_reflected_resource> separate_samplers; SmallVector<spvc_reflected_resource> acceleration_structures; @@ -1684,6 +1685,8 @@ bool spvc_resources_s::copy_resources(const ShaderResources &resources) return false; if (!copy_resources(push_constant_buffers, resources.push_constant_buffers)) return false; + if (!copy_resources(shader_record_buffers, resources.shader_record_buffers)) + return false; if (!copy_resources(separate_images, resources.separate_images)) return false; if (!copy_resources(separate_samplers, resources.separate_samplers)) @@ -1837,6 +1840,10 @@ spvc_result spvc_resources_get_resource_list_for_type(spvc_resources resources, list = &resources->acceleration_structures; break; + case SPVC_RESOURCE_TYPE_SHADER_RECORD_BUFFER: + list = &resources->shader_record_buffers; + break; + default: break; } diff --git a/spirv_cross_c.h b/spirv_cross_c.h index 4e6c6397..89434878 100644 --- a/spirv_cross_c.h +++ b/spirv_cross_c.h @@ -40,7 +40,7 @@ extern "C" { /* Bumped if ABI or API breaks backwards compatibility. */ #define SPVC_C_API_VERSION_MAJOR 0 /* Bumped if APIs or enumerations are added in a backwards compatible way. */ -#define SPVC_C_API_VERSION_MINOR 49 +#define SPVC_C_API_VERSION_MINOR 50 /* Bumped if internal implementation details change. */ #define SPVC_C_API_VERSION_PATCH 0 @@ -225,6 +225,7 @@ typedef enum spvc_resource_type SPVC_RESOURCE_TYPE_SEPARATE_SAMPLERS = 11, SPVC_RESOURCE_TYPE_ACCELERATION_STRUCTURE = 12, SPVC_RESOURCE_TYPE_RAY_QUERY = 13, + SPVC_RESOURCE_TYPE_SHADER_RECORD_BUFFER = 14, SPVC_RESOURCE_TYPE_INT_MAX = 0x7fffffff } spvc_resource_type; |