vkd3d-shader/hlsl: Store modifier flags as a uint32_t.

This commit is contained in:
Henri Verbeet 2023-12-06 19:36:35 +01:00 committed by Alexandre Julliard
parent fafe2a1dba
commit 3344c4e93d
Notes: Alexandre Julliard 2024-01-08 22:22:02 +01:00
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/543
4 changed files with 27 additions and 27 deletions

View File

@ -920,7 +920,7 @@ bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2
} }
struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old, struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old,
unsigned int default_majority, unsigned int modifiers) unsigned int default_majority, uint32_t modifiers)
{ {
struct hlsl_type *type; struct hlsl_type *type;
@ -1030,7 +1030,7 @@ struct hlsl_ir_node *hlsl_new_copy(struct hlsl_ctx *ctx, struct hlsl_ir_node *no
} }
struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type, struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type,
const struct vkd3d_shader_location *loc, const struct hlsl_semantic *semantic, unsigned int modifiers, const struct vkd3d_shader_location *loc, const struct hlsl_semantic *semantic, uint32_t modifiers,
const struct hlsl_reg_reservation *reg_reservation) const struct hlsl_reg_reservation *reg_reservation)
{ {
struct hlsl_ir_var *var; struct hlsl_ir_var *var;
@ -2246,7 +2246,7 @@ const char *debug_hlsl_type(struct hlsl_ctx *ctx, const struct hlsl_type *type)
return ret; return ret;
} }
struct vkd3d_string_buffer *hlsl_modifiers_to_string(struct hlsl_ctx *ctx, unsigned int modifiers) struct vkd3d_string_buffer *hlsl_modifiers_to_string(struct hlsl_ctx *ctx, uint32_t modifiers)
{ {
struct vkd3d_string_buffer *string; struct vkd3d_string_buffer *string;

View File

@ -155,7 +155,7 @@ struct hlsl_type
/* Bitfield for storing type modifiers, subset of HLSL_TYPE_MODIFIERS_MASK. /* Bitfield for storing type modifiers, subset of HLSL_TYPE_MODIFIERS_MASK.
* Modifiers that don't fall inside this mask are to be stored in the variable in * Modifiers that don't fall inside this mask are to be stored in the variable in
* hlsl_ir_var.modifiers, or in the struct field in hlsl_ir_field.modifiers. */ * hlsl_ir_var.modifiers, or in the struct field in hlsl_ir_field.modifiers. */
unsigned int modifiers; uint32_t modifiers;
/* Size of the type values on each dimension. For non-numeric types, they are set for the /* Size of the type values on each dimension. For non-numeric types, they are set for the
* convenience of the sm1/sm4 backends. * convenience of the sm1/sm4 backends.
* If type is HLSL_CLASS_SCALAR, then both dimx = 1 and dimy = 1. * If type is HLSL_CLASS_SCALAR, then both dimx = 1 and dimy = 1.
@ -234,7 +234,7 @@ struct hlsl_struct_field
/* Bitfield for storing modifiers that are not in HLSL_TYPE_MODIFIERS_MASK (these are stored in /* Bitfield for storing modifiers that are not in HLSL_TYPE_MODIFIERS_MASK (these are stored in
* type->modifiers instead) and that also are specific to the field and not the whole variable. * type->modifiers instead) and that also are specific to the field and not the whole variable.
* In particular, interpolation modifiers. */ * In particular, interpolation modifiers. */
unsigned int storage_modifiers; uint32_t storage_modifiers;
/* Offset of the field within the type it belongs to, in register components, for each regset. */ /* Offset of the field within the type it belongs to, in register components, for each regset. */
unsigned int reg_offset[HLSL_REGSET_LAST + 1]; unsigned int reg_offset[HLSL_REGSET_LAST + 1];
@ -392,7 +392,7 @@ struct hlsl_ir_var
/* Buffer where the variable's value is stored, in case it is uniform. */ /* Buffer where the variable's value is stored, in case it is uniform. */
struct hlsl_buffer *buffer; struct hlsl_buffer *buffer;
/* Bitfield for storage modifiers (type modifiers are stored in data_type->modifiers). */ /* Bitfield for storage modifiers (type modifiers are stored in data_type->modifiers). */
unsigned int storage_modifiers; uint32_t storage_modifiers;
/* Optional reservations of registers and/or offsets for variables within constant buffers. */ /* Optional reservations of registers and/or offsets for variables within constant buffers. */
struct hlsl_reg_reservation reg_reservation; struct hlsl_reg_reservation reg_reservation;
@ -1264,7 +1264,7 @@ struct hlsl_ir_node *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n
struct hlsl_ir_node *hlsl_new_unary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, struct hlsl_ir_node *hlsl_new_unary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg,
const struct vkd3d_shader_location *loc); const struct vkd3d_shader_location *loc);
struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type, struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type,
const struct vkd3d_shader_location *loc, const struct hlsl_semantic *semantic, unsigned int modifiers, const struct vkd3d_shader_location *loc, const struct hlsl_semantic *semantic, uint32_t modifiers,
const struct hlsl_reg_reservation *reg_reservation); const struct hlsl_reg_reservation *reg_reservation);
struct hlsl_ir_switch_case *hlsl_new_switch_case(struct hlsl_ctx *ctx, unsigned int value, bool is_default, struct hlsl_ir_switch_case *hlsl_new_switch_case(struct hlsl_ctx *ctx, unsigned int value, bool is_default,
struct hlsl_block *body, const struct vkd3d_shader_location *loc); struct hlsl_block *body, const struct vkd3d_shader_location *loc);
@ -1286,7 +1286,7 @@ void hlsl_pop_scope(struct hlsl_ctx *ctx);
bool hlsl_scope_add_type(struct hlsl_scope *scope, struct hlsl_type *type); bool hlsl_scope_add_type(struct hlsl_scope *scope, struct hlsl_type *type);
struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old, struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old,
unsigned int default_majority, unsigned int modifiers); unsigned int default_majority, uint32_t modifiers);
unsigned int hlsl_type_component_count(const struct hlsl_type *type); unsigned int hlsl_type_component_count(const struct hlsl_type *type);
unsigned int hlsl_type_get_array_element_reg_size(const struct hlsl_type *type, enum hlsl_regset regset); unsigned int hlsl_type_get_array_element_reg_size(const struct hlsl_type *type, enum hlsl_regset regset);
struct hlsl_type *hlsl_type_get_component_type(struct hlsl_ctx *ctx, struct hlsl_type *type, struct hlsl_type *hlsl_type_get_component_type(struct hlsl_ctx *ctx, struct hlsl_type *type,

View File

@ -40,7 +40,7 @@ struct parse_parameter
const char *name; const char *name;
struct hlsl_semantic semantic; struct hlsl_semantic semantic;
struct hlsl_reg_reservation reg_reservation; struct hlsl_reg_reservation reg_reservation;
unsigned int modifiers; uint32_t modifiers;
}; };
struct parse_colon_attribute struct parse_colon_attribute
@ -75,7 +75,7 @@ struct parse_variable_def
struct parse_initializer initializer; struct parse_initializer initializer;
struct hlsl_type *basic_type; struct hlsl_type *basic_type;
unsigned int modifiers; uint32_t modifiers;
struct vkd3d_shader_location modifiers_loc; struct vkd3d_shader_location modifiers_loc;
}; };
@ -405,7 +405,7 @@ static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct
return add_cast(ctx, block, node, dst_type, loc); return add_cast(ctx, block, node, dst_type, loc);
} }
static DWORD add_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, DWORD mod, static uint32_t add_modifiers(struct hlsl_ctx *ctx, uint32_t modifiers, uint32_t mod,
const struct vkd3d_shader_location *loc) const struct vkd3d_shader_location *loc)
{ {
if (modifiers & mod) if (modifiers & mod)
@ -868,7 +868,7 @@ static const struct hlsl_struct_field *get_struct_field(const struct hlsl_struct
} }
static struct hlsl_type *apply_type_modifiers(struct hlsl_ctx *ctx, struct hlsl_type *type, static struct hlsl_type *apply_type_modifiers(struct hlsl_ctx *ctx, struct hlsl_type *type,
unsigned int *modifiers, bool force_majority, const struct vkd3d_shader_location *loc) uint32_t *modifiers, bool force_majority, const struct vkd3d_shader_location *loc)
{ {
unsigned int default_majority = 0; unsigned int default_majority = 0;
struct hlsl_type *new_type; struct hlsl_type *new_type;
@ -926,7 +926,7 @@ static bool shader_profile_version_lt(const struct hlsl_ctx *ctx, unsigned int m
} }
static bool gen_struct_fields(struct hlsl_ctx *ctx, struct parse_fields *fields, static bool gen_struct_fields(struct hlsl_ctx *ctx, struct parse_fields *fields,
struct hlsl_type *type, unsigned int modifiers, struct list *defs) struct hlsl_type *type, uint32_t modifiers, struct list *defs)
{ {
struct parse_variable_def *v, *v_next; struct parse_variable_def *v, *v_next;
size_t i = 0; size_t i = 0;
@ -1019,7 +1019,7 @@ static bool add_typedef(struct hlsl_ctx *ctx, struct hlsl_type *const orig_type,
} }
else else
{ {
unsigned int var_modifiers = 0; uint32_t var_modifiers = 0;
if (!(type = apply_type_modifiers(ctx, orig_type, &var_modifiers, true, &v->loc))) if (!(type = apply_type_modifiers(ctx, orig_type, &var_modifiers, true, &v->loc)))
{ {
@ -4845,7 +4845,7 @@ static void check_duplicated_switch_cases(struct hlsl_ctx *ctx, const struct hls
FLOAT floatval; FLOAT floatval;
bool boolval; bool boolval;
char *name; char *name;
DWORD modifiers; uint32_t modifiers;
struct hlsl_ir_node *instr; struct hlsl_ir_node *instr;
struct hlsl_block *block; struct hlsl_block *block;
struct list *list; struct list *list;
@ -5283,7 +5283,7 @@ field:
var_modifiers field_type variables_def ';' var_modifiers field_type variables_def ';'
{ {
struct hlsl_type *type; struct hlsl_type *type;
unsigned int modifiers = $1; uint32_t modifiers = $1;
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, true, &@1))) if (!(type = apply_type_modifiers(ctx, $2, &modifiers, true, &@1)))
YYABORT; YYABORT;
@ -5436,7 +5436,7 @@ func_prototype_no_attrs:
/* var_modifiers is necessary to avoid shift/reduce conflicts. */ /* var_modifiers is necessary to avoid shift/reduce conflicts. */
var_modifiers type var_identifier '(' parameters ')' colon_attribute var_modifiers type var_identifier '(' parameters ')' colon_attribute
{ {
unsigned int modifiers = $1; uint32_t modifiers = $1;
struct hlsl_ir_var *var; struct hlsl_ir_var *var;
struct hlsl_type *type; struct hlsl_type *type;
@ -5710,7 +5710,7 @@ param_list:
parameter: parameter:
var_modifiers type_no_void any_identifier arrays colon_attribute var_modifiers type_no_void any_identifier arrays colon_attribute
{ {
unsigned int modifiers = $1; uint32_t modifiers = $1;
struct hlsl_type *type; struct hlsl_type *type;
unsigned int i; unsigned int i;
@ -6024,7 +6024,7 @@ typedef:
KW_TYPEDEF var_modifiers typedef_type type_specs ';' KW_TYPEDEF var_modifiers typedef_type type_specs ';'
{ {
struct parse_variable_def *v, *v_next; struct parse_variable_def *v, *v_next;
unsigned int modifiers = $2; uint32_t modifiers = $2;
struct hlsl_type *type; struct hlsl_type *type;
if (!(type = apply_type_modifiers(ctx, $3, &modifiers, false, &@2))) if (!(type = apply_type_modifiers(ctx, $3, &modifiers, false, &@2)))
@ -6161,7 +6161,7 @@ variable_def:
variable_def_typed: variable_def_typed:
var_modifiers struct_spec variable_def var_modifiers struct_spec variable_def
{ {
unsigned int modifiers = $1; uint32_t modifiers = $1;
struct hlsl_type *type; struct hlsl_type *type;
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, true, &@1))) if (!(type = apply_type_modifiers(ctx, $2, &modifiers, true, &@1)))
@ -6176,7 +6176,7 @@ variable_def_typed:
} }
| var_modifiers type variable_def | var_modifiers type variable_def
{ {
unsigned int modifiers = $1; uint32_t modifiers = $1;
struct hlsl_type *type; struct hlsl_type *type;
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, true, &@1))) if (!(type = apply_type_modifiers(ctx, $2, &modifiers, true, &@1)))

View File

@ -263,7 +263,7 @@ static bool types_are_semantic_equivalent(struct hlsl_ctx *ctx, const struct hls
} }
static struct hlsl_ir_var *add_semantic_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, static struct hlsl_ir_var *add_semantic_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *var,
struct hlsl_type *type, unsigned int modifiers, struct hlsl_semantic *semantic, struct hlsl_type *type, uint32_t modifiers, struct hlsl_semantic *semantic,
uint32_t index, bool output, const struct vkd3d_shader_location *loc) uint32_t index, bool output, const struct vkd3d_shader_location *loc)
{ {
struct hlsl_semantic new_semantic; struct hlsl_semantic new_semantic;
@ -331,7 +331,7 @@ static struct hlsl_ir_var *add_semantic_var(struct hlsl_ctx *ctx, struct hlsl_ir
} }
static void prepend_input_copy(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_load *lhs, static void prepend_input_copy(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_load *lhs,
unsigned int modifiers, struct hlsl_semantic *semantic, uint32_t semantic_index) uint32_t modifiers, struct hlsl_semantic *semantic, uint32_t semantic_index)
{ {
struct hlsl_type *type = lhs->node.data_type, *vector_type_src, *vector_type_dst; struct hlsl_type *type = lhs->node.data_type, *vector_type_src, *vector_type_dst;
struct vkd3d_shader_location *loc = &lhs->node.loc; struct vkd3d_shader_location *loc = &lhs->node.loc;
@ -395,7 +395,7 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct hlsl_block *block, s
} }
static void prepend_input_copy_recurse(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_load *lhs, static void prepend_input_copy_recurse(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_load *lhs,
unsigned int modifiers, struct hlsl_semantic *semantic, uint32_t semantic_index) uint32_t modifiers, struct hlsl_semantic *semantic, uint32_t semantic_index)
{ {
struct vkd3d_shader_location *loc = &lhs->node.loc; struct vkd3d_shader_location *loc = &lhs->node.loc;
struct hlsl_type *type = lhs->node.data_type; struct hlsl_type *type = lhs->node.data_type;
@ -411,7 +411,7 @@ static void prepend_input_copy_recurse(struct hlsl_ctx *ctx, struct hlsl_block *
for (i = 0; i < hlsl_type_element_count(type); ++i) for (i = 0; i < hlsl_type_element_count(type); ++i)
{ {
unsigned int element_modifiers = modifiers; uint32_t element_modifiers = modifiers;
if (type->class == HLSL_CLASS_ARRAY) if (type->class == HLSL_CLASS_ARRAY)
{ {
@ -473,7 +473,7 @@ static void prepend_input_var_copy(struct hlsl_ctx *ctx, struct hlsl_block *bloc
} }
static void append_output_copy(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_load *rhs, static void append_output_copy(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_load *rhs,
unsigned int modifiers, struct hlsl_semantic *semantic, uint32_t semantic_index) uint32_t modifiers, struct hlsl_semantic *semantic, uint32_t semantic_index)
{ {
struct hlsl_type *type = rhs->node.data_type, *vector_type; struct hlsl_type *type = rhs->node.data_type, *vector_type;
struct vkd3d_shader_location *loc = &rhs->node.loc; struct vkd3d_shader_location *loc = &rhs->node.loc;
@ -529,7 +529,7 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct hlsl_block *block, s
} }
static void append_output_copy_recurse(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_load *rhs, static void append_output_copy_recurse(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_load *rhs,
unsigned int modifiers, struct hlsl_semantic *semantic, uint32_t semantic_index) uint32_t modifiers, struct hlsl_semantic *semantic, uint32_t semantic_index)
{ {
struct vkd3d_shader_location *loc = &rhs->node.loc; struct vkd3d_shader_location *loc = &rhs->node.loc;
struct hlsl_type *type = rhs->node.data_type; struct hlsl_type *type = rhs->node.data_type;