vkd3d-shader/hlsl: Handle resource components individually for SM 5.0.

This commit is contained in:
Francisco Casas
2023-05-29 19:51:10 -04:00
committed by Alexandre Julliard
parent 8f8c7a02ee
commit c58d666d1b
Notes: Alexandre Julliard 2023-07-17 23:25:21 +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/209
4 changed files with 170 additions and 59 deletions

View File

@@ -430,6 +430,51 @@ struct hlsl_type *hlsl_type_get_component_type(struct hlsl_ctx *ctx, struct hlsl
return type;
}
unsigned int hlsl_type_get_component_offset(struct hlsl_ctx *ctx, struct hlsl_type *type,
enum hlsl_regset regset, unsigned int index)
{
struct hlsl_type *next_type;
unsigned int offset = 0;
unsigned int idx;
while (!type_is_single_component(type))
{
next_type = type;
idx = traverse_path_from_component_index(ctx, &next_type, &index);
switch (type->class)
{
case HLSL_CLASS_SCALAR:
case HLSL_CLASS_VECTOR:
case HLSL_CLASS_MATRIX:
if (regset == HLSL_REGSET_NUMERIC)
offset += idx;
break;
case HLSL_CLASS_STRUCT:
offset += type->e.record.fields[idx].reg_offset[regset];
break;
case HLSL_CLASS_ARRAY:
if (regset == HLSL_REGSET_NUMERIC)
offset += idx * align(type->e.array.type->reg_size[regset], 4);
else
offset += idx * type->e.array.type->reg_size[regset];
break;
case HLSL_CLASS_OBJECT:
assert(idx == 0);
break;
default:
vkd3d_unreachable();
}
type = next_type;
}
return offset;
}
static bool init_deref(struct hlsl_ctx *ctx, struct hlsl_deref *deref, struct hlsl_ir_var *var,
unsigned int path_len)
{
@@ -2068,6 +2113,31 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru
}
}
struct vkd3d_string_buffer *hlsl_component_to_string(struct hlsl_ctx *ctx, const struct hlsl_ir_var *var,
unsigned int index)
{
struct hlsl_type *type = var->data_type, *current_type;
struct vkd3d_string_buffer *buffer;
unsigned int element_index;
if (!(buffer = hlsl_get_string_buffer(ctx)))
return NULL;
vkd3d_string_buffer_printf(buffer, "%s", var->name);
while (!type_is_single_component(type))
{
current_type = type;
element_index = traverse_path_from_component_index(ctx, &type, &index);
if (current_type->class == HLSL_CLASS_STRUCT)
vkd3d_string_buffer_printf(buffer, ".%s", current_type->e.record.fields[element_index].name);
else
vkd3d_string_buffer_printf(buffer, "[%u]", element_index);
}
return buffer;
}
const char *debug_hlsl_type(struct hlsl_ctx *ctx, const struct hlsl_type *type)
{
struct vkd3d_string_buffer *string;