From cd6e8b5540bf278e871dbaaa6f1b750bcdd87bd4 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Mon, 13 Feb 2023 17:38:03 -0600 Subject: [PATCH] vkd3d-shader/hlsl: Allow empty parameter lists to be specified as "(void)". --- libs/vkd3d-shader/hlsl.y | 20 ++++++++++++++------ tests/hlsl-function.shader_test | 4 ++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 3bad2acc..7caba3e0 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -3721,6 +3721,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl %type unnamed_struct_spec %type struct_spec %type type +%type type_no_void %type typedef_type %type type_spec @@ -4233,6 +4234,10 @@ parameters: { memset(&$$, 0, sizeof($$)); } + | scope_start KW_VOID + { + memset(&$$, 0, sizeof($$)); + } | scope_start param_list { $$ = $2; @@ -4260,7 +4265,7 @@ param_list: } parameter: - var_modifiers type any_identifier colon_attribute + var_modifiers type_no_void any_identifier colon_attribute { struct hlsl_type *type; unsigned int modifiers = $1; @@ -4321,7 +4326,7 @@ uav_type: $$ = HLSL_SAMPLER_DIM_3D; } -type: +type_no_void: KW_VECTOR '<' type ',' C_INTEGER '>' { if ($3->type != HLSL_CLASS_SCALAR) @@ -4382,10 +4387,6 @@ type: { $$ = hlsl_get_matrix_type(ctx, HLSL_TYPE_FLOAT, 4, 4); } - | KW_VOID - { - $$ = ctx->builtin_types.Void; - } | KW_SAMPLER { $$ = ctx->builtin_types.sampler[HLSL_SAMPLER_DIM_GENERIC]; @@ -4467,6 +4468,13 @@ type: vkd3d_free($2); } +type: + type_no_void + | KW_VOID + { + $$ = ctx->builtin_types.Void; + } + declaration_statement: declaration | struct_declaration diff --git a/tests/hlsl-function.shader_test b/tests/hlsl-function.shader_test index 80412727..75521d4d 100644 --- a/tests/hlsl-function.shader_test +++ b/tests/hlsl-function.shader_test @@ -149,7 +149,7 @@ void func() { } -[pixel shader todo] +[pixel shader] /* This is something of an internal test: we need to make sure that we use the * correct variables for a function's arguments and returns regardless of @@ -176,7 +176,7 @@ float4 main() : sv_target } [test] -todo draw quad +draw quad todo probe all rgba (0.1, 0.2, 0.3, 0.4) [pixel shader]