[PATCH vkd3d v2 2/9] vkd3d-shader/hlsl: Check types when folding constants.
Giovanni Mascellani
gmascellani at codeweavers.com
Tue Mar 29 04:47:43 CDT 2022
Hi,
Il 28/03/22 20:35, Zebediah Figura ha scritto:
> We currently can't construct HLSL_IR_CONSTANT nodes that aren't vectors
> anyway, though (as evidenced by patch 6/9). Is there a real situation,
> now or in the future, where we might need this?
WRT the check on the arguments, as you say no HLSL_IR_CONSTANT object
should ever be of type > VECTOR, which is why the check is an assert().
Any assert() is strictly speaking not necessary, but they are useful for
making the code easier to read.
As for the check on the result type, let us consider the expression
"(float1x4)float4(1.0, 2.0, 3.0, 4.0)". Unless I am missing something
(and supposing that the compiler was able to see "float4(1.0, 2.0, 3.0,
4.0)" as a constant), hlsl_fold_constants() would see that it is an
expression with constant operands, and would try to create an
HLSL_IR_CONSTANT to accommodate the result, without realizing that it is
a matrix type. This would introduce an inconsistency. So I think it is
appropriate to have one additional check.
I guess in the long run this problem would go away because eventually
all matrix types will have been lowered before we go through constant
folding, but we're not still there.
Giovanni.
More information about the wine-devel
mailing list