Commit Graph

1322 Commits

Author SHA1 Message Date
Giovanni Mascellani
d5fd309ef8 vkd3d: Add a macro to mark unreachable code.
This should silence warnings about some branches non returning any value
without requiring additional "return 0" statement or similar.

Also, in theory this might enable to compiler to optimize the program
a little bit more, though that's unlikely to have any measurable effect.
2022-09-27 20:14:27 +02:00
Henri Verbeet
56b2f56b86 Release 1.5. 2022-09-21 16:47:49 +02:00
Francisco Casas
8e07423ba1 vkd3d-shader/hlsl: Add offset parameter to 'Load' method.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
609632279f vkd3d-shader/hlsl: Properly check argument count in gather methods. 2022-08-23 15:57:54 -05:00
Francisco Casas
32e6f594f2 vkd3d-shader/hlsl: Properly check argument count in SampleLevel method.
Also, TextureCube and TextureCubeArray don't support the offset
argument, so this check is updated here too.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
15b19b15c0 vkd3d-shader/hlsl: Use proper dimensions on SampleLevel method offset parameter. 2022-08-23 15:57:54 -05:00
Francisco Casas
c4be4a4ebf vkd3d-shader/hlsl: Properly check argument count in Sample method.
Also, TextureCube and TextureCubeArray don't support the offset
argument, so this check is updated.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
562f647c2a vkd3d-shader/hlsl: Use proper dimensions on gather methods offset parameter. 2022-08-23 15:57:54 -05:00
Francisco Casas
652906aea7 vkd3d-shader/hlsl: Use proper dimensions on Sample method offset parameter.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Zebediah Figura
d6f45b730f vkd3d-shader/hlsl: Parse the SampleLevel method. 2022-08-23 15:57:54 -05:00
Francisco Casas
3d9baef321 vkd3d-shader/hlsl: Support initialization of implicit size arrays.
HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT (zero) is used as a temporal value
for elements_count for implicit size arrays.
This value is replaced by the correct one after parsing the initializer.

In case the implicit array is not initialized correctly, hlsl_error()
is called but the array size is kept at 0. So the rest of the code
must handle these cases.

In shader model 5.1, unlike in 5.0, declaring a multi-dimensional
object-type array with the last dimension implicit results in
an error. This happens even in presence of an initializer.

So, both gen_struct_fields() and declare_vars() first check if the
shader model is 5.1, the array elements are objects, and if there is
at least one implicit array size to handle the whole type as an
unbounded resource array.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
96a7236700 vkd3d-shader/hlsl: Set objects' register size back to 0.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
6989266e76 vkd3d-shader/hlsl: Check for non-static object references.
It is responsibility of the shader's programmer to ensure that
object references can be solved statically.

Resource arrays for ps_5_1 and vs_5_1 are an exception which is not
properly handled yet. They probably deserve a different object type.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
1bba18aa75 vkd3d-shader/hlsl: Invalidate components more precisely in copy propagation.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
b5b08bd8a0 vkd3d-shader/hlsl: Replace register offsets with index paths in copy propagation.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
10bd0c48f8 vkd3d-shader/hlsl: Print halfs in dump_ir_constant().
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
a8b77b85ca vkd3d-shader/hlsl: Skip implicit conversion if types are equal.
Otherwise we get false in implicit_compatible_data_types() when passing
types that are equal but not convertible according to
convertible_data_type(); e.g. getting:

"Can't implicitly convert from Texture2D<float4> to Texture2D<float4>."

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
732f1737f4 vkd3d-shader/hlsl: Set component count for objects to 1.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
f3432966da vkd3d-shader/hlsl: Emit a fixme on complex resource load object derefs.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
f843a7babb vkd3d-shader/hlsl: Rename 'inner_type' to 'element_type' in function name.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Martin Storsjö
1c61b20616 vkd3d-shader/spirv: Fix the signature of vkd3d_spirv_build_op_type_image.
Don't assume that enums and uint32_t parameters are identical. Clang
16 changes the diagonstic for incompatible function pointer types
from a warning into an error by default.

This fixes the following error, when built (for aarch64, but probably
also for other architectures) in MSVC mode:

