MSL: Fix initializer for tess level outputs.

It's an array, not vector.
This commit is contained in:
Hans-Kristian Arntzen 2021-01-06 10:39:39 +01:00
parent ab9200ffdf
commit efed4c9738
3 changed files with 31 additions and 28 deletions

View File

@ -55,10 +55,18 @@ struct main0_out
kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]])
{ {
device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4];
spvTessLevel[gl_PrimitiveID].edgeTessellationFactor = half4(0.0, 0.0, 0.0, 0.0); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(0.0);
spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half2(0.0, 0.0); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(0.0);
spvTessLevel[gl_PrimitiveID].edgeTessellationFactor = half4(0.0, 0.0, 0.0, 0.0); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(0.0);
spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half2(0.0, 0.0); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[3] = half(0.0);
spvTessLevel[gl_PrimitiveID].insideTessellationFactor[0] = half(0.0);
spvTessLevel[gl_PrimitiveID].insideTessellationFactor[1] = half(0.0);
spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(0.0);
spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(0.0);
spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(0.0);
spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[3] = half(0.0);
spvTessLevel[gl_PrimitiveID].insideTessellationFactor[0] = half(0.0);
spvTessLevel[gl_PrimitiveID].insideTessellationFactor[1] = half(0.0);
gl_out[gl_InvocationID].gl_Position = float4(1.0); gl_out[gl_InvocationID].gl_Position = float4(1.0);
spvTessLevel[gl_PrimitiveID].insideTessellationFactor[0] = half(1.0); spvTessLevel[gl_PrimitiveID].insideTessellationFactor[0] = half(1.0);
spvTessLevel[gl_PrimitiveID].insideTessellationFactor[1] = half(2.0); spvTessLevel[gl_PrimitiveID].insideTessellationFactor[1] = half(2.0);

View File

@ -55,9 +55,13 @@ struct main0_out
kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]])
{ {
device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4];
spvTessLevel[gl_PrimitiveID].edgeTessellationFactor = half3(0.0, 0.0, 0.0); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(0.0);
spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(0.0);
spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(0.0);
spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(0.0); spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(0.0);
spvTessLevel[gl_PrimitiveID].edgeTessellationFactor = half3(0.0, 0.0, 0.0); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(0.0);
spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(0.0);
spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(0.0);
spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(0.0); spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(0.0);
gl_out[gl_InvocationID].gl_Position = float4(1.0); gl_out[gl_InvocationID].gl_Position = float4(1.0);
spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(1.0); spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(1.0);

View File

@ -10752,25 +10752,14 @@ void CompilerMSL::entry_point_args_builtin(string &ep_args)
if (outer_factor_initializer_id && (c = maybe_get<SPIRConstant>(outer_factor_initializer_id))) if (outer_factor_initializer_id && (c = maybe_get<SPIRConstant>(outer_factor_initializer_id)))
{ {
auto &entry_func = get<SPIRFunction>(ir.default_entry_point); auto &entry_func = get<SPIRFunction>(ir.default_entry_point);
if (get_execution_mode_bitset().get(ExecutionModeTriangles))
{
entry_func.fixup_hooks_in.push_back([=]() { entry_func.fixup_hooks_in.push_back([=]() {
statement(builtin_to_glsl(BuiltInTessLevelOuter, StorageClassOutput), " = ", "half3(", uint32_t components = get_execution_mode_bitset().get(ExecutionModeTriangles) ? 3 : 4;
to_expression(c->subconstants[0]), ", ", for (uint32_t i = 0; i < components; i++)
to_expression(c->subconstants[1]), ", ",
to_expression(c->subconstants[2]), ");");
});
}
else
{ {
entry_func.fixup_hooks_in.push_back([=]() { statement(builtin_to_glsl(BuiltInTessLevelOuter, StorageClassOutput), "[", i, "] = ",
statement(builtin_to_glsl(BuiltInTessLevelOuter, StorageClassOutput), " = ", "half4(", "half(", to_expression(c->subconstants[i]), ");");
to_expression(c->subconstants[0]), ", ",
to_expression(c->subconstants[1]), ", ",
to_expression(c->subconstants[2]), ", ",
to_expression(c->subconstants[3]), ");");
});
} }
});
} }
if (inner_factor_initializer_id && (c = maybe_get<SPIRConstant>(inner_factor_initializer_id))) if (inner_factor_initializer_id && (c = maybe_get<SPIRConstant>(inner_factor_initializer_id)))
@ -10786,9 +10775,11 @@ void CompilerMSL::entry_point_args_builtin(string &ep_args)
else else
{ {
entry_func.fixup_hooks_in.push_back([=]() { entry_func.fixup_hooks_in.push_back([=]() {
statement(builtin_to_glsl(BuiltInTessLevelInner, StorageClassOutput), " = ", "half2(", for (uint32_t i = 0; i < 2; i++)
to_expression(c->subconstants[0]), ", ", {
to_expression(c->subconstants[1]), ");"); statement(builtin_to_glsl(BuiltInTessLevelInner, StorageClassOutput), "[", i, "] = ",
"half(", to_expression(c->subconstants[i]), ");");
}
}); });
} }
} }