Zebediah Figura : vkd3d-shader: Forbid storage modifiers on struct fields.

Alexandre Julliard julliard at winehq.org
Wed Mar 24 16:06:51 CDT 2021


Module: vkd3d
Branch: master
Commit: e285fc57d2a86d982dc375f47699d08f303b04ac
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=e285fc57d2a86d982dc375f47699d08f303b04ac

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Mon Mar 22 17:02:35 2021 -0500

vkd3d-shader: Forbid storage modifiers on struct fields.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 libs/vkd3d-shader/hlsl.c |  1 -
 libs/vkd3d-shader/hlsl.h |  1 -
 libs/vkd3d-shader/hlsl.y | 15 +++++++++++----
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
index 85859ad..4526348 100644
--- a/libs/vkd3d-shader/hlsl.c
+++ b/libs/vkd3d-shader/hlsl.c
@@ -340,7 +340,6 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old, u
                 field->name = vkd3d_strdup(old_field->name);
                 if (old_field->semantic)
                     field->semantic = vkd3d_strdup(old_field->semantic);
-                field->modifiers = old_field->modifiers;
                 field->reg_offset = reg_size;
                 reg_size += field->type->reg_size;
                 list_add_tail(type->e.elements, &field->entry);
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
index 819b882..523d156 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -134,7 +134,6 @@ struct hlsl_struct_field
     struct hlsl_type *type;
     const char *name;
     const char *semantic;
-    DWORD modifiers;
     unsigned int reg_offset;
 };
 
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 45767de..4b0ddea 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -721,8 +721,7 @@ 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,
-        DWORD modifiers, struct list *fields)
+static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *type, struct list *fields)
 {
     struct parse_variable_def *v, *v_next;
     struct hlsl_struct_field *field;
@@ -748,7 +747,6 @@ static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *ty
             field->type = hlsl_new_array_type(ctx, field->type, v->arrays.sizes[i]);
         field->loc = v->loc;
         field->name = v->name;
-        field->modifiers = modifiers;
         field->semantic = v->semantic;
         if (v->initializer.args_count)
         {
@@ -1937,7 +1935,16 @@ field:
 
             if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1)))
                 YYABORT;
-            $$ = gen_struct_fields(ctx, type, modifiers, $3);
+            if (modifiers)
+            {
+                struct vkd3d_string_buffer *string;
+
+                if ((string = hlsl_modifiers_to_string(&ctx->string_buffers, modifiers)))
+                    hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+                            "Modifiers '%s' are not allowed on struct fields.", string->buffer);
+                vkd3d_string_buffer_release(&ctx->string_buffers, string);
+            }
+            $$ = gen_struct_fields(ctx, type, $3);
         }
 
 func_declaration:




More information about the wine-cvs mailing list