vkd3d-shader/hlsl: Do not immediately fail parsing for malformed 'b' register reservations.

This is a fxc quirk. In most cases, this throws an error, but for global
variables it's completely ignored.
This commit is contained in:
Victor Chiletto 2024-07-03 14:05:58 -03:00
parent b5b3c8b9ff
commit 27414ef928
Notes: Henri Verbeet 2024-07-08 18:04:49 +02:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/792
2 changed files with 17 additions and 5 deletions

View File

@ -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; reservation->reg_index = strtoul(string + 1, &endptr, 10) + bracket_offset;
if (endptr == string + 1) if (*endptr)
return false; {
/* 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; return true;
} }

View File

@ -377,7 +377,7 @@ probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0)
% Weird FXC behavior. % Weird FXC behavior.
% SM4 accepts anything for 'b' reservations and discards it silently for global numeric variables. % 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); float a : register(banana);
float4 main() : sv_target float4 main() : sv_target
@ -387,7 +387,7 @@ float4 main() : sv_target
[test] [test]
uniform 0 float 1.0 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) 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" % 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. % DXC fails during parsing.
[pixel shader fail] [pixel shader fail todo]
cbuffer buf : register(banana) cbuffer buf : register(banana)
{ {
float a; float a;