mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Move get_array_size() and get_array_type() to hlsl.c.
This commit is contained in:
parent
d5068fd3ff
commit
b589c2b32d
Notes:
Alexandre Julliard
2023-05-01 22:24:44 +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/148
@ -1198,24 +1198,10 @@ static D3DXPARAMETER_TYPE sm1_base_type(const struct hlsl_type *type)
|
||||
}
|
||||
}
|
||||
|
||||
static const struct hlsl_type *get_array_type(const struct hlsl_type *type)
|
||||
{
|
||||
if (type->class == HLSL_CLASS_ARRAY)
|
||||
return get_array_type(type->e.array.type);
|
||||
return type;
|
||||
}
|
||||
|
||||
static unsigned int get_array_size(const struct hlsl_type *type)
|
||||
{
|
||||
if (type->class == HLSL_CLASS_ARRAY)
|
||||
return get_array_size(type->e.array.type) * type->e.array.elements_count;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void write_sm1_type(struct vkd3d_bytecode_buffer *buffer, struct hlsl_type *type, unsigned int ctab_start)
|
||||
{
|
||||
const struct hlsl_type *array_type = get_array_type(type);
|
||||
unsigned int array_size = get_array_size(type);
|
||||
const struct hlsl_type *array_type = hlsl_get_multiarray_element_type(type);
|
||||
unsigned int array_size = hlsl_get_multiarray_size(type);
|
||||
unsigned int field_count = 0;
|
||||
size_t fields_offset = 0;
|
||||
size_t i;
|
||||
|
@ -157,10 +157,17 @@ unsigned int hlsl_type_element_count(const struct hlsl_type *type)
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned int get_array_size(const struct hlsl_type *type)
|
||||
const struct hlsl_type *hlsl_get_multiarray_element_type(const struct hlsl_type *type)
|
||||
{
|
||||
if (type->class == HLSL_CLASS_ARRAY)
|
||||
return get_array_size(type->e.array.type) * type->e.array.elements_count;
|
||||
return hlsl_get_multiarray_element_type(type->e.array.type);
|
||||
return type;
|
||||
}
|
||||
|
||||
unsigned int hlsl_get_multiarray_size(const struct hlsl_type *type)
|
||||
{
|
||||
if (type->class == HLSL_CLASS_ARRAY)
|
||||
return hlsl_get_multiarray_size(type->e.array.type) * type->e.array.elements_count;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -279,7 +286,7 @@ static void hlsl_type_calculate_reg_size(struct hlsl_ctx *ctx, struct hlsl_type
|
||||
type->reg_size[k] += field->type->reg_size[k];
|
||||
}
|
||||
|
||||
type->dimx += field->type->dimx * field->type->dimy * get_array_size(field->type);
|
||||
type->dimx += field->type->dimx * field->type->dimy * hlsl_get_multiarray_size(field->type);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1147,6 +1147,9 @@ 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);
|
||||
|
||||
const struct hlsl_type *hlsl_get_multiarray_element_type(const struct hlsl_type *type);
|
||||
unsigned int hlsl_get_multiarray_size(const struct hlsl_type *type);
|
||||
|
||||
unsigned int hlsl_combine_swizzles(unsigned int first, unsigned int second, unsigned int dim);
|
||||
unsigned int hlsl_combine_writemasks(unsigned int first, unsigned int second);
|
||||
unsigned int hlsl_map_swizzle(unsigned int swizzle, unsigned int writemask);
|
||||
|
@ -2448,20 +2448,6 @@ static void write_sm4_signature(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc,
|
||||
add_section(dxbc, output ? TAG_OSGN : TAG_ISGN, &buffer);
|
||||
}
|
||||
|
||||
static const struct hlsl_type *get_array_type(const struct hlsl_type *type)
|
||||
{
|
||||
if (type->class == HLSL_CLASS_ARRAY)
|
||||
return get_array_type(type->e.array.type);
|
||||
return type;
|
||||
}
|
||||
|
||||
static unsigned int get_array_size(const struct hlsl_type *type)
|
||||
{
|
||||
if (type->class == HLSL_CLASS_ARRAY)
|
||||
return get_array_size(type->e.array.type) * type->e.array.elements_count;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static D3D_SHADER_VARIABLE_CLASS sm4_class(const struct hlsl_type *type)
|
||||
{
|
||||
switch (type->class)
|
||||
@ -2552,7 +2538,7 @@ static D3D_SHADER_VARIABLE_TYPE sm4_base_type(const struct hlsl_type *type)
|
||||
|
||||
static void write_sm4_type(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, struct hlsl_type *type)
|
||||
{
|
||||
const struct hlsl_type *array_type = get_array_type(type);
|
||||
const struct hlsl_type *array_type = hlsl_get_multiarray_element_type(type);
|
||||
const char *name = array_type->name ? array_type->name : "<unnamed>";
|
||||
const struct hlsl_profile_info *profile = ctx->profile;
|
||||
unsigned int field_count = 0, array_size = 0;
|
||||
@ -2566,7 +2552,7 @@ static void write_sm4_type(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b
|
||||
name_offset = put_string(buffer, name);
|
||||
|
||||
if (type->class == HLSL_CLASS_ARRAY)
|
||||
array_size = get_array_size(type);
|
||||
array_size = hlsl_get_multiarray_size(type);
|
||||
|
||||
if (array_type->class == HLSL_CLASS_STRUCT)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user