diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 0d3003f4..e81da352 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -5537,9 +5537,9 @@ static bool state_block_add_entry(struct hlsl_state_block *state_block, struct h %type any_identifier %type var_identifier +%type stateblock_lhs_identifier %type name_opt - %type parameter %type param_list @@ -6707,6 +6707,22 @@ state_block_start: ctx->in_state_block = 1; } +stateblock_lhs_identifier: + any_identifier + { + $$ = $1; + } + | KW_PIXELSHADER + { + if (!($$ = hlsl_strdup(ctx, "pixelshader"))) + YYABORT; + } + | KW_VERTEXSHADER + { + if (!($$ = hlsl_strdup(ctx, "vertexshader"))) + YYABORT; + } + state_block_index_opt: %empty { @@ -6731,7 +6747,7 @@ state_block: if (!($$ = hlsl_alloc(ctx, sizeof(*$$)))) YYABORT; } - | state_block any_identifier state_block_index_opt '=' complex_initializer ';' + | state_block stateblock_lhs_identifier state_block_index_opt '=' complex_initializer ';' { struct hlsl_state_block_entry *entry; diff --git a/tests/hlsl/state-block-syntax.shader_test b/tests/hlsl/state-block-syntax.shader_test index 5c2d6f9b..fb0e7312 100644 --- a/tests/hlsl/state-block-syntax.shader_test +++ b/tests/hlsl/state-block-syntax.shader_test @@ -442,7 +442,7 @@ float4 main() : sv_target { return 0; } % PixelShader and VertexShader are valid identifiers for the lhs -[pixel shader todo] +[pixel shader] sampler sam { pixelShader = 20;