[PATCH vkd3d 5/6] vkd3d-shader/hlsl: Allow "nointerpolation" to be specified on struct fields.
Zebediah Figura
zfigura at codeweavers.com
Tue Mar 22 16:59:14 CDT 2022
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
libs/vkd3d-shader/hlsl.h | 1 +
libs/vkd3d-shader/hlsl.y | 8 +++++---
libs/vkd3d-shader/hlsl_codegen.c | 18 ++++++++++--------
3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
index 59aca8fc2..fe702bdb9 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -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;
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 920bb520c..77490c110 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -667,7 +667,8 @@ static struct hlsl_type *apply_type_modifiers(struct hlsl_ctx *ctx, struct hlsl_
return new_type;
}
-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;
@@ -694,6 +695,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.");
@@ -2636,7 +2638,7 @@ field:
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1)))
YYABORT;
- if (modifiers)
+ if (modifiers & ~HLSL_STORAGE_NOINTERPOLATION)
{
struct vkd3d_string_buffer *string;
@@ -2645,7 +2647,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:
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c
index a6a574a70..b6a8e393f 100644
--- a/libs/vkd3d-shader/hlsl_codegen.c
+++ b/libs/vkd3d-shader/hlsl_codegen.c
@@ -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 *),
--
2.35.1
More information about the wine-devel
mailing list