From 50254c284b7597202f84cf65e668379a56f04f14 Mon Sep 17 00:00:00 2001 From: "Anna (navi) Figueiredo Gomes" Date: Thu, 27 Feb 2025 16:04:30 +0100 Subject: [PATCH] vkd3d-shader: Parse angle bracket initializer in state blocks. While fxc allows full expressions inside the angle brackets, we don't parse that yet as it'd be quite a mess to properly do so with yacc, and I'm not aware of any game doing so in their shaders. --- libs/vkd3d-shader/hlsl.y | 20 ++++++++++++++++++++ tests/hlsl/state-block-syntax.shader_test | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index a862429b..f4186967 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -8639,6 +8639,26 @@ state_block: hlsl_src_from_node(&entry->args[i], $5.args[i]); vkd3d_free($5.args); + $$ = $1; + hlsl_state_block_add_entry($$, entry); + } + | state_block stateblock_lhs_identifier state_block_index_opt '=' '<' primary_expr '>' ';' + { + struct hlsl_state_block_entry *entry; + + if (!(entry = hlsl_alloc(ctx, sizeof(*entry)))) + YYABORT; + + entry->name = $2; + entry->lhs_has_index = $3.has_index; + entry->lhs_index = $3.index; + + entry->instrs = $6; + entry->args_count = 1; + if (!(entry->args = hlsl_alloc(ctx, sizeof(*entry->args) * entry->args_count))) + YYABORT; + hlsl_src_from_node(&entry->args[0], node_from_block($6)); + $$ = $1; hlsl_state_block_add_entry($$, entry); } diff --git a/tests/hlsl/state-block-syntax.shader_test b/tests/hlsl/state-block-syntax.shader_test index 5764bedd..1fb0277c 100644 --- a/tests/hlsl/state-block-syntax.shader_test +++ b/tests/hlsl/state-block-syntax.shader_test @@ -653,7 +653,7 @@ DepthStencilState dss1 RandomField = vec.w; }; -[pixel shader todo] +[pixel shader] sampler sams { Filter = ;