Commit Graph

138 Commits

Author SHA1 Message Date
Zebediah Figura
03f9d16047 vkd3d-shader/hlsl: Parse UAV stores. 2022-10-31 22:07:44 +01:00
Zebediah Figura
0ef04659c7 vkd3d-shader/hlsl: Parse UAV types. 2022-10-19 21:59:55 +02:00
Zebediah Figura
20fc4375ad vkd3d-shader/hlsl: Introduce a hlsl_new_expr() helper. 2022-10-12 21:58:01 +02:00
Zebediah Figura
2d4d2e1244 vkd3d-shader/hlsl: Parse the asuint() intrinsic. 2022-10-12 21:57:57 +02:00
Zebediah Figura
3fc2fdc37f vkd3d-shader/hlsl: Introduce a hlsl_new_bool_constant() helper. 2022-09-28 19:11:02 +02:00
Zebediah Figura
4c5fd9c7b9 vkd3d-shader/hlsl: Introduce a hlsl_new_float_constant() helper. 2022-09-28 19:10:58 +02:00
Zebediah Figura
15a0b44ada vkd3d-shader/hlsl: Pass the arguments to hlsl_new_resource_load() as an indirect structure.
The function has far too many arguments, including multiple different arguments
with the same type. Use a structure for clarity and to avoid errors.

Merge hlsl_new_sample_lod() into hlsl_new_resource_load() accordingly.
2022-09-27 20:14:54 +02:00
Zebediah Figura
fb724d60e3 vkd3d-shader/hlsl: Make the source parameter to hlsl_copy_deref() const. 2022-09-27 20:14:53 +02:00
Zebediah Figura
e3123f5bd0 vkd3d-shader/hlsl: Pass only a template string to hlsl_new_synthetic_var().
Synthesize the internal name from the template inside of this function.
2022-09-27 20:14:51 +02:00
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
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
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
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
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
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
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
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
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
Francisco Casas
246ff14511 vkd3d-shader/hlsl: Support all complex initalizers.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
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-04-27 21:45:41 +02:00
Giovanni Mascellani
d9dc79de66 vkd3d-shader/hlsl: Store boolean constants as unsigned.
With this change it is possible to store booleans as 0xffffffff,
similarly as what happens at runtime.

Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-05 17:51:07 +02:00
Giovanni Mascellani
5b24f7a06c vkd3d-shader/hlsl: Add a helper to create constants of arbitrary type.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-05 17:51:07 +02:00
Giovanni Mascellani
39bd9b0943 vkd3d-shader/hlsl: Pass a pointer to the location to hlsl_new_*_constant().
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-05 17:51:07 +02:00
Zebediah Figura
6e966bcf23 vkd3d-shader/hlsl: Allow "nointerpolation" to be specified on struct fields.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-05 17:50:19 +02:00
Giovanni Mascellani
84059d61c3 vkd3d-shader/hlsl: Allow offsets for scalar and vector variables.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-18 22:20:36 +01:00
Zebediah Figura
ee764359d0 vkd3d-shader/hlsl: Correctly calculate offsets for array elements.
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-18 22:20:32 +01:00
Henri Verbeet
f5c4c06090 vkd3d-shader/hlsl: Respect the requested target type.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-28 22:23:13 +01:00
Zebediah Figura
7f166c4da4 vkd3d-shader/hlsl: Return false from hlsl_offset_from_deref() if the offset falls out of bounds.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-24 18:39:11 +01:00
Francisco Casas
812123ffbf vkd3d-shader/hlsl: Move fold_constants() to a separate file.
Also rename it to hlsl_fold_constants().

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: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-17 21:19:04 +01:00
Francisco Casas
7b687751cc vkd3d-shader/hlsl: Move replace_node() to hlsl.c.
Also rename it to hlsl_replace_node().

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-17 21:19:00 +01:00
Francisco Casas
68b9422470 vkd3d-shader/hlsl: Handle additional dimension types for textures.
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: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-09 18:45:33 +01:00
Francisco Casas
ce2454db6d vkd3d-shader/hlsl: Move sampler_dim_count() to hlsl.h.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-09 18:45:29 +01:00
Nikolay Sivov
4e36c1825d vkd3d-shader/hlsl: Implement floor().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-02 21:06:19 +01:00
Francisco Casas
6de080088a vkd3d-shader/hlsl: Implement texture gather methods.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-26 18:36:26 +01:00
Francisco Casas
2570967aab vkd3d-shader/hlsl: Add texel_offset field to hlsl_ir_resource_load.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-26 18:36:20 +01:00
Giovanni Mascellani
2d619f3d52 vkd3d-shader/hlsl: Remove HLSL_OP2_GREATER and HLSL_OP2_LEQUAL.
They are replaced with HLSL_OP2_LESS and HLSL_OP2_GEQUAL after swapping
the parameters.

Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-19 22:47:13 +01:00
Giovanni Mascellani
0e45838370 vkd3d-shader/hlsl: Make pre/post decrement generate a signed one.
If a float expression is pre/post decremented and an unsigned one is
used to execute it, the unsigned one is first negated (becoming 2^32-1)
and then casted to float (becoming 2^32), which leads to an incorrect
result.

Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-16 11:41:56 +01:00
Zebediah Figura
3ad8609247 vkd3d-shader/hlsl: Pass a vkd3d_shader_location pointer to the intrinsic handler callback.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-16 11:41:49 +01:00
Zebediah Figura
943bd2fede vkd3d-shader/hlsl: Pass a vkd3d_shader_location pointer to message reporting functions.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-16 11:41:45 +01:00
Giovanni Mascellani
5c1c9cba7a vkd3d-shader/hlsl: Introduce a copy propagation pass.
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-16 11:41:09 +01:00
Francisco Casas
3dad54845e vkd3d-shader/hlsl: Implement round() intrinsic function in SM4.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-22 16:24:56 +01:00
Francisco Casas
a32f89c714 vkd3d-shader/hlsl: Explicitly specify the swizzle type for sm4 source registers.
Some register types do not use a consistent swizzle type, so the
sm4_swizzle_type() function is removed.

The swizzle type now must be specified using the swizzle_type field.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-19 15:21:26 +01:00
Giovanni Mascellani
b266133a8c vkd3d-shader/hlsl: Allow failure in hlsl_offset_from_deref.
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: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-19 15:20:44 +01:00
Zebediah Figura
d76d777876 vkd3d-shader/hlsl: Parse the Sample() method.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-08 11:44:30 +01:00