MSL: Expand quad gl_TessCoord to a float3.
This is the actual SPIR-V type of the builtin. We forced to a `float2` in the declaration because that's what Metal wants.
This commit is contained in:
Родитель
68b09f2a34
Коммит
c8ee9fbe76
|
@ -29,9 +29,9 @@ struct main0_patchIn
|
|||
[[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], constant UBO& _31 [[buffer(1)]], texture2d<float> uHeightmapDisplacement [[texture(0)]], sampler uHeightmapDisplacementSmplr [[sampler(0)]], float2 gl_TessCoord [[position_in_patch]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float2 _201 = patchIn.vOutPatchPosBase + (gl_TessCoord.xy * _31.uPatchSize);
|
||||
float2 _214 = mix(patchIn.vPatchLods.yx, patchIn.vPatchLods.zw, float2(gl_TessCoord.x));
|
||||
float _221 = mix(_214.x, _214.y, gl_TessCoord.y);
|
||||
float2 _201 = patchIn.vOutPatchPosBase + (float3(gl_TessCoord, 0).xy * _31.uPatchSize);
|
||||
float2 _214 = mix(patchIn.vPatchLods.yx, patchIn.vPatchLods.zw, float2(float3(gl_TessCoord, 0).x));
|
||||
float _221 = mix(_214.x, _214.y, float3(gl_TessCoord, 0).y);
|
||||
float _223 = floor(_221);
|
||||
float2 _125 = _201 * _31.uInvHeightmapSize;
|
||||
float2 _141 = _31.uInvHeightmapSize * exp2(_223);
|
||||
|
|
|
@ -50,7 +50,7 @@ float3 sample_height_displacement(thread const float2& uv, thread const float2&
|
|||
[[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], constant UBO& v_31 [[buffer(1)]], texture2d<float> uHeightmapDisplacement [[texture(0)]], sampler uHeightmapDisplacementSmplr [[sampler(0)]], float2 gl_TessCoord [[position_in_patch]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float2 tess_coord = gl_TessCoord.xy;
|
||||
float2 tess_coord = float3(gl_TessCoord, 0).xy;
|
||||
float2 param = tess_coord;
|
||||
float2 pos = lerp_vertex(param, patchIn.vOutPatchPosBase, v_31);
|
||||
float2 param_1 = tess_coord;
|
||||
|
|
|
@ -7147,6 +7147,14 @@ void CompilerMSL::bitcast_from_builtin_load(uint32_t source_id, std::string &exp
|
|||
|
||||
if (expected_type != expr_type.basetype)
|
||||
expr = bitcast_expression(expr_type, expected_type, expr);
|
||||
|
||||
if (builtin == BuiltInTessCoord && get_entry_point().flags.get(ExecutionModeQuads) && expr_type.vecsize == 3)
|
||||
{
|
||||
// In SPIR-V, this is always a vec3, even for quads. In Metal, though, it's a float2 for quads.
|
||||
// The code is expecting a float3, so we need to widen this.
|
||||
expr = join("float3(", expr, ", 0)");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CompilerMSL::bitcast_to_builtin_store(uint32_t target_id, std::string &expr, const SPIRType &expr_type)
|
||||
|
|
Загрузка…
Ссылка в новой задаче