vkd3d-shader/hlsl: Support stores to raw groupshared variables.

This commit is contained in:
Shaun Ren
2025-07-17 13:57:08 -04:00
committed by Henri Verbeet
parent c8d2d40b91
commit 8d0d8d106b
Notes: Henri Verbeet 2025-08-05 16:40:26 +02:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1605
5 changed files with 71 additions and 28 deletions

View File

@@ -2112,9 +2112,9 @@ struct hlsl_ir_node *hlsl_block_add_resource_load(struct hlsl_ctx *ctx, struct h
return append_new_instr(ctx, block, &load->node);
}
static struct hlsl_ir_node *hlsl_new_resource_store(struct hlsl_ctx *ctx, enum hlsl_resource_store_type type,
const struct hlsl_deref *resource, struct hlsl_ir_node *coords, struct hlsl_ir_node *value,
const struct vkd3d_shader_location *loc)
static struct hlsl_ir_node *hlsl_new_resource_store(struct hlsl_ctx *ctx,
enum hlsl_resource_store_type type, const struct hlsl_deref *resource, struct hlsl_ir_node *coords,
struct hlsl_ir_node *value, uint32_t writemask, const struct vkd3d_shader_location *loc)
{
struct hlsl_ir_resource_store *store;
@@ -2122,6 +2122,7 @@ static struct hlsl_ir_node *hlsl_new_resource_store(struct hlsl_ctx *ctx, enum h
return NULL;
init_node(&store->node, HLSL_IR_RESOURCE_STORE, NULL, loc);
store->store_type = type;
store->writemask = writemask;
hlsl_copy_deref(ctx, &store->resource, resource);
hlsl_src_from_node(&store->coords, coords);
@@ -2131,9 +2132,9 @@ static struct hlsl_ir_node *hlsl_new_resource_store(struct hlsl_ctx *ctx, enum h
void hlsl_block_add_resource_store(struct hlsl_ctx *ctx, struct hlsl_block *block,
enum hlsl_resource_store_type type, const struct hlsl_deref *resource, struct hlsl_ir_node *coords,
struct hlsl_ir_node *value, const struct vkd3d_shader_location *loc)
struct hlsl_ir_node *value, uint32_t writemask, const struct vkd3d_shader_location *loc)
{
append_new_instr(ctx, block, hlsl_new_resource_store(ctx, type, resource, coords, value, loc));
append_new_instr(ctx, block, hlsl_new_resource_store(ctx, type, resource, coords, value, writemask, loc));
}
struct hlsl_ir_node *hlsl_new_swizzle(struct hlsl_ctx *ctx, uint32_t s, unsigned int component_count,
@@ -2674,6 +2675,7 @@ static struct hlsl_ir_node *clone_resource_store(struct hlsl_ctx *ctx,
return NULL;
init_node(&dst->node, HLSL_IR_RESOURCE_STORE, NULL, &src->node.loc);
dst->store_type = src->store_type;
dst->writemask = src->writemask;
if (!clone_deref(ctx, map, &dst->resource, &src->resource))
{
vkd3d_free(dst);
@@ -3824,7 +3826,8 @@ static void dump_ir_resource_load(struct vkd3d_string_buffer *buffer, const stru
vkd3d_string_buffer_printf(buffer, ")");
}
static void dump_ir_resource_store(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_resource_store *store)
static void dump_ir_resource_store(struct hlsl_ctx *ctx,
struct vkd3d_string_buffer *buffer, const struct hlsl_ir_resource_store *store)
{
static const char *const type_names[] =
{
@@ -3836,6 +3839,8 @@ static void dump_ir_resource_store(struct vkd3d_string_buffer *buffer, const str
VKD3D_ASSERT(store->store_type < ARRAY_SIZE(type_names));
vkd3d_string_buffer_printf(buffer, "%s(resource = ", type_names[store->store_type]);
dump_deref(buffer, &store->resource);
if (store->writemask != VKD3DSP_WRITEMASK_ALL && type_is_single_reg(hlsl_deref_get_type(ctx, &store->resource)))
vkd3d_string_buffer_printf(buffer, "%s", debug_hlsl_writemask(store->writemask));
if (store->coords.node)
{
vkd3d_string_buffer_printf(buffer, ", coords = ");
@@ -4048,7 +4053,7 @@ static void dump_instr(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer,
break;
case HLSL_IR_RESOURCE_STORE:
dump_ir_resource_store(buffer, hlsl_ir_resource_store(instr));
dump_ir_resource_store(ctx, buffer, hlsl_ir_resource_store(instr));
break;
case HLSL_IR_STRING_CONSTANT: