vkd3d-shader: Store the hlsl_reg_reservation struct directly.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-05-31 21:41:14 -05:00 committed by Alexandre Julliard
parent bb79ca76ae
commit e8e138ed54
4 changed files with 22 additions and 30 deletions

View File

@ -95,7 +95,6 @@ void hlsl_free_var(struct hlsl_ir_var *decl)
{
vkd3d_free((void *)decl->name);
vkd3d_free((void *)decl->semantic.name);
vkd3d_free((void *)decl->reg_reservation);
vkd3d_free(decl);
}
@ -406,7 +405,8 @@ struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct
if (semantic)
var->semantic = *semantic;
var->modifiers = modifiers;
var->reg_reservation = reg_reservation;
if (reg_reservation)
var->reg_reservation = *reg_reservation;
return var;
}

View File

@ -223,7 +223,7 @@ struct hlsl_ir_var
const char *name;
struct hlsl_semantic semantic;
unsigned int modifiers;
const struct hlsl_reg_reservation *reg_reservation;
struct hlsl_reg_reservation reg_reservation;
struct list scope_entry, param_entry, extern_entry;
unsigned int first_write, last_read;

View File

@ -33,14 +33,14 @@ struct parse_parameter
struct hlsl_type *type;
const char *name;
struct hlsl_semantic semantic;
const struct hlsl_reg_reservation *reg_reservation;
struct hlsl_reg_reservation reg_reservation;
unsigned int modifiers;
};
struct parse_colon_attribute
{
struct hlsl_semantic semantic;
struct hlsl_reg_reservation *reg_reservation;
struct hlsl_reg_reservation reg_reservation;
};
struct parse_initializer
@ -64,7 +64,7 @@ struct parse_variable_def
char *name;
struct parse_array_sizes arrays;
struct hlsl_semantic semantic;
struct hlsl_reg_reservation *reg_reservation;
struct hlsl_reg_reservation reg_reservation;
struct parse_initializer initializer;
};
@ -767,7 +767,7 @@ static bool add_func_parameter(struct hlsl_ctx *ctx, struct list *list,
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"Parameter '%s' is declared as both \"out\" and \"uniform\".", param->name);
if (!(var = hlsl_new_var(ctx, param->name, param->type, loc, &param->semantic, param->modifiers, param->reg_reservation)))
if (!(var = hlsl_new_var(ctx, param->name, param->type, loc, &param->semantic, param->modifiers, &param->reg_reservation)))
return false;
var->is_param = 1;
@ -780,22 +780,17 @@ static bool add_func_parameter(struct hlsl_ctx *ctx, struct list *list,
return true;
}
static struct hlsl_reg_reservation *parse_reg_reservation(struct hlsl_ctx *ctx, const char *reg_string)
static struct hlsl_reg_reservation parse_reg_reservation(const char *reg_string)
{
struct hlsl_reg_reservation *reg_res;
DWORD regnum = 0;
struct hlsl_reg_reservation reservation = {0};
if (!sscanf(reg_string + 1, "%u", &regnum))
if (!sscanf(reg_string + 1, "%u", &reservation.regnum))
{
FIXME("Unsupported register reservation syntax.\n");
return NULL;
return reservation;
}
if (!(reg_res = hlsl_alloc(ctx, sizeof(*reg_res))))
return NULL;
reg_res->type = reg_string[0];
reg_res->regnum = regnum;
return reg_res;
reservation.type = reg_string[0];
return reservation;
}
static const struct hlsl_ir_function_decl *get_overloaded_func(struct rb_tree *funcs, char *name,
@ -1354,7 +1349,6 @@ static void free_parse_variable_def(struct parse_variable_def *v)
vkd3d_free(v->arrays.sizes);
vkd3d_free(v->name);
vkd3d_free((void *)v->semantic.name);
vkd3d_free(v->reg_reservation);
vkd3d_free(v);
}
@ -1393,7 +1387,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
if (type->type != HLSL_CLASS_MATRIX)
check_invalid_matrix_modifiers(ctx, modifiers, v->loc);
if (!(var = hlsl_new_var(ctx, v->name, type, v->loc, &v->semantic, modifiers, v->reg_reservation)))
if (!(var = hlsl_new_var(ctx, v->name, type, v->loc, &v->semantic, modifiers, &v->reg_reservation)))
{
free_parse_variable_def(v);
continue;
@ -1564,7 +1558,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
struct parse_if_body if_body;
enum parse_unary_op unary_op;
enum parse_assign_op assign_op;
struct hlsl_reg_reservation *reg_reservation;
struct hlsl_reg_reservation reg_reservation;
struct parse_colon_attribute colon_attribute;
struct hlsl_semantic semantic;
}
@ -1962,11 +1956,9 @@ func_prototype:
"Semantics are not allowed on void functions.");
}
if ($7.reg_reservation)
{
if ($7.reg_reservation.type)
FIXME("Unexpected register reservation for a function.\n");
vkd3d_free($7.reg_reservation);
}
if (!($$.decl = hlsl_new_func_decl(ctx, $2, $5, &$7.semantic, @3)))
YYABORT;
$$.name = $3;
@ -1999,12 +1991,12 @@ colon_attribute:
%empty
{
$$.semantic.name = NULL;
$$.reg_reservation = NULL;
$$.reg_reservation.type = 0;
}
| semantic
{
$$.semantic = $1;
$$.reg_reservation = NULL;
$$.reg_reservation.type = 0;
}
| register_opt
{
@ -2028,7 +2020,7 @@ semantic:
register_opt:
':' KW_REGISTER '(' any_identifier ')'
{
$$ = parse_reg_reservation(ctx, $4);
$$ = parse_reg_reservation($4);
vkd3d_free($4);
}
| ':' KW_REGISTER '(' any_identifier ',' any_identifier ')'
@ -2036,7 +2028,7 @@ register_opt:
FIXME("Ignoring shader target %s in a register reservation.\n", debugstr_a($4));
vkd3d_free($4);
$$ = parse_reg_reservation(ctx, $6);
$$ = parse_reg_reservation($6);
vkd3d_free($6);
}

View File

@ -35,7 +35,7 @@ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, stru
/* Use the synthetic name for the temp, rather than the uniform, so that we
* can write the uniform name into the shader reflection data. */
if (!(uniform = hlsl_new_var(ctx, temp->name, temp->data_type, temp->loc, NULL, 0, temp->reg_reservation)))
if (!(uniform = hlsl_new_var(ctx, temp->name, temp->data_type, temp->loc, NULL, 0, &temp->reg_reservation)))
return;
list_add_before(&temp->scope_entry, &uniform->scope_entry);
list_add_tail(&ctx->extern_vars, &uniform->extern_entry);