vkd3d-shader/hlsl: Parse barriers.

And introduce hlsl_ir_sync to represent them.
This commit is contained in:
Francisco Casas
2025-04-16 00:30:01 +00:00
committed by Henri Verbeet
parent 541060215e
commit 758a4bef09
Notes: Henri Verbeet 2025-05-05 15:28:08 +02:00
Approved-by: Conor McCarthy (@cmccarthy)
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1470
6 changed files with 175 additions and 2 deletions

View File

@@ -2291,6 +2291,26 @@ struct hlsl_ir_node *hlsl_new_interlocked(struct hlsl_ctx *ctx, enum hlsl_interl
return &interlocked->node;
}
static struct hlsl_ir_node *hlsl_new_sync(struct hlsl_ctx *ctx,
uint32_t sync_flags, const struct vkd3d_shader_location *loc)
{
struct hlsl_ir_sync *sync;
if (!(sync = hlsl_alloc(ctx, sizeof(*sync))))
return NULL;
init_node(&sync->node, HLSL_IR_SYNC, NULL, loc);
sync->sync_flags = sync_flags;
return &sync->node;
}
struct hlsl_ir_node *hlsl_block_add_sync(struct hlsl_ctx *ctx, struct hlsl_block *block,
uint32_t sync_flags, const struct vkd3d_shader_location *loc)
{
return append_new_instr(ctx, block, hlsl_new_sync(ctx, sync_flags, loc));
}
bool hlsl_index_is_noncontiguous(struct hlsl_ir_index *index)
{
struct hlsl_type *type = index->val.node->data_type;
@@ -2681,6 +2701,18 @@ static struct hlsl_ir_node *clone_interlocked(struct hlsl_ctx *ctx,
return &dst->node;
}
static struct hlsl_ir_node *clone_sync(struct hlsl_ctx *ctx, struct hlsl_ir_sync *src)
{
struct hlsl_ir_sync *dst;
if (!(dst = hlsl_alloc(ctx, sizeof(*dst))))
return NULL;
init_node(&dst->node, HLSL_IR_SYNC, NULL, &src->node.loc);
dst->sync_flags = src->sync_flags;
return &dst->node;
}
static struct hlsl_ir_node *clone_compile(struct hlsl_ctx *ctx,
struct clone_instr_map *map, struct hlsl_ir_compile *compile)
{
@@ -2884,6 +2916,9 @@ static struct hlsl_ir_node *clone_instr(struct hlsl_ctx *ctx,
case HLSL_IR_INTERLOCKED:
return clone_interlocked(ctx, map, hlsl_ir_interlocked(instr));
case HLSL_IR_SYNC:
return clone_sync(ctx, hlsl_ir_sync(instr));
case HLSL_IR_COMPILE:
return clone_compile(ctx, map, hlsl_ir_compile(instr));
@@ -3341,7 +3376,9 @@ const char *hlsl_node_type_to_string(enum hlsl_ir_node_type type)
[HLSL_IR_STORE ] = "HLSL_IR_STORE",
[HLSL_IR_SWITCH ] = "HLSL_IR_SWITCH",
[HLSL_IR_SWIZZLE ] = "HLSL_IR_SWIZZLE",
[HLSL_IR_INTERLOCKED ] = "HLSL_IR_INTERLOCKED",
[HLSL_IR_SYNC ] = "HLSL_IR_SYNC",
[HLSL_IR_COMPILE] = "HLSL_IR_COMPILE",
[HLSL_IR_SAMPLER_STATE] = "HLSL_IR_SAMPLER_STATE",
@@ -3831,6 +3868,19 @@ static void dump_ir_interlocked(struct vkd3d_string_buffer *buffer, const struct
vkd3d_string_buffer_printf(buffer, ")");
}
static void dump_ir_sync(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_sync *sync)
{
vkd3d_string_buffer_printf(buffer, "sync");
if (sync->sync_flags & VKD3DSSF_GLOBAL_UAV)
vkd3d_string_buffer_printf(buffer, "_uglobal");
if (sync->sync_flags & VKD3DSSF_THREAD_GROUP_UAV)
vkd3d_string_buffer_printf(buffer, "_ugroup");
if (sync->sync_flags & VKD3DSSF_GROUP_SHARED_MEMORY)
vkd3d_string_buffer_printf(buffer, "_g");
if (sync->sync_flags & VKD3DSSF_THREAD_GROUP)
vkd3d_string_buffer_printf(buffer, "_t");
}
static void dump_ir_compile(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer,
const struct hlsl_ir_compile *compile)
{
@@ -3968,6 +4018,10 @@ static void dump_instr(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer,
dump_ir_interlocked(buffer, hlsl_ir_interlocked(instr));
break;
case HLSL_IR_SYNC:
dump_ir_sync(buffer, hlsl_ir_sync(instr));
break;
case HLSL_IR_COMPILE:
dump_ir_compile(ctx, buffer, hlsl_ir_compile(instr));
break;
@@ -4205,6 +4259,11 @@ static void free_ir_interlocked(struct hlsl_ir_interlocked *interlocked)
vkd3d_free(interlocked);
}
static void free_ir_sync(struct hlsl_ir_sync *sync)
{
vkd3d_free(sync);
}
static void free_ir_compile(struct hlsl_ir_compile *compile)
{
unsigned int i;
@@ -4295,6 +4354,10 @@ void hlsl_free_instr(struct hlsl_ir_node *node)
free_ir_interlocked(hlsl_ir_interlocked(node));
break;
case HLSL_IR_SYNC:
free_ir_sync(hlsl_ir_sync(node));
break;
case HLSL_IR_COMPILE:
free_ir_compile(hlsl_ir_compile(node));
break;