vkd3d-shader/msl: Implement VKD3DSIH_IMUL.

This commit is contained in:
Henri Verbeet
2025-05-23 15:23:10 +02:00
parent a2eb3324d4
commit a570932b82
Notes: Henri Verbeet 2025-06-10 18:06:32 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1554
6 changed files with 51 additions and 17 deletions

View File

@@ -908,6 +908,37 @@ static void msl_movc(struct msl_generator *gen, const struct vkd3d_shader_instru
msl_dst_cleanup(&dst, &gen->string_buffers); msl_dst_cleanup(&dst, &gen->string_buffers);
} }
static void msl_mul64(struct msl_generator *gen, const struct vkd3d_shader_instruction *ins)
{
struct msl_src src[2];
struct msl_dst dst;
uint32_t mask;
if (ins->dst[0].reg.type != VKD3DSPR_NULL)
{
/* TODO: mulhi(). */
mask = msl_dst_init(&dst, gen, ins, &ins->dst[0]);
msl_print_assignment(gen, &dst, "<unhandled 64-bit multiplication>");
msl_dst_cleanup(&dst, &gen->string_buffers);
msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
"Internal compiler error: Unhandled 64-bit integer multiplication.");
}
if (ins->dst[1].reg.type != VKD3DSPR_NULL)
{
mask = msl_dst_init(&dst, gen, ins, &ins->dst[1]);
msl_src_init(&src[0], gen, &ins->src[0], mask);
msl_src_init(&src[1], gen, &ins->src[1], mask);
msl_print_assignment(gen, &dst, "%s * %s", src[0].str->buffer, src[1].str->buffer);
msl_src_cleanup(&src[1], &gen->string_buffers);
msl_src_cleanup(&src[0], &gen->string_buffers);
msl_dst_cleanup(&dst, &gen->string_buffers);
}
}
static void msl_ret(struct msl_generator *gen, const struct vkd3d_shader_instruction *ins) static void msl_ret(struct msl_generator *gen, const struct vkd3d_shader_instruction *ins)
{ {
msl_print_indent(gen->buffer, gen->indent); msl_print_indent(gen->buffer, gen->indent);
@@ -1001,6 +1032,9 @@ static void msl_handle_instruction(struct msl_generator *gen, const struct vkd3d
case VKD3DSIH_MIN: case VKD3DSIH_MIN:
msl_intrinsic(gen, ins, "min"); msl_intrinsic(gen, ins, "min");
break; break;
case VKD3DSIH_IMUL:
msl_mul64(gen, ins);
break;
case VKD3DSIH_INE: case VKD3DSIH_INE:
case VKD3DSIH_NEU: case VKD3DSIH_NEU:
msl_relop(gen, ins, "!="); msl_relop(gen, ins, "!=");

View File

@@ -314,7 +314,7 @@ uniform 0 uint 7
uniform 4 uint 0xfffffff7 uniform 4 uint 0xfffffff7
uniform 8 uint 0xfffffff9 uniform 8 uint 0xfffffff9
uniform 12 uint 9 uniform 12 uint 9
todo(msl) draw quad draw quad
probe (0, 0) rgbai(-21, -45, 21, 45) probe (0, 0) rgbai(-21, -45, 21, 45)
[pixel shader fail todo] [pixel shader fail todo]

View File

@@ -66,7 +66,7 @@ float4 main() : SV_TARGET
[test] [test]
uniform 0 uint4 0 1 2 3 uniform 0 uint4 0 1 2 3
todo(msl) draw quad draw quad
probe (0, 0) rgba (1.0, 7.0, 13.0, 19.0) probe (0, 0) rgba (1.0, 7.0, 13.0, 19.0)
% Test collecting terms with constant coefficients. % Test collecting terms with constant coefficients.
@@ -171,7 +171,7 @@ uniform 0 uint 7
uniform 4 uint 9 uniform 4 uint 9
uniform 8 uint 0xff9 uniform 8 uint 0xff9
uniform 12 uint 0xff7 uniform 12 uint 0xff7
todo(msl) draw quad draw quad
probe (0, 0) rgbaui(21, 45, 0x2feb, 0x4fd3) probe (0, 0) rgbaui(21, 45, 0x2feb, 0x4fd3)
[pixel shader] [pixel shader]

View File

@@ -88,7 +88,7 @@ if(sm<4) uniform 0 float4 10 20 30 40
if(sm<4) uniform 4 float4 50 60 70 80 if(sm<4) uniform 4 float4 50 60 70 80
if(sm>=4) uniform 0 int4 10 20 30 40 if(sm>=4) uniform 0 int4 10 20 30 40
if(sm>=4) uniform 4 int4 50 60 70 80 if(sm>=4) uniform 4 int4 50 60 70 80
todo(msl) draw quad draw quad
probe (0, 0) rgba (100, 120, 140, 160) probe (0, 0) rgba (100, 120, 140, 160)

View File

@@ -121,11 +121,11 @@ uniform 28 float -2.0
uniform 32 float -3.0 uniform 32 float -3.0
if(sm<4) uniform 36 float4 0 1 2 0 if(sm<4) uniform 36 float4 0 1 2 0
if(sm>=4) uniform 36 uint4 0 1 2 0 if(sm>=4) uniform 36 uint4 0 1 2 0
todo(msl) draw quad draw quad
probe (0, 0) rgba(1.0, 4.0, -1.0, 2.0) probe (0, 0) rgba(1.0, 4.0, -1.0, 2.0)
if(sm<4) uniform 36 float4 2 0 1 1 if(sm<4) uniform 36 float4 2 0 1 1
if(sm>=4) uniform 36 uint4 2 0 1 1 if(sm>=4) uniform 36 uint4 2 0 1 1
todo(msl) draw quad draw quad
probe (0, 0) rgba(3.0, 2.0, -2.0, 6.0) probe (0, 0) rgba(3.0, 2.0, -2.0, 6.0)
[pixel shader] [pixel shader]

View File

@@ -83,16 +83,16 @@ float4 main() : SV_TARGET
[test] [test]
uniform 0 float 0 uniform 0 float 0
todo(msl) draw quad draw quad
probe (0, 0) rgba (21.0, 1.0, 24.0, 0.0) probe (0, 0) rgba (21.0, 1.0, 24.0, 0.0)
uniform 0 float 1 uniform 0 float 1
todo(msl) draw quad draw quad
probe (0, 0) rgba (22.0, 0.0, 23.0, 1.0) probe (0, 0) rgba (22.0, 0.0, 23.0, 1.0)
uniform 0 float 2 uniform 0 float 2
todo(msl) draw quad draw quad
probe (0, 0) rgba (23.0, 1.0, 22.0, 0.0) probe (0, 0) rgba (23.0, 1.0, 22.0, 0.0)
uniform 0 float 3 uniform 0 float 3
todo(msl) draw quad draw quad
probe (0, 0) rgba (24.0, 0.0, 21.0, 1.0) probe (0, 0) rgba (24.0, 0.0, 21.0, 1.0)
@@ -154,12 +154,12 @@ float4 main() : sv_target
if(sm<4) uniform 0 float 3 if(sm<4) uniform 0 float 3
if(sm<4) uniform 4 float 1 if(sm<4) uniform 4 float 1
if(sm>=4) uniform 0 float4 3 1 0 0 if(sm>=4) uniform 0 float4 3 1 0 0
todo(msl) draw quad draw quad
probe (0, 0) rgba (7, 7, 7, 7) probe (0, 0) rgba (7, 7, 7, 7)
if(sm<4) uniform 0 float 5 if(sm<4) uniform 0 float 5
if(sm<4) uniform 4 float 0 if(sm<4) uniform 4 float 0
if(sm>=4) uniform 0 float4 5 0 0 0 if(sm>=4) uniform 0 float4 5 0 0 0
todo(msl) draw quad draw quad
probe (0, 0) rgba (10, 10, 10, 10) probe (0, 0) rgba (10, 10, 10, 10)
@@ -192,13 +192,13 @@ if(sm<4) uniform 0 float 2
if(sm<4) uniform 4 float 1 if(sm<4) uniform 4 float 1
if(sm<4) uniform 8 float -1 if(sm<4) uniform 8 float -1
if(sm>=4) uniform 0 float4 2 1 -1 0 if(sm>=4) uniform 0 float4 2 1 -1 0
todo(msl) draw quad draw quad
probe (0, 0) rgba (30, 31, 32, 33) probe (0, 0) rgba (30, 31, 32, 33)
if(sm<4) uniform 0 float 1 if(sm<4) uniform 0 float 1
if(sm<4) uniform 4 float 0 if(sm<4) uniform 4 float 0
if(sm<4) uniform 8 float 1 if(sm<4) uniform 8 float 1
if(sm>=4) uniform 0 float4 1 0 1 0 if(sm>=4) uniform 0 float4 1 0 1 0
todo(msl) draw quad draw quad
probe (0, 0) rgba (70, 71, 72, 73) probe (0, 0) rgba (70, 71, 72, 73)
@@ -220,12 +220,12 @@ float4 main() : sv_target
if(sm<4) uniform 0 float 11 if(sm<4) uniform 0 float 11
if(sm<4) uniform 4 float 12 if(sm<4) uniform 4 float 12
if(sm>=4) uniform 0 float4 11 12 0 0 if(sm>=4) uniform 0 float4 11 12 0 0
todo(msl) draw quad draw quad
probe (0, 0) rgba (5, 5, 5, 5) probe (0, 0) rgba (5, 5, 5, 5)
if(sm<4) uniform 0 float 13 if(sm<4) uniform 0 float 13
if(sm<4) uniform 4 float 10 if(sm<4) uniform 4 float 10
if(sm>=4) uniform 0 float4 13 10 0 0 if(sm>=4) uniform 0 float4 13 10 0 0
todo(msl) draw quad draw quad
probe (0, 0) rgba (9, 9, 9, 9) probe (0, 0) rgba (9, 9, 9, 9)
[pixel shader] [pixel shader]
@@ -244,7 +244,7 @@ uniform 8 float4 -1.0 -2.0 -3.0 -4.0
uniform 12 float4 -5.0 -6.0 -7.0 -8.0 uniform 12 float4 -5.0 -6.0 -7.0 -8.0
if(sm<4) uniform 16 float4 1 0 0 0 if(sm<4) uniform 16 float4 1 0 0 0
if(sm>=4) uniform 16 int4 1 0 0 0 if(sm>=4) uniform 16 int4 1 0 0 0
todo(msl) draw quad draw quad
probe (0, 0) rgba(-1.0, -5.0, 2.0, 6.0) probe (0, 0) rgba(-1.0, -5.0, 2.0, 6.0)
% SM1 doesn't support relative addressing if it is used in a l-value. % SM1 doesn't support relative addressing if it is used in a l-value.