From: Francisco Casas fcasas@codeweavers.com
This field is now analogous to vkd3d_shader_register_index.rel_addr.
Also, it makes sense to rename it now because all the constant part of the offset is now handled to hlsl_deref.offset_const. Consequently, it may also be NULL now. --- libs/vkd3d-shader/hlsl.c | 18 +++++++-------- libs/vkd3d-shader/hlsl.h | 4 ++-- libs/vkd3d-shader/hlsl_codegen.c | 38 ++++++++++++++++---------------- 3 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index cb5b23db3..3618d3473 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -512,7 +512,7 @@ static bool init_deref(struct hlsl_ctx *ctx, struct hlsl_deref *deref, struct hl { deref->var = var; deref->path_len = path_len; - deref->offset.node = NULL; + deref->offset_rel.node = NULL; deref->offset_const = 0; deref->is_lowered = false; deref->data_type = NULL; @@ -542,7 +542,7 @@ bool hlsl_init_deref_from_index_chain(struct hlsl_ctx *ctx, struct hlsl_deref *d
deref->path = NULL; deref->path_len = 0; - deref->offset.node = NULL; + deref->offset_rel.node = NULL; deref->offset_const = 0;
assert(chain); @@ -1117,7 +1117,7 @@ bool hlsl_copy_deref(struct hlsl_ctx *ctx, struct hlsl_deref *deref, const struc if (!other) return true;
- assert(!other->offset.node); + assert(!other->offset_rel.node);
if (!init_deref(ctx, deref, other->var, other->path_len)) return false; @@ -1139,7 +1139,7 @@ void hlsl_cleanup_deref(struct hlsl_deref *deref) deref->path = NULL; deref->path_len = 0;
- hlsl_src_remove(&deref->offset); + hlsl_src_remove(&deref->offset_rel); deref->offset_const = 0; }
@@ -1175,7 +1175,7 @@ struct hlsl_ir_node *hlsl_new_store_index(struct hlsl_ctx *ctx, const struct hls unsigned int i;
assert(lhs); - assert(!lhs->offset.node); + assert(!lhs->offset_rel.node);
if (!(store = hlsl_alloc(ctx, sizeof(*store)))) return NULL; @@ -1621,7 +1621,7 @@ static bool clone_deref(struct hlsl_ctx *ctx, struct clone_instr_map *map, { unsigned int i;
- assert(!src->offset.node); + assert(!src->offset_rel.node);
if (!init_deref(ctx, dst, src->var, src->path_len)) return false; @@ -2335,9 +2335,9 @@ static void dump_deref(struct vkd3d_string_buffer *buffer, const struct hlsl_der else if (deref->is_lowered) { vkd3d_string_buffer_printf(buffer, "["); - if (deref->offset.node) + if (deref->offset_rel.node) { - dump_src(buffer, &deref->offset); + dump_src(buffer, &deref->offset_rel); vkd3d_string_buffer_printf(buffer, " + "); } vkd3d_string_buffer_printf(buffer, "%uc]", deref->offset_const); @@ -2875,7 +2875,7 @@ static void free_ir_resource_load(struct hlsl_ir_resource_load *load)
static void free_ir_resource_store(struct hlsl_ir_resource_store *store) { - hlsl_src_remove(&store->resource.offset); + hlsl_src_remove(&store->resource.offset_rel); hlsl_src_remove(&store->coords); hlsl_src_remove(&store->value); vkd3d_free(store); diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index d801da31c..c35af4229 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -619,11 +619,11 @@ struct hlsl_deref * regset) from the start of the variable, to the part of the variable that is referenced. * This offset is stored using two fields, one for a variable part and other for a constant * part, which are added together: - * - offset: An offset given by an instruction node, in whole registers. + * - offset_rel: An offset given by an instruction node, in whole registers. * - offset_const: A constant number of register components. * Since the type information cannot longer be retrieved from the offset alone, the type is * stored in the data_type field. */ - struct hlsl_src offset; + struct hlsl_src offset_rel; unsigned int offset_const; struct hlsl_type *data_type; /* Whether the path has been lowered to an offset or not. */ diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index e25396a79..fc21cd0a4 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -148,7 +148,7 @@ static bool replace_deref_path_with_offset(struct hlsl_ctx *ctx, struct hlsl_der assert(deref->var);
/* register offsets shouldn't be used before this point is reached. */ - assert(!deref->offset.node); + assert(!deref->offset_rel.node); assert(!deref->offset_const);
type = hlsl_deref_get_type(ctx, deref); @@ -169,7 +169,7 @@ static bool replace_deref_path_with_offset(struct hlsl_ctx *ctx, struct hlsl_der list_move_before(&instr->entry, &block.instrs);
hlsl_cleanup_deref(deref); - hlsl_src_from_node(&deref->offset, offset); + hlsl_src_from_node(&deref->offset_rel, offset); deref->offset_const = offset_component;
return true; @@ -178,15 +178,15 @@ static bool replace_deref_path_with_offset(struct hlsl_ctx *ctx, struct hlsl_der static bool clean_constant_deref_offset_srcs(struct hlsl_ctx *ctx, struct hlsl_deref *deref, struct hlsl_ir_node *instr) { - if (deref->offset.node && deref->offset.node->type == HLSL_IR_CONSTANT) + if (deref->offset_rel.node && deref->offset_rel.node->type == HLSL_IR_CONSTANT) { enum hlsl_regset regset = hlsl_deref_get_regset(ctx, deref);
if (regset == HLSL_REGSET_NUMERIC) - deref->offset_const += 4 * hlsl_ir_constant(deref->offset.node)->value.u[0].u; + deref->offset_const += 4 * hlsl_ir_constant(deref->offset_rel.node)->value.u[0].u; else - deref->offset_const += hlsl_ir_constant(deref->offset.node)->value.u[0].u; - hlsl_src_remove(&deref->offset); + deref->offset_const += hlsl_ir_constant(deref->offset_rel.node)->value.u[0].u; + hlsl_src_remove(&deref->offset_rel); return true; } return false; @@ -3088,8 +3088,8 @@ static void compute_liveness_recurse(struct hlsl_block *block, unsigned int loop if (!var->first_write) var->first_write = loop_first ? min(instr->index, loop_first) : instr->index; store->rhs.node->last_read = last_read; - if (store->lhs.offset.node) - store->lhs.offset.node->last_read = last_read; + if (store->lhs.offset_rel.node) + store->lhs.offset_rel.node->last_read = last_read; break; } case HLSL_IR_EXPR: @@ -3116,8 +3116,8 @@ static void compute_liveness_recurse(struct hlsl_block *block, unsigned int loop
var = load->src.var; var->last_read = max(var->last_read, last_read); - if (load->src.offset.node) - load->src.offset.node->last_read = last_read; + if (load->src.offset_rel.node) + load->src.offset_rel.node->last_read = last_read; break; } case HLSL_IR_LOOP: @@ -3134,14 +3134,14 @@ static void compute_liveness_recurse(struct hlsl_block *block, unsigned int loop
var = load->resource.var; var->last_read = max(var->last_read, last_read); - if (load->resource.offset.node) - load->resource.offset.node->last_read = last_read; + if (load->resource.offset_rel.node) + load->resource.offset_rel.node->last_read = last_read;
if ((var = load->sampler.var)) { var->last_read = max(var->last_read, last_read); - if (load->sampler.offset.node) - load->sampler.offset.node->last_read = last_read; + if (load->sampler.offset_rel.node) + load->sampler.offset_rel.node->last_read = last_read; }
if (load->coords.node) @@ -3166,8 +3166,8 @@ static void compute_liveness_recurse(struct hlsl_block *block, unsigned int loop
var = store->resource.var; var->last_read = max(var->last_read, last_read); - if (store->resource.offset.node) - store->resource.offset.node->last_read = last_read; + if (store->resource.offset_rel.node) + store->resource.offset_rel.node->last_read = last_read; store->coords.node->last_read = last_read; store->value.node->last_read = last_read; break; @@ -4229,7 +4229,7 @@ bool hlsl_regset_index_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref bool hlsl_offset_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref, unsigned int *offset) { enum hlsl_regset regset = hlsl_deref_get_regset(ctx, deref); - struct hlsl_ir_node *offset_node = deref->offset.node; + struct hlsl_ir_node *offset_node = deref->offset_rel.node; unsigned int size;
*offset = deref->offset_const; @@ -4261,8 +4261,8 @@ unsigned int hlsl_offset_from_deref_safe(struct hlsl_ctx *ctx, const struct hlsl if (hlsl_offset_from_deref(ctx, deref, &offset)) return offset;
- hlsl_fixme(ctx, &deref->offset.node->loc, "Dereference with non-constant offset of type %s.", - hlsl_node_type_to_string(deref->offset.node->type)); + hlsl_fixme(ctx, &deref->offset_rel.node->loc, "Dereference with non-constant offset of type %s.", + hlsl_node_type_to_string(deref->offset_rel.node->type));
return 0; }