Syntax and format updates from code review.

This commit is contained in:
Bill Hollings 2020-11-02 22:15:20 -05:00
parent 7f67abe0fe
commit 4bdd49df3f
2 changed files with 7 additions and 7 deletions

View File

@ -103,12 +103,14 @@ bool CompilerMSL::is_msl_resource_binding_used(ExecutionModel model, uint32_t de
return itr != end(resource_bindings) && itr->second.second; return itr != end(resource_bindings) && itr->second.second;
} }
// Returns the size of the array of resources used by the variable with the specified id.
// The returned value is retrieved from the resource binding added using add_msl_resource_binding().
uint32_t CompilerMSL::get_resource_array_size(uint32_t id) const uint32_t CompilerMSL::get_resource_array_size(uint32_t id) const
{ {
StageSetBinding tuple = { get_entry_point().model, get_decoration(id, DecorationDescriptorSet), StageSetBinding tuple = { get_entry_point().model, get_decoration(id, DecorationDescriptorSet),
get_decoration(id, DecorationBinding) }; get_decoration(id, DecorationBinding) };
auto itr = resource_bindings.find(tuple); auto itr = resource_bindings.find(tuple);
return itr != end(resource_bindings) ? itr->second.first.size : 0; return itr != end(resource_bindings) ? itr->second.first.count : 0;
} }
uint32_t CompilerMSL::get_automatic_msl_resource_binding(uint32_t id) const uint32_t CompilerMSL::get_automatic_msl_resource_binding(uint32_t id) const

View File

@ -60,10 +60,11 @@ struct MSLShaderInput
// Matches the binding index of a MSL resource for a binding within a descriptor set. // Matches the binding index of a MSL resource for a binding within a descriptor set.
// Taken together, the stage, desc_set and binding combine to form a reference to a resource // Taken together, the stage, desc_set and binding combine to form a reference to a resource
// descriptor used in a particular shading stage. The size element indicates the number of // descriptor used in a particular shading stage. The count field indicates the number of
// resources consumed by this binding, if the binding represents an array of resources. // resources consumed by this binding, if the binding represents an array of resources.
// If the resource array is a run-time-sized array, which are legal in GLSL or SPIR-V, this value // If the resource array is a run-time-sized array, which are legal in GLSL or SPIR-V, this value
// will be used to declare the array size in MSL, which does not support run-time-sized arrays. // will be used to declare the array size in MSL, which does not support run-time-sized arrays.
// For resources that are not held in a run-time-sized array, the count field does not need to be populated.
// If using MSL 2.0 argument buffers, the descriptor set is not marked as a discrete descriptor set, // If using MSL 2.0 argument buffers, the descriptor set is not marked as a discrete descriptor set,
// and (for iOS only) the resource is not a storage image (sampled != 2), the binding reference we // and (for iOS only) the resource is not a storage image (sampled != 2), the binding reference we
// remap to will become an [[id(N)]] attribute within the "descriptor set" argument buffer structure. // remap to will become an [[id(N)]] attribute within the "descriptor set" argument buffer structure.
@ -74,7 +75,7 @@ struct MSLResourceBinding
spv::ExecutionModel stage = spv::ExecutionModelMax; spv::ExecutionModel stage = spv::ExecutionModelMax;
uint32_t desc_set = 0; uint32_t desc_set = 0;
uint32_t binding = 0; uint32_t binding = 0;
uint32_t size = 0; uint32_t count = 0;
uint32_t msl_buffer = 0; uint32_t msl_buffer = 0;
uint32_t msl_texture = 0; uint32_t msl_texture = 0;
uint32_t msl_sampler = 0; uint32_t msl_sampler = 0;
@ -521,10 +522,6 @@ public:
// by remap_constexpr_sampler(_by_binding). // by remap_constexpr_sampler(_by_binding).
bool is_msl_resource_binding_used(spv::ExecutionModel model, uint32_t set, uint32_t binding) const; bool is_msl_resource_binding_used(spv::ExecutionModel model, uint32_t set, uint32_t binding) const;
// Returns the size of the array of resources used by the variable with the specified id.
// The returned value is retrieved from the resource binding added using add_msl_resource_binding().
uint32_t get_resource_array_size(uint32_t id) const;
// This must only be called after a successful call to CompilerMSL::compile(). // This must only be called after a successful call to CompilerMSL::compile().
// For a variable resource ID obtained through reflection API, report the automatically assigned resource index. // For a variable resource ID obtained through reflection API, report the automatically assigned resource index.
// If the descriptor set was part of an argument buffer, report the [[id(N)]], // If the descriptor set was part of an argument buffer, report the [[id(N)]],
@ -764,6 +761,7 @@ protected:
void emit_specialization_constants_and_structs(); void emit_specialization_constants_and_structs();
void emit_interface_block(uint32_t ib_var_id); void emit_interface_block(uint32_t ib_var_id);
bool maybe_emit_array_assignment(uint32_t id_lhs, uint32_t id_rhs); bool maybe_emit_array_assignment(uint32_t id_lhs, uint32_t id_rhs);
uint32_t get_resource_array_size(uint32_t id) const;
void fix_up_shader_inputs_outputs(); void fix_up_shader_inputs_outputs();