vkd3d-shader/hlsl: Don't count cast to param type on IN as part of OUT var's lhs.

If the parameter is HLSL_STORAGE_IN, we add a cast from the arg to the
param type so that it can enter the function, however this cast should
not be considered part of the lhs on the implicit assignment that happens
if the var is also HLSL_STORAGE_OUT.
This commit is contained in:
Francisco Casas 2025-01-20 14:52:47 -03:00 committed by Henri Verbeet
parent b55fe1950e
commit 0a15ab702f
Notes: Henri Verbeet 2025-01-22 15:04:09 +01:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1350
2 changed files with 16 additions and 17 deletions

View File

@ -3192,20 +3192,19 @@ static struct hlsl_ir_node *add_user_call(struct hlsl_ctx *ctx,
break;
arg = args->args[k];
if (!hlsl_types_are_equal(arg->data_type, param->data_type))
{
struct hlsl_ir_node *cast;
if (!(cast = add_cast(ctx, args->instrs, arg, param->data_type, &arg->loc)))
return NULL;
args->args[k] = cast;
arg = cast;
}
if (param->storage_modifiers & HLSL_STORAGE_IN)
{
struct hlsl_ir_node *store;
if (!hlsl_types_are_equal(arg->data_type, param->data_type))
{
struct hlsl_ir_node *cast;
if (!(cast = add_cast(ctx, args->instrs, arg, param->data_type, &arg->loc)))
return NULL;
arg = cast;
}
if (!(store = hlsl_new_simple_store(ctx, param, arg)))
return NULL;
hlsl_block_add_instr(args->instrs, store);

View File

@ -1,6 +1,6 @@
% Test implicit and explicit casts on function output parameters.
[pixel shader todo(sm>=4)]
[pixel shader]
uniform float4 f;
@ -18,7 +18,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 -1.9 -1.0 2.9 4.0
todo(sm>=4 & sm<6) draw quad
draw quad
probe (0, 0) rgba (-1.0, -1.0, 2.0, 4.0)
% As above, but cast "x" to float4 first.
@ -67,10 +67,10 @@ float4 main() : sv_target
[test]
uniform 0 float4 -1.9 -1.0 2.9 4.0
todo(sm>=4) draw quad
todo(sm<4) probe (0, 0) rgba (-1.0, -1.0, 2.0, 4.0)
probe (0, 0) rgba (-1.0, -1.0, 2.0, 4.0)
[pixel shader todo(sm>=4)]
[pixel shader]
uniform int4 i;
void func(inout float4 a)
@ -88,7 +88,7 @@ float4 main() : sv_target
[test]
if(sm<4) uniform 0 float4 -2 0 1 -3000000
if(sm>=4) uniform 0 int4 -2 0 1 -3000000
todo(sm>=4 & sm<6) draw quad
draw quad
probe (0, 0) rgba (-1.0, 0.0, 1.0, -3000000.0) 4
@ -109,10 +109,10 @@ float4 main() : sv_target
[test]
todo(sm>=4) draw quad
todo probe (0, 0) rgba(1, 2, 3, 4)
probe (0, 0) rgba(1, 2, 3, 4)
[pixel shader todo fail]
[pixel shader fail]
void fun(out float2 f)
{
f = float2(1, 2);