[PATCH 0/3] MR369: vkd3d-shader/d3d-asm: Minor disassembler fixes.
Some minor fixes so that we match better the native disassembler's output. Explanations in the commit descriptions. -- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/369
From: Francisco Casas <fcasas(a)codeweavers.com> 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. --- libs/vkd3d-shader/d3d_asm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/vkd3d-shader/d3d_asm.c b/libs/vkd3d-shader/d3d_asm.c index 4582b22a7..7df2f1634 100644 --- a/libs/vkd3d-shader/d3d_asm.c +++ b/libs/vkd3d-shader/d3d_asm.c @@ -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); -- GitLab https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/369
From: Francisco Casas <fcasas(a)codeweavers.com> This change ensures that we don't dump the writemask for registers that have a scalar dimension. For instance, for this shader: float r; float4 main(out float d : DEPTH) : sv_target { d = r; return 0; } we now correctly dump dcl_output oDepth instead of dcl_output oDepth.x --- libs/vkd3d-shader/d3d_asm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/vkd3d-shader/d3d_asm.c b/libs/vkd3d-shader/d3d_asm.c index 7df2f1634..62b50876a 100644 --- a/libs/vkd3d-shader/d3d_asm.c +++ b/libs/vkd3d-shader/d3d_asm.c @@ -1264,7 +1264,7 @@ static void shader_dump_dst_param(struct vkd3d_d3d_asm_compiler *compiler, shader_dump_register(compiler, ¶m->reg, is_declaration); - if (write_mask) + if (write_mask && param->reg.dimension == VSIR_DIMENSION_VEC4) { static const char write_mask_chars[] = "xyzw"; -- GitLab https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/369
From: Francisco Casas <fcasas(a)codeweavers.com> This register is unique and thus is not accompanied with an offset in the native disassembler output. --- libs/vkd3d-shader/d3d_asm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/vkd3d-shader/d3d_asm.c b/libs/vkd3d-shader/d3d_asm.c index 62b50876a..6a3513a28 100644 --- a/libs/vkd3d-shader/d3d_asm.c +++ b/libs/vkd3d-shader/d3d_asm.c @@ -1164,7 +1164,8 @@ static void shader_dump_register(struct vkd3d_d3d_asm_compiler *compiler, const } else if (reg->type != VKD3DSPR_RASTOUT && reg->type != VKD3DSPR_MISCTYPE - && reg->type != VKD3DSPR_NULL) + && reg->type != VKD3DSPR_NULL + && reg->type != VKD3DSPR_DEPTHOUT) { if (offset != ~0u) { -- GitLab https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/369
This merge request was approved by Giovanni Mascellani. -- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/369
```diff if (param->reg.type != VKD3DSPR_IMMCONST && param->reg.type != VKD3DSPR_IMMCONST64 - && param->reg.type != VKD3DSPR_SAMPLER) + && param->reg.dimension == VSIR_DIMENSION_VEC4) ```
Does that make the IMMCONST/IMMCONST64 checks redundant as well? -- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/369#note_46973
On Wed Sep 27 17:28:38 2023 +0000, Henri Verbeet wrote:
```diff if (param->reg.type != VKD3DSPR_IMMCONST && param->reg.type != VKD3DSPR_IMMCONST64 - && param->reg.type != VKD3DSPR_SAMPLER) + && param->reg.dimension == VSIR_DIMENSION_VEC4) ```
Does that make the IMMCONST/IMMCONST64 checks redundant as well? VKD3DSPR_IMMCONST64~s have dimension VSIR_DIMENSION_VEC4 but their swizzles are not intended to be used nor shown. shader_dump_register() takes care of showing the immconst as an expression such as `l(1.0, 2.0, 3.0, 4.0)`.
On the other hand we could get rid of the check for the regular VKD3DSPR_IMMCONST~s since they have dimension VSIR_DIMENSION_SCALAR, but it feels right to keep it for documentation purposes, since their swizzles are also not intended to be used nor shown. -- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/369#note_46981
This merge request was approved by Henri Verbeet. -- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/369
participants (4)
-
Francisco Casas -
Francisco Casas (@fcasas) -
Giovanni Mascellani (@giomasce) -
Henri Verbeet (@hverbeet)