|
@@ -324,6 +324,8 @@ public:
|
|
// of the shader with the additional fixed sample mask.
|
|
// of the shader with the additional fixed sample mask.
|
|
uint32_t additional_fixed_sample_mask = 0xffffffff;
|
|
uint32_t additional_fixed_sample_mask = 0xffffffff;
|
|
bool enable_point_size_builtin = true;
|
|
bool enable_point_size_builtin = true;
|
|
|
|
+ bool enable_point_size_default = false;
|
|
|
|
+ float default_point_size = 1.0f;
|
|
bool enable_frag_depth_builtin = true;
|
|
bool enable_frag_depth_builtin = true;
|
|
bool enable_frag_stencil_ref_builtin = true;
|
|
bool enable_frag_stencil_ref_builtin = true;
|
|
bool disable_rasterization = false;
|
|
bool disable_rasterization = false;
|
|
@@ -536,6 +538,14 @@ public:
|
|
// if the fragment does not modify the depth value.
|
|
// if the fragment does not modify the depth value.
|
|
bool input_attachment_is_ds_attachment = false;
|
|
bool input_attachment_is_ds_attachment = false;
|
|
|
|
|
|
|
|
+ // If BuiltInPosition is not written, automatically disable rasterization.
|
|
|
|
+ // The result can be queried with get_is_rasterization_disabled.
|
|
|
|
+ bool auto_disable_rasterization = false;
|
|
|
|
+
|
|
|
|
+ // Use Fast Math pragmas in MSL code, based on SPIR-V float controls and FP ExecutionModes.
|
|
|
|
+ // Requires MSL 3.2 or above, and has no effect with earlier MSL versions.
|
|
|
|
+ bool use_fast_math_pragmas = false;
|
|
|
|
+
|
|
bool is_ios() const
|
|
bool is_ios() const
|
|
{
|
|
{
|
|
return platform == iOS;
|
|
return platform == iOS;
|
|
@@ -756,6 +766,19 @@ public:
|
|
void set_combined_sampler_suffix(const char *suffix);
|
|
void set_combined_sampler_suffix(const char *suffix);
|
|
const char *get_combined_sampler_suffix() const;
|
|
const char *get_combined_sampler_suffix() const;
|
|
|
|
|
|
|
|
+ // Information about specialization constants that are translated into MSL macros
|
|
|
|
+ // instead of using function constant
|
|
|
|
+ // These must only be called after a successful call to CompilerMSL::compile().
|
|
|
|
+ bool specialization_constant_is_macro(uint32_t constant_id) const;
|
|
|
|
+
|
|
|
|
+ // Returns a mask of SPIR-V FP Fast Math Mode flags, that represents the set of flags that can be applied
|
|
|
|
+ // across all floating-point types. Each FPFastMathDefault execution mode operation identifies the flags
|
|
|
|
+ // for one floating-point type, and the value returned here is a bitwise-AND combination across all types.
|
|
|
|
+ // If incl_ops is enabled, the FPFastMathMode of any SPIR-V operations are also included in the bitwise-AND
|
|
|
|
+ // to determine the minimal fast-math that applies to all default execution modes and all operations.
|
|
|
|
+ // The returned value is also affected by execution modes SignedZeroInfNanPreserve and ContractionOff.
|
|
|
|
+ uint32_t get_fp_fast_math_flags(bool incl_ops);
|
|
|
|
+
|
|
protected:
|
|
protected:
|
|
// An enum of SPIR-V functions that are implemented in additional
|
|
// An enum of SPIR-V functions that are implemented in additional
|
|
// source code that is added to the shader if necessary.
|
|
// source code that is added to the shader if necessary.
|
|
@@ -763,6 +786,7 @@ protected:
|
|
{
|
|
{
|
|
SPVFuncImplNone,
|
|
SPVFuncImplNone,
|
|
SPVFuncImplMod,
|
|
SPVFuncImplMod,
|
|
|
|
+ SPVFuncImplSMod,
|
|
SPVFuncImplRadians,
|
|
SPVFuncImplRadians,
|
|
SPVFuncImplDegrees,
|
|
SPVFuncImplDegrees,
|
|
SPVFuncImplFindILsb,
|
|
SPVFuncImplFindILsb,
|
|
@@ -784,12 +808,11 @@ protected:
|
|
SPVFuncImplInverse4x4,
|
|
SPVFuncImplInverse4x4,
|
|
SPVFuncImplInverse3x3,
|
|
SPVFuncImplInverse3x3,
|
|
SPVFuncImplInverse2x2,
|
|
SPVFuncImplInverse2x2,
|
|
- // It is very important that this come before *Swizzle and ChromaReconstruct*, to ensure it's
|
|
|
|
- // emitted before them.
|
|
|
|
- SPVFuncImplForwardArgs,
|
|
|
|
- // Likewise, this must come before *Swizzle.
|
|
|
|
|
|
+ // It is very important that this come before *Swizzle, to ensure it's emitted before them.
|
|
SPVFuncImplGetSwizzle,
|
|
SPVFuncImplGetSwizzle,
|
|
SPVFuncImplTextureSwizzle,
|
|
SPVFuncImplTextureSwizzle,
|
|
|
|
+ SPVFuncImplGatherReturn,
|
|
|
|
+ SPVFuncImplGatherCompareReturn,
|
|
SPVFuncImplGatherSwizzle,
|
|
SPVFuncImplGatherSwizzle,
|
|
SPVFuncImplGatherCompareSwizzle,
|
|
SPVFuncImplGatherCompareSwizzle,
|
|
SPVFuncImplGatherConstOffsets,
|
|
SPVFuncImplGatherConstOffsets,
|
|
@@ -806,6 +829,30 @@ protected:
|
|
SPVFuncImplSubgroupShuffleXor,
|
|
SPVFuncImplSubgroupShuffleXor,
|
|
SPVFuncImplSubgroupShuffleUp,
|
|
SPVFuncImplSubgroupShuffleUp,
|
|
SPVFuncImplSubgroupShuffleDown,
|
|
SPVFuncImplSubgroupShuffleDown,
|
|
|
|
+ SPVFuncImplSubgroupRotate,
|
|
|
|
+ SPVFuncImplSubgroupClusteredAdd,
|
|
|
|
+ SPVFuncImplSubgroupClusteredFAdd = SPVFuncImplSubgroupClusteredAdd,
|
|
|
|
+ SPVFuncImplSubgroupClusteredIAdd = SPVFuncImplSubgroupClusteredAdd,
|
|
|
|
+ SPVFuncImplSubgroupClusteredMul,
|
|
|
|
+ SPVFuncImplSubgroupClusteredFMul = SPVFuncImplSubgroupClusteredMul,
|
|
|
|
+ SPVFuncImplSubgroupClusteredIMul = SPVFuncImplSubgroupClusteredMul,
|
|
|
|
+ SPVFuncImplSubgroupClusteredMin,
|
|
|
|
+ SPVFuncImplSubgroupClusteredFMin = SPVFuncImplSubgroupClusteredMin,
|
|
|
|
+ SPVFuncImplSubgroupClusteredSMin = SPVFuncImplSubgroupClusteredMin,
|
|
|
|
+ SPVFuncImplSubgroupClusteredUMin = SPVFuncImplSubgroupClusteredMin,
|
|
|
|
+ SPVFuncImplSubgroupClusteredMax,
|
|
|
|
+ SPVFuncImplSubgroupClusteredFMax = SPVFuncImplSubgroupClusteredMax,
|
|
|
|
+ SPVFuncImplSubgroupClusteredSMax = SPVFuncImplSubgroupClusteredMax,
|
|
|
|
+ SPVFuncImplSubgroupClusteredUMax = SPVFuncImplSubgroupClusteredMax,
|
|
|
|
+ SPVFuncImplSubgroupClusteredAnd,
|
|
|
|
+ SPVFuncImplSubgroupClusteredBitwiseAnd = SPVFuncImplSubgroupClusteredAnd,
|
|
|
|
+ SPVFuncImplSubgroupClusteredLogicalAnd = SPVFuncImplSubgroupClusteredAnd,
|
|
|
|
+ SPVFuncImplSubgroupClusteredOr,
|
|
|
|
+ SPVFuncImplSubgroupClusteredBitwiseOr = SPVFuncImplSubgroupClusteredOr,
|
|
|
|
+ SPVFuncImplSubgroupClusteredLogicalOr = SPVFuncImplSubgroupClusteredOr,
|
|
|
|
+ SPVFuncImplSubgroupClusteredXor,
|
|
|
|
+ SPVFuncImplSubgroupClusteredBitwiseXor = SPVFuncImplSubgroupClusteredXor,
|
|
|
|
+ SPVFuncImplSubgroupClusteredLogicalXor = SPVFuncImplSubgroupClusteredXor,
|
|
SPVFuncImplQuadBroadcast,
|
|
SPVFuncImplQuadBroadcast,
|
|
SPVFuncImplQuadSwap,
|
|
SPVFuncImplQuadSwap,
|
|
SPVFuncImplReflectScalar,
|
|
SPVFuncImplReflectScalar,
|
|
@@ -841,6 +888,7 @@ protected:
|
|
SPVFuncImplTextureCast,
|
|
SPVFuncImplTextureCast,
|
|
SPVFuncImplMulExtended,
|
|
SPVFuncImplMulExtended,
|
|
SPVFuncImplSetMeshOutputsEXT,
|
|
SPVFuncImplSetMeshOutputsEXT,
|
|
|
|
+ SPVFuncImplAssume,
|
|
};
|
|
};
|
|
|
|
|
|
// If the underlying resource has been used for comparison then duplicate loads of that resource must be too
|
|
// If the underlying resource has been used for comparison then duplicate loads of that resource must be too
|
|
@@ -858,6 +906,11 @@ protected:
|
|
void emit_function_prototype(SPIRFunction &func, const Bitset &return_flags) override;
|
|
void emit_function_prototype(SPIRFunction &func, const Bitset &return_flags) override;
|
|
void emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id) override;
|
|
void emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id) override;
|
|
void emit_subgroup_op(const Instruction &i) override;
|
|
void emit_subgroup_op(const Instruction &i) override;
|
|
|
|
+ void emit_subgroup_cluster_op(uint32_t result_type, uint32_t result_id, uint32_t cluster_size, uint32_t op0,
|
|
|
|
+ const char *op);
|
|
|
|
+ void emit_subgroup_cluster_op_cast(uint32_t result_type, uint32_t result_id, uint32_t cluster_size, uint32_t op0,
|
|
|
|
+ const char *op, SPIRType::BaseType input_type,
|
|
|
|
+ SPIRType::BaseType expected_result_type);
|
|
std::string to_texture_op(const Instruction &i, bool sparse, bool *forward,
|
|
std::string to_texture_op(const Instruction &i, bool sparse, bool *forward,
|
|
SmallVector<uint32_t> &inherited_expressions) override;
|
|
SmallVector<uint32_t> &inherited_expressions) override;
|
|
void emit_fixup() override;
|
|
void emit_fixup() override;
|
|
@@ -872,6 +925,7 @@ protected:
|
|
void emit_mesh_entry_point();
|
|
void emit_mesh_entry_point();
|
|
void emit_mesh_outputs();
|
|
void emit_mesh_outputs();
|
|
void emit_mesh_tasks(SPIRBlock &block) override;
|
|
void emit_mesh_tasks(SPIRBlock &block) override;
|
|
|
|
+ void emit_workgroup_initialization(const SPIRVariable &var) override;
|
|
|
|
|
|
// Allow Metal to use the array<T> template to make arrays a value type
|
|
// Allow Metal to use the array<T> template to make arrays a value type
|
|
std::string type_to_array_glsl(const SPIRType &type, uint32_t variable_id) override;
|
|
std::string type_to_array_glsl(const SPIRType &type, uint32_t variable_id) override;
|
|
@@ -985,6 +1039,7 @@ protected:
|
|
void add_tess_level_input_to_interface_block(const std::string &ib_var_ref, SPIRType &ib_type, SPIRVariable &var);
|
|
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 add_tess_level_input(const std::string &base_ref, const std::string &mbr_name, SPIRVariable &var);
|
|
|
|
|
|
|
|
+ void ensure_struct_members_valid_vecsizes(SPIRType &struct_type, uint32_t &location);
|
|
void fix_up_interface_member_indices(spv::StorageClass storage, uint32_t ib_type_id);
|
|
void fix_up_interface_member_indices(spv::StorageClass storage, uint32_t ib_type_id);
|
|
|
|
|
|
void mark_location_as_used_by_shader(uint32_t location, const SPIRType &type,
|
|
void mark_location_as_used_by_shader(uint32_t location, const SPIRType &type,
|
|
@@ -1069,7 +1124,8 @@ protected:
|
|
bool validate_member_packing_rules_msl(const SPIRType &type, uint32_t index) const;
|
|
bool validate_member_packing_rules_msl(const SPIRType &type, uint32_t index) const;
|
|
std::string get_argument_address_space(const SPIRVariable &argument);
|
|
std::string get_argument_address_space(const SPIRVariable &argument);
|
|
std::string get_type_address_space(const SPIRType &type, uint32_t id, bool argument = false);
|
|
std::string get_type_address_space(const SPIRType &type, uint32_t id, bool argument = false);
|
|
- static bool decoration_flags_signal_volatile(const Bitset &flags);
|
|
|
|
|
|
+ bool decoration_flags_signal_volatile(const Bitset &flags) const;
|
|
|
|
+ bool decoration_flags_signal_coherent(const Bitset &flags) const;
|
|
const char *to_restrict(uint32_t id, bool space);
|
|
const char *to_restrict(uint32_t id, bool space);
|
|
SPIRType &get_stage_in_struct_type();
|
|
SPIRType &get_stage_in_struct_type();
|
|
SPIRType &get_stage_out_struct_type();
|
|
SPIRType &get_stage_out_struct_type();
|
|
@@ -1082,7 +1138,7 @@ protected:
|
|
uint32_t mem_order_1, uint32_t mem_order_2, bool has_mem_order_2, uint32_t op0, uint32_t op1 = 0,
|
|
uint32_t mem_order_1, uint32_t mem_order_2, bool has_mem_order_2, uint32_t op0, uint32_t op1 = 0,
|
|
bool op1_is_pointer = false, bool op1_is_literal = false, uint32_t op2 = 0);
|
|
bool op1_is_pointer = false, bool op1_is_literal = false, uint32_t op2 = 0);
|
|
const char *get_memory_order(uint32_t spv_mem_sem);
|
|
const char *get_memory_order(uint32_t spv_mem_sem);
|
|
- void add_pragma_line(const std::string &line);
|
|
|
|
|
|
+ void add_pragma_line(const std::string &line, bool recompile_on_unique);
|
|
void add_typedef_line(const std::string &line);
|
|
void add_typedef_line(const std::string &line);
|
|
void emit_barrier(uint32_t id_exe_scope, uint32_t id_mem_scope, uint32_t id_mem_sem);
|
|
void emit_barrier(uint32_t id_exe_scope, uint32_t id_mem_scope, uint32_t id_mem_sem);
|
|
bool emit_array_copy(const char *expr, uint32_t lhs_id, uint32_t rhs_id,
|
|
bool emit_array_copy(const char *expr, uint32_t lhs_id, uint32_t rhs_id,
|
|
@@ -1133,12 +1189,13 @@ protected:
|
|
void emit_store_statement(uint32_t lhs_expression, uint32_t rhs_expression) override;
|
|
void emit_store_statement(uint32_t lhs_expression, uint32_t rhs_expression) override;
|
|
|
|
|
|
void analyze_sampled_image_usage();
|
|
void analyze_sampled_image_usage();
|
|
|
|
+ void analyze_workgroup_variables();
|
|
|
|
|
|
bool access_chain_needs_stage_io_builtin_translation(uint32_t base) override;
|
|
bool access_chain_needs_stage_io_builtin_translation(uint32_t base) override;
|
|
bool prepare_access_chain_for_scalar_access(std::string &expr, const SPIRType &type, spv::StorageClass storage,
|
|
bool prepare_access_chain_for_scalar_access(std::string &expr, const SPIRType &type, spv::StorageClass storage,
|
|
bool &is_packed) override;
|
|
bool &is_packed) override;
|
|
void fix_up_interpolant_access_chain(const uint32_t *ops, uint32_t length);
|
|
void fix_up_interpolant_access_chain(const uint32_t *ops, uint32_t length);
|
|
- void check_physical_type_cast(std::string &expr, const SPIRType *type, uint32_t physical_type) override;
|
|
|
|
|
|
+ bool check_physical_type_cast(std::string &expr, const SPIRType *type, uint32_t physical_type) override;
|
|
|
|
|
|
bool emit_tessellation_access_chain(const uint32_t *ops, uint32_t length);
|
|
bool emit_tessellation_access_chain(const uint32_t *ops, uint32_t length);
|
|
bool emit_tessellation_io_load(uint32_t result_type, uint32_t id, uint32_t ptr);
|
|
bool emit_tessellation_io_load(uint32_t result_type, uint32_t id, uint32_t ptr);
|
|
@@ -1164,9 +1221,10 @@ protected:
|
|
std::unordered_map<uint32_t, uint32_t> fragment_output_components;
|
|
std::unordered_map<uint32_t, uint32_t> fragment_output_components;
|
|
std::unordered_map<uint32_t, uint32_t> builtin_to_automatic_input_location;
|
|
std::unordered_map<uint32_t, uint32_t> builtin_to_automatic_input_location;
|
|
std::unordered_map<uint32_t, uint32_t> builtin_to_automatic_output_location;
|
|
std::unordered_map<uint32_t, uint32_t> builtin_to_automatic_output_location;
|
|
- std::set<std::string> pragma_lines;
|
|
|
|
- std::set<std::string> typedef_lines;
|
|
|
|
|
|
+ std::vector<std::string> pragma_lines;
|
|
|
|
+ std::vector<std::string> typedef_lines;
|
|
SmallVector<uint32_t> vars_needing_early_declaration;
|
|
SmallVector<uint32_t> vars_needing_early_declaration;
|
|
|
|
+ std::unordered_set<uint32_t> constant_macro_ids;
|
|
|
|
|
|
std::unordered_map<StageSetBinding, std::pair<MSLResourceBinding, bool>, InternalHasher> resource_bindings;
|
|
std::unordered_map<StageSetBinding, std::pair<MSLResourceBinding, bool>, InternalHasher> resource_bindings;
|
|
std::unordered_map<StageSetBinding, uint32_t, InternalHasher> resource_arg_buff_idx_to_binding_number;
|
|
std::unordered_map<StageSetBinding, uint32_t, InternalHasher> resource_arg_buff_idx_to_binding_number;
|
|
@@ -1210,11 +1268,14 @@ protected:
|
|
bool needs_swizzle_buffer_def = false;
|
|
bool needs_swizzle_buffer_def = false;
|
|
bool used_swizzle_buffer = false;
|
|
bool used_swizzle_buffer = false;
|
|
bool added_builtin_tess_level = false;
|
|
bool added_builtin_tess_level = false;
|
|
|
|
+ bool needs_local_invocation_index = false;
|
|
bool needs_subgroup_invocation_id = false;
|
|
bool needs_subgroup_invocation_id = false;
|
|
bool needs_subgroup_size = false;
|
|
bool needs_subgroup_size = false;
|
|
bool needs_sample_id = false;
|
|
bool needs_sample_id = false;
|
|
bool needs_helper_invocation = false;
|
|
bool needs_helper_invocation = false;
|
|
|
|
+ bool needs_workgroup_zero_init = false;
|
|
bool writes_to_depth = false;
|
|
bool writes_to_depth = false;
|
|
|
|
+ bool writes_to_point_size = false;
|
|
std::string qual_pos_var_name;
|
|
std::string qual_pos_var_name;
|
|
std::string stage_in_var_name = "in";
|
|
std::string stage_in_var_name = "in";
|
|
std::string stage_out_var_name = "out";
|
|
std::string stage_out_var_name = "out";
|
|
@@ -1276,6 +1337,7 @@ protected:
|
|
|
|
|
|
bool suppress_missing_prototypes = false;
|
|
bool suppress_missing_prototypes = false;
|
|
bool suppress_incompatible_pointer_types_discard_qualifiers = false;
|
|
bool suppress_incompatible_pointer_types_discard_qualifiers = false;
|
|
|
|
+ bool suppress_sometimes_unitialized = false;
|
|
|
|
|
|
void add_spv_func_and_recompile(SPVFuncImpl spv_func);
|
|
void add_spv_func_and_recompile(SPVFuncImpl spv_func);
|
|
|
|
|
|
@@ -1308,7 +1370,7 @@ protected:
|
|
}
|
|
}
|
|
|
|
|
|
bool handle(spv::Op opcode, const uint32_t *args, uint32_t length) override;
|
|
bool handle(spv::Op opcode, const uint32_t *args, uint32_t length) override;
|
|
- CompilerMSL::SPVFuncImpl get_spv_func_impl(spv::Op opcode, const uint32_t *args);
|
|
|
|
|
|
+ CompilerMSL::SPVFuncImpl get_spv_func_impl(spv::Op opcode, const uint32_t *args, uint32_t length);
|
|
void check_resource_write(uint32_t var_id);
|
|
void check_resource_write(uint32_t var_id);
|
|
|
|
|
|
CompilerMSL &compiler;
|
|
CompilerMSL &compiler;
|
|
@@ -1319,6 +1381,7 @@ protected:
|
|
bool uses_image_write = false;
|
|
bool uses_image_write = false;
|
|
bool uses_buffer_write = false;
|
|
bool uses_buffer_write = false;
|
|
bool uses_discard = false;
|
|
bool uses_discard = false;
|
|
|
|
+ bool needs_local_invocation_index = false;
|
|
bool needs_subgroup_invocation_id = false;
|
|
bool needs_subgroup_invocation_id = false;
|
|
bool needs_subgroup_size = false;
|
|
bool needs_subgroup_size = false;
|
|
bool needs_sample_id = false;
|
|
bool needs_sample_id = false;
|