diff options
-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 | ||||
-rw-r--r-- | spirv_msl.cpp | 10 | ||||
-rw-r--r-- | spirv_msl.hpp | 5 |
8 files changed, 27 insertions, 7 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; diff --git a/spirv_msl.cpp b/spirv_msl.cpp index f870444e..b974b669 100644 --- a/spirv_msl.cpp +++ b/spirv_msl.cpp @@ -856,7 +856,7 @@ void CompilerMSL::build_implicit_builtins() swizzle_buffer_id = var_id; } - if (!buffers_requiring_array_length.empty()) + if (needs_buffer_size_buffer()) { uint32_t var_id = build_constant_uint_array_pointer(); set_name(var_id, "spvBufferSizeConstants"); @@ -10021,7 +10021,7 @@ void CompilerMSL::emit_function_prototype(SPIRFunction &func, const Bitset &) decl += join(", constant uint", arg_is_array ? "* " : "& ", to_swizzle_expression(arg.id)); } - if (buffers_requiring_array_length.count(name_id)) + if (buffer_requires_array_length(name_id)) { bool arg_is_array = !arg_type.array.empty(); decl += join(", constant uint", arg_is_array ? "* " : "& ", to_buffer_size_expression(name_id)); @@ -11058,7 +11058,7 @@ string CompilerMSL::to_func_call_arg(const SPIRFunction::Parameter &arg, uint32_ else if (msl_options.swizzle_texture_samples && has_sampled_images && is_sampled_image_type(type)) arg_str += ", " + to_swizzle_expression(var_id ? var_id : id); - if (buffers_requiring_array_length.count(var_id)) + if (buffer_requires_array_length(var_id)) arg_str += ", " + to_buffer_size_expression(var_id ? var_id : id); if (is_dynamic_img_sampler) @@ -12767,7 +12767,7 @@ void CompilerMSL::fix_up_shader_inputs_outputs() else if ((var.storage == StorageClassStorageBuffer || (var.storage == StorageClassUniform && ssbo)) && !is_hidden_variable(var)) { - if (buffers_requiring_array_length.count(var.self)) + if (buffer_requires_array_length(var.self)) { entry_func.fixup_hooks_in.push_back([this, &type, &var, var_id]() { bool is_array_type = !type.array.empty(); @@ -16710,7 +16710,7 @@ void CompilerMSL::analyze_argument_buffers() // Check if this descriptor set needs a swizzle buffer. if (needs_swizzle_buffer_def && is_sampled_image_type(type)) set_needs_swizzle_buffer[desc_set] = true; - else if (buffers_requiring_array_length.count(var_id) != 0) + else if (buffer_requires_array_length(var_id)) { set_needs_buffer_sizes[desc_set] = true; needs_buffer_sizes = true; diff --git a/spirv_msl.hpp b/spirv_msl.hpp index 1a7ee5c0..a848f9b5 100644 --- a/spirv_msl.hpp +++ b/spirv_msl.hpp @@ -504,6 +504,11 @@ public: return !buffers_requiring_array_length.empty(); } + bool buffer_requires_array_length(VariableID id) const + { + return buffers_requiring_array_length.count(id) != 0; + } + // Provide feedback to calling API to allow it to pass a buffer // containing the view mask for the current multiview subpass. bool needs_view_mask_buffer() const |