On 1/3/22 08:57, Francisco Casas wrote:
On constant folding, first switch on the op type, handling each operation using a function defined on hlsl_constant_ops.c. Each of these operations switches on the data type, if needed.
Since constant value casting had to be rewritten, support was extended to all numeric types.
Signed-off-by: Francisco Casas fcasas@codeweavers.com
I suggest moving the definitions of the operations to this new file since they may end up being considerably large and similar.
I am not sure if I should be on the copyright notice of the new files.
Signed-off-by: Francisco Casas fcasas@codeweavers.com
Makefile.am | 2 +- libs/vkd3d-shader/hlsl_codegen.c | 104 ++++--------- libs/vkd3d-shader/hlsl_constant_ops.c | 209 ++++++++++++++++++++++++++ libs/vkd3d-shader/hlsl_constant_ops.h | 30 ++++ 4 files changed, 268 insertions(+), 77 deletions(-) create mode 100644 libs/vkd3d-shader/hlsl_constant_ops.c create mode 100644 libs/vkd3d-shader/hlsl_constant_ops.h
Giovanni has already said most of what I would say. I would append, though, that this patch does at least three things at once. In general please try to avoid moving code and changing it at the same time. I.e. move hlsl_fold_constants() to a separate file, *then* change the switch order, *then* make cast folding more generic.