Commit Graph

3702 Commits

Author SHA1 Message Date
Nikolay Sivov
7d41cf4440 vkd3d-shader/hlsl: Partially implement static expressions evaluation. 2023-05-02 20:46:08 +02:00
Zebediah Figura
6de904b448 vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_resource_store(). 2023-05-02 20:46:03 +02:00
Zebediah Figura
3cc18f1e9f vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_resource_load(). 2023-05-02 20:46:02 +02:00
Zebediah Figura
8485b2ee95 vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_loop(). 2023-05-02 20:46:00 +02:00
Zebediah Figura
3ca9656e84 vkd3d-shader/hlsl: Pass an hlsl_block pointer to hlsl_new_loop(). 2023-05-02 20:45:59 +02:00
Zebediah Figura
e848c57b46 vkd3d-shader/hlsl: Reuse the "init" instruction list if possible in create_loop(). 2023-05-02 20:45:57 +02:00
Henri Verbeet
3f8aa0e272 vkd3d-shader/d3d-asm: Rename trace.c to d3d_asm.c. 2023-05-02 20:45:33 +02:00
Henri Verbeet
73dc62aebf vkd3d-shader: Get rid of the unused vkd3d_shader_src_param_entry structure. 2023-05-02 20:45:27 +02:00
Francisco Casas
abb207fab0 vkd3d-shader/hlsl: Always specify resource on intrinsic_tex().
Otherwise, in the added test, we get:

