MSL: Refactor out location consumption count computation.
This commit is contained in:
parent
6f1f6775f3
commit
aa271c1460
@ -100,7 +100,7 @@ void CompilerMSL::set_argument_buffer_device_address_space(uint32_t desc_set, bo
|
||||
|
||||
bool CompilerMSL::is_msl_shader_input_used(uint32_t location)
|
||||
{
|
||||
return inputs_in_use.count(location) != 0;
|
||||
return location_inputs_in_use.count(location) != 0;
|
||||
}
|
||||
|
||||
bool CompilerMSL::is_msl_resource_binding_used(ExecutionModel model, uint32_t desc_set, uint32_t binding) const
|
||||
@ -1801,34 +1801,28 @@ void CompilerMSL::mark_as_packable(SPIRType &type)
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t CompilerMSL::type_to_location_count(const SPIRType &type) const
|
||||
{
|
||||
// In MSL, we cannot place structs in any context where we need locations.
|
||||
assert(type.basetype != SPIRType::Struct);
|
||||
|
||||
uint32_t dim = 1;
|
||||
for (uint32_t i = 0; i < type.array.size(); i++)
|
||||
dim *= to_array_size_literal(type, i);
|
||||
|
||||
uint32_t count = dim * type.columns;
|
||||
return count;
|
||||
}
|
||||
|
||||
// If a shader input exists at the location, it is marked as being used by this shader
|
||||
void CompilerMSL::mark_location_as_used_by_shader(uint32_t location, const SPIRType &type, StorageClass storage)
|
||||
{
|
||||
if (storage != StorageClassInput)
|
||||
return;
|
||||
if (is_array(type))
|
||||
{
|
||||
uint32_t dim = 1;
|
||||
for (uint32_t i = 0; i < type.array.size(); i++)
|
||||
dim *= to_array_size_literal(type, i);
|
||||
for (uint32_t i = 0; i < dim; i++)
|
||||
{
|
||||
if (is_matrix(type))
|
||||
{
|
||||
for (uint32_t j = 0; j < type.columns; j++)
|
||||
inputs_in_use.insert(location++);
|
||||
}
|
||||
else
|
||||
inputs_in_use.insert(location++);
|
||||
}
|
||||
}
|
||||
else if (is_matrix(type))
|
||||
{
|
||||
for (uint32_t i = 0; i < type.columns; i++)
|
||||
inputs_in_use.insert(location + i);
|
||||
}
|
||||
else
|
||||
inputs_in_use.insert(location);
|
||||
|
||||
uint32_t count = type_to_location_count(type);
|
||||
for (uint32_t i = 0; i < count; i++)
|
||||
location_inputs_in_use.insert(location + i);
|
||||
}
|
||||
|
||||
uint32_t CompilerMSL::get_target_components_for_fragment_location(uint32_t location) const
|
||||
|
@ -929,13 +929,14 @@ protected:
|
||||
// Must be ordered to ensure declarations are in a specific order.
|
||||
std::map<uint32_t, MSLShaderInput> inputs_by_location;
|
||||
std::unordered_map<uint32_t, MSLShaderInput> inputs_by_builtin;
|
||||
std::unordered_set<uint32_t> inputs_in_use;
|
||||
std::unordered_set<uint32_t> location_inputs_in_use;
|
||||
std::unordered_map<uint32_t, uint32_t> fragment_output_components;
|
||||
std::set<std::string> pragma_lines;
|
||||
std::set<std::string> typedef_lines;
|
||||
SmallVector<uint32_t> vars_needing_early_declaration;
|
||||
|
||||
std::unordered_map<StageSetBinding, std::pair<MSLResourceBinding, bool>, InternalHasher> resource_bindings;
|
||||
uint32_t type_to_location_count(const SPIRType &type) const;
|
||||
|
||||
uint32_t next_metal_resource_index_buffer = 0;
|
||||
uint32_t next_metal_resource_index_texture = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user