vkd3d-shader/hlsl: Implement the InterlockedXor() intrinsic.

This commit is contained in:
Shaun Ren 2024-12-18 19:47:04 -05:00 committed by Henri Verbeet
parent cbd504e888
commit 802d7317cb
Notes: Henri Verbeet 2025-01-20 16:18:51 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Elizabeth Figura (@zfigura)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1330
6 changed files with 18 additions and 5 deletions

View File

@ -3513,6 +3513,7 @@ static void dump_ir_interlocked(struct vkd3d_string_buffer *buffer, const struct
[HLSL_INTERLOCKED_MAX] = "max",
[HLSL_INTERLOCKED_MIN] = "min",
[HLSL_INTERLOCKED_OR] = "or",
[HLSL_INTERLOCKED_XOR] = "xor",
};
VKD3D_ASSERT(interlocked->op < ARRAY_SIZE(op_names));

View File

@ -960,6 +960,7 @@ enum hlsl_interlocked_op
HLSL_INTERLOCKED_MAX,
HLSL_INTERLOCKED_MIN,
HLSL_INTERLOCKED_OR,
HLSL_INTERLOCKED_XOR,
};
/* Represents an interlocked operation.

View File

@ -5548,6 +5548,12 @@ static bool intrinsic_InterlockedOr(struct hlsl_ctx *ctx,
return intrinsic_interlocked(ctx, HLSL_INTERLOCKED_OR, params, loc, "InterlockedOr");
}
static bool intrinsic_InterlockedXor(struct hlsl_ctx *ctx,
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
{
return intrinsic_interlocked(ctx, HLSL_INTERLOCKED_XOR, params, loc, "InterlockedXor");
}
static const struct intrinsic_function
{
const char *name;
@ -5569,6 +5575,7 @@ intrinsic_functions[] =
{"InterlockedMax", -1, true, intrinsic_InterlockedMax},
{"InterlockedMin", -1, true, intrinsic_InterlockedMin},
{"InterlockedOr", -1, true, intrinsic_InterlockedOr},
{"InterlockedXor", -1, true, intrinsic_InterlockedXor},
{"abs", 1, true, intrinsic_abs},
{"acos", 1, true, intrinsic_acos},
{"all", 1, true, intrinsic_all},

View File

@ -10006,6 +10006,7 @@ static bool sm4_generate_vsir_instr_interlocked(struct hlsl_ctx *ctx,
[HLSL_INTERLOCKED_MAX] = VKD3DSIH_ATOMIC_UMAX,
[HLSL_INTERLOCKED_MIN] = VKD3DSIH_ATOMIC_UMIN,
[HLSL_INTERLOCKED_OR] = VKD3DSIH_ATOMIC_OR,
[HLSL_INTERLOCKED_XOR] = VKD3DSIH_ATOMIC_XOR,
};
static const enum vkd3d_shader_opcode imm_opcodes[] =
@ -10017,6 +10018,7 @@ static bool sm4_generate_vsir_instr_interlocked(struct hlsl_ctx *ctx,
[HLSL_INTERLOCKED_MAX] = VKD3DSIH_IMM_ATOMIC_UMAX,
[HLSL_INTERLOCKED_MIN] = VKD3DSIH_IMM_ATOMIC_UMIN,
[HLSL_INTERLOCKED_OR] = VKD3DSIH_IMM_ATOMIC_OR,
[HLSL_INTERLOCKED_XOR] = VKD3DSIH_IMM_ATOMIC_XOR,
};
struct hlsl_ir_node *cmp_value = interlocked->cmp_value.node, *value = interlocked->value.node;

View File

@ -4034,6 +4034,7 @@ static void tpf_handle_instruction(struct tpf_compiler *tpf, const struct vkd3d_
case VKD3DSIH_ATOMIC_UMAX:
case VKD3DSIH_ATOMIC_UMIN:
case VKD3DSIH_ATOMIC_OR:
case VKD3DSIH_ATOMIC_XOR:
case VKD3DSIH_AND:
case VKD3DSIH_BREAK:
case VKD3DSIH_CASE:
@ -4085,6 +4086,7 @@ static void tpf_handle_instruction(struct tpf_compiler *tpf, const struct vkd3d_
case VKD3DSIH_IMM_ATOMIC_UMAX:
case VKD3DSIH_IMM_ATOMIC_UMIN:
case VKD3DSIH_IMM_ATOMIC_OR:
case VKD3DSIH_IMM_ATOMIC_XOR:
case VKD3DSIH_IMUL:
case VKD3DSIH_INE:
case VKD3DSIH_INEG:

View File

@ -8,7 +8,7 @@ size (buffer, 11)
0xd 5 6 0x10 4 4 7 2 0 5 0
[compute shader fail(sm<5) todo(sm>=5)]
[compute shader fail(sm<5)]
RWBuffer<uint> u : register(u1);
uniform uint4 v;
@ -32,7 +32,7 @@ void main()
[test]
uniform 0 uint4 3 5 0 0
todo(sm<6) dispatch 1 1 1
todo(glsl | msl) dispatch 1 1 1
probe uav 1 (0) rui (1)
probe uav 1 (1) rui (3)
probe uav 1 (2) rui (15)
@ -46,7 +46,7 @@ probe uav 1 (9) rui (3)
probe uav 1 (10) rui (1)
uniform 0 uint4 1 2 0 0
todo(sm<6) dispatch 2 1 1
todo(glsl | msl) dispatch 2 1 1
probe uav 1 (0) rui (1)
probe uav 1 (1) rui (3)
probe uav 1 (2) rui (21)
@ -96,7 +96,7 @@ size (2d, 11, 1)
0xd 5 6 0x10 4 4 7 2 0 5 0
[compute shader fail(sm<5) todo(sm>=5)]
[compute shader fail(sm<5)]
RWTexture2D<uint> u : register(u1);
uniform uint4 v;
@ -120,7 +120,7 @@ void main()
[test]
uniform 0 uint4 3 5 0 0
todo(sm<6) dispatch 1 1 1
todo(glsl | msl) dispatch 1 1 1
probe uav 1 (0) rui (1)
probe uav 1 (1) rui (3)
probe uav 1 (2) rui (15)