mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Replace hlsl_type_get_regset() uses with hlsl_deref_get_regset().
This commit is contained in:
parent
a214b7374b
commit
4ab6572be7
Notes:
Alexandre Julliard
2023-10-05 22:36:55 +02: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/342
@ -216,13 +216,15 @@ bool hlsl_type_is_resource(const struct hlsl_type *type)
|
||||
return false;
|
||||
}
|
||||
|
||||
enum hlsl_regset hlsl_type_get_regset(const struct hlsl_type *type)
|
||||
/* Only intended to be used for derefs (after copies have been lowered to components or vectors) or
|
||||
* resources, since for both their data types span across a single regset. */
|
||||
static enum hlsl_regset type_get_regset(const struct hlsl_type *type)
|
||||
{
|
||||
if (type->class <= HLSL_CLASS_LAST_NUMERIC)
|
||||
return HLSL_REGSET_NUMERIC;
|
||||
|
||||
if (type->class == HLSL_CLASS_ARRAY)
|
||||
return hlsl_type_get_regset(type->e.array.type);
|
||||
return type_get_regset(type->e.array.type);
|
||||
|
||||
if (type->class == HLSL_CLASS_OBJECT)
|
||||
{
|
||||
@ -245,6 +247,18 @@ enum hlsl_regset hlsl_type_get_regset(const struct hlsl_type *type)
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
enum hlsl_regset hlsl_deref_get_regset(struct hlsl_ctx *ctx, const struct hlsl_deref *deref)
|
||||
{
|
||||
struct hlsl_type *type;
|
||||
|
||||
if (deref->data_type)
|
||||
type = deref->data_type;
|
||||
else
|
||||
type = hlsl_deref_get_type(ctx, deref);
|
||||
|
||||
return type_get_regset(type);
|
||||
}
|
||||
|
||||
unsigned int hlsl_type_get_sm4_offset(const struct hlsl_type *type, unsigned int offset)
|
||||
{
|
||||
/* Align to the next vec4 boundary if:
|
||||
@ -324,7 +338,7 @@ static void hlsl_type_calculate_reg_size(struct hlsl_ctx *ctx, struct hlsl_type
|
||||
{
|
||||
if (hlsl_type_is_resource(type))
|
||||
{
|
||||
enum hlsl_regset regset = hlsl_type_get_regset(type);
|
||||
enum hlsl_regset regset = type_get_regset(type);
|
||||
|
||||
type->reg_size[regset] = 1;
|
||||
}
|
||||
@ -496,7 +510,7 @@ unsigned int hlsl_type_get_component_offset(struct hlsl_ctx *ctx, struct hlsl_ty
|
||||
type = next_type;
|
||||
}
|
||||
|
||||
*regset = hlsl_type_get_regset(type);
|
||||
*regset = type_get_regset(type);
|
||||
return offset[*regset];
|
||||
}
|
||||
|
||||
|
@ -1238,7 +1238,6 @@ unsigned int hlsl_type_minor_size(const struct hlsl_type *type);
|
||||
unsigned int hlsl_type_major_size(const struct hlsl_type *type);
|
||||
unsigned int hlsl_type_element_count(const struct hlsl_type *type);
|
||||
bool hlsl_type_is_resource(const struct hlsl_type *type);
|
||||
enum hlsl_regset hlsl_type_get_regset(const struct hlsl_type *type);
|
||||
unsigned int hlsl_type_get_sm4_offset(const struct hlsl_type *type, unsigned int offset);
|
||||
bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2);
|
||||
|
||||
@ -1251,6 +1250,7 @@ unsigned int hlsl_map_swizzle(unsigned int swizzle, unsigned int writemask);
|
||||
unsigned int hlsl_swizzle_from_writemask(unsigned int writemask);
|
||||
|
||||
struct hlsl_type *hlsl_deref_get_type(struct hlsl_ctx *ctx, const struct hlsl_deref *deref);
|
||||
enum hlsl_regset hlsl_deref_get_regset(struct hlsl_ctx *ctx, const struct hlsl_deref *deref);
|
||||
bool hlsl_component_index_range_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref,
|
||||
unsigned int *start, unsigned int *count);
|
||||
bool hlsl_regset_index_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref,
|
||||
|
@ -97,7 +97,7 @@ static struct hlsl_ir_node *new_offset_from_path_index(struct hlsl_ctx *ctx, str
|
||||
static struct hlsl_ir_node *new_offset_instr_from_deref(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||
const struct hlsl_deref *deref, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
enum hlsl_regset regset = hlsl_type_get_regset(deref->data_type);
|
||||
enum hlsl_regset regset = hlsl_deref_get_regset(ctx, deref);
|
||||
struct hlsl_ir_node *offset = NULL;
|
||||
struct hlsl_type *type;
|
||||
unsigned int i;
|
||||
@ -2177,7 +2177,7 @@ static bool lower_combined_samples(struct hlsl_ctx *ctx, struct hlsl_ir_node *in
|
||||
return false;
|
||||
}
|
||||
|
||||
assert(hlsl_type_get_regset(load->resource.var->data_type) == HLSL_REGSET_SAMPLERS);
|
||||
assert(hlsl_deref_get_regset(ctx, &load->resource) == HLSL_REGSET_SAMPLERS);
|
||||
|
||||
if (!(name = hlsl_get_string_buffer(ctx)))
|
||||
return false;
|
||||
@ -3339,7 +3339,7 @@ static bool track_object_components_sampler_dim(struct hlsl_ctx *ctx, struct hls
|
||||
load = hlsl_ir_resource_load(instr);
|
||||
var = load->resource.var;
|
||||
|
||||
regset = hlsl_type_get_regset(hlsl_deref_get_type(ctx, &load->resource));
|
||||
regset = hlsl_deref_get_regset(ctx, &load->resource);
|
||||
if (!hlsl_regset_index_from_deref(ctx, &load->resource, regset, &index))
|
||||
return false;
|
||||
|
||||
@ -3384,7 +3384,8 @@ static bool track_object_components_usage(struct hlsl_ctx *ctx, struct hlsl_ir_n
|
||||
load = hlsl_ir_resource_load(instr);
|
||||
var = load->resource.var;
|
||||
|
||||
regset = hlsl_type_get_regset(hlsl_deref_get_type(ctx, &load->resource));
|
||||
regset = hlsl_deref_get_regset(ctx, &load->resource);
|
||||
|
||||
if (!hlsl_regset_index_from_deref(ctx, &load->resource, regset, &index))
|
||||
return false;
|
||||
|
||||
@ -4191,7 +4192,7 @@ bool hlsl_offset_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref
|
||||
return false;
|
||||
|
||||
*offset = hlsl_ir_constant(offset_node)->value.u[0].u;
|
||||
regset = hlsl_type_get_regset(deref->data_type);
|
||||
regset = hlsl_deref_get_regset(ctx, deref);
|
||||
|
||||
size = deref->var->data_type->reg_size[regset];
|
||||
if (*offset >= size)
|
||||
|
@ -3656,7 +3656,7 @@ static void sm4_register_from_deref(struct hlsl_ctx *ctx, struct vkd3d_shader_re
|
||||
|
||||
if (var->is_uniform)
|
||||
{
|
||||
enum hlsl_regset regset = hlsl_type_get_regset(data_type);
|
||||
enum hlsl_regset regset = hlsl_deref_get_regset(ctx, deref);
|
||||
|
||||
if (regset == HLSL_REGSET_TEXTURES)
|
||||
{
|
||||
@ -4433,7 +4433,7 @@ static void write_sm4_ld(const struct tpf_writer *tpf, const struct hlsl_ir_node
|
||||
const struct hlsl_type *resource_type = hlsl_deref_get_type(tpf->ctx, resource);
|
||||
bool multisampled = resource_type->base_type == HLSL_TYPE_TEXTURE
|
||||
&& (resource_type->sampler_dim == HLSL_SAMPLER_DIM_2DMS || resource_type->sampler_dim == HLSL_SAMPLER_DIM_2DMSARRAY);
|
||||
bool uav = (hlsl_type_get_regset(resource_type) == HLSL_REGSET_UAVS);
|
||||
bool uav = (hlsl_deref_get_regset(tpf->ctx, resource) == HLSL_REGSET_UAVS);
|
||||
unsigned int coords_writemask = VKD3DSP_WRITEMASK_ALL;
|
||||
struct sm4_instruction instr;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user