../src/libs/vkd3d/libs/vkd3d-shader/spirv.c:1083:13: error: incompatible function pointer types passing 'uint32_t (struct vkd3d_spirv_builder *, uint32_t, SpvDim, uint32_t, uint32_t, uint32_t, uint32_t, SpvImageFormat)' (aka 'unsigned int (struct vkd3d_spirv_builder *, unsigned int, enum SpvDim_, unsigned int, unsigned int, unsigned int, unsigned int, enum SpvImageFormat_)') to parameter of type 'vkd3d_spirv_build7_pfn' (aka 'unsigned int (*)(struct vkd3d_spirv_builder *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)') [-Wincompatible-function-pointer-types]
            vkd3d_spirv_build_op_type_image);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/libs/vkd3d/libs/vkd3d-shader/spirv.c:612:68: note: passing argument to parameter 'build_pfn' here
        SpvOp op, const uint32_t *operands, vkd3d_spirv_build7_pfn build_pfn)
                                                                   ^

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-08-15 21:59:38 +02:00
Francisco Casas
577014c017 vkd3d-shader/hlsl: Replace register offsets with index paths in split copies.
hlsl_new_store() and hlsl_new_load() are deleted, so now there are no more
direct ways to create derefs with offsets in hlsl.c and hlsl.h.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:34:19 +02:00
Francisco Casas
d7d2fe145f vkd3d-shader/hlsl: Replace register offsets with index paths in input/output copies.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:34:08 +02:00
Francisco Casas
1b69adbd13 vkd3d-shader/hlsl: Add input and output variables using the same function.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:34:05 +02:00
Francisco Casas
c572adbf2a vkd3d-shader/hlsl: Move register offset functions to hlsl_codegen.c.
This can be done now, to ensure that register offsets are no longer used
in hlsl.c and hlsl.h.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:34:01 +02:00
Francisco Casas
349aab2a6a vkd3d-shader/hlsl: Replace register offsets with index paths in resource loads initialization.
At this point, the parse code is free of offsets; it only uses index
paths.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:33:58 +02:00
Francisco Casas
5b664c7a5c vkd3d-shader/hlsl: Introduce hlsl_new_store_index().
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:33:55 +02:00
Francisco Casas
f3289e1661 vkd3d-shader/hlsl: Introduce hlsl_new_store_component().
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:33:51 +02:00
Francisco Casas
7515b8255b vkd3d-shader/hlsl: Print index paths in dump_deref().
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:33:46 +02:00
Francisco Casas
4fede46c9a vkd3d-shader/hlsl: Replace register offsets with index paths in load initializations.
The transform_deref_paths_into_offsets pass turns these index paths back
into register offsets.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:33:37 +02:00
Francisco Casas
2dcfc888fb vkd3d-shader/hlsl: Unify type minor/major size functions.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:33:29 +02:00
Francisco Casas
039b69ace9 vkd3d-shader/hlsl: Introduce add_load_index().
At this point add_load() is split into add_load_component() and
add_load_index(); register offsets are hidden for these functions.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:33:25 +02:00
Francisco Casas
a32157f586 vkd3d-shader/hlsl: Introduce add_load_component().
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:33:19 +02:00
Conor McCarthy
3dbd2ceca6 vkd3d-shader: Introduce a compile option to use Unknown format for typed UAV loads.
Specifying R32 for UAVs created with a vector format, e.g. R32G32B32A32_FLOAT,
results in only the red being loaded/stored, potentially causing images to
contain only the red component.

Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
2022-08-09 22:14:28 +02:00
Stefan Dösinger
aae4e31ba8 vkd3d-shader: Initialize counter_var_info unconditionally. 2022-07-25 21:09:30 +02:00
Francisco Casas
a7a4eb95e5 vkd3d-shader/hlsl: Introduce function to clean up hlsl_derefs.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-07-18 22:07:42 +02:00
Francisco Casas
b9435fb1ff vkd3d-shader/hlsl: Pass field to add_record_load() via index.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-07-18 22:07:33 +02:00
Francisco Casas
300a6c8fc3 vkd3d-shader/hlsl: Handle errors in recursive calls in hlsl_type_clone().
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-07-18 22:07:30 +02:00
Zebediah Figura
e5905bbf0f vkd3d-shader/hlsl: Store the struct fields as an array.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-07-18 22:07:26 +02:00
Giovanni Mascellani
448f856c09 vkd3d-shader/hlsl: Write SM4 logic or instructions.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-07-05 22:43:28 +02:00
Giovanni Mascellani
15e4b9bafb vkd3d-shader/hlsl: Write SM4 logic and instructions.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-07-05 22:43:25 +02:00
Giovanni Mascellani
02d92c9af6 vkd3d-shader/hlsl: Write SM4 logic not instructions.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-07-05 22:43:22 +02:00
Giovanni Mascellani
3e88a46d4c vkd3d-shader/hlsl: Write SM4 casts from bool.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-07-05 22:43:18 +02:00
Giovanni Mascellani
98ebe9b69c vkd3d-shader/hlsl: Fold constant integral bitwise or.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-28 22:20:27 +02:00
Giovanni Mascellani
06c22b6a65 vkd3d-shader/hlsl: Fold constant integral bitwise and.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-28 22:20:24 +02:00
Giovanni Mascellani
4016ddff77 vkd3d-shader/hlsl: Fold constant integral bitwise xor.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-28 22:20:22 +02:00
Giovanni Mascellani
4a692dca4e vkd3d-shader/hlsl: Fold constant integral min().
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-28 22:20:17 +02:00
Giovanni Mascellani
8cb865d65a vkd3d-shader/hlsl: Fold constant integral max().
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-28 22:20:11 +02:00
Zebediah Figura
0ddaa80616 vkd3d-shader/hlsl: Fold constant swizzles.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-28 22:20:08 +02:00
Giovanni Mascellani
7682da58a8 vkd3d-shader/hlsl: Parse lerp() intrinsic.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-27 21:23:33 +02:00