Added an Op field to SPIRType
This field allows telling what the 'head' of the type is, without having to look at parent types.
This commit is contained in:
parent
a3da0e87fa
commit
950cad5913
@ -548,6 +548,9 @@ struct SPIRType : IVariant
|
||||
type = TypeType
|
||||
};
|
||||
|
||||
spv::Op op = spv::Op::OpNop;
|
||||
SPIRType(spv::Op op_) : op(op_) {}
|
||||
|
||||
enum BaseType
|
||||
{
|
||||
Unknown,
|
||||
|
@ -2738,8 +2738,8 @@ void Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(SPIR
|
||||
auto ptr_type_id = id + 1;
|
||||
auto combined_id = id + 2;
|
||||
auto &base = compiler.expression_type(image_id);
|
||||
auto &type = compiler.set<SPIRType>(type_id);
|
||||
auto &ptr_type = compiler.set<SPIRType>(ptr_type_id);
|
||||
auto &type = compiler.set<SPIRType>(type_id, spv::Op::OpTypeSampledImage);
|
||||
auto &ptr_type = compiler.set<SPIRType>(ptr_type_id, spv::Op::OpTypePointer);
|
||||
|
||||
type = base;
|
||||
type.self = type_id;
|
||||
@ -2998,7 +2998,7 @@ bool Compiler::CombinedImageSamplerHandler::handle(Op opcode, const uint32_t *ar
|
||||
{
|
||||
// Have to invent the sampled image type.
|
||||
sampled_type = compiler.ir.increase_bound_by(1);
|
||||
auto &type = compiler.set<SPIRType>(sampled_type);
|
||||
auto &type = compiler.set<SPIRType>(sampled_type, spv::Op::OpTypeSampledImage);
|
||||
type = compiler.expression_type(args[2]);
|
||||
type.self = sampled_type;
|
||||
type.basetype = SPIRType::SampledImage;
|
||||
@ -3017,7 +3017,7 @@ bool Compiler::CombinedImageSamplerHandler::handle(Op opcode, const uint32_t *ar
|
||||
|
||||
// Make a new type, pointer to OpTypeSampledImage, so we can make a variable of this type.
|
||||
// We will probably have this type lying around, but it doesn't hurt to make duplicates for internal purposes.
|
||||
auto &type = compiler.set<SPIRType>(type_id);
|
||||
auto &type = compiler.set<SPIRType>(type_id, spv::Op::OpTypePointer);
|
||||
auto &base = compiler.get<SPIRType>(sampled_type);
|
||||
type = base;
|
||||
type.pointer = true;
|
||||
@ -3063,11 +3063,10 @@ VariableID Compiler::build_dummy_sampler_for_combined_images()
|
||||
auto ptr_type_id = offset + 1;
|
||||
auto var_id = offset + 2;
|
||||
|
||||
SPIRType sampler_type;
|
||||
auto &sampler = set<SPIRType>(type_id);
|
||||
auto &sampler = set<SPIRType>(type_id, spv::Op::OpTypeSampler);
|
||||
sampler.basetype = SPIRType::Sampler;
|
||||
|
||||
auto &ptr_sampler = set<SPIRType>(ptr_type_id);
|
||||
auto &ptr_sampler = set<SPIRType>(ptr_type_id, spv::Op::OpTypePointer);
|
||||
ptr_sampler = sampler;
|
||||
ptr_sampler.self = type_id;
|
||||
ptr_sampler.storage = StorageClassUniformConstant;
|
||||
|
@ -223,7 +223,7 @@ static const char *to_pls_layout(PlsFormat format)
|
||||
}
|
||||
}
|
||||
|
||||
static SPIRType::BaseType pls_format_to_basetype(PlsFormat format)
|
||||
static std::tuple<spv::Op, SPIRType::BaseType> pls_format_to_basetype(PlsFormat format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
@ -234,17 +234,17 @@ static SPIRType::BaseType pls_format_to_basetype(PlsFormat format)
|
||||
case PlsRGB10A2:
|
||||
case PlsRGBA8:
|
||||
case PlsRG16:
|
||||
return SPIRType::Float;
|
||||
return std::make_tuple(spv::OpTypeFloat, SPIRType::Float);
|
||||
|
||||
case PlsRGBA8I:
|
||||
case PlsRG16I:
|
||||
return SPIRType::Int;
|
||||
return std::make_tuple(spv::OpTypeInt, SPIRType::Int);
|
||||
|
||||
case PlsRGB10A2UI:
|
||||
case PlsRGBA8UI:
|
||||
case PlsRG16UI:
|
||||
case PlsR32UI:
|
||||
return SPIRType::UInt;
|
||||
return std::make_tuple(spv::OpTypeInt, SPIRType::UInt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2489,7 +2489,7 @@ void CompilerGLSL::emit_buffer_block_flattened(const SPIRVariable &var)
|
||||
SPIRType::BaseType basic_type;
|
||||
if (get_common_basic_type(type, basic_type))
|
||||
{
|
||||
SPIRType tmp;
|
||||
SPIRType tmp { spv::Op::OpTypeVector };
|
||||
tmp.basetype = basic_type;
|
||||
tmp.vecsize = 4;
|
||||
if (basic_type != SPIRType::Float && basic_type != SPIRType::Int && basic_type != SPIRType::UInt)
|
||||
@ -3949,10 +3949,9 @@ void CompilerGLSL::emit_output_variable_initializer(const SPIRVariable &var)
|
||||
if (is_control_point)
|
||||
{
|
||||
uint32_t ids = ir.increase_bound_by(3);
|
||||
SPIRType uint_type;
|
||||
auto& uint_type = set<SPIRType>(ids, spv::Op::OpTypeInt);
|
||||
uint_type.basetype = SPIRType::UInt;
|
||||
uint_type.width = 32;
|
||||
set<SPIRType>(ids, uint_type);
|
||||
set<SPIRExpression>(ids + 1, builtin_to_glsl(BuiltInInvocationId, StorageClassInput), ids, true);
|
||||
set<SPIRConstant>(ids + 2, ids, i, false);
|
||||
invocation_id = ids + 1;
|
||||
@ -5148,7 +5147,7 @@ string CompilerGLSL::to_rerolled_array_expression(const SPIRType &parent_type,
|
||||
type.basetype == SPIRType::Boolean &&
|
||||
backend.boolean_in_struct_remapped_type != SPIRType::Boolean;
|
||||
|
||||
SPIRType tmp_type;
|
||||
SPIRType tmp_type { spv::Op::OpNop };
|
||||
if (remapped_boolean)
|
||||
{
|
||||
tmp_type = get<SPIRType>(type.parent_type);
|
||||
@ -5777,7 +5776,7 @@ string CompilerGLSL::constant_expression(const SPIRConstant &c,
|
||||
type_is_top_level_array(type) && !array_type_decays)
|
||||
{
|
||||
const auto *p_type = &type;
|
||||
SPIRType tmp_type;
|
||||
SPIRType tmp_type { spv::Op::OpNop };
|
||||
|
||||
if (inside_struct_scope &&
|
||||
backend.boolean_in_struct_remapped_type != SPIRType::Boolean &&
|
||||
@ -5916,7 +5915,7 @@ string CompilerGLSL::convert_half_to_string(const SPIRConstant &c, uint32_t col,
|
||||
// of complicated workarounds, just value-cast to the half type always.
|
||||
if (std::isnan(float_value) || std::isinf(float_value))
|
||||
{
|
||||
SPIRType type;
|
||||
SPIRType type { spv::Op::OpTypeFloat };
|
||||
type.basetype = SPIRType::Half;
|
||||
type.vecsize = 1;
|
||||
type.columns = 1;
|
||||
@ -5932,7 +5931,7 @@ string CompilerGLSL::convert_half_to_string(const SPIRConstant &c, uint32_t col,
|
||||
}
|
||||
else
|
||||
{
|
||||
SPIRType type;
|
||||
SPIRType type { spv::Op::OpTypeFloat };
|
||||
type.basetype = SPIRType::Half;
|
||||
type.vecsize = 1;
|
||||
type.columns = 1;
|
||||
@ -5952,8 +5951,8 @@ string CompilerGLSL::convert_float_to_string(const SPIRConstant &c, uint32_t col
|
||||
// Use special representation.
|
||||
if (!is_legacy())
|
||||
{
|
||||
SPIRType out_type;
|
||||
SPIRType in_type;
|
||||
SPIRType out_type { spv::Op::OpTypeFloat };
|
||||
SPIRType in_type { spv::Op::OpTypeInt };
|
||||
out_type.basetype = SPIRType::Float;
|
||||
in_type.basetype = SPIRType::UInt;
|
||||
out_type.vecsize = 1;
|
||||
@ -6022,8 +6021,8 @@ std::string CompilerGLSL::convert_double_to_string(const SPIRConstant &c, uint32
|
||||
// Use special representation.
|
||||
if (!is_legacy())
|
||||
{
|
||||
SPIRType out_type;
|
||||
SPIRType in_type;
|
||||
SPIRType out_type { spv::Op::OpTypeFloat };
|
||||
SPIRType in_type { spv::Op::OpTypeInt };
|
||||
out_type.basetype = SPIRType::Double;
|
||||
in_type.basetype = SPIRType::UInt64;
|
||||
out_type.vecsize = 1;
|
||||
@ -6731,7 +6730,7 @@ SPIRType CompilerGLSL::binary_op_bitcast_helper(string &cast_op0, string &cast_o
|
||||
|
||||
// Create a fake type so we can bitcast to it.
|
||||
// We only deal with regular arithmetic types here like int, uints and so on.
|
||||
SPIRType expected_type;
|
||||
SPIRType expected_type = type0.op;
|
||||
expected_type.basetype = input_type;
|
||||
expected_type.vecsize = type0.vecsize;
|
||||
expected_type.columns = type0.columns;
|
||||
@ -7085,7 +7084,9 @@ void CompilerGLSL::emit_bitfield_insert_op(uint32_t result_type, uint32_t result
|
||||
auto op2_expr = to_unpacked_expression(op2);
|
||||
auto op3_expr = to_unpacked_expression(op3);
|
||||
|
||||
SPIRType target_type;
|
||||
assert(offset_count_type == SPIRType::UInt || offset_count_type == SPIRType::Int);
|
||||
SPIRType target_type { spv::Op::OpTypeInt };
|
||||
target_type.width = 32;
|
||||
target_type.vecsize = 1;
|
||||
target_type.basetype = offset_count_type;
|
||||
|
||||
@ -15340,9 +15341,16 @@ string CompilerGLSL::pls_decl(const PlsRemap &var)
|
||||
{
|
||||
auto &variable = get<SPIRVariable>(var.id);
|
||||
|
||||
SPIRType type;
|
||||
type.vecsize = pls_format_to_components(var.format);
|
||||
type.basetype = pls_format_to_basetype(var.format);
|
||||
auto op_and_basetype = pls_format_to_basetype(var.format);
|
||||
|
||||
SPIRType type { std::get<0>(op_and_basetype) };
|
||||
type.basetype = std::get<1>(op_and_basetype);
|
||||
auto vecsize = pls_format_to_components(var.format);
|
||||
if (vecsize > 1)
|
||||
{
|
||||
type.op = OpTypeVector;
|
||||
type.vecsize = vecsize;
|
||||
}
|
||||
|
||||
return join(to_pls_layout(var.format), to_pls_qualifiers_glsl(variable), type_to_glsl(type), " ",
|
||||
to_name(variable.self));
|
||||
@ -17653,7 +17661,7 @@ bool CompilerGLSL::unroll_array_to_complex_store(uint32_t target_id, uint32_t so
|
||||
else
|
||||
array_expr = to_expression(type.array.back());
|
||||
|
||||
SPIRType target_type;
|
||||
SPIRType target_type { spv::Op::OpTypeInt };
|
||||
target_type.basetype = SPIRType::Int;
|
||||
|
||||
statement("for (int i = 0; i < int(", array_expr, "); i++)");
|
||||
@ -17718,7 +17726,7 @@ void CompilerGLSL::unroll_array_from_complex_load(uint32_t target_id, uint32_t s
|
||||
statement(new_expr, "[i] = gl_in[i].", expr, ";");
|
||||
else if (is_sample_mask)
|
||||
{
|
||||
SPIRType target_type;
|
||||
SPIRType target_type { spv::Op::OpTypeInt };
|
||||
target_type.basetype = SPIRType::Int;
|
||||
statement(new_expr, "[i] = ", bitcast_expression(target_type, type.basetype, join(expr, "[i]")), ";");
|
||||
}
|
||||
|
@ -2432,7 +2432,7 @@ void CompilerHLSL::analyze_meshlet_writes()
|
||||
uint32_t op_ptr = op_type + 2;
|
||||
uint32_t op_var = op_type + 3;
|
||||
|
||||
auto &type = set<SPIRType>(op_type);
|
||||
auto &type = set<SPIRType>(op_type, spv::Op::OpTypeStruct);
|
||||
type.basetype = SPIRType::Struct;
|
||||
set_name(op_type, block_name);
|
||||
set_decoration(op_type, DecorationBlock);
|
||||
@ -4508,7 +4508,7 @@ void CompilerHLSL::read_access_chain(string *expr, const string &lhs, const SPIR
|
||||
{
|
||||
auto &type = get<SPIRType>(chain.basetype);
|
||||
|
||||
SPIRType target_type;
|
||||
SPIRType target_type { is_scalar(type) ? spv::Op::OpTypeInt : type.op };
|
||||
target_type.basetype = SPIRType::UInt;
|
||||
target_type.vecsize = type.vecsize;
|
||||
target_type.columns = type.columns;
|
||||
@ -4755,7 +4755,7 @@ void CompilerHLSL::write_access_chain_array(const SPIRAccessChain &chain, uint32
|
||||
|
||||
uint32_t id = ir.increase_bound_by(2);
|
||||
uint32_t int_type_id = id + 1;
|
||||
SPIRType int_type;
|
||||
SPIRType int_type { spv::Op::OpTypeInt };
|
||||
int_type.basetype = SPIRType::Int;
|
||||
int_type.width = 32;
|
||||
set<SPIRType>(int_type_id, int_type);
|
||||
@ -4843,7 +4843,7 @@ void CompilerHLSL::write_access_chain(const SPIRAccessChain &chain, uint32_t val
|
||||
// Make sure we trigger a read of the constituents in the access chain.
|
||||
track_expression_read(chain.self);
|
||||
|
||||
SPIRType target_type;
|
||||
SPIRType target_type { is_scalar(type) ? spv::Op::OpTypeInt : type.op };
|
||||
target_type.basetype = SPIRType::UInt;
|
||||
target_type.vecsize = type.vecsize;
|
||||
target_type.columns = type.columns;
|
||||
@ -6583,14 +6583,14 @@ VariableID CompilerHLSL::remap_num_workgroups_builtin()
|
||||
uint32_t block_pointer_type_id = offset + 2;
|
||||
uint32_t variable_id = offset + 3;
|
||||
|
||||
SPIRType uint_type;
|
||||
SPIRType uint_type { spv::Op::OpTypeVector };
|
||||
uint_type.basetype = SPIRType::UInt;
|
||||
uint_type.width = 32;
|
||||
uint_type.vecsize = 3;
|
||||
uint_type.columns = 1;
|
||||
set<SPIRType>(uint_type_id, uint_type);
|
||||
|
||||
SPIRType block_type;
|
||||
SPIRType block_type { spv::Op::OpTypeStruct };
|
||||
block_type.basetype = SPIRType::Struct;
|
||||
block_type.member_types.push_back(uint_type_id);
|
||||
set<SPIRType>(block_type_id, block_type);
|
||||
|
@ -478,13 +478,13 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 2;
|
||||
|
||||
// Create gl_FragCoord.
|
||||
SPIRType vec4_type;
|
||||
SPIRType vec4_type { spv::Op::OpTypeVector };
|
||||
vec4_type.basetype = SPIRType::Float;
|
||||
vec4_type.width = 32;
|
||||
vec4_type.vecsize = 4;
|
||||
set<SPIRType>(type_id, vec4_type);
|
||||
|
||||
SPIRType vec4_type_ptr;
|
||||
SPIRType vec4_type_ptr { spv::Op::OpTypePointer };
|
||||
vec4_type_ptr = vec4_type;
|
||||
vec4_type_ptr.pointer = true;
|
||||
vec4_type_ptr.pointer_depth++;
|
||||
@ -506,7 +506,7 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 1;
|
||||
|
||||
// Create gl_Layer.
|
||||
SPIRType uint_type_ptr;
|
||||
SPIRType uint_type_ptr { spv::Op::OpTypePointer };
|
||||
uint_type_ptr = get_uint_type();
|
||||
uint_type_ptr.pointer = true;
|
||||
uint_type_ptr.pointer_depth++;
|
||||
@ -528,7 +528,7 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 1;
|
||||
|
||||
// Create gl_ViewIndex.
|
||||
SPIRType uint_type_ptr;
|
||||
SPIRType uint_type_ptr { spv::Op::OpTypePointer };
|
||||
uint_type_ptr = get_uint_type();
|
||||
uint_type_ptr.pointer = true;
|
||||
uint_type_ptr.pointer_depth++;
|
||||
@ -551,7 +551,7 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 1;
|
||||
|
||||
// Create gl_SampleID.
|
||||
SPIRType uint_type_ptr;
|
||||
SPIRType uint_type_ptr { spv::Op::OpTypePointer };
|
||||
uint_type_ptr = get_uint_type();
|
||||
uint_type_ptr.pointer = true;
|
||||
uint_type_ptr.pointer_depth++;
|
||||
@ -571,7 +571,7 @@ void CompilerMSL::build_implicit_builtins()
|
||||
{
|
||||
uint32_t type_ptr_id = ir.increase_bound_by(1);
|
||||
|
||||
SPIRType uint_type_ptr;
|
||||
SPIRType uint_type_ptr { spv::Op::OpTypePointer };
|
||||
uint_type_ptr = get_uint_type();
|
||||
uint_type_ptr.pointer = true;
|
||||
uint_type_ptr.pointer_depth++;
|
||||
@ -631,7 +631,7 @@ void CompilerMSL::build_implicit_builtins()
|
||||
// Note that we can't just abuse gl_ViewIndex for this purpose: it's an input, but
|
||||
// gl_Layer is an output in vertex-pipeline shaders.
|
||||
uint32_t type_ptr_out_id = ir.increase_bound_by(2);
|
||||
SPIRType uint_type_ptr_out;
|
||||
SPIRType uint_type_ptr_out { spv::Op::OpTypePointer };
|
||||
uint_type_ptr_out = get_uint_type();
|
||||
uint_type_ptr_out.pointer = true;
|
||||
uint_type_ptr_out.pointer_depth++;
|
||||
@ -663,7 +663,7 @@ void CompilerMSL::build_implicit_builtins()
|
||||
{
|
||||
uint32_t type_ptr_id = ir.increase_bound_by(1);
|
||||
|
||||
SPIRType uint_type_ptr;
|
||||
SPIRType uint_type_ptr { spv::Op::OpTypePointer };
|
||||
uint_type_ptr = get_uint_type();
|
||||
uint_type_ptr.pointer = true;
|
||||
uint_type_ptr.pointer_depth++;
|
||||
@ -723,7 +723,7 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 1;
|
||||
|
||||
// Create gl_SubgroupInvocationID.
|
||||
SPIRType uint_type_ptr;
|
||||
SPIRType uint_type_ptr { spv::Op::OpTypePointer };
|
||||
uint_type_ptr = get_uint_type();
|
||||
uint_type_ptr.pointer = true;
|
||||
uint_type_ptr.pointer_depth++;
|
||||
@ -745,7 +745,7 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 1;
|
||||
|
||||
// Create gl_SubgroupSize.
|
||||
SPIRType uint_type_ptr;
|
||||
SPIRType uint_type_ptr { spv::Op::OpTypePointer };
|
||||
uint_type_ptr = get_uint_type();
|
||||
uint_type_ptr.pointer = true;
|
||||
uint_type_ptr.pointer_depth++;
|
||||
@ -804,7 +804,7 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 1;
|
||||
|
||||
// Create gl_SampleMask.
|
||||
SPIRType uint_type_ptr_out;
|
||||
SPIRType uint_type_ptr_out { spv::Op::OpTypePointer };
|
||||
uint_type_ptr_out = get_uint_type();
|
||||
uint_type_ptr_out.pointer = true;
|
||||
uint_type_ptr_out.pointer_depth++;
|
||||
@ -827,13 +827,13 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 2;
|
||||
|
||||
// Create gl_HelperInvocation.
|
||||
SPIRType bool_type;
|
||||
SPIRType bool_type { spv::Op::OpTypeBool };
|
||||
bool_type.basetype = SPIRType::Boolean;
|
||||
bool_type.width = 8;
|
||||
bool_type.vecsize = 1;
|
||||
set<SPIRType>(type_id, bool_type);
|
||||
|
||||
SPIRType bool_type_ptr_in;
|
||||
SPIRType bool_type_ptr_in { spv::Op::OpTypePointer };
|
||||
bool_type_ptr_in = bool_type;
|
||||
bool_type_ptr_in.pointer = true;
|
||||
bool_type_ptr_in.pointer_depth++;
|
||||
@ -855,7 +855,7 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 1;
|
||||
|
||||
// Create gl_LocalInvocationIndex.
|
||||
SPIRType uint_type_ptr;
|
||||
SPIRType uint_type_ptr { spv::Op::OpTypePointer };
|
||||
uint_type_ptr = get_uint_type();
|
||||
uint_type_ptr.pointer = true;
|
||||
uint_type_ptr.pointer_depth++;
|
||||
@ -986,13 +986,13 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 2;
|
||||
|
||||
// Create gl_Position.
|
||||
SPIRType vec4_type;
|
||||
SPIRType vec4_type { spv::Op::OpTypeVector };
|
||||
vec4_type.basetype = SPIRType::Float;
|
||||
vec4_type.width = 32;
|
||||
vec4_type.vecsize = 4;
|
||||
set<SPIRType>(type_id, vec4_type);
|
||||
|
||||
SPIRType vec4_type_ptr;
|
||||
SPIRType vec4_type_ptr { spv::Op::OpTypePointer };
|
||||
vec4_type_ptr = vec4_type;
|
||||
vec4_type_ptr.pointer = true;
|
||||
vec4_type_ptr.pointer_depth++;
|
||||
@ -1148,7 +1148,7 @@ uint32_t CompilerMSL::get_uint_type_id()
|
||||
|
||||
uint_type_id = ir.increase_bound_by(1);
|
||||
|
||||
SPIRType type;
|
||||
SPIRType type { spv::Op::OpTypeInt };
|
||||
type.basetype = SPIRType::UInt;
|
||||
type.width = 32;
|
||||
set<SPIRType>(uint_type_id, type);
|
||||
@ -3937,7 +3937,7 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch)
|
||||
// declaraion is emitted, because it is cleared after each compilation pass.
|
||||
uint32_t next_id = ir.increase_bound_by(3);
|
||||
uint32_t ib_type_id = next_id++;
|
||||
auto &ib_type = set<SPIRType>(ib_type_id);
|
||||
auto &ib_type = set<SPIRType>(ib_type_id, spv::Op::OpTypeStruct);
|
||||
ib_type.basetype = SPIRType::Struct;
|
||||
ib_type.storage = storage;
|
||||
set_decoration(ib_type_id, DecorationBlock);
|
||||
@ -4166,7 +4166,7 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch)
|
||||
uint32_t ptr_type_id = offset + 2;
|
||||
uint32_t var_id = offset + 3;
|
||||
|
||||
SPIRType type;
|
||||
SPIRType type { spv::Op::OpTypeInt };
|
||||
switch (input.second.format)
|
||||
{
|
||||
case MSL_SHADER_VARIABLE_FORMAT_UINT16:
|
||||
@ -4224,7 +4224,7 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch)
|
||||
uint32_t ptr_type_id = offset + 2;
|
||||
uint32_t var_id = offset + 3;
|
||||
|
||||
SPIRType type;
|
||||
SPIRType type { spv::Op::OpTypeInt };
|
||||
switch (output.second.format)
|
||||
{
|
||||
case MSL_SHADER_VARIABLE_FORMAT_UINT16:
|
||||
@ -4396,7 +4396,7 @@ uint32_t CompilerMSL::ensure_correct_builtin_type(uint32_t type_id, BuiltIn buil
|
||||
{
|
||||
uint32_t next_id = ir.increase_bound_by(type.pointer ? 2 : 1);
|
||||
uint32_t base_type_id = next_id++;
|
||||
auto &base_type = set<SPIRType>(base_type_id);
|
||||
auto &base_type = set<SPIRType>(base_type_id, spv::Op::OpTypeInt);
|
||||
base_type.basetype = SPIRType::UInt;
|
||||
base_type.width = 32;
|
||||
|
||||
@ -4404,7 +4404,7 @@ uint32_t CompilerMSL::ensure_correct_builtin_type(uint32_t type_id, BuiltIn buil
|
||||
return base_type_id;
|
||||
|
||||
uint32_t ptr_type_id = next_id++;
|
||||
auto &ptr_type = set<SPIRType>(ptr_type_id);
|
||||
auto &ptr_type = set<SPIRType>(ptr_type_id, spv::OpTypePointer);
|
||||
ptr_type = base_type;
|
||||
ptr_type.pointer = true;
|
||||
ptr_type.pointer_depth++;
|
||||
@ -10809,7 +10809,7 @@ string CompilerMSL::to_function_name(const TextureFunctionNameArguments &args)
|
||||
|
||||
string CompilerMSL::convert_to_f32(const string &expr, uint32_t components)
|
||||
{
|
||||
SPIRType t;
|
||||
SPIRType t { spv::Op::OpTypeFloat };
|
||||
t.basetype = SPIRType::Float;
|
||||
t.vecsize = components;
|
||||
t.columns = 1;
|
||||
@ -11918,7 +11918,7 @@ string CompilerMSL::to_struct_member(const SPIRType &type, uint32_t member_type_
|
||||
if (is_matrix(physical_type))
|
||||
row_major = has_member_decoration(type.self, index, DecorationRowMajor);
|
||||
|
||||
SPIRType row_major_physical_type;
|
||||
SPIRType row_major_physical_type { spv::Op::OpTypeMatrix };
|
||||
const SPIRType *declared_type = &physical_type;
|
||||
|
||||
// If a struct is being declared with physical layout,
|
||||
@ -17762,7 +17762,7 @@ void CompilerMSL::analyze_argument_buffers()
|
||||
uint32_t ptr_type_id = next_id + 2;
|
||||
argument_buffer_ids[desc_set] = next_id;
|
||||
|
||||
auto &buffer_type = set<SPIRType>(type_id);
|
||||
auto &buffer_type = set<SPIRType>(type_id, spv::Op::OpTypeStruct);
|
||||
|
||||
buffer_type.basetype = SPIRType::Struct;
|
||||
|
||||
@ -17779,7 +17779,7 @@ void CompilerMSL::analyze_argument_buffers()
|
||||
|
||||
set_name(type_id, join("spvDescriptorSetBuffer", desc_set));
|
||||
|
||||
auto &ptr_type = set<SPIRType>(ptr_type_id);
|
||||
auto &ptr_type = set<SPIRType>(ptr_type_id, spv::Op::OpTypePointer);
|
||||
ptr_type = buffer_type;
|
||||
ptr_type.pointer = true;
|
||||
ptr_type.pointer_depth++;
|
||||
@ -17863,14 +17863,14 @@ void CompilerMSL::analyze_argument_buffers()
|
||||
|
||||
bool type_is_array = !type.array.empty();
|
||||
uint32_t sampler_type_id = ir.increase_bound_by(type_is_array ? 2 : 1);
|
||||
auto &new_sampler_type = set<SPIRType>(sampler_type_id);
|
||||
auto &new_sampler_type = set<SPIRType>(sampler_type_id, spv::Op::OpTypeSampler);
|
||||
new_sampler_type.basetype = SPIRType::Sampler;
|
||||
new_sampler_type.storage = StorageClassUniformConstant;
|
||||
|
||||
if (type_is_array)
|
||||
{
|
||||
uint32_t sampler_type_array_id = sampler_type_id + 1;
|
||||
auto &sampler_type_array = set<SPIRType>(sampler_type_array_id);
|
||||
auto &sampler_type_array = set<SPIRType>(sampler_type_array_id, spv::Op::OpTypeArray);
|
||||
sampler_type_array = new_sampler_type;
|
||||
sampler_type_array.array = type.array;
|
||||
sampler_type_array.array_size_literal = type.array_size_literal;
|
||||
@ -17921,7 +17921,7 @@ void CompilerMSL::analyze_argument_buffers()
|
||||
uint32_t atomic_type_id = offset;
|
||||
uint32_t type_ptr_id = offset + 1;
|
||||
|
||||
SPIRType atomic_type;
|
||||
SPIRType atomic_type { spv::Op::OpTypeInt };
|
||||
atomic_type.basetype = SPIRType::AtomicCounter;
|
||||
atomic_type.width = 32;
|
||||
atomic_type.vecsize = 1;
|
||||
@ -17987,12 +17987,12 @@ void CompilerMSL::add_argument_buffer_padding_buffer_type(SPIRType &struct_type,
|
||||
if (!argument_buffer_padding_buffer_type_id)
|
||||
{
|
||||
uint32_t buff_type_id = ir.increase_bound_by(2);
|
||||
auto &buff_type = set<SPIRType>(buff_type_id);
|
||||
auto &buff_type = set<SPIRType>(buff_type_id, spv::Op::OpNop);
|
||||
buff_type.basetype = rez_bind.basetype;
|
||||
buff_type.storage = StorageClassUniformConstant;
|
||||
|
||||
uint32_t ptr_type_id = buff_type_id + 1;
|
||||
auto &ptr_type = set<SPIRType>(ptr_type_id);
|
||||
auto &ptr_type = set<SPIRType>(ptr_type_id, spv::Op::OpTypePointer);
|
||||
ptr_type = buff_type;
|
||||
ptr_type.pointer = true;
|
||||
ptr_type.pointer_depth++;
|
||||
@ -18011,12 +18011,12 @@ void CompilerMSL::add_argument_buffer_padding_image_type(SPIRType &struct_type,
|
||||
if (!argument_buffer_padding_image_type_id)
|
||||
{
|
||||
uint32_t base_type_id = ir.increase_bound_by(2);
|
||||
auto &base_type = set<SPIRType>(base_type_id);
|
||||
auto &base_type = set<SPIRType>(base_type_id, spv::Op::OpTypeFloat);
|
||||
base_type.basetype = SPIRType::Float;
|
||||
base_type.width = 32;
|
||||
|
||||
uint32_t img_type_id = base_type_id + 1;
|
||||
auto &img_type = set<SPIRType>(img_type_id);
|
||||
auto &img_type = set<SPIRType>(img_type_id, spv::Op::OpTypeImage);
|
||||
img_type.basetype = SPIRType::Image;
|
||||
img_type.storage = StorageClassUniformConstant;
|
||||
|
||||
@ -18042,7 +18042,7 @@ void CompilerMSL::add_argument_buffer_padding_sampler_type(SPIRType &struct_type
|
||||
if (!argument_buffer_padding_sampler_type_id)
|
||||
{
|
||||
uint32_t samp_type_id = ir.increase_bound_by(1);
|
||||
auto &samp_type = set<SPIRType>(samp_type_id);
|
||||
auto &samp_type = set<SPIRType>(samp_type_id, spv::Op::OpTypeSampler);
|
||||
samp_type.basetype = SPIRType::Sampler;
|
||||
samp_type.storage = StorageClassUniformConstant;
|
||||
|
||||
@ -18061,7 +18061,7 @@ void CompilerMSL::add_argument_buffer_padding_type(uint32_t mbr_type_id, SPIRTyp
|
||||
if (count > 1)
|
||||
{
|
||||
uint32_t ary_type_id = ir.increase_bound_by(1);
|
||||
auto &ary_type = set<SPIRType>(ary_type_id);
|
||||
auto &ary_type = set<SPIRType>(ary_type_id, spv::Op::OpTypeArray);
|
||||
ary_type = get<SPIRType>(type_id);
|
||||
ary_type.array.push_back(count);
|
||||
ary_type.array_size_literal.push_back(true);
|
||||
|
@ -517,7 +517,7 @@ void Parser::parse(const Instruction &instruction)
|
||||
case OpTypeVoid:
|
||||
{
|
||||
uint32_t id = ops[0];
|
||||
auto &type = set<SPIRType>(id);
|
||||
auto &type = set<SPIRType>(id, op);
|
||||
type.basetype = SPIRType::Void;
|
||||
break;
|
||||
}
|
||||
@ -525,7 +525,7 @@ void Parser::parse(const Instruction &instruction)
|
||||
case OpTypeBool:
|
||||
{
|
||||
uint32_t id = ops[0];
|
||||
auto &type = set<SPIRType>(id);
|
||||
auto &type = set<SPIRType>(id, op);
|
||||
type.basetype = SPIRType::Boolean;
|
||||
type.width = 1;
|
||||
break;
|
||||
@ -535,7 +535,7 @@ void Parser::parse(const Instruction &instruction)
|
||||
{
|
||||
uint32_t id = ops[0];
|
||||
uint32_t width = ops[1];
|
||||
auto &type = set<SPIRType>(id);
|
||||
auto &type = set<SPIRType>(id, op);
|
||||
if (width == 64)
|
||||
type.basetype = SPIRType::Double;
|
||||
else if (width == 32)
|
||||
@ -553,7 +553,7 @@ void Parser::parse(const Instruction &instruction)
|
||||
uint32_t id = ops[0];
|
||||
uint32_t width = ops[1];
|
||||
bool signedness = ops[2] != 0;
|
||||
auto &type = set<SPIRType>(id);
|
||||
auto &type = set<SPIRType>(id, op);
|
||||
type.basetype = signedness ? to_signed_basetype(width) : to_unsigned_basetype(width);
|
||||
type.width = width;
|
||||
break;
|
||||
@ -568,7 +568,7 @@ void Parser::parse(const Instruction &instruction)
|
||||
uint32_t vecsize = ops[2];
|
||||
|
||||
auto &base = get<SPIRType>(ops[1]);
|
||||
auto &vecbase = set<SPIRType>(id);
|
||||
auto &vecbase = set<SPIRType>(id, op);
|
||||
|
||||
vecbase = base;
|
||||
vecbase.vecsize = vecsize;
|
||||
@ -583,7 +583,7 @@ void Parser::parse(const Instruction &instruction)
|
||||
uint32_t colcount = ops[2];
|
||||
|
||||
auto &base = get<SPIRType>(ops[1]);
|
||||
auto &matrixbase = set<SPIRType>(id);
|
||||
auto &matrixbase = set<SPIRType>(id, op);
|
||||
|
||||
matrixbase = base;
|
||||
matrixbase.columns = colcount;
|
||||
@ -595,7 +595,7 @@ void Parser::parse(const Instruction &instruction)
|
||||
case OpTypeArray:
|
||||
{
|
||||
uint32_t id = ops[0];
|
||||
auto &arraybase = set<SPIRType>(id);
|
||||
auto &arraybase = set<SPIRType>(id, op);
|
||||
|
||||
uint32_t tid = ops[1];
|
||||
auto &base = get<SPIRType>(tid);
|
||||
@ -624,7 +624,7 @@ void Parser::parse(const Instruction &instruction)
|
||||
uint32_t id = ops[0];
|
||||
|
||||
auto &base = get<SPIRType>(ops[1]);
|
||||
auto &arraybase = set<SPIRType>(id);
|
||||
auto &arraybase = set<SPIRType>(id, op);
|
||||
|
||||
// We're copying type information into Array types, so we'll need a fixup for any physical pointer
|
||||
// references.
|
||||
@ -642,7 +642,7 @@ void Parser::parse(const Instruction &instruction)
|
||||
case OpTypeImage:
|
||||
{
|
||||
uint32_t id = ops[0];
|
||||
auto &type = set<SPIRType>(id);
|
||||
auto &type = set<SPIRType>(id, op);
|
||||
type.basetype = SPIRType::Image;
|
||||
type.image.type = ops[1];
|
||||
type.image.dim = static_cast<Dim>(ops[2]);
|
||||
@ -659,7 +659,7 @@ void Parser::parse(const Instruction &instruction)
|
||||
{
|
||||
uint32_t id = ops[0];
|
||||
uint32_t imagetype = ops[1];
|
||||
auto &type = set<SPIRType>(id);
|
||||
auto &type = set<SPIRType>(id, op);
|
||||
type = get<SPIRType>(imagetype);
|
||||
type.basetype = SPIRType::SampledImage;
|
||||
type.self = id;
|
||||
@ -669,7 +669,7 @@ void Parser::parse(const Instruction &instruction)
|
||||
case OpTypeSampler:
|
||||
{
|
||||
uint32_t id = ops[0];
|
||||
auto &type = set<SPIRType>(id);
|
||||
auto &type = set<SPIRType>(id, op);
|
||||
type.basetype = SPIRType::Sampler;
|
||||
break;
|
||||
}
|
||||
@ -682,7 +682,7 @@ void Parser::parse(const Instruction &instruction)
|
||||
// We won't be able to compile it, but we shouldn't crash when parsing.
|
||||
// We should be able to reflect.
|
||||
auto *base = maybe_get<SPIRType>(ops[2]);
|
||||
auto &ptrbase = set<SPIRType>(id);
|
||||
auto &ptrbase = set<SPIRType>(id, op);
|
||||
|
||||
if (base)
|
||||
ptrbase = *base;
|
||||
@ -706,7 +706,7 @@ void Parser::parse(const Instruction &instruction)
|
||||
case OpTypeForwardPointer:
|
||||
{
|
||||
uint32_t id = ops[0];
|
||||
auto &ptrbase = set<SPIRType>(id);
|
||||
auto &ptrbase = set<SPIRType>(id, op);
|
||||
ptrbase.pointer = true;
|
||||
ptrbase.pointer_depth++;
|
||||
ptrbase.storage = static_cast<StorageClass>(ops[1]);
|
||||
@ -721,7 +721,7 @@ void Parser::parse(const Instruction &instruction)
|
||||
case OpTypeStruct:
|
||||
{
|
||||
uint32_t id = ops[0];
|
||||
auto &type = set<SPIRType>(id);
|
||||
auto &type = set<SPIRType>(id, op);
|
||||
type.basetype = SPIRType::Struct;
|
||||
for (uint32_t i = 1; i < length; i++)
|
||||
type.member_types.push_back(ops[i]);
|
||||
@ -770,7 +770,7 @@ void Parser::parse(const Instruction &instruction)
|
||||
case OpTypeAccelerationStructureKHR:
|
||||
{
|
||||
uint32_t id = ops[0];
|
||||
auto &type = set<SPIRType>(id);
|
||||
auto &type = set<SPIRType>(id, op);
|
||||
type.basetype = SPIRType::AccelerationStructure;
|
||||
break;
|
||||
}
|
||||
@ -778,7 +778,7 @@ void Parser::parse(const Instruction &instruction)
|
||||
case OpTypeRayQueryKHR:
|
||||
{
|
||||
uint32_t id = ops[0];
|
||||
auto &type = set<SPIRType>(id);
|
||||
auto &type = set<SPIRType>(id, op);
|
||||
type.basetype = SPIRType::RayQuery;
|
||||
break;
|
||||
}
|
||||
@ -1025,10 +1025,9 @@ void Parser::parse(const Instruction &instruction)
|
||||
{
|
||||
uint32_t ids = ir.increase_bound_by(2);
|
||||
|
||||
SPIRType type;
|
||||
auto& type = set<SPIRType>(ids, spv::Op::OpTypeInt);
|
||||
type.basetype = SPIRType::Int;
|
||||
type.width = 32;
|
||||
set<SPIRType>(ids, type);
|
||||
auto &c = set<SPIRConstant>(ids + 1, ids);
|
||||
|
||||
current_block->condition = c.self;
|
||||
|
Loading…
Reference in New Issue
Block a user