vkd3d-shader/hlsl: Parse array types in function parameters.

This commit is contained in:
Francisco Casas 2023-01-26 10:13:20 -03:00 committed by Alexandre Julliard
parent 9df54851c9
commit d279d34801
Notes: Alexandre Julliard 2023-02-20 22:45:40 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/99
2 changed files with 36 additions and 10 deletions

View File

@ -4317,10 +4317,11 @@ param_list:
}
parameter:
var_modifiers type_no_void any_identifier colon_attribute
var_modifiers type_no_void any_identifier arrays colon_attribute
{
struct hlsl_type *type;
unsigned int modifiers = $1;
struct hlsl_type *type;
unsigned int i;
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1)))
YYABORT;
@ -4328,10 +4329,21 @@ parameter:
$$.modifiers = modifiers;
if (!($$.modifiers & (HLSL_STORAGE_IN | HLSL_STORAGE_OUT)))
$$.modifiers |= HLSL_STORAGE_IN;
for (i = 0; i < $4.count; ++i)
{
if ($4.sizes[i] == HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT)
{
hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"Implicit size arrays not allowed in function parameters.");
}
type = hlsl_new_array_type(ctx, type, $4.sizes[i]);
}
$$.type = type;
$$.name = $3;
$$.semantic = $4.semantic;
$$.reg_reservation = $4.reg_reservation;
$$.semantic = $5.semantic;
$$.reg_reservation = $5.reg_reservation;
}
texture_type:

View File

@ -1,4 +1,4 @@
[pixel shader todo]
[pixel shader]
float fun(float a[2])
{
return 10 * a[0] + a[1];
@ -12,8 +12,8 @@ float4 main() : sv_target
}
[test]
todo draw quad
todo probe all rgba (25.0, 25.0, 25.0, 25.0)
draw quad
probe all rgba (25.0, 25.0, 25.0, 25.0)
[pixel shader fail]
@ -58,7 +58,7 @@ float4 main() : sv_target
}
[pixel shader todo]
[pixel shader]
float4 fun(float a[2][4])
{
float4 res;
@ -78,8 +78,22 @@ float4 main() : sv_target
}
[test]
todo draw quad
todo probe all rgba (15.0, 26.0, 37.0, 48.0)
draw quad
probe all rgba (15.0, 26.0, 37.0, 48.0)
[pixel shader fail]
float fun(float a[2])
{
return a[2]; // out of bounds.
}
float4 main() : sv_target
{
float f[2] = {1, 2};
return fun(f);
}
[pixel shader fail]