-- v4: vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_resource_store(). vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_resource_load(). vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_loop(). vkd3d-shader/hlsl: Pass an hlsl_block pointer to hlsl_new_loop().
From: Zebediah Figura zfigura@codeweavers.com
--- libs/vkd3d-shader/hlsl.y | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 10deda75..e82b6ffa 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -458,7 +458,6 @@ static bool attribute_list_has_duplicates(const struct parse_attribute_list *att static struct list *create_loop(struct hlsl_ctx *ctx, enum loop_type type, const struct parse_attribute_list *attributes, struct list *init, struct list *cond, struct list *iter, struct list *body, const struct vkd3d_shader_location *loc) { - struct list *list = NULL; struct hlsl_ir_loop *loop = NULL; unsigned int i;
@@ -492,15 +491,12 @@ static struct list *create_loop(struct hlsl_ctx *ctx, enum loop_type type, const } }
- if (!(list = make_empty_list(ctx))) + if (!init && !(init = make_empty_list(ctx))) goto oom;
- if (init) - list_move_head(list, init); - if (!(loop = hlsl_new_loop(ctx, loc))) goto oom; - list_add_tail(list, &loop->node.entry); + list_add_tail(init, &loop->node.entry);
if (!append_conditional_break(ctx, cond)) goto oom; @@ -516,14 +512,12 @@ static struct list *create_loop(struct hlsl_ctx *ctx, enum loop_type type, const if (type == LOOP_DO_WHILE) list_move_tail(&loop->body.instrs, cond);
- vkd3d_free(init); vkd3d_free(cond); vkd3d_free(body); - return list; + return init;
oom: vkd3d_free(loop); - vkd3d_free(list); destroy_instr_list(init); destroy_instr_list(cond); destroy_instr_list(iter);
From: Zebediah Figura zfigura@codeweavers.com
--- libs/vkd3d-shader/hlsl.c | 12 ++++++++---- libs/vkd3d-shader/hlsl.h | 3 ++- libs/vkd3d-shader/hlsl.y | 19 +++++++++++-------- 3 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index f0b6a5ef..c3822122 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1396,7 +1396,8 @@ struct hlsl_ir_node *hlsl_new_jump(struct hlsl_ctx *ctx, enum hlsl_ir_jump_type return &jump->node; }
-struct hlsl_ir_loop *hlsl_new_loop(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc) +struct hlsl_ir_loop *hlsl_new_loop(struct hlsl_ctx *ctx, + struct hlsl_block *block, const struct vkd3d_shader_location *loc) { struct hlsl_ir_loop *loop;
@@ -1404,6 +1405,7 @@ struct hlsl_ir_loop *hlsl_new_loop(struct hlsl_ctx *ctx, const struct vkd3d_shad return NULL; init_node(&loop->node, HLSL_IR_LOOP, NULL, loc); hlsl_block_init(&loop->body); + hlsl_block_add_block(&loop->body, block); return loop; }
@@ -1565,12 +1567,14 @@ static struct hlsl_ir_node *clone_load(struct hlsl_ctx *ctx, struct clone_instr_ static struct hlsl_ir_node *clone_loop(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_loop *src) { struct hlsl_ir_loop *dst; + struct hlsl_block body;
- if (!(dst = hlsl_new_loop(ctx, &src->node.loc))) + if (!clone_block(ctx, &body, &src->body, map)) return NULL; - if (!clone_block(ctx, &dst->body, &src->body, map)) + + if (!(dst = hlsl_new_loop(ctx, &body, &src->node.loc))) { - hlsl_free_instr(&dst->node); + hlsl_block_cleanup(&body); return NULL; } return &dst->node; diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 2ff18536..4862843e 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -1095,7 +1095,8 @@ bool hlsl_index_is_noncontiguous(struct hlsl_ir_index *index);
struct hlsl_ir_node *hlsl_new_index(struct hlsl_ctx *ctx, struct hlsl_ir_node *val, struct hlsl_ir_node *idx, const struct vkd3d_shader_location *loc); -struct hlsl_ir_loop *hlsl_new_loop(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc); +struct hlsl_ir_loop *hlsl_new_loop(struct hlsl_ctx *ctx, + struct hlsl_block *block, const struct vkd3d_shader_location *loc); struct hlsl_ir_resource_load *hlsl_new_resource_load(struct hlsl_ctx *ctx, const struct hlsl_resource_load_params *params, const struct vkd3d_shader_location *loc); struct hlsl_ir_resource_store *hlsl_new_resource_store(struct hlsl_ctx *ctx, const struct hlsl_deref *resource, diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index e82b6ffa..1fc5cf38 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -459,6 +459,7 @@ static struct list *create_loop(struct hlsl_ctx *ctx, enum loop_type type, const struct list *iter, struct list *body, const struct vkd3d_shader_location *loc) { struct hlsl_ir_loop *loop = NULL; + struct hlsl_block body_block; unsigned int i;
if (attribute_list_has_duplicates(attributes)) @@ -494,23 +495,25 @@ static struct list *create_loop(struct hlsl_ctx *ctx, enum loop_type type, const if (!init && !(init = make_empty_list(ctx))) goto oom;
- if (!(loop = hlsl_new_loop(ctx, loc))) - goto oom; - list_add_tail(init, &loop->node.entry); - if (!append_conditional_break(ctx, cond)) goto oom;
+ hlsl_block_init(&body_block); + if (type != LOOP_DO_WHILE) - list_move_tail(&loop->body.instrs, cond); + list_move_tail(&body_block.instrs, cond);
- list_move_tail(&loop->body.instrs, body); + list_move_tail(&body_block.instrs, body);
if (iter) - list_move_tail(&loop->body.instrs, iter); + list_move_tail(&body_block.instrs, iter);
if (type == LOOP_DO_WHILE) - list_move_tail(&loop->body.instrs, cond); + list_move_tail(&body_block.instrs, cond); + + if (!(loop = hlsl_new_loop(ctx, &body_block, loc))) + goto oom; + list_add_tail(init, &loop->node.entry);
vkd3d_free(cond); vkd3d_free(body);
From: Zebediah Figura zfigura@codeweavers.com
--- libs/vkd3d-shader/hlsl.c | 8 ++++---- libs/vkd3d-shader/hlsl.h | 2 +- libs/vkd3d-shader/hlsl.y | 5 ++--- 3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index c3822122..9b1909a5 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1396,7 +1396,7 @@ struct hlsl_ir_node *hlsl_new_jump(struct hlsl_ctx *ctx, enum hlsl_ir_jump_type return &jump->node; }
-struct hlsl_ir_loop *hlsl_new_loop(struct hlsl_ctx *ctx, +struct hlsl_ir_node *hlsl_new_loop(struct hlsl_ctx *ctx, struct hlsl_block *block, const struct vkd3d_shader_location *loc) { struct hlsl_ir_loop *loop; @@ -1406,7 +1406,7 @@ struct hlsl_ir_loop *hlsl_new_loop(struct hlsl_ctx *ctx, init_node(&loop->node, HLSL_IR_LOOP, NULL, loc); hlsl_block_init(&loop->body); hlsl_block_add_block(&loop->body, block); - return loop; + return &loop->node; }
struct clone_instr_map @@ -1566,7 +1566,7 @@ static struct hlsl_ir_node *clone_load(struct hlsl_ctx *ctx, struct clone_instr_
static struct hlsl_ir_node *clone_loop(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_loop *src) { - struct hlsl_ir_loop *dst; + struct hlsl_ir_node *dst; struct hlsl_block body;
if (!clone_block(ctx, &body, &src->body, map)) @@ -1577,7 +1577,7 @@ static struct hlsl_ir_node *clone_loop(struct hlsl_ctx *ctx, struct clone_instr_ hlsl_block_cleanup(&body); return NULL; } - return &dst->node; + return dst; }
static struct hlsl_ir_node *clone_resource_load(struct hlsl_ctx *ctx, diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 4862843e..9d46188c 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -1095,7 +1095,7 @@ bool hlsl_index_is_noncontiguous(struct hlsl_ir_index *index);
struct hlsl_ir_node *hlsl_new_index(struct hlsl_ctx *ctx, struct hlsl_ir_node *val, struct hlsl_ir_node *idx, const struct vkd3d_shader_location *loc); -struct hlsl_ir_loop *hlsl_new_loop(struct hlsl_ctx *ctx, +struct hlsl_ir_node *hlsl_new_loop(struct hlsl_ctx *ctx, struct hlsl_block *block, const struct vkd3d_shader_location *loc); struct hlsl_ir_resource_load *hlsl_new_resource_load(struct hlsl_ctx *ctx, const struct hlsl_resource_load_params *params, const struct vkd3d_shader_location *loc); diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 1fc5cf38..2484519c 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -458,8 +458,8 @@ static bool attribute_list_has_duplicates(const struct parse_attribute_list *att static struct list *create_loop(struct hlsl_ctx *ctx, enum loop_type type, const struct parse_attribute_list *attributes, struct list *init, struct list *cond, struct list *iter, struct list *body, const struct vkd3d_shader_location *loc) { - struct hlsl_ir_loop *loop = NULL; struct hlsl_block body_block; + struct hlsl_ir_node *loop; unsigned int i;
if (attribute_list_has_duplicates(attributes)) @@ -513,14 +513,13 @@ static struct list *create_loop(struct hlsl_ctx *ctx, enum loop_type type, const
if (!(loop = hlsl_new_loop(ctx, &body_block, loc))) goto oom; - list_add_tail(init, &loop->node.entry); + list_add_tail(init, &loop->entry);
vkd3d_free(cond); vkd3d_free(body); return init;
oom: - vkd3d_free(loop); destroy_instr_list(init); destroy_instr_list(cond); destroy_instr_list(iter);
From: Zebediah Figura zfigura@codeweavers.com
--- libs/vkd3d-shader/hlsl.c | 4 ++-- libs/vkd3d-shader/hlsl.h | 2 +- libs/vkd3d-shader/hlsl.y | 25 ++++++++++++------------- 3 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 9b1909a5..a94bf841 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1291,7 +1291,7 @@ struct hlsl_ir_node *hlsl_new_load_component(struct hlsl_ctx *ctx, struct hlsl_b return &load->node; }
-struct hlsl_ir_resource_load *hlsl_new_resource_load(struct hlsl_ctx *ctx, +struct hlsl_ir_node *hlsl_new_resource_load(struct hlsl_ctx *ctx, const struct hlsl_resource_load_params *params, const struct vkd3d_shader_location *loc) { struct hlsl_ir_resource_load *load; @@ -1320,7 +1320,7 @@ struct hlsl_ir_resource_load *hlsl_new_resource_load(struct hlsl_ctx *ctx, hlsl_src_from_node(&load->coords, params->coords); hlsl_src_from_node(&load->texel_offset, params->texel_offset); hlsl_src_from_node(&load->lod, params->lod); - return load; + return &load->node; }
struct hlsl_ir_resource_store *hlsl_new_resource_store(struct hlsl_ctx *ctx, const struct hlsl_deref *resource, diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 9d46188c..fc16348a 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -1097,7 +1097,7 @@ struct hlsl_ir_node *hlsl_new_index(struct hlsl_ctx *ctx, struct hlsl_ir_node *v struct hlsl_ir_node *idx, const struct vkd3d_shader_location *loc); struct hlsl_ir_node *hlsl_new_loop(struct hlsl_ctx *ctx, struct hlsl_block *block, const struct vkd3d_shader_location *loc); -struct hlsl_ir_resource_load *hlsl_new_resource_load(struct hlsl_ctx *ctx, +struct hlsl_ir_node *hlsl_new_resource_load(struct hlsl_ctx *ctx, const struct hlsl_resource_load_params *params, const struct vkd3d_shader_location *loc); struct hlsl_ir_resource_store *hlsl_new_resource_store(struct hlsl_ctx *ctx, const struct hlsl_deref *resource, struct hlsl_ir_node *coords, struct hlsl_ir_node *value, const struct vkd3d_shader_location *loc); diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 2484519c..0ac193c3 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -757,7 +757,7 @@ static bool add_array_access(struct hlsl_ctx *ctx, struct list *instrs, struct h { struct hlsl_resource_load_params load_params = {.type = HLSL_RESOURCE_LOAD}; unsigned int dim_count = hlsl_sampler_dim_count(expr_type->sampler_dim); - struct hlsl_ir_resource_load *resource_load; + struct hlsl_ir_node *resource_load;
if (index_type->class > HLSL_CLASS_VECTOR || index_type->dimx != dim_count) { @@ -783,7 +783,7 @@ static bool add_array_access(struct hlsl_ctx *ctx, struct list *instrs, struct h
if (!(resource_load = hlsl_new_resource_load(ctx, &load_params, loc))) return false; - list_add_tail(instrs, &resource_load->node.entry); + list_add_tail(instrs, &resource_load->entry); return true; }
@@ -3242,8 +3242,7 @@ static bool intrinsic_tex(struct hlsl_ctx *ctx, const struct parse_initializer * { struct hlsl_resource_load_params load_params = {.type = HLSL_RESOURCE_SAMPLE}; const struct hlsl_type *sampler_type; - struct hlsl_ir_resource_load *load; - struct hlsl_ir_node *coords; + struct hlsl_ir_node *coords, *load;
if (params->args_count != 2 && params->args_count != 4) { @@ -3283,7 +3282,7 @@ static bool intrinsic_tex(struct hlsl_ctx *ctx, const struct parse_initializer *
if (!(load = hlsl_new_resource_load(ctx, &load_params, loc))) return false; - list_add_tail(params->instrs, &load->node.entry); + list_add_tail(params->instrs, &load->entry); return true; }
@@ -3615,7 +3614,7 @@ static bool add_load_method_call(struct hlsl_ctx *ctx, struct list *instrs, stru const unsigned int sampler_dim = hlsl_sampler_dim_count(object_type->sampler_dim); const unsigned int offset_dim = hlsl_offset_dim_count(object_type->sampler_dim); struct hlsl_resource_load_params load_params = {.type = HLSL_RESOURCE_LOAD}; - struct hlsl_ir_resource_load *load; + struct hlsl_ir_node *load; bool multisampled;
multisampled = object_type->sampler_dim == HLSL_SAMPLER_DIM_2DMS @@ -3655,7 +3654,7 @@ static bool add_load_method_call(struct hlsl_ctx *ctx, struct list *instrs, stru
if (!(load = hlsl_new_resource_load(ctx, &load_params, loc))) return false; - list_add_tail(instrs, &load->node.entry); + list_add_tail(instrs, &load->entry); return true; }
@@ -3667,7 +3666,7 @@ static bool add_sample_method_call(struct hlsl_ctx *ctx, struct list *instrs, st const unsigned int offset_dim = hlsl_offset_dim_count(object_type->sampler_dim); struct hlsl_resource_load_params load_params = {.type = HLSL_RESOURCE_SAMPLE}; const struct hlsl_type *sampler_type; - struct hlsl_ir_resource_load *load; + struct hlsl_ir_node *load;
if (params->args_count < 2 || params->args_count > 4 + !!offset_dim) { @@ -3712,7 +3711,7 @@ static bool add_sample_method_call(struct hlsl_ctx *ctx, struct list *instrs, st
if (!(load = hlsl_new_resource_load(ctx, &load_params, loc))) return false; - list_add_tail(instrs, &load->node.entry); + list_add_tail(instrs, &load->entry);
return true; } @@ -3725,7 +3724,7 @@ static bool add_gather_method_call(struct hlsl_ctx *ctx, struct list *instrs, st const unsigned int offset_dim = hlsl_offset_dim_count(object_type->sampler_dim); struct hlsl_resource_load_params load_params = {0}; const struct hlsl_type *sampler_type; - struct hlsl_ir_resource_load *load; + struct hlsl_ir_node *load; unsigned int read_channel;
if (!strcmp(name, "GatherGreen")) @@ -3811,7 +3810,7 @@ static bool add_gather_method_call(struct hlsl_ctx *ctx, struct list *instrs, st
if (!(load = hlsl_new_resource_load(ctx, &load_params, loc))) return false; - list_add_tail(instrs, &load->node.entry); + list_add_tail(instrs, &load->entry); return true; }
@@ -3823,7 +3822,7 @@ static bool add_sample_lod_method_call(struct hlsl_ctx *ctx, struct list *instrs const unsigned int sampler_dim = hlsl_sampler_dim_count(object_type->sampler_dim); const unsigned int offset_dim = hlsl_offset_dim_count(object_type->sampler_dim); const struct hlsl_type *sampler_type; - struct hlsl_ir_resource_load *load; + struct hlsl_ir_node *load;
if (!strcmp(name, "SampleLevel")) load_params.type = HLSL_RESOURCE_SAMPLE_LOD; @@ -3875,7 +3874,7 @@ static bool add_sample_lod_method_call(struct hlsl_ctx *ctx, struct list *instrs
if (!(load = hlsl_new_resource_load(ctx, &load_params, loc))) return false; - list_add_tail(instrs, &load->node.entry); + list_add_tail(instrs, &load->entry); return true; }
From: Zebediah Figura zfigura@codeweavers.com
--- libs/vkd3d-shader/hlsl.c | 4 ++-- libs/vkd3d-shader/hlsl.h | 2 +- libs/vkd3d-shader/hlsl.y | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index a94bf841..80f87984 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1323,7 +1323,7 @@ struct hlsl_ir_node *hlsl_new_resource_load(struct hlsl_ctx *ctx, return &load->node; }
-struct hlsl_ir_resource_store *hlsl_new_resource_store(struct hlsl_ctx *ctx, const struct hlsl_deref *resource, +struct hlsl_ir_node *hlsl_new_resource_store(struct hlsl_ctx *ctx, const struct hlsl_deref *resource, struct hlsl_ir_node *coords, struct hlsl_ir_node *value, const struct vkd3d_shader_location *loc) { struct hlsl_ir_resource_store *store; @@ -1334,7 +1334,7 @@ struct hlsl_ir_resource_store *hlsl_new_resource_store(struct hlsl_ctx *ctx, con hlsl_copy_deref(ctx, &store->resource, resource); hlsl_src_from_node(&store->coords, coords); hlsl_src_from_node(&store->value, value); - return store; + return &store->node; }
struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned int components, diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index fc16348a..8ff72a98 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -1099,7 +1099,7 @@ struct hlsl_ir_node *hlsl_new_loop(struct hlsl_ctx *ctx, struct hlsl_block *block, const struct vkd3d_shader_location *loc); struct hlsl_ir_node *hlsl_new_resource_load(struct hlsl_ctx *ctx, const struct hlsl_resource_load_params *params, const struct vkd3d_shader_location *loc); -struct hlsl_ir_resource_store *hlsl_new_resource_store(struct hlsl_ctx *ctx, const struct hlsl_deref *resource, +struct hlsl_ir_node *hlsl_new_resource_store(struct hlsl_ctx *ctx, const struct hlsl_deref *resource, struct hlsl_ir_node *coords, struct hlsl_ir_node *value, const struct vkd3d_shader_location *loc); struct hlsl_type *hlsl_new_struct_type(struct hlsl_ctx *ctx, const char *name, struct hlsl_struct_field *fields, size_t field_count); diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 0ac193c3..5ab0987e 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1778,9 +1778,9 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in if (lhs->type == HLSL_IR_RESOURCE_LOAD) { struct hlsl_ir_resource_load *load = hlsl_ir_resource_load(lhs); - struct hlsl_ir_resource_store *store; struct hlsl_type *resource_type; struct hlsl_ir_swizzle *coords; + struct hlsl_ir_node *store; unsigned int dim_count;
/* Such an lvalue was produced by an index expression. */ @@ -1809,7 +1809,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
if (!(store = hlsl_new_resource_store(ctx, &load->resource, &coords->node, rhs, &lhs->loc))) return NULL; - list_add_tail(instrs, &store->node.entry); + list_add_tail(instrs, &store->entry); } else if (lhs->type == HLSL_IR_INDEX && hlsl_index_is_noncontiguous(hlsl_ir_index(lhs))) {
On Sun Apr 30 21:30:55 2023 +0000, Zebediah Figura wrote:
changed this line in [version 4 of the diff](/wine/vkd3d/-/merge_requests/176/diffs?diff_id=44786&start_sha=2eb659042abc5483b7c83d789899013bb639c67b#c6c9a40d72060550079c91bb6dd5741748169928_1408_1408)
Indeed. Yet another casualty of patch reordering, done in v4.
This merge request was approved by Giovanni Mascellani.
This merge request was approved by Henri Verbeet.