Commit Graph

2655 Commits

Author SHA1 Message Date
Francisco Casas
6f71077e3e vkd3d-shader/hlsl: Skip object components when creating input/output copies. 2023-05-08 20:22:19 +02:00
Francisco Casas
4413f6b64b vkd3d-shader/hlsl: Add fixme for uniform copies for objects within structs. 2023-05-08 20:22:17 +02:00
Francisco Casas
69ff249ef4 vkd3d-shader/hlsl: Support multiple-register variables in object regsets.
Variables that contain more than one object (arrays or structs) require
the allocation of contiguous registers in the respective object
register spaces.
2023-05-08 20:22:14 +02:00
Conor McCarthy
f039c86aac vkd3d: Create smaller UAV-only descriptor pools in the allocator if Vulkan-backed heaps are enabled.
In this case d3d12_command_allocator_allocate_descriptor_set() is
only called for clearing UAVs. This helps on platforms with limited
descriptor maximum counts.
2023-05-08 20:22:02 +02:00
Nikolay Sivov
7516adeeae vkd3d-shader/hlsl: Add support for fmod() intrinsic. 2023-05-08 20:21:52 +02:00
Zebediah Figura
8b57a612d7 vkd3d-shader/hlsl: Map the colour output for ps_1_* to r0. 2023-05-03 21:12:39 +02:00
Zebediah Figura
b2959739ed vkd3d-shader/hlsl: Rewrite the register allocator to allow allocating in multiple passes.
We will need this in order to allocate some "special" registers: ps_1_* output, sincos output, etc.
2023-05-03 21:12:38 +02:00
Zebediah Figura
71d8ff85c6 vkd3d-shader/hlsl: Avoid leaking the allocator register map in allocate_const_registers(). 2023-05-03 21:12:37 +02:00
Zebediah Figura
c57ac0b207 vkd3d-shader/hlsl: Rename struct liveness to struct register_allocator. 2023-05-03 21:12:34 +02:00
Conor McCarthy
a0a18b1620 vkd3d-shader: Introduce an internal shader signature structure.
A register count is required for Shader Model 6 signatures, including
those normalised from earlier models.
2023-05-03 21:12:07 +02:00
Conor McCarthy
5ae068168c vkd3d-shader/tpf: Return an error from vkd3d_shader_sm4_parser_create() if the parser failed. 2023-05-03 21:12:06 +02:00
Conor McCarthy
85eb231492 vkd3d-shader/d3dbc: Return an error from vkd3d_shader_sm1_parser_create() if the parser failed. 2023-05-03 21:12:03 +02:00
Francisco Casas
34ddc13390 vkd3d-shader/hlsl: Don't keep the implicit mipmap level on hlsl_ir_index. 2023-05-03 21:11:59 +02:00
Francisco Casas
4aaf6b8895 vkd3d-shader/hlsl: Use hlsl_ir_index for resource access.
This patch makes index expressions on resources hlsl_ir_index nodes
instead of hlsl_ir_resource_load nodes, because it is not known if they
will be used later as the lhs of an hlsl_ir_resource_store.

For now, the only benefit is consistency.
2023-05-03 21:11:56 +02:00
Conor McCarthy
e2dac061e2 vkd3d: Do not reset the descriptor heap count unless full or the command list is reset.
The same heaps must be flushed again if the command list is executed again
without a reset.
2023-05-02 20:46:23 +02:00
Nikolay Sivov
87037d3748 vkd3d-shader/hlsl: Implement asfloat().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-05-02 20:46:16 +02:00
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
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
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
61c72a4fd1 vkd3d-shader/hlsl: Avoid invalid input/output copies for non-numeric types. 2023-05-01 22:18:17 +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
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
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