Commit Graph

159 Commits

Author SHA1 Message Date
Zebediah Figura
8c2b8ff245 vkd3d-shader/hlsl: Synthesize the swizzle and replace the instruction inside of copy_propagation_compute_replacement().
Rename it to copy_propagation_replace_with_single_instr() accordingly.

The idea is to introduce a constant vector replacement pass which will do the
same thing.
2023-01-24 18:10:41 +01:00
Zebediah Figura
5d34790402 vkd3d-shader/hlsl: Call copy_propagation_get_value() directly in copy_propagation_transform_object_load().
copy_propagation_compute_replacement() is not doing very much for us, and
conceptually is a bit of an odd fit anyway, since it's meant to deal with
multi-component types.
2023-01-24 18:10:40 +01:00
Zebediah Figura
8fd30aa87d vkd3d-shader/hlsl: Add some swizzle manipulation definitions. 2023-01-24 18:10:39 +01:00
Zebediah Figura
9c817e5e6d vkd3d-shader/hlsl: Forbid recursive calls. 2023-01-19 19:16:27 +01:00
Francisco Casas
17d6a4411e vkd3d-shader/hlsl: Validate that non-uniform objects are not referenced.
Note that in the future we should call
validate_static_object_references() after DCE and pruning branches,
because shaders such as these compile (at least in more modern versions
of the native compiler):

Branch pruning:
```
static RWTexture2D<float> tex;

float4 main() : sv_target
{
    if (0)
    {
        tex[int2(0, 0)] = 2;
    }
    return 0;
}
```

DCE:
```
static Texture2D tex;
uniform uint i;

float4 main() : sv_target
{
    float4 unused = tex.Load(int3(0, 1, 2));

    return 0;
}
```

These are "todo" tests in hlsl-static-initializer.shader_test
that depend on this.
2023-01-19 12:29:39 +01:00
Zebediah Figura
b29d3489de vkd3d-shader/hlsl: Generate IR for user-defined function calls. 2023-01-13 17:32:42 +01:00
Zebediah Figura
30550c0831 vkd3d-shader/hlsl: Avoid assuming that expressions have at least one argument. 2023-01-13 17:32:40 +01:00
Francisco Casas
cc811dc3c2 vkd3d-shader/hlsl: Rename hlsl_struct_field.modifiers to "storage_modifiers". 2023-01-11 16:03:47 +01:00
Francisco Casas
4dbbb8beb4 vkd3d-shader/hlsl: Rename hlsl_ir_var.modifiers to "storage_modifiers". 2023-01-11 16:03:45 +01:00
Francisco Casas
f100f5b726 vkd3d-shader/hlsl: Check for non-static object references on resource stores. 2022-11-18 22:29:04 +01:00
Francisco Casas
f21693b284 vkd3d-shader/hlsl: Use reg_size as component count when allocating a single register.
Otherwise, for instance, the added test results in:

debug_hlsl_writemask: Assertion `!(writemask & ~VKD3DSP_WRITEMASK_ALL)' failed.

Which happens in allocate_variable_temp_register() when the variable's
type reg_size is <= 4 but its component count is larger, which may
happen if it contains objects.
2022-11-10 22:48:26 +01:00
Francisco Casas
3153ce3145 vkd3d-shader/hlsl: Don't allocate object types as constant registers. 2022-11-10 22:48:16 +01:00
Zebediah Figura
718c79b823 vkd3d-shader/hlsl: Parse the numthreads attribute. 2022-11-08 20:53:04 +01:00
Zebediah Figura
d6799bd5d3 vkd3d-shader/hlsl: Parse function attributes. 2022-11-08 20:53:03 +01:00
Zebediah Figura
c416627e64 vkd3d-shader/hlsl: Propagate copies for resource store instructions. 2022-10-31 22:07:47 +01:00
Zebediah Figura
03f9d16047 vkd3d-shader/hlsl: Parse UAV stores. 2022-10-31 22:07:44 +01:00
Zebediah Figura
2ec67e0f10 vkd3d-shader/hlsl: Allocate UAVs. 2022-10-31 22:07:40 +01:00
Giovanni Mascellani
0a07ac6f88 vkd3d-shader/hlsl: Lower float modulus.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-10-19 21:59:17 +02:00
Giovanni Mascellani
eb119878f7 vkd3d-shader/hlsl: Lower int modulus.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-10-19 21:59:15 +02:00
Giovanni Mascellani
eb7b594002 vkd3d-shader/hlsl: Lower int division. 2022-10-17 17:58:17 +02:00
Giovanni Mascellani
4c13ae5764 vkd3d-shader/hlsl: Lower int absolute value. 2022-10-17 17:58:14 +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
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
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
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
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
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
Giovanni Mascellani
8cd4995958 vkd3d-shader/hlsl: Allocate enough space for temporary matrices.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
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-06-08 18:51:28 +02:00
Zebediah Figura
ea38ecc4ff vkd3d-shader/hlsl: Split matrices into multiple variables in prepend_input_copy().
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-08 18:51:03 +02:00
Zebediah Figura
d2d4bc24e9 vkd3d-shader/hlsl: Split matrices into multiple variables in append_output_copy().
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-08 18:50:52 +02:00
Giovanni Mascellani
e6ce077ad4 vkd3d-shader/hlsl: Handle loops in copy propagation.
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-05-04 18:32:35 +02:00
Giovanni Mascellani
6167b3a4e2 vkd3d-shader/hlsl: Handle branches in copy propagation.
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-05-02 11:30:21 +02:00
Francisco Casas
a58c0e7c9d vkd3d-shader/hlsl: Detect missing loads on rhs when splitting copies of non-numeric types.
Otherwise we can get failed assertions:
assert(node->type == HLSL_IR_LOAD);
because broadcasts to these types are not implemented yet.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
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-05-02 11:29:54 +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
c5c50a8b9b vkd3d-shader/hlsl: Do not generate useless swizzles.
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:37 +02:00
Giovanni Mascellani
74273ccadd vkd3d-shader/hlsl: Do not handle vector types in major_size() and minor_size().
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-04-25 22:12:55 +02:00
Giovanni Mascellani
d2ba10a696 vkd3d-shader/hlsl: Update split_copy()'s introductory comment.
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: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-25 22:12:39 +02:00
Giovanni Mascellani
e38ee49e99 vkd3d-shader/hlsl: Split matrix copies.
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: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-20 23:02:14 +02:00
Giovanni Mascellani
8c086b5c91 vkd3d-shader/hlsl: Lower casts to bool to comparisons.
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-04-07 18:31:52 +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
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