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

This commit is contained in:
Shaun Ren 2024-12-12 17:57:27 -05:00 committed by Henri Verbeet
parent 660a71ef22
commit 3b19a4aaf3
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
5 changed files with 13 additions and 0 deletions

View File

@ -3507,6 +3507,7 @@ static void dump_ir_interlocked(struct vkd3d_string_buffer *buffer, const struct
static const char *const op_names[] = static const char *const op_names[] =
{ {
[HLSL_INTERLOCKED_ADD] = "add", [HLSL_INTERLOCKED_ADD] = "add",
[HLSL_INTERLOCKED_AND] = "and",
}; };
VKD3D_ASSERT(interlocked->op < ARRAY_SIZE(op_names)); VKD3D_ASSERT(interlocked->op < ARRAY_SIZE(op_names));

View File

@ -954,6 +954,7 @@ struct hlsl_ir_stateblock_constant
enum hlsl_interlocked_op enum hlsl_interlocked_op
{ {
HLSL_INTERLOCKED_ADD, HLSL_INTERLOCKED_ADD,
HLSL_INTERLOCKED_AND,
}; };
/* Represents an interlocked operation. /* Represents an interlocked operation.

View File

@ -5478,6 +5478,12 @@ static bool intrinsic_InterlockedAdd(struct hlsl_ctx *ctx,
return intrinsic_interlocked(ctx, HLSL_INTERLOCKED_ADD, params, loc, "InterlockedAdd"); return intrinsic_interlocked(ctx, HLSL_INTERLOCKED_ADD, params, loc, "InterlockedAdd");
} }
static bool intrinsic_InterlockedAnd(struct hlsl_ctx *ctx,
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
{
return intrinsic_interlocked(ctx, HLSL_INTERLOCKED_AND, params, loc, "InterlockedAnd");
}
static const struct intrinsic_function static const struct intrinsic_function
{ {
const char *name; const char *name;
@ -5492,6 +5498,7 @@ intrinsic_functions[] =
{"D3DCOLORtoUBYTE4", 1, true, intrinsic_d3dcolor_to_ubyte4}, {"D3DCOLORtoUBYTE4", 1, true, intrinsic_d3dcolor_to_ubyte4},
{"GetRenderTargetSampleCount", 0, true, intrinsic_GetRenderTargetSampleCount}, {"GetRenderTargetSampleCount", 0, true, intrinsic_GetRenderTargetSampleCount},
{"InterlockedAdd", -1, true, intrinsic_InterlockedAdd}, {"InterlockedAdd", -1, true, intrinsic_InterlockedAdd},
{"InterlockedAnd", -1, true, intrinsic_InterlockedAnd},
{"abs", 1, true, intrinsic_abs}, {"abs", 1, true, intrinsic_abs},
{"acos", 1, true, intrinsic_acos}, {"acos", 1, true, intrinsic_acos},
{"all", 1, true, intrinsic_all}, {"all", 1, true, intrinsic_all},

View File

@ -10001,11 +10001,13 @@ static bool sm4_generate_vsir_instr_interlocked(struct hlsl_ctx *ctx,
static const enum vkd3d_shader_opcode opcodes[] = static const enum vkd3d_shader_opcode opcodes[] =
{ {
[HLSL_INTERLOCKED_ADD] = VKD3DSIH_ATOMIC_IADD, [HLSL_INTERLOCKED_ADD] = VKD3DSIH_ATOMIC_IADD,
[HLSL_INTERLOCKED_AND] = VKD3DSIH_ATOMIC_AND,
}; };
static const enum vkd3d_shader_opcode imm_opcodes[] = static const enum vkd3d_shader_opcode imm_opcodes[] =
{ {
[HLSL_INTERLOCKED_ADD] = VKD3DSIH_IMM_ATOMIC_IADD, [HLSL_INTERLOCKED_ADD] = VKD3DSIH_IMM_ATOMIC_IADD,
[HLSL_INTERLOCKED_AND] = VKD3DSIH_IMM_ATOMIC_AND,
}; };
struct hlsl_ir_node *coords = interlocked->coords.node, *value = interlocked->value.node; struct hlsl_ir_node *coords = interlocked->coords.node, *value = interlocked->value.node;

View File

@ -4026,6 +4026,7 @@ static void tpf_handle_instruction(struct tpf_compiler *tpf, const struct vkd3d_
break; break;
case VKD3DSIH_ADD: case VKD3DSIH_ADD:
case VKD3DSIH_ATOMIC_AND:
case VKD3DSIH_ATOMIC_IADD: case VKD3DSIH_ATOMIC_IADD:
case VKD3DSIH_AND: case VKD3DSIH_AND:
case VKD3DSIH_BREAK: case VKD3DSIH_BREAK:
@ -4069,6 +4070,7 @@ static void tpf_handle_instruction(struct tpf_compiler *tpf, const struct vkd3d_
case VKD3DSIH_IMAD: case VKD3DSIH_IMAD:
case VKD3DSIH_IMAX: case VKD3DSIH_IMAX:
case VKD3DSIH_IMIN: case VKD3DSIH_IMIN:
case VKD3DSIH_IMM_ATOMIC_AND:
case VKD3DSIH_IMM_ATOMIC_IADD: case VKD3DSIH_IMM_ATOMIC_IADD:
case VKD3DSIH_IMUL: case VKD3DSIH_IMUL:
case VKD3DSIH_INE: case VKD3DSIH_INE: