From cbd504e888d57e4e6927ae76f3871fec9fc16fb4 Mon Sep 17 00:00:00 2001 From: Shaun Ren Date: Fri, 13 Dec 2024 16:26:24 -0500 Subject: [PATCH] vkd3d-shader/hlsl: Implement the InterlockedOr() intrinsic. --- libs/vkd3d-shader/hlsl.c | 1 + libs/vkd3d-shader/hlsl.h | 1 + libs/vkd3d-shader/hlsl.y | 7 +++++++ libs/vkd3d-shader/hlsl_codegen.c | 2 ++ libs/vkd3d-shader/tpf.c | 2 ++ 5 files changed, 13 insertions(+) diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index cdf32459..ec713fa2 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -3512,6 +3512,7 @@ static void dump_ir_interlocked(struct vkd3d_string_buffer *buffer, const struct [HLSL_INTERLOCKED_EXCH] = "exch", [HLSL_INTERLOCKED_MAX] = "max", [HLSL_INTERLOCKED_MIN] = "min", + [HLSL_INTERLOCKED_OR] = "or", }; VKD3D_ASSERT(interlocked->op < ARRAY_SIZE(op_names)); diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 88ca5282..571f5517 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -959,6 +959,7 @@ enum hlsl_interlocked_op HLSL_INTERLOCKED_EXCH, HLSL_INTERLOCKED_MAX, HLSL_INTERLOCKED_MIN, + HLSL_INTERLOCKED_OR, }; /* Represents an interlocked operation. diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 106459ee..e7b55117 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -5542,6 +5542,12 @@ static bool intrinsic_InterlockedMin(struct hlsl_ctx *ctx, return intrinsic_interlocked(ctx, HLSL_INTERLOCKED_MIN, params, loc, "InterlockedMin"); } +static bool intrinsic_InterlockedOr(struct hlsl_ctx *ctx, + const struct parse_initializer *params, const struct vkd3d_shader_location *loc) +{ + return intrinsic_interlocked(ctx, HLSL_INTERLOCKED_OR, params, loc, "InterlockedOr"); +} + static const struct intrinsic_function { const char *name; @@ -5562,6 +5568,7 @@ intrinsic_functions[] = {"InterlockedExchange", 3, true, intrinsic_InterlockedExchange}, {"InterlockedMax", -1, true, intrinsic_InterlockedMax}, {"InterlockedMin", -1, true, intrinsic_InterlockedMin}, + {"InterlockedOr", -1, true, intrinsic_InterlockedOr}, {"abs", 1, true, intrinsic_abs}, {"acos", 1, true, intrinsic_acos}, {"all", 1, true, intrinsic_all}, diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index c0eaacba..20433094 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -10005,6 +10005,7 @@ static bool sm4_generate_vsir_instr_interlocked(struct hlsl_ctx *ctx, [HLSL_INTERLOCKED_CMP_EXCH] = VKD3DSIH_ATOMIC_CMP_STORE, [HLSL_INTERLOCKED_MAX] = VKD3DSIH_ATOMIC_UMAX, [HLSL_INTERLOCKED_MIN] = VKD3DSIH_ATOMIC_UMIN, + [HLSL_INTERLOCKED_OR] = VKD3DSIH_ATOMIC_OR, }; static const enum vkd3d_shader_opcode imm_opcodes[] = @@ -10015,6 +10016,7 @@ static bool sm4_generate_vsir_instr_interlocked(struct hlsl_ctx *ctx, [HLSL_INTERLOCKED_EXCH] = VKD3DSIH_IMM_ATOMIC_EXCH, [HLSL_INTERLOCKED_MAX] = VKD3DSIH_IMM_ATOMIC_UMAX, [HLSL_INTERLOCKED_MIN] = VKD3DSIH_IMM_ATOMIC_UMIN, + [HLSL_INTERLOCKED_OR] = VKD3DSIH_IMM_ATOMIC_OR, }; struct hlsl_ir_node *cmp_value = interlocked->cmp_value.node, *value = interlocked->value.node; diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index 8a91620e..04b1077c 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -4033,6 +4033,7 @@ static void tpf_handle_instruction(struct tpf_compiler *tpf, const struct vkd3d_ case VKD3DSIH_ATOMIC_IMIN: case VKD3DSIH_ATOMIC_UMAX: case VKD3DSIH_ATOMIC_UMIN: + case VKD3DSIH_ATOMIC_OR: case VKD3DSIH_AND: case VKD3DSIH_BREAK: case VKD3DSIH_CASE: @@ -4083,6 +4084,7 @@ static void tpf_handle_instruction(struct tpf_compiler *tpf, const struct vkd3d_ case VKD3DSIH_IMM_ATOMIC_IMIN: case VKD3DSIH_IMM_ATOMIC_UMAX: case VKD3DSIH_IMM_ATOMIC_UMIN: + case VKD3DSIH_IMM_ATOMIC_OR: case VKD3DSIH_IMUL: case VKD3DSIH_INE: case VKD3DSIH_INEG: