diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 4b3ca8c9..3b5915a1 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1235,8 +1235,20 @@ static bool parse_reservation_index(struct hlsl_ctx *ctx, const char *string, un reservation->reg_index = strtoul(string + 1, &endptr, 10) + bracket_offset; - if (endptr == string + 1) - return false; + if (*endptr) + { + /* fxc for SM >= 4 treats all parse failures for 'b' types as successes, + * setting index to -1. It will later fail while validating slot limits. */ + if (reservation->reg_type == 'b' && hlsl_version_ge(ctx, 4, 0)) + { + reservation->reg_index = -1; + return true; + } + + /* All other types tolerate leftover characters. */ + if (endptr == string + 1) + return false; + } return true; } diff --git a/tests/hlsl/register-reservations-numeric.shader_test b/tests/hlsl/register-reservations-numeric.shader_test index a6d7e087..f5cb5f24 100644 --- a/tests/hlsl/register-reservations-numeric.shader_test +++ b/tests/hlsl/register-reservations-numeric.shader_test @@ -377,7 +377,7 @@ probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0) % Weird FXC behavior. % SM4 accepts anything for 'b' reservations and discards it silently for global numeric variables. -[pixel shader fail(sm<4 | sm>=6) todo(sm>=4)] +[pixel shader fail(sm<4 | sm>=6)] float a : register(banana); float4 main() : sv_target @@ -387,7 +387,7 @@ float4 main() : sv_target [test] uniform 0 float 1.0 -todo(glsl | sm>=4 | sm<6) draw quad +todo(glsl) draw quad probe (0, 0) rgba(1.0, 1.0, 1.0, 1.0) % Testing other reservation types. This is a parse failure, i.e "X3530: register sa not valid" @@ -451,7 +451,7 @@ float4 main() : sv_target % DXC fails during parsing. -[pixel shader fail] +[pixel shader fail todo] cbuffer buf : register(banana) { float a;