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 b9e03325..ea87263d 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -442,18 +442,14 @@ enum loop_type static struct list *create_loop(struct hlsl_ctx *ctx, enum loop_type type, 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;
- 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; @@ -469,14 +465,12 @@ static struct list *create_loop(struct hlsl_ctx *ctx, enum loop_type type, struc 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 32511590..29094899 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); + list_move_tail(&loop->body.instrs, &block->instrs); 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_free_instr_list(&body.instrs); return NULL; } return &dst->node; diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 86f35df2..e8af0095 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -1094,7 +1094,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 ea87263d..921aae90 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -443,27 +443,30 @@ static struct list *create_loop(struct hlsl_ctx *ctx, enum loop_type type, struc struct list *iter, struct list *body, const struct vkd3d_shader_location *loc) { struct hlsl_ir_loop *loop = NULL; + struct hlsl_block body_block;
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;
+ list_init(&body_block.instrs); + 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 29094899..b0d75268 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); list_move_tail(&loop->body.instrs, &block->instrs); - 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_free_instr_list(&body.instrs); 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 e8af0095..7e219a1e 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -1094,7 +1094,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 921aae90..cff89047 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -442,8 +442,8 @@ enum loop_type static struct list *create_loop(struct hlsl_ctx *ctx, enum loop_type type, 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;
if (!init && !(init = make_empty_list(ctx))) goto oom; @@ -466,14 +466,13 @@ static struct list *create_loop(struct hlsl_ctx *ctx, enum loop_type type, struc
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 b0d75268..033d58a8 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 7e219a1e..195cec10 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -1096,7 +1096,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 cff89047..4f243dc3 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -710,7 +710,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) { @@ -736,7 +736,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; }
@@ -3195,8 +3195,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) { @@ -3236,7 +3235,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; }
@@ -3585,7 +3584,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl 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 @@ -3625,7 +3624,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
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; } else if (!strcmp(name, "Sample") @@ -3636,7 +3635,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl 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) { @@ -3681,7 +3680,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
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; } @@ -3696,7 +3695,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl 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")) @@ -3782,7 +3781,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
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; } else if (!strcmp(name, "SampleLevel") @@ -3793,7 +3792,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl 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 (params->args_count < 3 || params->args_count > 4 + !!offset_dim) { @@ -3840,7 +3839,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
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; } else
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 033d58a8..7138a99a 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 195cec10..fac59df7 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -1098,7 +1098,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 4f243dc3..1a913cb0 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1731,9 +1731,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. */ @@ -1762,7 +1762,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))) {