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;
int32_t i = 0;
if (dst_type->e.numeric.dimx != src->node.data_type->e.numeric.dimx
|| 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)
for (k = 0; k < src->node.data_type->e.numeric.dimx; ++k)
{
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;
}
}
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;
}