Pass the original pointer type to ensure_correct_attribute_type().

This prevents us from overwriting the variable's type with a non-pointer
type.
This commit is contained in:
Chip Davis 2019-02-11 16:07:43 -06:00
parent eb89c3a428
commit 1919eb1b46
5 changed files with 10 additions and 7 deletions

View File

@ -31,7 +31,7 @@ void spvArrayCopyFromConstant1(thread T (&dst)[N], constant T (&src)[N])
for (uint i = 0; i < N; dst[i] = src[i], i++);
}
float4 consume_constant_arrays2(thread const float4 (&positions)[4], thread const float4 (&positions2)[4], int Index1, int Index2)
float4 consume_constant_arrays2(thread const float4 (&positions)[4], thread const float4 (&positions2)[4], thread int& Index1, thread int& Index2)
{
float4 indexable[4];
spvArrayCopyFromStack1(indexable, positions);
@ -40,7 +40,7 @@ float4 consume_constant_arrays2(thread const float4 (&positions)[4], thread cons
return indexable[Index1] + indexable_1[Index2];
}
float4 consume_constant_arrays(thread const float4 (&positions)[4], thread const float4 (&positions2)[4], int Index1, int Index2)
float4 consume_constant_arrays(thread const float4 (&positions)[4], thread const float4 (&positions2)[4], thread int& Index1, thread int& Index2)
{
return consume_constant_arrays2(positions, positions2, Index1, Index2);
}

View File

@ -44,7 +44,7 @@ void write_deeper_in_function(thread float4x4& outTransModel, constant UBO& ubo,
color = colors[2];
}
void write_in_function(thread float4x4& outTransModel, constant UBO& ubo, thread float4& color, thread float4 (&colors)[3], float3 inNormal)
void write_in_function(thread float4x4& outTransModel, constant UBO& ubo, thread float4& color, thread float4 (&colors)[3], thread float3& inNormal)
{
outTransModel[2] = float4(inNormal, 1.0);
write_deeper_in_function(outTransModel, ubo, color, colors);

View File

@ -22,7 +22,7 @@ struct main0_in
float3 aNormal [[attribute(1)]];
};
void set_output(device float4& gl_Position, constant UBO& v_18, float4 aVertex, device float3& vNormal, float3 aNormal)
void set_output(device float4& gl_Position, constant UBO& v_18, thread float4& aVertex, device float3& vNormal, thread float3& aNormal)
{
gl_Position = v_18.uMVP * aVertex;
vNormal = aNormal;

View File

@ -36,7 +36,7 @@ void test(thread float4 (&SPIRV_Cross_return_value)[2])
spvArrayCopyFromConstant1(SPIRV_Cross_return_value, _20);
}
void test2(thread float4 (&SPIRV_Cross_return_value)[2], float4 vInput0, float4 vInput1)
void test2(thread float4 (&SPIRV_Cross_return_value)[2], thread float4& vInput0, thread float4& vInput1)
{
float4 foobar[2];
foobar[0] = vInput0;

View File

@ -1100,9 +1100,12 @@ void CompilerMSL::add_plain_variable_to_interface_block(StorageClass storage, co
if (storage == StorageClassInput && (get_execution_model() == ExecutionModelVertex ||
get_execution_model() == ExecutionModelTessellationControl))
{
type_id = ensure_correct_attribute_type(type_id, locn);
type_id = ensure_correct_attribute_type(var.basetype, locn);
var.basetype = type_id;
ib_type.member_types[ib_mbr_idx] = get_pointee_type_id(type_id);
type_id = get_pointee_type_id(type_id);
if (strip_array && is_array(get<SPIRType>(type_id)))
type_id = get<SPIRType>(type_id).parent_type;
ib_type.member_types[ib_mbr_idx] = type_id;
}
set_member_decoration(ib_type.self, ib_mbr_idx, DecorationLocation, locn);
mark_location_as_used_by_shader(locn, storage);