summaryrefslogtreecommitdiff
path: root/spirv_msl.hpp
diff options
context:
space:
mode:
authorChip Davis <chip@holochip.com>2022-10-02 23:33:50 -0700
committerChip Davis <chip@holochip.com>2022-10-18 14:58:59 -0700
commita17108718015a58cb9e3e9c792ff49202498f6ce (patch)
tree928309d45685a10de0d51ff88288616cd1cfe6a9 /spirv_msl.hpp
parentf09ba2777714871bddb70d049878af34b94fa54d (diff)
downloadSPIRV-Cross-a17108718015a58cb9e3e9c792ff49202498f6ce.tar.gz
SPIRV-Cross-a17108718015a58cb9e3e9c792ff49202498f6ce.tar.bz2
SPIRV-Cross-a17108718015a58cb9e3e9c792ff49202498f6ce.zip
MSL: Support "raw" buffer input in tessellation evaluation shaders.
Using vertex-style stage input is complex, and it doesn't support nesting of structures or arrays. By using raw buffer input instead, we get this support "for free," and everything becomes much simpler. Arguably, this is the way I should've done this in the first place. Eventually, I'd like to make this the default, and then remove the option altogether. (And I still need to do that with `multi_patch_workgroup`...) Should help fix 66 tests in the Vulkan CTS, under the following trees: - `dEQP-VK.pipeline.*.interface_matching.*` - `dEQP-VK.tessellation.user_defined_io.*` - `dEQP-VK.clipping.user_defined.*`
Diffstat (limited to 'spirv_msl.hpp')
-rw-r--r--spirv_msl.hpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/spirv_msl.hpp b/spirv_msl.hpp
index a848f9b5..9bf7672b 100644
--- a/spirv_msl.hpp
+++ b/spirv_msl.hpp
@@ -306,6 +306,7 @@ public:
uint32_t dynamic_offsets_buffer_index = 23;
uint32_t shader_input_buffer_index = 22;
uint32_t shader_index_buffer_index = 21;
+ uint32_t shader_patch_input_buffer_index = 20;
uint32_t shader_input_wg_index = 0;
uint32_t device_index = 0;
uint32_t enable_frag_output_mask = 0xffffffff;
@@ -387,6 +388,11 @@ public:
// builtins are processed, but should result in more efficient usage of the GPU.
bool multi_patch_workgroup = false;
+ // Use storage buffers instead of vertex-style attributes for tessellation evaluation
+ // input. This may require conversion of inputs in the generated post-tessellation
+ // vertex shader, but allows the use of nested arrays.
+ bool raw_buffer_tese_input = false;
+
// If set, a vertex shader will be compiled as part of a tessellation pipeline.
// It will be translated as a compute kernel, so it can use the global invocation ID
// to index the output buffer.
@@ -820,6 +826,9 @@ protected:
std::string convert_row_major_matrix(std::string exp_str, const SPIRType &exp_type, uint32_t physical_type_id,
bool is_packed) override;
+ bool is_tesc_shader() const;
+ bool is_tese_shader() const;
+
void preprocess_op_codes();
void localize_global_variables();
void extract_global_variables_from_functions();
@@ -876,6 +885,7 @@ protected:
const std::string &var_chain_qual,
uint32_t &location, uint32_t &var_mbr_idx);
void add_tess_level_input_to_interface_block(const std::string &ib_var_ref, SPIRType &ib_type, SPIRVariable &var);
+ void add_tess_level_input(const std::string &base_ref, const std::string &mbr_name, SPIRVariable &var);
void fix_up_interface_member_indices(spv::StorageClass storage, uint32_t ib_type_id);
@@ -1063,6 +1073,8 @@ protected:
VariableID patch_stage_out_var_id = 0;
VariableID stage_in_ptr_var_id = 0;
VariableID stage_out_ptr_var_id = 0;
+ VariableID tess_level_inner_var_id = 0;
+ VariableID tess_level_outer_var_id = 0;
VariableID stage_out_masked_builtin_type_id = 0;
// Handle HLSL-style 0-based vertex/instance index.
@@ -1101,6 +1113,7 @@ protected:
std::string input_wg_var_name = "gl_in";
std::string input_buffer_var_name = "spvIn";
std::string output_buffer_var_name = "spvOut";
+ std::string patch_input_buffer_var_name = "spvPatchIn";
std::string patch_output_buffer_var_name = "spvPatchOut";
std::string tess_factor_buffer_var_name = "spvTessLevel";
std::string index_buffer_var_name = "spvIndices";