mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-06 08:08:20 +00:00
d3dcompiler: Calculate the register size of types.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f82b44748a
commit
5f18f9f75a
|
@ -614,6 +614,7 @@ struct hlsl_type
|
||||||
unsigned int modifiers;
|
unsigned int modifiers;
|
||||||
unsigned int dimx;
|
unsigned int dimx;
|
||||||
unsigned int dimy;
|
unsigned int dimy;
|
||||||
|
unsigned int reg_size;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct list *elements;
|
struct list *elements;
|
||||||
|
@ -632,6 +633,7 @@ struct hlsl_struct_field
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *semantic;
|
const char *semantic;
|
||||||
DWORD modifiers;
|
DWORD modifiers;
|
||||||
|
unsigned int reg_offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct source_location
|
struct source_location
|
||||||
|
@ -1083,6 +1085,7 @@ struct hlsl_type *new_hlsl_type(const char *name, enum hlsl_type_class type_clas
|
||||||
struct hlsl_type *new_array_type(struct hlsl_type *basic_type, unsigned int array_size) DECLSPEC_HIDDEN;
|
struct hlsl_type *new_array_type(struct hlsl_type *basic_type, unsigned int array_size) DECLSPEC_HIDDEN;
|
||||||
struct hlsl_type *clone_hlsl_type(struct hlsl_type *old, unsigned int default_majority) DECLSPEC_HIDDEN;
|
struct hlsl_type *clone_hlsl_type(struct hlsl_type *old, unsigned int default_majority) DECLSPEC_HIDDEN;
|
||||||
struct hlsl_type *get_type(struct hlsl_scope *scope, const char *name, BOOL recursive) DECLSPEC_HIDDEN;
|
struct hlsl_type *get_type(struct hlsl_scope *scope, const char *name, BOOL recursive) DECLSPEC_HIDDEN;
|
||||||
|
BOOL is_row_major(const struct hlsl_type *type) DECLSPEC_HIDDEN;
|
||||||
BOOL find_function(const char *name) DECLSPEC_HIDDEN;
|
BOOL find_function(const char *name) DECLSPEC_HIDDEN;
|
||||||
unsigned int components_count_type(struct hlsl_type *type) DECLSPEC_HIDDEN;
|
unsigned int components_count_type(struct hlsl_type *type) DECLSPEC_HIDDEN;
|
||||||
BOOL compare_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2) DECLSPEC_HIDDEN;
|
BOOL compare_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -720,6 +720,13 @@ static BOOL add_struct_field(struct list *fields, struct hlsl_struct_field *fiel
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL is_row_major(const struct hlsl_type *type)
|
||||||
|
{
|
||||||
|
/* Default to column-major if the majority isn't explicitly set, which can
|
||||||
|
* happen for anonymous nodes. */
|
||||||
|
return !!(type->modifiers & HLSL_MODIFIER_ROW_MAJOR);
|
||||||
|
}
|
||||||
|
|
||||||
static struct hlsl_type *apply_type_modifiers(struct hlsl_type *type,
|
static struct hlsl_type *apply_type_modifiers(struct hlsl_type *type,
|
||||||
unsigned int *modifiers, struct source_location loc)
|
unsigned int *modifiers, struct source_location loc)
|
||||||
{
|
{
|
||||||
|
@ -750,6 +757,9 @@ static struct hlsl_type *apply_type_modifiers(struct hlsl_type *type,
|
||||||
|
|
||||||
new_type->modifiers = add_modifiers(new_type->modifiers, *modifiers, loc);
|
new_type->modifiers = add_modifiers(new_type->modifiers, *modifiers, loc);
|
||||||
*modifiers &= ~HLSL_TYPE_MODIFIERS_MASK;
|
*modifiers &= ~HLSL_TYPE_MODIFIERS_MASK;
|
||||||
|
|
||||||
|
if (new_type->type == HLSL_CLASS_MATRIX)
|
||||||
|
new_type->reg_size = is_row_major(new_type) ? new_type->dimy : new_type->dimx;
|
||||||
return new_type;
|
return new_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -798,6 +808,8 @@ static struct list *gen_struct_fields(struct hlsl_type *type, DWORD modifiers, s
|
||||||
static struct hlsl_type *new_struct_type(const char *name, struct list *fields)
|
static struct hlsl_type *new_struct_type(const char *name, struct list *fields)
|
||||||
{
|
{
|
||||||
struct hlsl_type *type = d3dcompiler_alloc(sizeof(*type));
|
struct hlsl_type *type = d3dcompiler_alloc(sizeof(*type));
|
||||||
|
struct hlsl_struct_field *field;
|
||||||
|
unsigned int reg_size = 0;
|
||||||
|
|
||||||
if (!type)
|
if (!type)
|
||||||
{
|
{
|
||||||
|
@ -809,6 +821,13 @@ static struct hlsl_type *new_struct_type(const char *name, struct list *fields)
|
||||||
type->dimx = type->dimy = 1;
|
type->dimx = type->dimy = 1;
|
||||||
type->e.elements = fields;
|
type->e.elements = fields;
|
||||||
|
|
||||||
|
LIST_FOR_EACH_ENTRY(field, fields, struct hlsl_struct_field, entry)
|
||||||
|
{
|
||||||
|
field->reg_offset = reg_size;
|
||||||
|
reg_size += field->type->reg_size;
|
||||||
|
}
|
||||||
|
type->reg_size = reg_size;
|
||||||
|
|
||||||
list_add_tail(&hlsl_ctx.types, &type->entry);
|
list_add_tail(&hlsl_ctx.types, &type->entry);
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
|
@ -837,6 +856,8 @@ static BOOL add_typedef(DWORD modifiers, struct hlsl_type *orig_type, struct lis
|
||||||
|
|
||||||
if (type->type != HLSL_CLASS_MATRIX)
|
if (type->type != HLSL_CLASS_MATRIX)
|
||||||
check_invalid_matrix_modifiers(type->modifiers, v->loc);
|
check_invalid_matrix_modifiers(type->modifiers, v->loc);
|
||||||
|
else
|
||||||
|
type->reg_size = is_row_major(type) ? type->dimy : type->dimx;
|
||||||
|
|
||||||
if ((type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR)
|
if ((type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR)
|
||||||
&& (type->modifiers & HLSL_MODIFIER_ROW_MAJOR))
|
&& (type->modifiers & HLSL_MODIFIER_ROW_MAJOR))
|
||||||
|
|
|
@ -820,6 +820,10 @@ struct hlsl_type *new_hlsl_type(const char *name, enum hlsl_type_class type_clas
|
||||||
type->base_type = base_type;
|
type->base_type = base_type;
|
||||||
type->dimx = dimx;
|
type->dimx = dimx;
|
||||||
type->dimy = dimy;
|
type->dimy = dimy;
|
||||||
|
if (type_class == HLSL_CLASS_MATRIX)
|
||||||
|
type->reg_size = is_row_major(type) ? dimy : dimx;
|
||||||
|
else
|
||||||
|
type->reg_size = 1;
|
||||||
|
|
||||||
list_add_tail(&hlsl_ctx.types, &type->entry);
|
list_add_tail(&hlsl_ctx.types, &type->entry);
|
||||||
|
|
||||||
|
@ -836,6 +840,7 @@ struct hlsl_type *new_array_type(struct hlsl_type *basic_type, unsigned int arra
|
||||||
type->modifiers = basic_type->modifiers;
|
type->modifiers = basic_type->modifiers;
|
||||||
type->e.array.elements_count = array_size;
|
type->e.array.elements_count = array_size;
|
||||||
type->e.array.type = basic_type;
|
type->e.array.type = basic_type;
|
||||||
|
type->reg_size = basic_type->reg_size * array_size;
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -960,8 +965,13 @@ struct hlsl_type *clone_hlsl_type(struct hlsl_type *old, unsigned int default_ma
|
||||||
case HLSL_CLASS_ARRAY:
|
case HLSL_CLASS_ARRAY:
|
||||||
type->e.array.type = clone_hlsl_type(old->e.array.type, default_majority);
|
type->e.array.type = clone_hlsl_type(old->e.array.type, default_majority);
|
||||||
type->e.array.elements_count = old->e.array.elements_count;
|
type->e.array.elements_count = old->e.array.elements_count;
|
||||||
|
type->reg_size = type->e.array.elements_count * type->e.array.type->reg_size;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HLSL_CLASS_STRUCT:
|
case HLSL_CLASS_STRUCT:
|
||||||
|
{
|
||||||
|
unsigned int reg_size = 0;
|
||||||
|
|
||||||
type->e.elements = d3dcompiler_alloc(sizeof(*type->e.elements));
|
type->e.elements = d3dcompiler_alloc(sizeof(*type->e.elements));
|
||||||
if (!type->e.elements)
|
if (!type->e.elements)
|
||||||
{
|
{
|
||||||
|
@ -991,10 +1001,20 @@ struct hlsl_type *clone_hlsl_type(struct hlsl_type *old, unsigned int default_ma
|
||||||
if (old_field->semantic)
|
if (old_field->semantic)
|
||||||
field->semantic = d3dcompiler_strdup(old_field->semantic);
|
field->semantic = d3dcompiler_strdup(old_field->semantic);
|
||||||
field->modifiers = old_field->modifiers;
|
field->modifiers = old_field->modifiers;
|
||||||
|
field->reg_offset = reg_size;
|
||||||
|
reg_size += field->type->reg_size;
|
||||||
list_add_tail(type->e.elements, &field->entry);
|
list_add_tail(type->e.elements, &field->entry);
|
||||||
}
|
}
|
||||||
|
type->reg_size = reg_size;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case HLSL_CLASS_MATRIX:
|
||||||
|
type->reg_size = is_row_major(type) ? type->dimy : type->dimx;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
type->reg_size = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue