vkd3d-shader/d3d-asm: Use vkd3d_shader_register.dimension to know when to dump swizzle.

The assumption that sampler registers never have a swizzle is not
totally correct.

For instance, for the following shader:

    Texture2D tex;
    sampler sam;

    float4 main() : sv_target
    {
        return tex.GatherGreen(sam, float2(0, 0));
    }

the gather instruction is being disassembled as

  gather4_indexable(texture2d) o0.xyzw, l(0.0, 0.0, 0.0, 0.0), t0.xyzw, s0

instead of

  gather4_indexable(texture2d)(float,float,float,float) o0.xyzw, l(0.0, 0.0, 0.0, 0.0), t0.xyzw, s0.y

(notice the missing swizzle in the last parameter s0).

This is because the Gather instructions give the sampler register a vec4
dimension (and scalar swizzle type) to indicate the channel for the
gather operation.

The solution is using the new vkd3d_shader_register.dimension instead of
checking the swizzle type.
This commit is contained in:
Francisco Casas 2023-08-16 01:33:43 -04:00 committed by Alexandre Julliard
parent e44a1927e5
commit a358722f71
Notes: Alexandre Julliard 2023-09-27 23:00:17 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/369

View File

@ -1330,7 +1330,7 @@ static void shader_dump_src_param(struct vkd3d_d3d_asm_compiler *compiler,
}
if (param->reg.type != VKD3DSPR_IMMCONST && param->reg.type != VKD3DSPR_IMMCONST64
&& param->reg.type != VKD3DSPR_SAMPLER)
&& param->reg.dimension == VSIR_DIMENSION_VEC4)
{
unsigned int swizzle_x = vkd3d_swizzle_get_component(swizzle, 0);
unsigned int swizzle_y = vkd3d_swizzle_get_component(swizzle, 1);