vkd3d-compiler: vkd3d-shader/hlsl.c:452: hlsl_init_deref_from_index_chain: Assertion `chain' failed.

because on the path that triggers the following error:

E5002: Wrong type for argument 1 of 'tex3D': expected 'sampler' or 'sampler3D', but got 'sampler2D'.

a NULL params.resource is passed to hlsl_new_resource_load() and
then to hlsl_init_deref_from_index_chain().
2023-05-01 22:18:46 +02:00
Ethan Lee
5d735f3b0e vkd3d-shader/hlsl: Add support for sign() intrinsic.
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
2023-05-01 22:18:41 +02:00
Ethan Lee
109f7094bc tests: Add tests for sign() intrinsic.
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
2023-05-01 22:18:41 +02:00
Zebediah Figura
6e677def71 vkd3d-shader/hlsl: Normalize bools when loading from uniforms or vertex input. 2023-05-01 22:18:36 +02:00
Zebediah Figura
834497d5ac vkd3d-shader/hlsl: Introduce an sm4_src_from_constant_value() helper. 2023-05-01 22:18:35 +02:00
Zebediah Figura
0a44e6043e vkd3d-shader/hlsl: Put the hlsl_ir_constant value in a structure. 2023-05-01 22:18:33 +02:00
Zebediah Figura
3cce4e70e9 tests: Test bool semantics. 2023-05-01 22:18:33 +02:00
Zebediah Figura
8b4e70dfee tests: Test casting from a bool uniform. 2023-05-01 22:18:33 +02:00
Francisco Casas
dcd991deda vkd3d-shader/hlsl: Consider duplicated input semantic types equivalent in SM1. 2023-05-01 22:18:27 +02:00
Francisco Casas
34431239a5 vkd3d-shader/hlsl: Handle possibly different types in input semantic var load.
Since in SM1 all vector types use 4 register components, and since SM1
doesn't consider vectors of different dimx incompatible, it is necessary
to ensure that the semantic var is created with dimx=4, and to add a
cast node.
2023-05-01 22:18:26 +02:00
Francisco Casas
537d7c27a2 vkd3d-shader/hlsl: Error out when a semantic is used with incompatible types.
Considering row vectors from row_major matrices as having a different
layout as regular vectors, and error out in that case, is left as todo.
2023-05-01 22:18:24 +02:00
Francisco Casas
d96e9665b1 vkd3d-shader/hlsl: Error out when an output semantic is used more than once.
The use of the hlsl_semantic.reported_duplicated_output_next_index field
allows reporting multiple overlapping indexes, such as in the following
vertex shader:

    void main(out float1x3 x : OVERLAP0, out float1x3 y : OVERLAP1)
    {
        x = float3(1.0, 2.0, 3.2);
        y = float3(5.0, 6.0, 5.0);
    }

    apple.hlsl:1:41: E5013: Output semantic "OVERLAP1" is used multiple times.
    apple.hlsl:1:13: First use of "OVERLAP1" is here.
    apple.hlsl:1:41: E5013: Output semantic "OVERLAP2" is used multiple times.
    apple.hlsl:1:13: First use of "OVERLAP2" is here.

While at the same time avoiding reporting overlaps more than once for
large arrays:

    struct apple
    {
        float2 p : sv_position;
    };

    void main(out apple aps[4])
    {
    }

    apple.hlsl:3:8: E5013: Output semantic "sv_position0" is used multiple times.
    apple.hlsl:3:8: First use of "sv_position0" is here.
2023-05-01 22:18:22 +02:00
Francisco Casas
edc72fdefc vkd3d-shader/hlsl: Support semantics for array types. 2023-05-01 22:18:21 +02:00
Francisco Casas
a488889494 vkd3d-shader/hlsl: Don't create semantic vars more than once. 2023-05-01 22:18:20 +02:00
Francisco Casas
b589c2b32d vkd3d-shader/hlsl: Move get_array_size() and get_array_type() to hlsl.c. 2023-05-01 22:18:19 +02:00
Francisco Casas
d5068fd3ff tests: Test duplicated semantics. 2023-05-01 22:18:19 +02:00
Francisco Casas
f1276f9fb9 tests: Test array types with semantics. 2023-05-01 22:18:19 +02:00
Francisco Casas
61c72a4fd1 vkd3d-shader/hlsl: Avoid invalid input/output copies for non-numeric types. 2023-05-01 22:18:17 +02:00
Francisco Casas
627678a632 tests: Map unindentified hrs on compilation. 2023-05-01 22:18:17 +02:00
Francisco Casas
9cc1c7fe9d tests: Allow invalid vertex shader tests. 2023-05-01 22:18:17 +02:00
Francisco Casas
877fd3f0b4 tests: Expect S_OK result on [vertex shader]. 2023-05-01 22:18:16 +02:00
Nikolay Sivov
7ba373946b vkd3d-shader/hlsl: Implement D3DCOLORtoUBYTE4() function. 2023-04-28 21:04:13 +02:00
Nikolay Sivov
4b3707aeb4 vkd3d-shader/hlsl: Partially implement trunc().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-28 21:04:11 +02:00
Conor McCarthy
5366ca7001 vkd3d: Synchronise concurrent descriptor heap binding by multiple command lists.
It is possible for multiple command lists to use the same heap, and
submit it simultaneously to multiple d3d12 queues.
2023-04-28 21:04:02 +02:00
Conor McCarthy
fa63da6030 vkd3d: Track all descriptor heaps bound during command list recording and flush their writes.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54895
2023-04-28 21:04:02 +02:00
Ethan Lee
d3876e49bc tests: Add tests for ddx(), ddy() intrinsics.
Thanks to Giovanni for the second set of tests! Note that the
tolerance for the final pixel was set much higher than the others;
this test seems to be an issue for some devices (in my case, a 7900
XTX running RADV).

Co-authored-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
2023-04-28 21:03:43 +02:00
Ethan Lee
138c32ce88 vkd3d-shader/hlsl: Add support for ddx(), ddy() intrinsics.
SPIR-V already handled DSX/DSY, so only D3DBC/TPF needed new case blocks.

Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
2023-04-28 21:03:40 +02:00
Nikolay Sivov
af4bb03795 vkd3d-shader/hlsl: Implement SampleBias() method.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-26 22:46:55 +02:00
Nikolay Sivov
c166ab9727 vkd3d-shader/hlsl: Add separate helpers to generate object methods.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-26 22:46:53 +02:00
Nikolay Sivov
4fe4784e8a tests: Add a simple test for "discard".
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-26 22:46:52 +02:00
Ethan Lee
e541e71532 tests: Remove rtv clears in Vulkan runner.
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-26 22:46:52 +02:00
Nikolay Sivov
c74d148cbe tests: Remove rtv clears in d3d12 runner.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-26 22:46:52 +02:00
Nikolay Sivov
59c63ec584 vkd3d-shader/hlsl: Handle discard statement.
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-26 22:46:50 +02:00
Nikolay Sivov
6da7d16d4c vkd3d-shader/trace: Add separate id for discard.
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
2023-04-26 22:46:49 +02:00
Conor McCarthy
06cc2e1aee vkd3d: Collect multiple descriptor writes in a buffer and update in one call.
Reduces the cost of calling vkUpdateDescriptorSets() via winevulkan
and its thunks. The performance gain can be as high as 20%.
2023-04-25 22:20:17 +02:00
Conor McCarthy
f50e53e7c9 vkd3d: Use atomic exchange for descriptor writes.
The descriptor component of struct d3d12_desc is replaced with a union
containing a pointer which can be swapped out using
InterlockedExchangePointer(). To make it safe to increment the refcount
of such an object it is necessary to cache freed objects. Elimination
of the descriptor mutexes on games which use multithreaded descriptor
writes nearly doubles framerate on recent hardware.
2023-04-25 22:20:15 +02:00
Conor McCarthy
e63201a7a3 vkd3d: Delay writing Vulkan descriptors until submitted to a queue.
Eliminates vk_sets_mutex. Performance on average may be lower until
the descriptor mutexes are replaced and Vulkan writes are buffered
to reduce thunk calls.
2023-04-25 22:20:09 +02:00
Conor McCarthy
505c8c5a2f vkd3d: Ensure descriptors are pointer aligned.
The descriptor structure contains pointer and size types.
2023-04-25 22:20:06 +02:00
Zebediah Figura
b46df551eb vkd3d-shader/tpf: Return unsigned int from hlsl_sm4_register_from_semantic().
Fix a compile warning:

../vkd3d/libs/vkd3d-shader/hlsl_codegen.c: In function 'allocate_semantic_register':
../vkd3d/libs/vkd3d-shader/hlsl_codegen.c:2947:85: error: passing argument 4 of 'hlsl_sm4_register_from_semantic' from incompatible pointer type [-Werror=incompatible-pointer-types]
 2947 |         if ((builtin = hlsl_sm4_register_from_semantic(ctx, &var->semantic, output, &type, NULL, &has_idx)))
      |                                                                                     ^~~~~
      |                                                                                     |
      |                                                                                     unsigned int *
In file included from ../vkd3d/libs/vkd3d-shader/hlsl_codegen.c:21:
../vkd3d/libs/vkd3d-shader/hlsl.h:1171:52: note: expected 'enum vkd3d_sm4_register_type *' but argument is of type 'unsigned int *'
 1171 |         bool output, enum vkd3d_sm4_register_type *type, enum vkd3d_sm4_swizzle_type *swizzle_type, bool *has_idx);
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
2023-04-21 20:55:56 +02:00
Nikolay Sivov
317b8aa039 vkd3d-shader/hlsl: Ignore "unroll" attribute for loops. 2023-04-21 20:55:48 +02:00
Henri Verbeet
8e0df3f720 vkd3d-shader/sm1: Merge hlsl_sm1.c into d3dbc.c. 2023-04-20 22:54:32 +02:00
Henri Verbeet
99bc07ccf5 vkd3d-shader/sm4: Merge sm4.h into tpf.c. 2023-04-20 22:54:31 +02:00