commit
13aab7f07e
@ -15,8 +15,8 @@ struct main0_patchOut
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
uint3 m_86;
|
||||
ushort2 m_90;
|
||||
uint3 m_87;
|
||||
ushort2 m_92;
|
||||
float4 gl_Position;
|
||||
};
|
||||
|
||||
|
@ -68,7 +68,7 @@ struct main0_patchOut
|
||||
struct main0_in
|
||||
{
|
||||
float3 in_tc_attr;
|
||||
ushort2 m_196;
|
||||
ushort2 m_197;
|
||||
};
|
||||
|
||||
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]])
|
||||
|
@ -11,7 +11,7 @@ struct main0_out
|
||||
struct main0_in
|
||||
{
|
||||
float4 vInputs;
|
||||
ushort2 m_44;
|
||||
ushort2 m_45;
|
||||
};
|
||||
|
||||
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]])
|
||||
|
@ -13,7 +13,7 @@ struct main0_out
|
||||
struct main0_in
|
||||
{
|
||||
float3 in_tc_attr;
|
||||
ushort2 m_104;
|
||||
ushort2 m_105;
|
||||
};
|
||||
|
||||
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]])
|
||||
|
@ -10,8 +10,8 @@ struct main0_out
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
uint3 m_82;
|
||||
ushort2 m_86;
|
||||
uint3 m_83;
|
||||
ushort2 m_88;
|
||||
float4 gl_Position;
|
||||
};
|
||||
|
||||
|
@ -20,7 +20,7 @@ struct main0_out
|
||||
struct main0_in
|
||||
{
|
||||
float3 in_tc_attr;
|
||||
ushort2 m_119;
|
||||
ushort2 m_120;
|
||||
};
|
||||
|
||||
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]])
|
||||
|
@ -22,7 +22,7 @@ struct main0_patchOut
|
||||
struct main0_in
|
||||
{
|
||||
float3 vPatchPosBase;
|
||||
ushort2 m_996;
|
||||
ushort2 m_997;
|
||||
};
|
||||
|
||||
kernel void main0(constant UBO& _41 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]])
|
||||
|
@ -81,7 +81,7 @@ struct main0_out
|
||||
struct main0_in
|
||||
{
|
||||
VertexOutput_1 p;
|
||||
ushort2 m_173;
|
||||
ushort2 m_174;
|
||||
float4 gl_Position;
|
||||
};
|
||||
|
||||
|
@ -52,8 +52,8 @@ struct main0_out
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
uint3 m_57;
|
||||
ushort2 m_61;
|
||||
uint3 m_58;
|
||||
ushort2 m_63;
|
||||
spvUnsafeArray<float, 2> gl_ClipDistance;
|
||||
spvUnsafeArray<float, 1> gl_CullDistance;
|
||||
};
|
||||
|
@ -17,8 +17,8 @@ struct main0_patchOut
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
uint3 m_78;
|
||||
ushort2 m_82;
|
||||
uint3 m_79;
|
||||
ushort2 m_84;
|
||||
float4 gl_Position;
|
||||
};
|
||||
|
||||
|
@ -68,7 +68,7 @@ struct main0_patchOut
|
||||
struct main0_in
|
||||
{
|
||||
float3 in_tc_attr;
|
||||
ushort2 m_179;
|
||||
ushort2 m_180;
|
||||
};
|
||||
|
||||
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]])
|
||||
|
@ -52,7 +52,7 @@ struct main0_out
|
||||
struct main0_in
|
||||
{
|
||||
float4 vInputs;
|
||||
ushort2 m_43;
|
||||
ushort2 m_44;
|
||||
};
|
||||
|
||||
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]])
|
||||
|
@ -13,7 +13,7 @@ struct main0_out
|
||||
struct main0_in
|
||||
{
|
||||
float3 in_tc_attr;
|
||||
ushort2 m_103;
|
||||
ushort2 m_104;
|
||||
};
|
||||
|
||||
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]])
|
||||
|
@ -10,8 +10,8 @@ struct main0_out
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
uint3 m_82;
|
||||
ushort2 m_86;
|
||||
uint3 m_83;
|
||||
ushort2 m_88;
|
||||
float4 gl_Position;
|
||||
};
|
||||
|
||||
|
@ -20,7 +20,7 @@ struct main0_out
|
||||
struct main0_in
|
||||
{
|
||||
float3 in_tc_attr;
|
||||
ushort2 m_107;
|
||||
ushort2 m_108;
|
||||
};
|
||||
|
||||
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]])
|
||||
|
@ -24,7 +24,7 @@ struct main0_patchOut
|
||||
struct main0_in
|
||||
{
|
||||
float3 vPatchPosBase;
|
||||
ushort2 m_430;
|
||||
ushort2 m_431;
|
||||
};
|
||||
|
||||
static inline __attribute__((always_inline))
|
||||
|
@ -548,6 +548,9 @@ struct SPIRType : IVariant
|
||||
type = TypeType
|
||||
};
|
||||
|
||||
spv::Op op = spv::Op::OpNop;
|
||||
explicit SPIRType(spv::Op op_) : op(op_) {}
|
||||
|
||||
enum BaseType
|
||||
{
|
||||
Unknown,
|
||||
@ -618,7 +621,7 @@ struct SPIRType : IVariant
|
||||
uint32_t sampled;
|
||||
spv::ImageFormat format;
|
||||
spv::AccessQualifier access;
|
||||
} image;
|
||||
} image = {};
|
||||
|
||||
// Structs can be declared multiple times if they are used as part of interface blocks.
|
||||
// We want to detect this so that we only emit the struct definition once.
|
||||
|
@ -627,15 +627,22 @@ bool Compiler::is_matrix(const SPIRType &type) const
|
||||
|
||||
bool Compiler::is_array(const SPIRType &type) const
|
||||
{
|
||||
return !type.array.empty();
|
||||
return type.op == OpTypeArray || type.op == OpTypeRuntimeArray;
|
||||
}
|
||||
|
||||
bool Compiler::is_pointer(const SPIRType &type) const
|
||||
{
|
||||
return type.op == OpTypePointer && type.basetype != SPIRType::Unknown; // Ignore function pointers.
|
||||
}
|
||||
|
||||
bool Compiler::is_physical_pointer(const SPIRType &type) const
|
||||
{
|
||||
return type.op == OpTypePointer && type.storage == StorageClassPhysicalStorageBuffer;
|
||||
}
|
||||
|
||||
bool Compiler::is_runtime_size_array(const SPIRType &type)
|
||||
{
|
||||
if (type.array.empty())
|
||||
return false;
|
||||
assert(type.array.size() == type.array_size_literal.size());
|
||||
return type.array_size_literal.back() && type.array.back() == 0;
|
||||
return type.op == OpTypeRuntimeArray;
|
||||
}
|
||||
|
||||
ShaderResources Compiler::get_shader_resources() const
|
||||
@ -2738,8 +2745,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, OpTypeSampledImage);
|
||||
auto &ptr_type = compiler.set<SPIRType>(ptr_type_id, OpTypePointer);
|
||||
|
||||
type = base;
|
||||
type.self = type_id;
|
||||
@ -2998,7 +3005,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, OpTypeSampledImage);
|
||||
type = compiler.expression_type(args[2]);
|
||||
type.self = sampled_type;
|
||||
type.basetype = SPIRType::SampledImage;
|
||||
@ -3017,7 +3024,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, OpTypePointer);
|
||||
auto &base = compiler.get<SPIRType>(sampled_type);
|
||||
type = base;
|
||||
type.pointer = true;
|
||||
@ -3063,11 +3070,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, OpTypeSampler);
|
||||
sampler.basetype = SPIRType::Sampler;
|
||||
|
||||
auto &ptr_sampler = set<SPIRType>(ptr_type_id);
|
||||
auto &ptr_sampler = set<SPIRType>(ptr_type_id, OpTypePointer);
|
||||
ptr_sampler = sampler;
|
||||
ptr_sampler.self = type_id;
|
||||
ptr_sampler.storage = StorageClassUniformConstant;
|
||||
@ -5497,7 +5503,7 @@ bool Compiler::type_contains_recursion(const SPIRType &type)
|
||||
|
||||
bool Compiler::type_is_array_of_pointers(const SPIRType &type) const
|
||||
{
|
||||
if (!type_is_top_level_array(type))
|
||||
if (!is_array(type))
|
||||
return false;
|
||||
|
||||
// BDA types must have parent type hierarchy.
|
||||
@ -5506,45 +5512,10 @@ bool Compiler::type_is_array_of_pointers(const SPIRType &type) const
|
||||
|
||||
// Punch through all array layers.
|
||||
auto *parent = &get<SPIRType>(type.parent_type);
|
||||
while (type_is_top_level_array(*parent))
|
||||
while (is_array(*parent))
|
||||
parent = &get<SPIRType>(parent->parent_type);
|
||||
|
||||
return type_is_top_level_pointer(*parent);
|
||||
}
|
||||
|
||||
bool Compiler::type_is_top_level_pointer(const SPIRType &type) const
|
||||
{
|
||||
if (!type.pointer)
|
||||
return false;
|
||||
|
||||
// Function pointers, should not be hit by valid SPIR-V.
|
||||
// Parent type will be SPIRFunction instead.
|
||||
if (type.basetype == SPIRType::Unknown)
|
||||
return false;
|
||||
|
||||
// Some types are synthesized in-place without complete type hierarchy and might not have parent types,
|
||||
// but these types are never array-of-pointer or any complicated BDA type, infer reasonable defaults.
|
||||
if (type.parent_type)
|
||||
return type.pointer_depth > get<SPIRType>(type.parent_type).pointer_depth;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Compiler::type_is_top_level_physical_pointer(const SPIRType &type) const
|
||||
{
|
||||
return type_is_top_level_pointer(type) && type.storage == StorageClassPhysicalStorageBuffer;
|
||||
}
|
||||
|
||||
bool Compiler::type_is_top_level_array(const SPIRType &type) const
|
||||
{
|
||||
if (type.array.empty())
|
||||
return false;
|
||||
|
||||
// If we have pointer and array, we infer pointer-to-array as it's the only meaningful thing outside BDA.
|
||||
if (type.parent_type)
|
||||
return type.array.size() > get<SPIRType>(type.parent_type).array.size();
|
||||
else
|
||||
return !type.pointer;
|
||||
return is_pointer(*parent);
|
||||
}
|
||||
|
||||
bool Compiler::flush_phi_required(BlockID from, BlockID to) const
|
||||
|
@ -683,6 +683,8 @@ protected:
|
||||
bool is_vector(const SPIRType &type) const;
|
||||
bool is_matrix(const SPIRType &type) const;
|
||||
bool is_array(const SPIRType &type) const;
|
||||
bool is_pointer(const SPIRType &type) const;
|
||||
bool is_physical_pointer(const SPIRType &type) const;
|
||||
static bool is_runtime_size_array(const SPIRType &type);
|
||||
uint32_t expression_type_id(uint32_t id) const;
|
||||
const SPIRType &expression_type(uint32_t id) const;
|
||||
@ -1148,9 +1150,6 @@ protected:
|
||||
bool check_internal_recursion(const SPIRType &type, std::unordered_set<uint32_t> &checked_ids);
|
||||
bool type_contains_recursion(const SPIRType &type);
|
||||
bool type_is_array_of_pointers(const SPIRType &type) const;
|
||||
bool type_is_top_level_physical_pointer(const SPIRType &type) const;
|
||||
bool type_is_top_level_pointer(const SPIRType &type) const;
|
||||
bool type_is_top_level_array(const SPIRType &type) const;
|
||||
bool type_is_block_like(const SPIRType &type) const;
|
||||
bool type_is_top_level_block(const SPIRType &type) const;
|
||||
bool type_is_opaque_value(const SPIRType &type) const;
|
||||
|
@ -223,7 +223,7 @@ static const char *to_pls_layout(PlsFormat format)
|
||||
}
|
||||
}
|
||||
|
||||
static SPIRType::BaseType pls_format_to_basetype(PlsFormat format)
|
||||
static std::pair<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_pair(spv::OpTypeFloat, SPIRType::Float);
|
||||
|
||||
case PlsRGBA8I:
|
||||
case PlsRG16I:
|
||||
return SPIRType::Int;
|
||||
return std::make_pair(spv::OpTypeInt, SPIRType::Int);
|
||||
|
||||
case PlsRGB10A2UI:
|
||||
case PlsRGBA8UI:
|
||||
case PlsRG16UI:
|
||||
case PlsR32UI:
|
||||
return SPIRType::UInt;
|
||||
return std::make_pair(spv::OpTypeInt, SPIRType::UInt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1529,7 +1529,7 @@ uint32_t CompilerGLSL::type_to_packed_alignment(const SPIRType &type, const Bits
|
||||
{
|
||||
// If using PhysicalStorageBufferEXT storage class, this is a pointer,
|
||||
// and is 64-bit.
|
||||
if (type_is_top_level_physical_pointer(type))
|
||||
if (is_physical_pointer(type))
|
||||
{
|
||||
if (!type.pointer)
|
||||
SPIRV_CROSS_THROW("Types in PhysicalStorageBufferEXT must be pointers.");
|
||||
@ -1544,7 +1544,7 @@ uint32_t CompilerGLSL::type_to_packed_alignment(const SPIRType &type, const Bits
|
||||
else
|
||||
SPIRV_CROSS_THROW("AddressingModelPhysicalStorageBuffer64EXT must be used for PhysicalStorageBufferEXT.");
|
||||
}
|
||||
else if (type_is_top_level_array(type))
|
||||
else if (is_array(type))
|
||||
{
|
||||
uint32_t minimum_alignment = 1;
|
||||
if (packing_is_vec4_padded(packing))
|
||||
@ -1652,7 +1652,7 @@ uint32_t CompilerGLSL::type_to_packed_size(const SPIRType &type, const Bitset &f
|
||||
{
|
||||
// If using PhysicalStorageBufferEXT storage class, this is a pointer,
|
||||
// and is 64-bit.
|
||||
if (type_is_top_level_physical_pointer(type))
|
||||
if (is_physical_pointer(type))
|
||||
{
|
||||
if (!type.pointer)
|
||||
SPIRV_CROSS_THROW("Types in PhysicalStorageBufferEXT must be pointers.");
|
||||
@ -1662,7 +1662,7 @@ uint32_t CompilerGLSL::type_to_packed_size(const SPIRType &type, const Bitset &f
|
||||
else
|
||||
SPIRV_CROSS_THROW("AddressingModelPhysicalStorageBuffer64EXT must be used for PhysicalStorageBufferEXT.");
|
||||
}
|
||||
else if (type_is_top_level_array(type))
|
||||
else if (is_array(type))
|
||||
{
|
||||
uint32_t packed_size = to_array_size_literal(type) * type_to_packed_array_stride(type, flags, packing);
|
||||
|
||||
@ -1840,7 +1840,7 @@ bool CompilerGLSL::buffer_is_packing_standard(const SPIRType &type, BufferPackin
|
||||
}
|
||||
|
||||
// Verify array stride rules.
|
||||
if (type_is_top_level_array(memb_type) &&
|
||||
if (is_array(memb_type) &&
|
||||
type_to_packed_array_stride(memb_type, member_flags, packing) !=
|
||||
type_struct_member_array_stride(type, i))
|
||||
{
|
||||
@ -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 { OpTypeVector };
|
||||
tmp.basetype = basic_type;
|
||||
tmp.vecsize = 4;
|
||||
if (basic_type != SPIRType::Float && basic_type != SPIRType::Int && basic_type != SPIRType::UInt)
|
||||
@ -3926,6 +3926,7 @@ void CompilerGLSL::emit_output_variable_initializer(const SPIRVariable &var)
|
||||
auto &member_type = get<SPIRType>(member_type_id);
|
||||
auto array_type = member_type;
|
||||
array_type.parent_type = member_type_id;
|
||||
array_type.op = OpTypeArray;
|
||||
array_type.array.push_back(array_size);
|
||||
array_type.array_size_literal.push_back(true);
|
||||
|
||||
@ -3949,10 +3950,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, 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 +5148,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 { OpNop };
|
||||
if (remapped_boolean)
|
||||
{
|
||||
tmp_type = get<SPIRType>(type.parent_type);
|
||||
@ -5169,7 +5169,7 @@ string CompilerGLSL::to_rerolled_array_expression(const SPIRType &parent_type,
|
||||
for (uint32_t i = 0; i < size; i++)
|
||||
{
|
||||
auto subexpr = join(base_expr, "[", convert_to_string(i), "]");
|
||||
if (!type_is_top_level_array(parent))
|
||||
if (!is_array(parent))
|
||||
{
|
||||
if (remapped_boolean)
|
||||
subexpr = join(type_to_glsl(tmp_type), "(", subexpr, ")");
|
||||
@ -5195,7 +5195,7 @@ string CompilerGLSL::to_composite_constructor_expression(const SPIRType &parent_
|
||||
type.basetype == SPIRType::Boolean &&
|
||||
backend.boolean_in_struct_remapped_type != SPIRType::Boolean;
|
||||
|
||||
if (type_is_top_level_array(type))
|
||||
if (is_array(type))
|
||||
{
|
||||
reroll_array = !backend.array_is_value_type ||
|
||||
(block_like_type && !backend.array_is_value_type_in_buffer_blocks);
|
||||
@ -5748,7 +5748,7 @@ string CompilerGLSL::constant_expression(const SPIRConstant &c,
|
||||
{
|
||||
auto &type = get<SPIRType>(c.constant_type);
|
||||
|
||||
if (type_is_top_level_pointer(type))
|
||||
if (is_pointer(type))
|
||||
{
|
||||
return backend.null_pointer_literal;
|
||||
}
|
||||
@ -5763,21 +5763,21 @@ string CompilerGLSL::constant_expression(const SPIRConstant &c,
|
||||
// with Offset = 0, using no ArrayStride on the enclosed array type.
|
||||
// A particular CTS test hits this scenario.
|
||||
bool array_type_decays = inside_block_like_struct_scope &&
|
||||
type_is_top_level_array(type) &&
|
||||
is_array(type) &&
|
||||
!backend.array_is_value_type_in_buffer_blocks;
|
||||
|
||||
// Allow Metal to use the array<T> template to make arrays a value type
|
||||
bool needs_trailing_tracket = false;
|
||||
if (backend.use_initializer_list && backend.use_typed_initializer_list && type.basetype == SPIRType::Struct &&
|
||||
!type_is_top_level_array(type))
|
||||
!is_array(type))
|
||||
{
|
||||
res = type_to_glsl_constructor(type) + "{ ";
|
||||
}
|
||||
else if (backend.use_initializer_list && backend.use_typed_initializer_list && backend.array_is_value_type &&
|
||||
type_is_top_level_array(type) && !array_type_decays)
|
||||
is_array(type) && !array_type_decays)
|
||||
{
|
||||
const auto *p_type = &type;
|
||||
SPIRType tmp_type;
|
||||
SPIRType tmp_type { OpNop };
|
||||
|
||||
if (inside_struct_scope &&
|
||||
backend.boolean_in_struct_remapped_type != SPIRType::Boolean &&
|
||||
@ -5818,7 +5818,7 @@ string CompilerGLSL::constant_expression(const SPIRConstant &c,
|
||||
res += to_name(elem);
|
||||
else
|
||||
{
|
||||
if (!type_is_top_level_array(type) && type.basetype == SPIRType::Struct)
|
||||
if (!is_array(type) && type.basetype == SPIRType::Struct)
|
||||
{
|
||||
// When we get down to emitting struct members, override the block-like information.
|
||||
// For constants, we can freely mix and match block-like state.
|
||||
@ -5916,7 +5916,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 { OpTypeFloat };
|
||||
type.basetype = SPIRType::Half;
|
||||
type.vecsize = 1;
|
||||
type.columns = 1;
|
||||
@ -5932,7 +5932,7 @@ string CompilerGLSL::convert_half_to_string(const SPIRConstant &c, uint32_t col,
|
||||
}
|
||||
else
|
||||
{
|
||||
SPIRType type;
|
||||
SPIRType type { OpTypeFloat };
|
||||
type.basetype = SPIRType::Half;
|
||||
type.vecsize = 1;
|
||||
type.columns = 1;
|
||||
@ -5952,8 +5952,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 { OpTypeFloat };
|
||||
SPIRType in_type { OpTypeInt };
|
||||
out_type.basetype = SPIRType::Float;
|
||||
in_type.basetype = SPIRType::UInt;
|
||||
out_type.vecsize = 1;
|
||||
@ -6022,8 +6022,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 { OpTypeFloat };
|
||||
SPIRType in_type { OpTypeInt };
|
||||
out_type.basetype = SPIRType::Double;
|
||||
in_type.basetype = SPIRType::UInt64;
|
||||
out_type.vecsize = 1;
|
||||
@ -6731,7 +6731,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 +7085,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 { OpTypeInt };
|
||||
target_type.width = 32;
|
||||
target_type.vecsize = 1;
|
||||
target_type.basetype = offset_count_type;
|
||||
|
||||
@ -7876,7 +7878,7 @@ bool CompilerGLSL::expression_is_constant_null(uint32_t id) const
|
||||
bool CompilerGLSL::expression_is_non_value_type_array(uint32_t ptr)
|
||||
{
|
||||
auto &type = expression_type(ptr);
|
||||
if (!type_is_top_level_array(get_pointee_type(type)))
|
||||
if (!is_array(get_pointee_type(type)))
|
||||
return false;
|
||||
|
||||
if (!backend.array_is_value_type)
|
||||
@ -10017,7 +10019,7 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice
|
||||
index &= 0x7fffffffu;
|
||||
}
|
||||
|
||||
bool ptr_chain_array_entry = ptr_chain && i == 0 && type_is_top_level_array(*type);
|
||||
bool ptr_chain_array_entry = ptr_chain && i == 0 && is_array(*type);
|
||||
|
||||
if (ptr_chain_array_entry)
|
||||
{
|
||||
@ -15363,9 +15365,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 { op_and_basetype.first };
|
||||
type.basetype = op_and_basetype.second;
|
||||
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));
|
||||
@ -17676,7 +17685,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 { OpTypeInt };
|
||||
target_type.basetype = SPIRType::Int;
|
||||
|
||||
statement("for (int i = 0; i < int(", array_expr, "); i++)");
|
||||
@ -17741,7 +17750,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 { 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, 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) ? 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 { 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) ? 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 { 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 { OpTypeStruct };
|
||||
block_type.basetype = SPIRType::Struct;
|
||||
block_type.member_types.push_back(uint_type_id);
|
||||
set<SPIRType>(block_type_id, block_type);
|
||||
|
227
spirv_msl.cpp
227
spirv_msl.cpp
@ -478,14 +478,14 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 2;
|
||||
|
||||
// Create gl_FragCoord.
|
||||
SPIRType vec4_type;
|
||||
SPIRType vec4_type { OpTypeVector };
|
||||
vec4_type.basetype = SPIRType::Float;
|
||||
vec4_type.width = 32;
|
||||
vec4_type.vecsize = 4;
|
||||
set<SPIRType>(type_id, vec4_type);
|
||||
|
||||
SPIRType vec4_type_ptr;
|
||||
vec4_type_ptr = vec4_type;
|
||||
SPIRType vec4_type_ptr = vec4_type;
|
||||
vec4_type_ptr.op = OpTypePointer;
|
||||
vec4_type_ptr.pointer = true;
|
||||
vec4_type_ptr.pointer_depth++;
|
||||
vec4_type_ptr.parent_type = type_id;
|
||||
@ -506,8 +506,8 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 1;
|
||||
|
||||
// Create gl_Layer.
|
||||
SPIRType uint_type_ptr;
|
||||
uint_type_ptr = get_uint_type();
|
||||
SPIRType uint_type_ptr = get_uint_type();
|
||||
uint_type_ptr.op = OpTypePointer;
|
||||
uint_type_ptr.pointer = true;
|
||||
uint_type_ptr.pointer_depth++;
|
||||
uint_type_ptr.parent_type = get_uint_type_id();
|
||||
@ -528,8 +528,8 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 1;
|
||||
|
||||
// Create gl_ViewIndex.
|
||||
SPIRType uint_type_ptr;
|
||||
uint_type_ptr = get_uint_type();
|
||||
SPIRType uint_type_ptr = get_uint_type();
|
||||
uint_type_ptr.op = OpTypePointer;
|
||||
uint_type_ptr.pointer = true;
|
||||
uint_type_ptr.pointer_depth++;
|
||||
uint_type_ptr.parent_type = get_uint_type_id();
|
||||
@ -551,8 +551,8 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 1;
|
||||
|
||||
// Create gl_SampleID.
|
||||
SPIRType uint_type_ptr;
|
||||
uint_type_ptr = get_uint_type();
|
||||
SPIRType uint_type_ptr = get_uint_type();
|
||||
uint_type_ptr.op = OpTypePointer;
|
||||
uint_type_ptr.pointer = true;
|
||||
uint_type_ptr.pointer_depth++;
|
||||
uint_type_ptr.parent_type = get_uint_type_id();
|
||||
@ -571,8 +571,8 @@ void CompilerMSL::build_implicit_builtins()
|
||||
{
|
||||
uint32_t type_ptr_id = ir.increase_bound_by(1);
|
||||
|
||||
SPIRType uint_type_ptr;
|
||||
uint_type_ptr = get_uint_type();
|
||||
SPIRType uint_type_ptr = get_uint_type();
|
||||
uint_type_ptr.op = OpTypePointer;
|
||||
uint_type_ptr.pointer = true;
|
||||
uint_type_ptr.pointer_depth++;
|
||||
uint_type_ptr.parent_type = get_uint_type_id();
|
||||
@ -631,8 +631,8 @@ 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;
|
||||
uint_type_ptr_out = get_uint_type();
|
||||
SPIRType uint_type_ptr_out = get_uint_type();
|
||||
uint_type_ptr.op = OpTypePointer;
|
||||
uint_type_ptr_out.pointer = true;
|
||||
uint_type_ptr_out.pointer_depth++;
|
||||
uint_type_ptr_out.parent_type = get_uint_type_id();
|
||||
@ -663,8 +663,8 @@ void CompilerMSL::build_implicit_builtins()
|
||||
{
|
||||
uint32_t type_ptr_id = ir.increase_bound_by(1);
|
||||
|
||||
SPIRType uint_type_ptr;
|
||||
uint_type_ptr = get_uint_type();
|
||||
SPIRType uint_type_ptr = get_uint_type();
|
||||
uint_type_ptr.op = OpTypePointer;
|
||||
uint_type_ptr.pointer = true;
|
||||
uint_type_ptr.pointer_depth++;
|
||||
uint_type_ptr.parent_type = get_uint_type_id();
|
||||
@ -723,8 +723,8 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 1;
|
||||
|
||||
// Create gl_SubgroupInvocationID.
|
||||
SPIRType uint_type_ptr;
|
||||
uint_type_ptr = get_uint_type();
|
||||
SPIRType uint_type_ptr = get_uint_type();
|
||||
uint_type_ptr.op = OpTypePointer;
|
||||
uint_type_ptr.pointer = true;
|
||||
uint_type_ptr.pointer_depth++;
|
||||
uint_type_ptr.parent_type = get_uint_type_id();
|
||||
@ -745,8 +745,8 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 1;
|
||||
|
||||
// Create gl_SubgroupSize.
|
||||
SPIRType uint_type_ptr;
|
||||
uint_type_ptr = get_uint_type();
|
||||
SPIRType uint_type_ptr = get_uint_type();
|
||||
uint_type_ptr.op = OpTypePointer;
|
||||
uint_type_ptr.pointer = true;
|
||||
uint_type_ptr.pointer_depth++;
|
||||
uint_type_ptr.parent_type = get_uint_type_id();
|
||||
@ -804,8 +804,8 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 1;
|
||||
|
||||
// Create gl_SampleMask.
|
||||
SPIRType uint_type_ptr_out;
|
||||
uint_type_ptr_out = get_uint_type();
|
||||
SPIRType uint_type_ptr_out = get_uint_type();
|
||||
uint_type_ptr_out.op = OpTypePointer;
|
||||
uint_type_ptr_out.pointer = true;
|
||||
uint_type_ptr_out.pointer_depth++;
|
||||
uint_type_ptr_out.parent_type = get_uint_type_id();
|
||||
@ -827,14 +827,14 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 2;
|
||||
|
||||
// Create gl_HelperInvocation.
|
||||
SPIRType bool_type;
|
||||
SPIRType bool_type { 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;
|
||||
bool_type_ptr_in = bool_type;
|
||||
SPIRType bool_type_ptr_in = bool_type;
|
||||
bool_type_ptr_in.op = spv::OpTypePointer;
|
||||
bool_type_ptr_in.pointer = true;
|
||||
bool_type_ptr_in.pointer_depth++;
|
||||
bool_type_ptr_in.parent_type = type_id;
|
||||
@ -855,8 +855,8 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 1;
|
||||
|
||||
// Create gl_LocalInvocationIndex.
|
||||
SPIRType uint_type_ptr;
|
||||
uint_type_ptr = get_uint_type();
|
||||
SPIRType uint_type_ptr = get_uint_type();
|
||||
uint_type_ptr.op = OpTypePointer;
|
||||
uint_type_ptr.pointer = true;
|
||||
uint_type_ptr.pointer_depth++;
|
||||
uint_type_ptr.parent_type = get_uint_type_id();
|
||||
@ -879,6 +879,7 @@ void CompilerMSL::build_implicit_builtins()
|
||||
// Create gl_WorkgroupSize.
|
||||
uint32_t type_id = build_extended_vector_type(get_uint_type_id(), 3);
|
||||
SPIRType uint_type_ptr = get<SPIRType>(type_id);
|
||||
uint_type_ptr.op = OpTypePointer;
|
||||
uint_type_ptr.pointer = true;
|
||||
uint_type_ptr.pointer_depth++;
|
||||
uint_type_ptr.parent_type = type_id;
|
||||
@ -986,14 +987,14 @@ void CompilerMSL::build_implicit_builtins()
|
||||
uint32_t var_id = offset + 2;
|
||||
|
||||
// Create gl_Position.
|
||||
SPIRType vec4_type;
|
||||
SPIRType vec4_type { OpTypeVector };
|
||||
vec4_type.basetype = SPIRType::Float;
|
||||
vec4_type.width = 32;
|
||||
vec4_type.vecsize = 4;
|
||||
set<SPIRType>(type_id, vec4_type);
|
||||
|
||||
SPIRType vec4_type_ptr;
|
||||
vec4_type_ptr = vec4_type;
|
||||
SPIRType vec4_type_ptr = vec4_type;
|
||||
vec4_type_ptr.op = OpTypePointer;
|
||||
vec4_type_ptr.pointer = true;
|
||||
vec4_type_ptr.pointer_depth++;
|
||||
vec4_type_ptr.parent_type = type_id;
|
||||
@ -1070,6 +1071,7 @@ uint32_t CompilerMSL::build_constant_uint_array_pointer()
|
||||
|
||||
// Create a buffer to hold extra data, including the swizzle constants.
|
||||
SPIRType uint_type_pointer = get_uint_type();
|
||||
uint_type_pointer.op = OpTypePointer;
|
||||
uint_type_pointer.pointer = true;
|
||||
uint_type_pointer.pointer_depth++;
|
||||
uint_type_pointer.parent_type = get_uint_type_id();
|
||||
@ -1148,7 +1150,7 @@ uint32_t CompilerMSL::get_uint_type_id()
|
||||
|
||||
uint_type_id = ir.increase_bound_by(1);
|
||||
|
||||
SPIRType type;
|
||||
SPIRType type { OpTypeInt };
|
||||
type.basetype = SPIRType::UInt;
|
||||
type.width = 32;
|
||||
set<SPIRType>(uint_type_id, type);
|
||||
@ -2331,9 +2333,27 @@ uint32_t CompilerMSL::get_target_components_for_fragment_location(uint32_t locat
|
||||
|
||||
uint32_t CompilerMSL::build_extended_vector_type(uint32_t type_id, uint32_t components, SPIRType::BaseType basetype)
|
||||
{
|
||||
assert(components > 1);
|
||||
uint32_t new_type_id = ir.increase_bound_by(1);
|
||||
auto &old_type = get<SPIRType>(type_id);
|
||||
auto *type = &set<SPIRType>(new_type_id, old_type);
|
||||
const auto *p_old_type = &get<SPIRType>(type_id);
|
||||
const SPIRType *old_ptr_t = nullptr;
|
||||
const SPIRType *old_array_t = nullptr;
|
||||
|
||||
if (is_pointer(*p_old_type))
|
||||
{
|
||||
old_ptr_t = p_old_type;
|
||||
p_old_type = &get_pointee_type(*old_ptr_t);
|
||||
}
|
||||
|
||||
if (is_array(*p_old_type))
|
||||
{
|
||||
old_array_t = p_old_type;
|
||||
p_old_type = &get_type(old_array_t->parent_type);
|
||||
}
|
||||
|
||||
auto *type = &set<SPIRType>(new_type_id, *p_old_type);
|
||||
assert(is_scalar(*type) || is_vector(*type));
|
||||
type->op = OpTypeVector;
|
||||
type->vecsize = components;
|
||||
if (basetype != SPIRType::Unknown)
|
||||
type->basetype = basetype;
|
||||
@ -2343,23 +2363,24 @@ uint32_t CompilerMSL::build_extended_vector_type(uint32_t type_id, uint32_t comp
|
||||
type->array_size_literal.clear();
|
||||
type->pointer = false;
|
||||
|
||||
if (is_array(old_type))
|
||||
if (old_array_t)
|
||||
{
|
||||
uint32_t array_type_id = ir.increase_bound_by(1);
|
||||
type = &set<SPIRType>(array_type_id, *type);
|
||||
type->op = OpTypeArray;
|
||||
type->parent_type = new_type_id;
|
||||
type->array = old_type.array;
|
||||
type->array_size_literal = old_type.array_size_literal;
|
||||
type->array = old_array_t->array;
|
||||
type->array_size_literal = old_array_t->array_size_literal;
|
||||
new_type_id = array_type_id;
|
||||
}
|
||||
|
||||
if (old_type.pointer)
|
||||
if (old_ptr_t)
|
||||
{
|
||||
uint32_t ptr_type_id = ir.increase_bound_by(1);
|
||||
type = &set<SPIRType>(ptr_type_id, *type);
|
||||
type->self = new_type_id;
|
||||
type->op = OpTypePointer;
|
||||
type->parent_type = new_type_id;
|
||||
type->storage = old_type.storage;
|
||||
type->storage = old_ptr_t->storage;
|
||||
type->pointer = true;
|
||||
type->pointer_depth++;
|
||||
new_type_id = ptr_type_id;
|
||||
@ -3937,7 +3958,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, OpTypeStruct);
|
||||
ib_type.basetype = SPIRType::Struct;
|
||||
ib_type.storage = storage;
|
||||
set_decoration(ib_type_id, DecorationBlock);
|
||||
@ -4160,13 +4181,14 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch)
|
||||
continue;
|
||||
|
||||
// Create a fake variable to put at the location.
|
||||
uint32_t offset = ir.increase_bound_by(4);
|
||||
uint32_t offset = ir.increase_bound_by(5);
|
||||
uint32_t type_id = offset;
|
||||
uint32_t array_type_id = offset + 1;
|
||||
uint32_t ptr_type_id = offset + 2;
|
||||
uint32_t var_id = offset + 3;
|
||||
uint32_t vec_type_id = offset + 1;
|
||||
uint32_t array_type_id = offset + 2;
|
||||
uint32_t ptr_type_id = offset + 3;
|
||||
uint32_t var_id = offset + 4;
|
||||
|
||||
SPIRType type;
|
||||
SPIRType type { OpTypeInt };
|
||||
switch (input.second.format)
|
||||
{
|
||||
case MSL_SHADER_VARIABLE_FORMAT_UINT16:
|
||||
@ -4180,14 +4202,23 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch)
|
||||
type.width = 32;
|
||||
break;
|
||||
}
|
||||
type.vecsize = input.second.vecsize;
|
||||
set<SPIRType>(type_id, type);
|
||||
if (input.second.vecsize > 1)
|
||||
{
|
||||
type.op = OpTypeVector;
|
||||
type.vecsize = input.second.vecsize;
|
||||
set<SPIRType>(vec_type_id, type);
|
||||
type_id = vec_type_id;
|
||||
}
|
||||
|
||||
type.op = OpTypeArray;
|
||||
type.array.push_back(0);
|
||||
type.array_size_literal.push_back(true);
|
||||
type.parent_type = type_id;
|
||||
set<SPIRType>(array_type_id, type);
|
||||
type.self = type_id;
|
||||
|
||||
type.op = OpTypePointer;
|
||||
type.pointer = true;
|
||||
type.pointer_depth++;
|
||||
type.parent_type = array_type_id;
|
||||
@ -4218,13 +4249,14 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch)
|
||||
continue;
|
||||
|
||||
// Create a fake variable to put at the location.
|
||||
uint32_t offset = ir.increase_bound_by(4);
|
||||
uint32_t offset = ir.increase_bound_by(5);
|
||||
uint32_t type_id = offset;
|
||||
uint32_t array_type_id = offset + 1;
|
||||
uint32_t ptr_type_id = offset + 2;
|
||||
uint32_t var_id = offset + 3;
|
||||
uint32_t vec_type_id = offset + 1;
|
||||
uint32_t array_type_id = offset + 2;
|
||||
uint32_t ptr_type_id = offset + 3;
|
||||
uint32_t var_id = offset + 4;
|
||||
|
||||
SPIRType type;
|
||||
SPIRType type { OpTypeInt };
|
||||
switch (output.second.format)
|
||||
{
|
||||
case MSL_SHADER_VARIABLE_FORMAT_UINT16:
|
||||
@ -4238,17 +4270,25 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch)
|
||||
type.width = 32;
|
||||
break;
|
||||
}
|
||||
type.vecsize = output.second.vecsize;
|
||||
set<SPIRType>(type_id, type);
|
||||
if (output.second.vecsize > 1)
|
||||
{
|
||||
type.op = OpTypeVector;
|
||||
type.vecsize = output.second.vecsize;
|
||||
set<SPIRType>(vec_type_id, type);
|
||||
type_id = vec_type_id;
|
||||
}
|
||||
|
||||
if (is_tesc_shader())
|
||||
{
|
||||
type.op = OpTypeArray;
|
||||
type.array.push_back(0);
|
||||
type.array_size_literal.push_back(true);
|
||||
type.parent_type = type_id;
|
||||
set<SPIRType>(array_type_id, type);
|
||||
}
|
||||
|
||||
type.op = OpTypePointer;
|
||||
type.pointer = true;
|
||||
type.pointer_depth++;
|
||||
type.parent_type = is_tesc_shader() ? array_type_id : type_id;
|
||||
@ -4335,6 +4375,7 @@ uint32_t CompilerMSL::add_interface_block_pointer(uint32_t ib_var_id, StorageCla
|
||||
// do the same with our struct here.
|
||||
uint32_t ib_ptr_type_id = next_id++;
|
||||
auto &ib_ptr_type = set<SPIRType>(ib_ptr_type_id, ib_type);
|
||||
ib_ptr_type.op = OpTypePointer;
|
||||
ib_ptr_type.parent_type = ib_ptr_type.type_alias = ib_type.self;
|
||||
ib_ptr_type.pointer = true;
|
||||
ib_ptr_type.pointer_depth++;
|
||||
@ -4389,23 +4430,24 @@ uint32_t CompilerMSL::add_interface_block_pointer(uint32_t ib_var_id, StorageCla
|
||||
uint32_t CompilerMSL::ensure_correct_builtin_type(uint32_t type_id, BuiltIn builtin)
|
||||
{
|
||||
auto &type = get<SPIRType>(type_id);
|
||||
auto &pointee_type = get_pointee_type(type);
|
||||
|
||||
if ((builtin == BuiltInSampleMask && is_array(type)) ||
|
||||
if ((builtin == BuiltInSampleMask && is_array(pointee_type)) ||
|
||||
((builtin == BuiltInLayer || builtin == BuiltInViewportIndex || builtin == BuiltInFragStencilRefEXT) &&
|
||||
type.basetype != SPIRType::UInt))
|
||||
pointee_type.basetype != SPIRType::UInt))
|
||||
{
|
||||
uint32_t next_id = ir.increase_bound_by(type.pointer ? 2 : 1);
|
||||
uint32_t next_id = ir.increase_bound_by(type_is_pointer(type) ? 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, OpTypeInt);
|
||||
base_type.basetype = SPIRType::UInt;
|
||||
base_type.width = 32;
|
||||
|
||||
if (!type.pointer)
|
||||
if (!type_is_pointer(type))
|
||||
return base_type_id;
|
||||
|
||||
uint32_t ptr_type_id = next_id++;
|
||||
auto &ptr_type = set<SPIRType>(ptr_type_id);
|
||||
ptr_type = base_type;
|
||||
auto &ptr_type = set<SPIRType>(ptr_type_id, base_type);
|
||||
ptr_type.op = spv::OpTypePointer;
|
||||
ptr_type.pointer = true;
|
||||
ptr_type.pointer_depth++;
|
||||
ptr_type.storage = type.storage;
|
||||
@ -4895,6 +4937,7 @@ void CompilerMSL::ensure_member_packing_rules_msl(SPIRType &ib_type, uint32_t in
|
||||
{
|
||||
type.columns = 1;
|
||||
assert(type.array.empty());
|
||||
type.op = OpTypeArray;
|
||||
type.array.push_back(1);
|
||||
type.array_size_literal.push_back(true);
|
||||
}
|
||||
@ -4911,6 +4954,7 @@ void CompilerMSL::ensure_member_packing_rules_msl(SPIRType &ib_type, uint32_t in
|
||||
type.vecsize = type.columns;
|
||||
type.columns = 1;
|
||||
assert(type.array.empty());
|
||||
type.op = OpTypeArray;
|
||||
type.array.push_back(1);
|
||||
type.array_size_literal.push_back(true);
|
||||
}
|
||||
@ -4935,7 +4979,7 @@ void CompilerMSL::emit_store_statement(uint32_t lhs_expression, uint32_t rhs_exp
|
||||
|
||||
if (has_decoration(lhs_expression, DecorationBuiltIn) &&
|
||||
BuiltIn(get_decoration(lhs_expression, DecorationBuiltIn)) == BuiltInSampleMask &&
|
||||
type_is_top_level_array(type))
|
||||
is_array(type))
|
||||
{
|
||||
// Storing an array to SampleMask, have to remove the array-ness before storing.
|
||||
statement(to_expression(lhs_expression), " = ", to_enclosed_unpacked_expression(rhs_expression), "[0];");
|
||||
@ -7451,7 +7495,7 @@ void CompilerMSL::declare_constant_arrays()
|
||||
// FIXME: However, hoisting constants to main() means we need to pass down constant arrays to leaf functions if they are used there.
|
||||
// If there are multiple functions in the module, drop this case to avoid breaking use cases which do not need to
|
||||
// link into Metal libraries. This is hacky.
|
||||
if (type_is_top_level_array(type) && (!fully_inlined || is_scalar(type) || is_vector(type)))
|
||||
if (is_array(type) && (!fully_inlined || is_scalar(type) || is_vector(type)))
|
||||
{
|
||||
add_resource_name(c.self);
|
||||
auto name = to_name(c.self);
|
||||
@ -7483,7 +7527,7 @@ void CompilerMSL::declare_complex_constant_arrays()
|
||||
return;
|
||||
|
||||
auto &type = this->get<SPIRType>(c.constant_type);
|
||||
if (type_is_top_level_array(type) && !(is_scalar(type) || is_vector(type)))
|
||||
if (is_array(type) && !(is_scalar(type) || is_vector(type)))
|
||||
{
|
||||
add_resource_name(c.self);
|
||||
auto name = to_name(c.self);
|
||||
@ -8222,8 +8266,9 @@ bool CompilerMSL::emit_tessellation_access_chain(const uint32_t *ops, uint32_t l
|
||||
|
||||
// We're not going to emit the actual member name, we let any further OpLoad take care of that.
|
||||
// Tag the access chain with the member index we're referencing.
|
||||
bool defer_access_chain = flatten_composites && (is_matrix(result_ptr_type) || is_array(result_ptr_type) ||
|
||||
result_ptr_type.basetype == SPIRType::Struct);
|
||||
auto &result_pointee_type = get_pointee_type(result_ptr_type);
|
||||
bool defer_access_chain = flatten_composites && (is_matrix(result_pointee_type) || is_array(result_pointee_type) ||
|
||||
result_pointee_type.basetype == SPIRType::Struct);
|
||||
|
||||
if (!defer_access_chain)
|
||||
{
|
||||
@ -9864,7 +9909,7 @@ bool CompilerMSL::maybe_emit_array_assignment(uint32_t id_lhs, uint32_t id_rhs)
|
||||
{
|
||||
// We only care about assignments of an entire array
|
||||
auto &type = expression_type(id_lhs);
|
||||
if (!type_is_top_level_array(get_pointee_type(type)))
|
||||
if (!is_array(get_pointee_type(type)))
|
||||
return false;
|
||||
|
||||
auto *var = maybe_get<SPIRVariable>(id_lhs);
|
||||
@ -10814,7 +10859,7 @@ string CompilerMSL::to_function_name(const TextureFunctionNameArguments &args)
|
||||
|
||||
string CompilerMSL::convert_to_f32(const string &expr, uint32_t components)
|
||||
{
|
||||
SPIRType t;
|
||||
SPIRType t { components > 1 ? OpTypeVector : OpTypeFloat };
|
||||
t.basetype = SPIRType::Float;
|
||||
t.vecsize = components;
|
||||
t.columns = 1;
|
||||
@ -11923,7 +11968,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 { OpTypeMatrix };
|
||||
const SPIRType *declared_type = &physical_type;
|
||||
|
||||
// If a struct is being declared with physical layout,
|
||||
@ -14318,7 +14363,6 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg)
|
||||
auto &type = get_variable_data_type(var);
|
||||
auto &var_type = get<SPIRType>(arg.type);
|
||||
StorageClass type_storage = var_type.storage;
|
||||
bool is_pointer = var_type.pointer;
|
||||
|
||||
// If we need to modify the name of the variable, make sure we use the original variable.
|
||||
// Our alias is just a shadow variable.
|
||||
@ -14326,7 +14370,7 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg)
|
||||
if (arg.alias_global_variable && var.basevariable)
|
||||
name_id = var.basevariable;
|
||||
|
||||
bool constref = !arg.alias_global_variable && is_pointer && arg.write_count == 0;
|
||||
bool constref = !arg.alias_global_variable && is_pointer(var_type) && arg.write_count == 0;
|
||||
// Framebuffer fetch is plain value, const looks out of place, but it is not wrong.
|
||||
if (type_is_msl_framebuffer_fetch(type))
|
||||
constref = false;
|
||||
@ -14424,7 +14468,7 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg)
|
||||
}
|
||||
}
|
||||
|
||||
if (!builtin && !is_pointer &&
|
||||
if (!builtin && !is_pointer(var_type) &&
|
||||
(type_storage == StorageClassFunction || type_storage == StorageClassGeneric))
|
||||
{
|
||||
// If the argument is a pure value and not an opaque type, we will pass by value.
|
||||
@ -14973,7 +15017,7 @@ string CompilerMSL::to_member_reference(uint32_t base, const SPIRType &type, uin
|
||||
|
||||
bool is_buffer_variable =
|
||||
is_block && (var->storage == StorageClassUniform || var->storage == StorageClassStorageBuffer);
|
||||
declared_as_pointer = is_buffer_variable && is_array(get<SPIRType>(var->basetype));
|
||||
declared_as_pointer = is_buffer_variable && is_array(get_pointee_type(var->basetype));
|
||||
}
|
||||
|
||||
if (declared_as_pointer || (!ptr_chain_is_resolved && should_dereference(base)))
|
||||
@ -15003,7 +15047,7 @@ string CompilerMSL::type_to_glsl(const SPIRType &type, uint32_t id, bool member)
|
||||
string type_name;
|
||||
|
||||
// Pointer?
|
||||
if (type_is_top_level_pointer(type) || type_is_array_of_pointers(type))
|
||||
if (is_pointer(type) || type_is_array_of_pointers(type))
|
||||
{
|
||||
assert(type.pointer_depth > 0);
|
||||
|
||||
@ -15031,7 +15075,7 @@ string CompilerMSL::type_to_glsl(const SPIRType &type, uint32_t id, bool member)
|
||||
// the C-style nesting works right.
|
||||
// FIXME: This is somewhat of a hack.
|
||||
bool old_is_using_builtin_array = is_using_builtin_array;
|
||||
if (type_is_top_level_physical_pointer(type))
|
||||
if (is_physical_pointer(type))
|
||||
is_using_builtin_array = false;
|
||||
|
||||
type_name = join(type_address_space, " ", type_to_glsl(*p_parent_type, id));
|
||||
@ -16890,8 +16934,7 @@ bool CompilerMSL::OpCodePreprocessor::handle(Op opcode, const uint32_t *args, ui
|
||||
auto *var = compiler.maybe_get_backing_variable(args[2]);
|
||||
if (var != nullptr)
|
||||
{
|
||||
auto &type = compiler.get<SPIRType>(var->basetype);
|
||||
if (!is_runtime_size_array(type))
|
||||
if (!compiler.is_var_runtime_size_array(*var))
|
||||
compiler.buffers_requiring_array_length.insert(var->self);
|
||||
}
|
||||
break;
|
||||
@ -17304,7 +17347,7 @@ void CompilerMSL::cast_from_variable_load(uint32_t source_id, std::string &expr,
|
||||
// Type fixups for workgroup variables if they are booleans.
|
||||
if (rewrite_boolean_load)
|
||||
{
|
||||
if (type_is_top_level_array(expr_type))
|
||||
if (is_array(expr_type))
|
||||
expr = to_rerolled_array_expression(expr_type, expr, expr_type);
|
||||
else
|
||||
expr = join(type_to_glsl(expr_type), "(", expr, ")");
|
||||
@ -17381,7 +17424,7 @@ void CompilerMSL::cast_from_variable_load(uint32_t source_id, std::string &expr,
|
||||
break;
|
||||
}
|
||||
|
||||
if (type_is_top_level_array(expr_type) && builtin == BuiltInSampleMask)
|
||||
if (is_array(expr_type) && builtin == BuiltInSampleMask)
|
||||
{
|
||||
// Needs special handling.
|
||||
auto wrap_expr = join(type_to_glsl(expr_type), "({ ");
|
||||
@ -17391,7 +17434,7 @@ void CompilerMSL::cast_from_variable_load(uint32_t source_id, std::string &expr,
|
||||
}
|
||||
else if (expected_type != expr_type.basetype)
|
||||
{
|
||||
if (type_is_top_level_array(expr_type) && (builtin == BuiltInTessLevelInner || builtin == BuiltInTessLevelOuter))
|
||||
if (is_array(expr_type) && (builtin == BuiltInTessLevelInner || builtin == BuiltInTessLevelOuter))
|
||||
{
|
||||
// Triggers when loading TessLevel directly as an array.
|
||||
// Need explicit padding + cast.
|
||||
@ -17450,7 +17493,7 @@ void CompilerMSL::cast_to_variable_store(uint32_t target_id, std::string &expr,
|
||||
// Type fixups for workgroup variables or struct members if they are booleans.
|
||||
if (rewrite_boolean_store)
|
||||
{
|
||||
if (type_is_top_level_array(expr_type))
|
||||
if (is_array(expr_type))
|
||||
{
|
||||
expr = to_rerolled_array_expression(*var_type, expr, expr_type);
|
||||
}
|
||||
@ -17729,6 +17772,7 @@ void CompilerMSL::analyze_argument_buffers()
|
||||
|
||||
// Create a buffer to hold extra data, including the swizzle constants.
|
||||
SPIRType uint_type_pointer = get_uint_type();
|
||||
uint_type_pointer.op = OpTypePointer;
|
||||
uint_type_pointer.pointer = true;
|
||||
uint_type_pointer.pointer_depth++;
|
||||
uint_type_pointer.parent_type = get_uint_type_id();
|
||||
@ -17784,7 +17828,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, OpTypeStruct);
|
||||
|
||||
buffer_type.basetype = SPIRType::Struct;
|
||||
|
||||
@ -17801,8 +17845,9 @@ 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, OpTypePointer);
|
||||
ptr_type = buffer_type;
|
||||
ptr_type.op = spv::OpTypePointer;
|
||||
ptr_type.pointer = true;
|
||||
ptr_type.pointer_depth++;
|
||||
ptr_type.parent_type = type_id;
|
||||
@ -17885,14 +17930,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, 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, OpTypeArray);
|
||||
sampler_type_array = new_sampler_type;
|
||||
sampler_type_array.array = type.array;
|
||||
sampler_type_array.array_size_literal = type.array_size_literal;
|
||||
@ -17943,12 +17988,13 @@ void CompilerMSL::analyze_argument_buffers()
|
||||
uint32_t atomic_type_id = offset;
|
||||
uint32_t type_ptr_id = offset + 1;
|
||||
|
||||
SPIRType atomic_type;
|
||||
SPIRType atomic_type { OpTypeInt };
|
||||
atomic_type.basetype = SPIRType::AtomicCounter;
|
||||
atomic_type.width = 32;
|
||||
atomic_type.vecsize = 1;
|
||||
set<SPIRType>(atomic_type_id, atomic_type);
|
||||
|
||||
atomic_type.op = OpTypePointer;
|
||||
atomic_type.pointer = true;
|
||||
atomic_type.pointer_depth++;
|
||||
atomic_type.parent_type = atomic_type_id;
|
||||
@ -18009,13 +18055,14 @@ 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, 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, OpTypePointer);
|
||||
ptr_type = buff_type;
|
||||
ptr_type.op = spv::OpTypePointer;
|
||||
ptr_type.pointer = true;
|
||||
ptr_type.pointer_depth++;
|
||||
ptr_type.parent_type = buff_type_id;
|
||||
@ -18033,12 +18080,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, 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, OpTypeImage);
|
||||
img_type.basetype = SPIRType::Image;
|
||||
img_type.storage = StorageClassUniformConstant;
|
||||
|
||||
@ -18064,7 +18111,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, OpTypeSampler);
|
||||
samp_type.basetype = SPIRType::Sampler;
|
||||
samp_type.storage = StorageClassUniformConstant;
|
||||
|
||||
@ -18083,8 +18130,8 @@ 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);
|
||||
ary_type = get<SPIRType>(type_id);
|
||||
auto &ary_type = set<SPIRType>(ary_type_id, get<SPIRType>(type_id));
|
||||
ary_type.op = OpTypeArray;
|
||||
ary_type.array.push_back(count);
|
||||
ary_type.array_size_literal.push_back(true);
|
||||
ary_type.parent_type = type_id;
|
||||
|
@ -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,9 +568,9 @@ 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, base);
|
||||
|
||||
vecbase = base;
|
||||
vecbase.op = op;
|
||||
vecbase.vecsize = vecsize;
|
||||
vecbase.self = id;
|
||||
vecbase.parent_type = ops[1];
|
||||
@ -583,9 +583,9 @@ 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, base);
|
||||
|
||||
matrixbase = base;
|
||||
matrixbase.op = op;
|
||||
matrixbase.columns = colcount;
|
||||
matrixbase.self = id;
|
||||
matrixbase.parent_type = ops[1];
|
||||
@ -595,12 +595,11 @@ void Parser::parse(const Instruction &instruction)
|
||||
case OpTypeArray:
|
||||
{
|
||||
uint32_t id = ops[0];
|
||||
auto &arraybase = set<SPIRType>(id);
|
||||
|
||||
uint32_t tid = ops[1];
|
||||
auto &base = get<SPIRType>(tid);
|
||||
auto &arraybase = set<SPIRType>(id, base);
|
||||
|
||||
arraybase = base;
|
||||
arraybase.op = op;
|
||||
arraybase.parent_type = tid;
|
||||
|
||||
uint32_t cid = ops[2];
|
||||
@ -615,7 +614,9 @@ void Parser::parse(const Instruction &instruction)
|
||||
|
||||
arraybase.array_size_literal.push_back(literal);
|
||||
arraybase.array.push_back(literal ? c->scalar() : cid);
|
||||
// Do NOT set arraybase.self!
|
||||
|
||||
// .self resolves down to non-array/non-pointer type.
|
||||
arraybase.self = base.self;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -624,25 +625,27 @@ 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, base);
|
||||
|
||||
// We're copying type information into Array types, so we'll need a fixup for any physical pointer
|
||||
// references.
|
||||
if (base.forward_pointer)
|
||||
forward_pointer_fixups.push_back({ id, ops[1] });
|
||||
|
||||
arraybase = base;
|
||||
arraybase.op = op;
|
||||
arraybase.array.push_back(0);
|
||||
arraybase.array_size_literal.push_back(true);
|
||||
arraybase.parent_type = ops[1];
|
||||
// Do NOT set arraybase.self!
|
||||
|
||||
// .self resolves down to non-array/non-pointer type.
|
||||
arraybase.self = base.self;
|
||||
break;
|
||||
}
|
||||
|
||||
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 +662,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 +672,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,10 +685,13 @@ 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;
|
||||
ptrbase.op = op;
|
||||
}
|
||||
|
||||
ptrbase.pointer = true;
|
||||
ptrbase.pointer_depth++;
|
||||
@ -706,7 +712,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 +727,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 +776,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 +784,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 +1031,9 @@ void Parser::parse(const Instruction &instruction)
|
||||
{
|
||||
uint32_t ids = ir.increase_bound_by(2);
|
||||
|
||||
SPIRType type;
|
||||
auto &type = set<SPIRType>(ids, OpTypeInt);
|
||||
type.basetype = SPIRType::Int;
|
||||
type.width = 32;
|
||||
set<SPIRType>(ids, type);
|
||||
auto &c = set<SPIRConstant>(ids + 1, ids);
|
||||
|
||||
current_block->condition = c.self;
|
||||
|
@ -291,7 +291,7 @@ static bool naturally_emit_type(const SPIRType &type)
|
||||
bool CompilerReflection::type_is_reference(const SPIRType &type) const
|
||||
{
|
||||
// Physical pointers and arrays of physical pointers need to refer to the pointee's type.
|
||||
return type_is_top_level_physical_pointer(type) ||
|
||||
return is_physical_pointer(type) ||
|
||||
(type_is_array_of_pointers(type) && type.storage == StorageClassPhysicalStorageBuffer);
|
||||
}
|
||||
|
||||
@ -341,7 +341,7 @@ void CompilerReflection::emit_type(uint32_t type_id, bool &emitted_open_tag)
|
||||
json_stream->emit_json_key_object("_" + std::to_string(type_id));
|
||||
json_stream->emit_json_key_value("name", name);
|
||||
|
||||
if (type_is_top_level_physical_pointer(type))
|
||||
if (is_physical_pointer(type))
|
||||
{
|
||||
json_stream->emit_json_key_value("type", "_" + std::to_string(type.parent_type));
|
||||
json_stream->emit_json_key_value("physical_pointer", true);
|
||||
@ -404,7 +404,7 @@ void CompilerReflection::emit_type_member(const SPIRType &type, uint32_t index)
|
||||
|
||||
void CompilerReflection::emit_type_array(const SPIRType &type)
|
||||
{
|
||||
if (!type_is_top_level_physical_pointer(type) && !type.array.empty())
|
||||
if (!is_physical_pointer(type) && !type.array.empty())
|
||||
{
|
||||
json_stream->emit_json_key_array("array");
|
||||
// Note that we emit the zeros here as a means of identifying
|
||||
@ -444,7 +444,7 @@ void CompilerReflection::emit_type_member_qualifiers(const SPIRType &type, uint3
|
||||
if (dec.decoration_flags.get(DecorationRowMajor))
|
||||
json_stream->emit_json_key_value("row_major", true);
|
||||
|
||||
if (type_is_top_level_physical_pointer(membertype))
|
||||
if (is_physical_pointer(membertype))
|
||||
json_stream->emit_json_key_value("physical_pointer", true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user