vkd3d-shader/hlsl: Rename hlsl_deref.offset to hlsl_deref.rel_offset.

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.const_offset. Consequently, it
may also be NULL now.
This commit is contained in:
Francisco Casas 2023-10-06 13:56:24 -03:00 committed by Alexandre Julliard
parent 74767beaf6
commit 313df300ad
Notes: Alexandre Julliard 2023-10-31 22:38:12 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/396
3 changed files with 26 additions and 26 deletions

View File

@ -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->rel_offset.node = NULL;
deref->const_offset = 0;
deref->data_type = NULL;
@ -541,7 +541,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->rel_offset.node = NULL;
deref->const_offset = 0;
assert(chain);
@ -1138,7 +1138,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->rel_offset);
deref->const_offset = 0;
}
@ -2432,12 +2432,12 @@ static void dump_deref(struct vkd3d_string_buffer *buffer, const struct hlsl_der
{
bool show_rel, show_const;
show_rel = deref->offset.node;
show_rel = deref->rel_offset.node;
show_const = deref->const_offset != 0 || !show_rel;
vkd3d_string_buffer_printf(buffer, "[");
if (show_rel)
dump_src(buffer, &deref->offset);
dump_src(buffer, &deref->rel_offset);
if (show_rel && show_const)
vkd3d_string_buffer_printf(buffer, " + ");
if (show_const)
@ -3011,7 +3011,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.rel_offset);
hlsl_src_remove(&store->coords);
hlsl_src_remove(&store->value);
vkd3d_free(store);

View File

@ -642,11 +642,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.
* - rel_offset: An offset given by an instruction node, in whole registers.
* - const_offset: 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, which remains NULL if the deref hasn't been lowered yet. */
struct hlsl_src offset;
struct hlsl_src rel_offset;
unsigned int const_offset;
struct hlsl_type *data_type;
};

View File

@ -168,7 +168,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->rel_offset, offset);
deref->const_offset = offset_component;
return true;
@ -177,15 +177,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->rel_offset.node && deref->rel_offset.node->type == HLSL_IR_CONSTANT)
{
enum hlsl_regset regset = hlsl_deref_get_regset(ctx, deref);
if (regset == HLSL_REGSET_NUMERIC)
deref->const_offset += 4 * hlsl_ir_constant(deref->offset.node)->value.u[0].u;
deref->const_offset += 4 * hlsl_ir_constant(deref->rel_offset.node)->value.u[0].u;
else
deref->const_offset += hlsl_ir_constant(deref->offset.node)->value.u[0].u;
hlsl_src_remove(&deref->offset);
deref->const_offset += hlsl_ir_constant(deref->rel_offset.node)->value.u[0].u;
hlsl_src_remove(&deref->rel_offset);
return true;
}
return false;
@ -3298,8 +3298,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.rel_offset.node)
store->lhs.rel_offset.node->last_read = last_read;
break;
}
case HLSL_IR_EXPR:
@ -3326,8 +3326,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.rel_offset.node)
load->src.rel_offset.node->last_read = last_read;
break;
}
case HLSL_IR_LOOP:
@ -3344,14 +3344,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.rel_offset.node)
load->resource.rel_offset.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.rel_offset.node)
load->sampler.rel_offset.node->last_read = last_read;
}
if (load->coords.node)
@ -3376,8 +3376,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.rel_offset.node)
store->resource.rel_offset.node->last_read = last_read;
store->coords.node->last_read = last_read;
store->value.node->last_read = last_read;
break;
@ -4473,7 +4473,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->rel_offset.node;
unsigned int size;
*offset = deref->const_offset;
@ -4505,8 +4505,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->rel_offset.node->loc, "Dereference with non-constant offset of type %s.",
hlsl_node_type_to_string(deref->rel_offset.node->type));
return 0;
}