vkd3d-shader/msl: Implement VKD3DSIH_NOT.

This commit is contained in:
Feifan He 2024-12-03 00:55:22 +08:00 committed by Henri Verbeet
parent 74fa51d57c
commit bbe10dcf17
Notes: Henri Verbeet 2024-12-05 21:36:59 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1302
6 changed files with 34 additions and 16 deletions

View File

@ -511,6 +511,21 @@ static void msl_endif(struct msl_generator *gen)
vkd3d_string_buffer_printf(gen->buffer, "}\n");
}
static void msl_unary_op(struct msl_generator *gen, const struct vkd3d_shader_instruction *ins, const char *op)
{
struct msl_src src;
struct msl_dst dst;
uint32_t mask;
mask = msl_dst_init(&dst, gen, ins, &ins->dst[0]);
msl_src_init(&src, gen, &ins->src[0], mask);
msl_print_assignment(gen, &dst, "%s%s", op, src.str->buffer);
msl_src_cleanup(&src, &gen->string_buffers);
msl_dst_cleanup(&dst, &gen->string_buffers);
}
static void msl_mov(struct msl_generator *gen, const struct vkd3d_shader_instruction *ins)
{
struct msl_src src;
@ -636,6 +651,9 @@ static void msl_handle_instruction(struct msl_generator *gen, const struct vkd3d
case VKD3DSIH_MUL:
msl_binop(gen, ins, "*");
break;
case VKD3DSIH_NOT:
msl_unary_op(gen, ins, "~");
break;
case VKD3DSIH_OR:
msl_binop(gen, ins, "|");
break;

View File

@ -124,8 +124,8 @@ float4 main() : sv_target
[test]
uniform 0 float4 -2.0 0.0 0.0 0.0
todo(sm<4 | msl) draw quad
todo(sm<4) draw quad
probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0)
uniform 0 float4 -0.0 0.0 0.0 0.0
todo(sm<4 | msl) draw quad
todo(sm<4) draw quad
probe (0, 0) rgba (0.0, 0.0, 0.0, 0.0)

View File

@ -87,10 +87,10 @@ float4 main() : sv_target
[test]
uniform 0 float -2
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1, 2, 3, 4)
uniform 0 float 10
todo(msl) draw quad
draw quad
probe (0, 0) rgba (10, 20, 30, 40)

View File

@ -134,13 +134,13 @@ float4 main() : sv_target
[test]
uniform 0 float 0.1
todo(sm<4 | msl) draw quad
todo(sm<4) draw quad
probe (0, 0) rgba (0.2, 0.1, 0.2, 0.1) 1
uniform 0 float 0.5
todo(sm<4 | msl) draw quad
todo(sm<4) draw quad
probe (0, 0) rgba (0.5, 0.4, 1.0, 0.9) 1
uniform 0 float 0.9
todo(sm<4 | msl) draw quad
todo(sm<4) draw quad
probe (0, 0) rgba (1.0, 0.9, 1.0, 0.6) 1
[pixel shader]

View File

@ -37,10 +37,10 @@ float4 main() : sv_target
[test]
uniform 0 float 0.2
todo(sm<4 | msl) draw quad
todo(sm<4) draw quad
probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4)
uniform 0 float 0.8
todo(sm<4 | msl) draw quad
todo(sm<4) draw quad
probe (0, 0) rgba (0.5, 0.6, 0.7, 0.8)
[pixel shader todo(sm<4)]
@ -89,13 +89,13 @@ void main(out float4 ret : sv_target)
[test]
uniform 0 float 0.1
todo(sm<4 | msl) draw quad
todo(sm<4) draw quad
probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4) 1
uniform 0 float 0.5
todo(sm<4 | msl) draw quad
todo(sm<4) draw quad
probe (0, 0) rgba (0.2, 0.3, 0.4, 0.5) 1
uniform 0 float 0.9
todo(sm<4 | msl) draw quad
todo(sm<4) draw quad
probe (0, 0) rgba (0.5, 0.6, 0.7, 0.8) 1
[pixel shader todo(sm<4)]
@ -115,13 +115,13 @@ void main(out float4 ret : sv_target)
[test]
uniform 0 float 0.1
todo(sm<4 | msl) draw quad
todo(sm<4) draw quad
probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4) 1
uniform 0 float 0.5
todo(sm<4 | msl) draw quad
todo(sm<4) draw quad
probe (0, 0) rgba (0.5, 0.6, 0.7, 0.8) 1
uniform 0 float 0.9
todo(sm<4 | msl) draw quad
todo(sm<4) draw quad
probe (0, 0) rgba (0.4, 0.5, 0.6, 0.7) 1
[pixel shader]

View File

@ -19,7 +19,7 @@ float4 main() : sv_target
[test]
uniform 0 float 1
todo(sm<4 | msl) draw quad
todo(sm<4) draw quad
probe (0,0) rgba(10.0, 1.0, 2.0, 3.0)
[pixel shader]