mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Allow "nointerpolation" to be specified on struct fields.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com> Signed-off-by: Francisco Casas <fcasas@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
428a6b4033
commit
6e966bcf23
@ -152,6 +152,7 @@ struct hlsl_struct_field
|
||||
struct hlsl_type *type;
|
||||
const char *name;
|
||||
struct hlsl_semantic semantic;
|
||||
unsigned int modifiers;
|
||||
unsigned int reg_offset;
|
||||
|
||||
size_t name_bytecode_offset;
|
||||
|
@ -677,7 +677,8 @@ static void free_parse_variable_def(struct parse_variable_def *v)
|
||||
vkd3d_free(v);
|
||||
}
|
||||
|
||||
static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *type, struct list *fields)
|
||||
static struct list *gen_struct_fields(struct hlsl_ctx *ctx,
|
||||
struct hlsl_type *type, unsigned int modifiers, struct list *fields)
|
||||
{
|
||||
struct parse_variable_def *v, *v_next;
|
||||
struct hlsl_struct_field *field;
|
||||
@ -705,6 +706,7 @@ static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *ty
|
||||
field->loc = v->loc;
|
||||
field->name = v->name;
|
||||
field->semantic = v->semantic;
|
||||
field->modifiers = modifiers;
|
||||
if (v->initializer.args_count)
|
||||
{
|
||||
hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Illegal initializer on a struct field.");
|
||||
@ -2657,7 +2659,7 @@ field:
|
||||
|
||||
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1)))
|
||||
YYABORT;
|
||||
if (modifiers)
|
||||
if (modifiers & ~HLSL_STORAGE_NOINTERPOLATION)
|
||||
{
|
||||
struct vkd3d_string_buffer *string;
|
||||
|
||||
@ -2666,7 +2668,7 @@ field:
|
||||
"Modifiers '%s' are not allowed on struct fields.", string->buffer);
|
||||
hlsl_release_string_buffer(ctx, string);
|
||||
}
|
||||
$$ = gen_struct_fields(ctx, type, $3);
|
||||
$$ = gen_struct_fields(ctx, type, modifiers, $3);
|
||||
}
|
||||
|
||||
func_declaration:
|
||||
|
@ -59,7 +59,7 @@ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, stru
|
||||
}
|
||||
|
||||
static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_var *var,
|
||||
struct hlsl_type *type, unsigned int field_offset, const struct hlsl_semantic *semantic)
|
||||
struct hlsl_type *type, unsigned int field_offset, unsigned int modifiers, const struct hlsl_semantic *semantic)
|
||||
{
|
||||
struct vkd3d_string_buffer *name;
|
||||
struct hlsl_semantic new_semantic;
|
||||
@ -78,7 +78,7 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct
|
||||
}
|
||||
new_semantic.index = semantic->index;
|
||||
if (!(input = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer),
|
||||
type, var->loc, &new_semantic, var->modifiers, NULL)))
|
||||
type, var->loc, &new_semantic, modifiers, NULL)))
|
||||
{
|
||||
hlsl_release_string_buffer(ctx, name);
|
||||
vkd3d_free((void *)new_semantic.name);
|
||||
@ -113,7 +113,8 @@ static void prepend_input_struct_copy(struct hlsl_ctx *ctx, struct list *instrs,
|
||||
if (field->type->type == HLSL_CLASS_STRUCT)
|
||||
prepend_input_struct_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset);
|
||||
else if (field->semantic.name)
|
||||
prepend_input_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset, &field->semantic);
|
||||
prepend_input_copy(ctx, instrs, var, field->type,
|
||||
field_offset + field->reg_offset, field->modifiers, &field->semantic);
|
||||
else
|
||||
hlsl_error(ctx, &field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC,
|
||||
"Field '%s' is missing a semantic.", field->name);
|
||||
@ -127,11 +128,11 @@ static void prepend_input_var_copy(struct hlsl_ctx *ctx, struct list *instrs, st
|
||||
if (var->data_type->type == HLSL_CLASS_STRUCT)
|
||||
prepend_input_struct_copy(ctx, instrs, var, var->data_type, 0);
|
||||
else if (var->semantic.name)
|
||||
prepend_input_copy(ctx, instrs, var, var->data_type, 0, &var->semantic);
|
||||
prepend_input_copy(ctx, instrs, var, var->data_type, 0, var->modifiers, &var->semantic);
|
||||
}
|
||||
|
||||
static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_var *var,
|
||||
struct hlsl_type *type, unsigned int field_offset, const struct hlsl_semantic *semantic)
|
||||
struct hlsl_type *type, unsigned int field_offset, unsigned int modifiers, const struct hlsl_semantic *semantic)
|
||||
{
|
||||
struct vkd3d_string_buffer *name;
|
||||
struct hlsl_semantic new_semantic;
|
||||
@ -150,7 +151,7 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct
|
||||
}
|
||||
new_semantic.index = semantic->index;
|
||||
if (!(output = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer),
|
||||
type, var->loc, &new_semantic, var->modifiers, NULL)))
|
||||
type, var->loc, &new_semantic, modifiers, NULL)))
|
||||
{
|
||||
vkd3d_free((void *)new_semantic.name);
|
||||
hlsl_release_string_buffer(ctx, name);
|
||||
@ -185,7 +186,8 @@ static void append_output_struct_copy(struct hlsl_ctx *ctx, struct list *instrs,
|
||||
if (field->type->type == HLSL_CLASS_STRUCT)
|
||||
append_output_struct_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset);
|
||||
else if (field->semantic.name)
|
||||
append_output_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset, &field->semantic);
|
||||
append_output_copy(ctx, instrs, var, field->type,
|
||||
field_offset + field->reg_offset, field->modifiers, &field->semantic);
|
||||
else
|
||||
hlsl_error(ctx, &field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC,
|
||||
"Field '%s' is missing a semantic.", field->name);
|
||||
@ -200,7 +202,7 @@ static void append_output_var_copy(struct hlsl_ctx *ctx, struct list *instrs, st
|
||||
if (var->data_type->type == HLSL_CLASS_STRUCT)
|
||||
append_output_struct_copy(ctx, instrs, var, var->data_type, 0);
|
||||
else if (var->semantic.name)
|
||||
append_output_copy(ctx, instrs, var, var->data_type, 0, &var->semantic);
|
||||
append_output_copy(ctx, instrs, var, var->data_type, 0, var->modifiers, &var->semantic);
|
||||
}
|
||||
|
||||
static bool transform_ir(struct hlsl_ctx *ctx, bool (*func)(struct hlsl_ctx *ctx, struct hlsl_ir_node *, void *),
|
||||
|
Loading…
x
Reference in New Issue
Block a user