Updates to MSL functionality to support PR review feedback.
This commit is contained in:
parent
65cd7eb670
commit
dc69427402
@ -920,9 +920,9 @@ uint64_t Compiler::get_member_decoration_mask(uint32_t id, uint32_t index) const
|
||||
return m.members[index].decoration_flags;
|
||||
}
|
||||
|
||||
bool Compiler::has_member_decoration(uint32_t id, uint32_t index, Decoration decoration)
|
||||
bool Compiler::has_member_decoration(uint32_t id, uint32_t index, Decoration decoration) const
|
||||
{
|
||||
return (get_member_decoration_mask(id, index) & (1ull << decoration));
|
||||
return get_member_decoration_mask(id, index) & (1ull << decoration);
|
||||
}
|
||||
|
||||
void Compiler::unset_member_decoration(uint32_t id, uint32_t index, Decoration decoration)
|
||||
@ -1022,9 +1022,9 @@ uint64_t Compiler::get_decoration_mask(uint32_t id) const
|
||||
return dec.decoration_flags;
|
||||
}
|
||||
|
||||
bool Compiler::has_decoration(uint32_t id, Decoration decoration)
|
||||
bool Compiler::has_decoration(uint32_t id, Decoration decoration) const
|
||||
{
|
||||
return (get_decoration_mask(id) & (1ull << decoration));
|
||||
return get_decoration_mask(id) & (1ull << decoration);
|
||||
}
|
||||
|
||||
uint32_t Compiler::get_decoration(uint32_t id, Decoration decoration) const
|
||||
|
@ -138,7 +138,7 @@ public:
|
||||
uint64_t get_decoration_mask(uint32_t id) const;
|
||||
|
||||
// Returns whether the decoration has been applied to the ID.
|
||||
bool has_decoration(uint32_t id, spv::Decoration decoration);
|
||||
bool has_decoration(uint32_t id, spv::Decoration decoration) const;
|
||||
|
||||
// Gets the value for decorations which take arguments.
|
||||
// If the decoration is a boolean (i.e. spv::DecorationNonWritable),
|
||||
@ -183,7 +183,7 @@ public:
|
||||
uint64_t get_member_decoration_mask(uint32_t id, uint32_t index) const;
|
||||
|
||||
// Returns whether the decoration has been applied to a member of a struct.
|
||||
bool has_member_decoration(uint32_t id, uint32_t index, spv::Decoration decoration);
|
||||
bool has_member_decoration(uint32_t id, uint32_t index, spv::Decoration decoration) const;
|
||||
|
||||
// Similar to set_decoration, but for struct members.
|
||||
void set_member_decoration(uint32_t id, uint32_t index, spv::Decoration decoration, uint32_t argument = 0);
|
||||
|
@ -504,7 +504,7 @@ void CompilerGLSL::emit_struct(SPIRType &type)
|
||||
for (auto &member : type.member_types)
|
||||
{
|
||||
add_member_name(type, i);
|
||||
emit_stuct_member(type, member, i);
|
||||
emit_struct_member(type, member, i);
|
||||
i++;
|
||||
emitted = true;
|
||||
}
|
||||
@ -1104,7 +1104,7 @@ void CompilerGLSL::emit_buffer_block_native(const SPIRVariable &var)
|
||||
for (auto &member : type.member_types)
|
||||
{
|
||||
add_member_name(type, i);
|
||||
emit_stuct_member(type, member, i);
|
||||
emit_struct_member(type, member, i);
|
||||
i++;
|
||||
}
|
||||
|
||||
@ -1194,7 +1194,7 @@ void CompilerGLSL::emit_flattened_io_block(const SPIRVariable &var, const char *
|
||||
// which is not allowed.
|
||||
auto member_name = get_member_name(type.self, i);
|
||||
set_member_name(type.self, i, sanitize_underscores(join(to_name(type.self), "_", member_name)));
|
||||
emit_stuct_member(type, member, i, qual);
|
||||
emit_struct_member(type, member, i, qual);
|
||||
// Restore member name.
|
||||
set_member_name(type.self, i, member_name);
|
||||
i++;
|
||||
@ -1256,7 +1256,7 @@ void CompilerGLSL::emit_interface_block(const SPIRVariable &var)
|
||||
for (auto &member : type.member_types)
|
||||
{
|
||||
add_member_name(type, i);
|
||||
emit_stuct_member(type, member, i);
|
||||
emit_struct_member(type, member, i);
|
||||
i++;
|
||||
}
|
||||
|
||||
@ -5541,8 +5541,8 @@ string CompilerGLSL::variable_decl(const SPIRType &type, const string &name)
|
||||
|
||||
// Emit a structure member. Subclasses may override to modify output,
|
||||
// or to dynamically add a padding member if needed.
|
||||
void CompilerGLSL::emit_stuct_member(const SPIRType &type, const uint32_t member_type_id, uint32_t index,
|
||||
const string &qualifier)
|
||||
void CompilerGLSL::emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index,
|
||||
const string &qualifier)
|
||||
{
|
||||
auto &membertype = get<SPIRType>(member_type_id);
|
||||
|
||||
|
@ -159,8 +159,8 @@ protected:
|
||||
virtual void emit_texture_op(const Instruction &i);
|
||||
virtual std::string type_to_glsl(const SPIRType &type);
|
||||
virtual std::string builtin_to_glsl(spv::BuiltIn builtin);
|
||||
virtual void emit_stuct_member(const SPIRType &type, const uint32_t member_type_id, uint32_t index,
|
||||
const std::string &qualifier = "");
|
||||
virtual void emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index,
|
||||
const std::string &qualifier = "");
|
||||
virtual std::string image_type_glsl(const SPIRType &type);
|
||||
virtual std::string constant_expression(const SPIRConstant &c);
|
||||
std::string constant_op_expression(const SPIRConstantOp &cop);
|
||||
|
@ -471,7 +471,7 @@ void CompilerHLSL::emit_buffer_block(const SPIRVariable &var)
|
||||
for (auto &member : type.member_types)
|
||||
{
|
||||
add_member_name(type, i);
|
||||
emit_stuct_member(type, member, i);
|
||||
emit_struct_member(type, member, i);
|
||||
i++;
|
||||
}
|
||||
end_scope_decl();
|
||||
|
@ -606,7 +606,7 @@ void CompilerMSL::align_struct(SPIRType &ib_type)
|
||||
// pass will mark the packed member, and the second pass will insert a padding member.
|
||||
// If we ever move to a single-pass design, this will break.
|
||||
uint32_t mbr_offset = get_member_decoration(ib_type_id, mbr_idx, DecorationOffset);
|
||||
int32_t gap = mbr_offset - curr_offset;
|
||||
int32_t gap = (int32_t)mbr_offset - (int32_t)curr_offset;
|
||||
if (gap > 0)
|
||||
{
|
||||
// Since MSL and SPIR-V have slightly different struct member alignment and
|
||||
@ -1333,8 +1333,8 @@ void CompilerMSL::emit_fixup()
|
||||
}
|
||||
|
||||
// Emit a structure member, padding and packing to maintain the correct memeber alignments.
|
||||
void CompilerMSL::emit_stuct_member(const SPIRType &type, const uint32_t member_type_id, uint32_t index,
|
||||
const string &qualifier)
|
||||
void CompilerMSL::emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index,
|
||||
const string &qualifier)
|
||||
{
|
||||
auto &membertype = get<SPIRType>(member_type_id);
|
||||
|
||||
@ -2126,7 +2126,6 @@ size_t CompilerMSL::get_declared_type_size(uint32_t type_id, uint64_t dec_mask)
|
||||
case SPIRType::SampledImage:
|
||||
case SPIRType::Sampler:
|
||||
SPIRV_CROSS_THROW("Querying size of opaque object.");
|
||||
return 4; // A pointer
|
||||
|
||||
case SPIRType::Struct:
|
||||
return get_declared_struct_size(type);
|
||||
@ -2196,7 +2195,6 @@ size_t CompilerMSL::get_declared_type_alignment(uint32_t type_id, uint64_t dec_m
|
||||
case SPIRType::SampledImage:
|
||||
case SPIRType::Sampler:
|
||||
SPIRV_CROSS_THROW("Querying alignment of opaque object.");
|
||||
return 4; // A pointer
|
||||
|
||||
case SPIRType::Struct:
|
||||
return 16; // Per Vulkan spec section 14.5.4
|
||||
|
@ -69,7 +69,7 @@ struct MSLResourceBinding
|
||||
};
|
||||
|
||||
// Tracks the type ID and member index of a struct member
|
||||
typedef uint64_t MSLStructMemberKey;
|
||||
using MSLStructMemberKey = uint64_t;
|
||||
|
||||
// Special constant used in a MSLResourceBinding desc_set
|
||||
// element to indicate the bindings for the push constants.
|
||||
@ -110,8 +110,8 @@ protected:
|
||||
void emit_function_prototype(SPIRFunction &func, uint64_t 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_fixup() override;
|
||||
void emit_stuct_member(const SPIRType &type, const uint32_t member_type_id, uint32_t index,
|
||||
const std::string &qualifier = "") override;
|
||||
void emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index,
|
||||
const std::string &qualifier = "") override;
|
||||
std::string type_to_glsl(const SPIRType &type) override;
|
||||
std::string image_type_glsl(const SPIRType &type) override;
|
||||
std::string builtin_to_glsl(spv::BuiltIn builtin) override;
|
||||
|
Loading…
Reference in New Issue
Block a user