vkd3d-shader/hlsl: Implement broadcasts in constant folding.

Normally lower_broadcasts() takes care of this, but loop unrolling executes before other constant passes.
This commit is contained in:
Elizabeth Figura 2025-01-20 22:18:57 -06:00 committed by Henri Verbeet
parent 9065a1ee23
commit d049ea640f
Notes: Henri Verbeet 2025-01-27 15:04:24 +01:00
Approved-by: Francisco Casas (@fcasas)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1349
2 changed files with 10 additions and 11 deletions

View File

@ -148,15 +148,7 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
float f = 0.0f; float f = 0.0f;
int32_t i = 0; int32_t i = 0;
if (dst_type->e.numeric.dimx != src->node.data_type->e.numeric.dimx for (k = 0; k < src->node.data_type->e.numeric.dimx; ++k)
|| dst_type->e.numeric.dimy != src->node.data_type->e.numeric.dimy)
{
FIXME("Cast from %s to %s.\n", debug_hlsl_type(ctx, src->node.data_type),
debug_hlsl_type(ctx, dst_type));
return false;
}
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{ {
switch (src->node.data_type->e.numeric.type) switch (src->node.data_type->e.numeric.type)
{ {
@ -221,6 +213,13 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
break; break;
} }
} }
if (src->node.data_type->e.numeric.dimx == 1)
{
for (k = 1; k < dst_type->e.numeric.dimx; ++k)
dst->u[k] = dst->u[0];
}
return true; return true;
} }

View File

@ -64,7 +64,7 @@ float4 main() : sv_target
draw quad draw quad
probe (0,0) rgba(1337.0, 0, 0, 0) probe (0,0) rgba(1337.0, 0, 0, 0)
[pixel shader todo(sm<6)] [pixel shader]
float4 main() : sv_target float4 main() : sv_target
{ {
float i = 0; float i = 0;
@ -79,5 +79,5 @@ float4 main() : sv_target
} }
[test] [test]
todo(sm<6) draw quad draw quad
probe (0,0) rgba(0, 0, 0, 0) probe (0,0) rgba(0, 0, 0, 0)