MSL: Non-functional fixes from PR code review.

This commit is contained in:
Bill Hollings 2022-02-28 18:18:07 -05:00 committed by Hans-Kristian Arntzen
parent 3d4daab29d
commit 3bb3b22b34
2 changed files with 12 additions and 8 deletions

View File

@ -2611,7 +2611,7 @@ void CompilerMSL::add_composite_member_variable_to_interface_block(StorageClass
// Once we determine the location of the first member within nested structures, // Once we determine the location of the first member within nested structures,
// from a var of the topmost structure, the remaining flattened members of the // from a var of the topmost structure, the remaining flattened members of the
// nested structures will have consecutive location values. // nested structures will have consecutive location values.
if (!is_builtin && location) if (!is_builtin && location != UINT32_MAX)
{ {
set_member_decoration(ib_type.self, ib_mbr_idx, DecorationLocation, location); set_member_decoration(ib_type.self, ib_mbr_idx, DecorationLocation, location);
mark_location_as_used_by_shader(location, *usable_type, storage); mark_location_as_used_by_shader(location, *usable_type, storage);
@ -2784,7 +2784,7 @@ void CompilerMSL::add_plain_member_variable_to_interface_block(StorageClass stor
// Once we determine the location of the first member within nested structures, // Once we determine the location of the first member within nested structures,
// from a var of the topmost structure, the remaining flattened members of the // from a var of the topmost structure, the remaining flattened members of the
// nested structures will have consecutive location values. // nested structures will have consecutive location values.
if (!is_builtin && location) if (!is_builtin && location != UINT32_MAX)
{ {
set_member_decoration(ib_type.self, ib_mbr_idx, DecorationLocation, location); set_member_decoration(ib_type.self, ib_mbr_idx, DecorationLocation, location);
mark_location_as_used_by_shader(location, get<SPIRType>(mbr_type_id), storage); mark_location_as_used_by_shader(location, get<SPIRType>(mbr_type_id), storage);
@ -3147,7 +3147,7 @@ void CompilerMSL::add_variable_to_interface_block(StorageClass storage, const st
else else
{ {
bool masked_block = false; bool masked_block = false;
uint32_t location = 0; uint32_t location = UINT32_MAX;
uint32_t var_mbr_idx = 0; uint32_t var_mbr_idx = 0;
uint32_t elem_cnt = 1; uint32_t elem_cnt = 1;
if (is_matrix(var_type)) if (is_matrix(var_type))
@ -3176,7 +3176,7 @@ void CompilerMSL::add_variable_to_interface_block(StorageClass storage, const st
if (storage == StorageClassOutput && is_stage_output_block_member_masked(var, mbr_idx, meta.strip_array)) if (storage == StorageClassOutput && is_stage_output_block_member_masked(var, mbr_idx, meta.strip_array))
{ {
location++; // Skip this location location = UINT32_MAX; // Skip this member and resolve location again on next var member
if (is_block) if (is_block)
masked_block = true; masked_block = true;
@ -3220,8 +3220,12 @@ void CompilerMSL::add_variable_to_interface_block(StorageClass storage, const st
if (builtin == BuiltInClipDistance || builtin == BuiltInCullDistance) if (builtin == BuiltInClipDistance || builtin == BuiltInCullDistance)
is_builtin = false; is_builtin = false;
string mbr_name_qual = to_name(var_type.self) + (elem_cnt == 1 ? "" : join("_", elem_idx)); string mbr_name_qual = to_name(var_type.self);
string var_chain_qual = to_name(var.self) + (elem_cnt == 1 ? "" : join("[", elem_idx, "]")); string var_chain_qual = to_name(var.self);
if (elem_cnt > 1) {
mbr_name_qual += join("_", elem_idx);
var_chain_qual += join("[", elem_idx, "]");
}
if ((!is_builtin || attribute_load_store) && storage_is_stage_io && is_composite_type) if ((!is_builtin || attribute_load_store) && storage_is_stage_io && is_composite_type)
{ {
@ -13047,7 +13051,7 @@ string CompilerMSL::to_name(uint32_t id, bool allow_alias) const
} }
// Appends the name of the member to the variable qualifier string, except for Builtins. // Appends the name of the member to the variable qualifier string, except for Builtins.
string CompilerMSL::append_member_name(const string qualifier, const SPIRType &type, uint32_t index) string CompilerMSL::append_member_name(const string &qualifier, const SPIRType &type, uint32_t index)
{ {
// Don't qualify Builtin names because they are unique and are treated as such when building expressions // Don't qualify Builtin names because they are unique and are treated as such when building expressions
BuiltIn builtin = BuiltInMax; BuiltIn builtin = BuiltInMax;

View File

@ -871,7 +871,7 @@ protected:
std::string entry_point_arg_stage_in(); std::string entry_point_arg_stage_in();
void entry_point_args_builtin(std::string &args); void entry_point_args_builtin(std::string &args);
void entry_point_args_discrete_descriptors(std::string &args); void entry_point_args_discrete_descriptors(std::string &args);
std::string append_member_name(const std::string qualifier, const SPIRType &type, uint32_t index); std::string append_member_name(const std::string &qualifier, const SPIRType &type, uint32_t index);
std::string ensure_valid_name(std::string name, std::string pfx); std::string ensure_valid_name(std::string name, std::string pfx);
std::string to_sampler_expression(uint32_t id); std::string to_sampler_expression(uint32_t id);
std::string to_swizzle_expression(uint32_t id); std::string to_swizzle_expression(uint32_t id);