Commit Graph

2641 Commits

Author SHA1 Message Date
Francisco Casas
3f9cd58f5b vkd3d-shader/hlsl: Fix missing extern resource names. 2023-04-19 20:46:53 +02:00
Conor McCarthy
333fdf7c74 vkd3d: Check for index buffer location zero.
VK_EXT_robustness2 does not support null index buffers so we only
warn and return immediately.
2023-04-19 20:46:53 +02:00
Conor McCarthy
0526f232cd vkd3d: Support null address for SRV/UAV root descriptors. 2023-04-19 20:46:00 +02:00
Conor McCarthy
963e5e26dc vkd3d: Support null address for CBV root descriptors. 2023-04-19 20:46:00 +02:00
Nikolay Sivov
827a359b45 vkd3d-shader/hlsl: Handle uppercase regset names in packoffset().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-19 20:45:50 +02:00
Nikolay Sivov
0cea4d352e vkd3d-shader/hlsl: Handle uppercase regset names in register(). 2023-04-19 20:45:48 +02:00
Zebediah Figura
d8ef0c69a8 vkd3d-shader/spirv: Do not declare resources as multisampled if the sample count is 1.
It is illegal to match a SPIR-V multisampled resource to a Vulkan resource which
is not multisampled. Vulkan considers a resource to be multisampled if its
sample count is greater than 1 (and SPIR-V does not care about the sample count).

This fixes validation errors in the case where the sample count does actually
match the resource. In order to provide correct behaviour when there is a
mismatch, or when the sample count is missing, we will need yet another
additional interface. In the absence of that it seems best to provide a best
guess.

This fixes a validation error with the not-yet-committed merge request 135, when
the d3d11 runner is run through Wine with the Vulkan backend.
2023-04-19 20:45:39 +02:00
Nikolay Sivov
dfe923ea1d vkd3d-shader: Consistently pass location structure by pointer. 2023-04-19 20:45:31 +02:00
Conor McCarthy
0ce55e8b8e vkd3d: Support 1D SRV. 2023-04-18 22:00:17 +02:00
Conor McCarthy
6db9ed14dc vkd3d: Support 1D UAV. 2023-04-18 22:00:17 +02:00
Zebediah Figura
7ee66351c8 vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_if(). 2023-04-18 21:59:49 +02:00
Zebediah Figura
50f0ae1b21 vkd3d-shader/hlsl: Pass hlsl_block pointers to hlsl_new_if(). 2023-04-18 21:59:45 +02:00
Zebediah Figura
5a3fe1609b vkd3d-shader/hlsl: Initialize the block in clone_block(). 2023-04-18 21:59:44 +02:00
Zebediah Figura
733141720a vkd3d-shader/hlsl: Introduce a hlsl_block_cleanup() helper. 2023-04-18 21:59:42 +02:00
Zebediah Figura
dc7514afc9 vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_float_constant(). 2023-04-18 21:59:39 +02:00
Zebediah Figura
b23ef3ca3b vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_cast() and hlsl_new_copy(). 2023-04-18 21:59:37 +02:00
Zebediah Figura
1bf3aa9275 vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_bool_constant(). 2023-04-18 21:59:34 +02:00
Zebediah Figura
0654d88edd vkd3d-shader/hlsl: Allow VPOS and VFACE to be specified in sm3 pixel shaders.
We were previously (accidentally) rejecting them because they didn't have a
usage.
2023-04-18 21:59:22 +02:00
Zebediah Figura
b19105eaeb vkd3d-shader/hlsl: Do not write DCL instructions for ps_1_* shaders. 2023-04-18 21:59:17 +02:00
Zebediah Figura
99d413206b vkd3d-shader/hlsl: Map ps_1_* color and texcoord semantics to registers. 2023-04-18 21:59:15 +02:00
Zebediah Figura
98e2461392 vkd3d-shader/hlsl: Sort only uniforms by name in the sm1 backend. 2023-04-18 21:59:13 +02:00
Zebediah Figura
8ed7437708 vkd3d-shader/hlsl: Evaluate index before array.
Co-authored-by: Francisco Casas <fcasas@codeweavers.com>
2023-04-13 23:05:43 +02:00
Francisco Casas
af1aa63ace vkd3d-shader/hlsl: Support column-major matrix indexing in the lhs. 2023-04-13 23:05:41 +02:00
Francisco Casas
dc2a34824d vkd3d-shader/hlsl: Always load from a synthetic copy in add_load_component(). 2023-04-13 23:05:39 +02:00
Francisco Casas
82ff408451 vkd3d-shader/hlsl: Remove add_load_index(). 2023-04-13 23:05:34 +02:00
Francisco Casas
5c285adc6b vkd3d-shader/hlsl: Use hlsl_ir_index for array and record access.
From this point on, it is no longer true that only hlsl_ir_loads can
return objects, because an object can also come from chain of
hlsl_ir_indexes that ends in an hlsl_ir_load.

The lower_index_loads pass takes care of lowering all hlsl_ir_indexes
into hlsl_ir_loads.

For this reason, hlsl_resource_load_params now expects both the resource
as the sampler to be just an hlsl_ir_node pointer instead of a pointer
to a more specific hlsl_ir_load.
2023-04-13 23:05:32 +02:00
Francisco Casas
741c9e5893 vkd3d-shader/hlsl: Introduce hlsl_ir_index.
This node type is intended for use during parse-time.

While we parse an indexing expression such as "a[3]", we don't know if
it will end up as part of an expression (in which case it must be folded
into a load) or it is for the lhs of a store (in which case it must be
folded into the store's deref).
2023-04-13 23:05:25 +02:00
Francisco Casas
0ceecd1225 vkd3d-shader/hlsl: Fix numeric offset of object fields. 2023-04-13 23:05:07 +02:00
Nikolay Sivov
ca59a3c35b vkd3d-shader/hlsl: Handle SV_IsFrontFace semantic. 2023-04-13 23:04:58 +02:00
Nikolay Sivov
a1bd4e080e vkd3d-shader/hlsl: Support log() intrinsic.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-13 23:04:44 +02:00
Nikolay Sivov
210caa931d vkd3d-shader/hlsl: Support log10() intrinsic.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-13 23:04:42 +02:00
Nikolay Sivov
49b63fbeba vkd3d-shader/hlsl: Support log2() intrinsic. 2023-04-13 23:04:40 +02:00
Nikolay Sivov
c93dac3620 vkd3d-shader/hlsl: Write 'log' instruction for SM1. 2023-04-13 23:04:37 +02:00
Henri Verbeet
0c05f2409c vkd3d-shader/sm4: Get rid of shader_sm4_is_end(). 2023-04-12 21:54:57 +02:00
Henri Verbeet
1e448b0b71 vkd3d-shader/sm4: Pass a vkd3d_shader_sm4_parser structure to shader_sm4_read_instruction(). 2023-04-12 21:54:56 +02:00
Henri Verbeet
1b7b694190 vkd3d-shader/sm1: Pass a vkd3d_shader_sm1_parser structure to shader_sm1_is_end(). 2023-04-12 21:54:55 +02:00
Henri Verbeet
df6a34e1bd vkd3d-shader/sm1: Pass a vkd3d_shader_sm1_parser structure to shader_sm1_read_instruction(). 2023-04-12 21:54:54 +02:00
Henri Verbeet
09566e2c25 vkd3d-shader: Get rid of the "ptr" field from struct vkd3d_shader_parser.
This is an implementation detail.
2023-04-12 21:54:53 +02:00
Henri Verbeet
c4d307a08d vkd3d-shader: Get rid of the "instruction_idx" field from struct vkd3d_shader_parser.
This is unused now.
2023-04-12 21:54:51 +02:00
Conor McCarthy
98b5e2c6e0 vkd3d-shader/ir: Insert hull shader control point input declarations if no control point phase is defined.
The SPIR-V backend will emit a default control point phase. Inserting
inputs into the IR allows handling of declarations via the usual path
instead of an ad hoc implementation which may not match later changes
to input handling.
2023-04-12 21:54:28 +02:00
Conor McCarthy
14295a224d vkd3d-shader/ir: Normalise control point phase output registers to include the control point id.
In SPIR-V the address must include the invocation id, but in TPF it
is implicit. Move the register index up one slot and insert an
OUTPOINTID relative address.
2023-04-12 21:54:27 +02:00
Philip Rebohle
c8a33431e3 vkd3d: Persistently map host-visible heaps on creation. 2023-04-10 21:00:17 +02:00
Zebediah Figura
616c4bf51f vkd3d-shader/hlsl: Always align section sizes.
This fixes disassembly using native D3DDisassemble() of shaders generated with vkd3d-shader.

Fixes: d6d9aab31c
2023-04-06 17:52:16 +02:00
Zebediah Figura
a60c47ff39 vkd3d-shader: Explicitly align the size in bytecode_get_next_offset() and rename it accordingly. 2023-04-06 17:52:16 +02:00
Zebediah Figura
6783524613 vkd3d-common: Make some global string variables const. 2023-04-06 17:52:08 +02:00
Zebediah Figura
1514755043 vkd3d-shader/hlsl: Make a string array const. 2023-04-06 17:52:07 +02:00
Zebediah Figura
09cda98deb vkd3d-shader: Factor out vkd3d_shader_parser_compile(). 2023-04-06 17:52:02 +02:00
Zebediah Figura
507e8644ae vkd3d-shader: Reuse the existing parser for scanning in compile_dxbc_tpf(). 2023-04-06 17:52:02 +02:00
Zebediah Figura
28774b3649 vkd3d-shader/spirv: Move spirv_compiler_destroy() to avoid forward declarations. 2023-04-06 17:52:01 +02:00
Zebediah Figura
70cfd58be6 vkd3d-shader/spirv: Introduce a spirv_compile() helper. 2023-04-06 17:51:59 +02:00
Nikolay Sivov
24c1eb562f vkd3d-shader/hlsl: Treat half as float for casts.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-06 17:51:55 +02:00
Nikolay Sivov
c190c184ce vkd3d-shader/hlsl: Add support for ternary operator. 2023-04-06 17:51:46 +02:00
Zebediah Figura
725d408974 vkd3d-shader/hlsl: Introduce an hlsl_block_init() helper. 2023-04-06 17:51:40 +02:00
Zebediah Figura
1da5a9a490 vkd3d-shader/hlsl: Introduce an hlsl_block_add_block() helper. 2023-04-06 17:51:38 +02:00
Zebediah Figura
ceac81b816 vkd3d-shader/hlsl: Introduce an hlsl_block_add_instr() helper. 2023-04-06 17:51:36 +02:00
Conor McCarthy
e27ceddfb4 vkd3d: Leave the command queue op mutex locked after a partial flush.
All return paths in d3d12_command_queue_flush_ops_locked() must
leave the op mutex locked.
2023-04-05 21:38:39 +02:00
Henri Verbeet
d6d9aab31c vkd3d-shader: Align the start offset instead of the size in bytecode_put_bytes().
The practical effect this has is that we avoid potential trailing padding at
the end of DXBC blobs. Unfortunately this also means we need to be more
careful about using bytecode_get_size() to find the offset where subsequent
data would get written, although in many cases this follows a put_u32() call.
2023-04-04 22:01:36 +02:00
Henri Verbeet
4e32adb8c1 vkd3d-utils: Export D3D12CreateDevice() once again.
Commit d27fee64ab inadvertently stopped
exporting D3D12CreateDevice().
2023-04-04 22:01:04 +02:00
Francisco Casas
f3e81327dc vkd3d-shader/hlsl: Consider register() as manual packing for resource fields. 2023-04-04 21:59:49 +02:00
Francisco Casas
bf4a125087 vkd3d-shader/hlsl: Ignore packoffset() contents for SM1. 2023-04-04 21:59:47 +02:00
Francisco Casas
60237cb773 vkd3d-shader/hlsl: Don't allow manual and automatic cbuffer offset packing. 2023-04-04 21:59:45 +02:00
Francisco Casas
4448d114ad vkd3d-shader/hlsl: Detect overlaps in cbuffer offsets. 2023-04-04 21:59:43 +02:00
Francisco Casas
7777c32cac vkd3d-shader/hlsl: Support packoffset(). 2023-04-04 21:59:42 +02:00
Francisco Casas
4aca335f42 vkd3d-shader/hlsl: Parse packoffset(). 2023-04-04 21:59:40 +02:00
Francisco Casas
9b70971696 vkd3d-shader/hlsl: Rename struct hlsl_reg_reservation fields. 2023-04-04 21:59:39 +02:00
Nikolay Sivov
eb71c5f20d vkd3d-shader/hlsl: Handle round() for SM1. 2023-04-03 18:00:03 +02:00
Conor McCarthy
88667098eb vkd3d: Do not destroy a heap until its resource count is zero.
Fixes a crash on exit in Horizon Zero Dawn (which requres added SM 6.0 support).

Placed resources should hold a reference to their heap:
https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-createheap
2023-04-03 17:59:41 +02:00
Zebediah Figura
7a9e393ea0 vkd3d-shader/hlsl: Rename the "type" field of struct hlsl_type to "class".
To be consistent with enum hlsl_type_class and HLSL_CLASS_*.
2023-04-03 17:59:24 +02:00
Nikolay Sivov
b172f4c257 vkd3d-shader/hlsl: Improve handling of builtin alias type "vector".
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-03 17:59:08 +02:00
Nikolay Sivov
5b5c020ade vkd3d-shader/hlsl: Improve handling of builtin alias type "matrix". 2023-04-03 17:59:06 +02:00
Conor McCarthy
c61f9f477c vkd3d-shader/spirv: Declare the phase SPIR-V function in spirv_compiler_enter_shader_phase().
The convoluted code path is no longer needed.
2023-04-03 17:58:26 +02:00
Conor McCarthy
b8472d2270 vkd3d-shader/spirv: Remove the hull shader phase array.
With no more than one phase each of control point and fork/join type,
an array is not required.
2023-04-03 17:58:24 +02:00
Conor McCarthy
16a7de4b38 vkd3d-shader/trace: Trace the normalised instruction array after tracing the input. 2023-04-03 17:58:23 +02:00
Conor McCarthy
eabdccb117 vkd3d-shader/ir: Merge all shader IR fork and join phases into a single phase.
Normalise the incoming vkd3d_shader_instruction IR to the shader model 6
pattern. This allows generation of a single patch constant function in
SPIR-V.
2023-04-03 17:58:21 +02:00
Henri Verbeet
57d92a15cf Release 1.7. 2023-03-24 11:22:28 +01:00
Nikolay Sivov
4110f1e547 vkd3d-shader: Fix a few typos in the comments. 2023-03-15 20:13:27 +01:00
Henri Verbeet
8509ec1e72 vkd3d-shader/spirv: Update the current source location in spirv_compiler_generate_spirv(). 2023-03-13 22:10:00 +01:00
Henri Verbeet
0a73c75db8 vkd3d-shader/glsl: Update the current source location in vkd3d_glsl_generator_generate().
Since the introduction of instruction arrays, the parser location no
longer matches the location of the current instruction. Ultimately we'll
likely want to add some kind of explicit location information to struct
vkd3d_shader_instruction_array, because we might do transformations that
change the order of the original instructions.
2023-03-13 22:09:58 +01:00
Henri Verbeet
685abf9c2d vkd3d-shader/sm4: Do not specify a destination register for VKD3D_SM4_OP_DCL_RESOURCE in opcode_table[].
We do not set one in shader_sm4_read_dcl_resource(), and
shader_sm4_read_instruction() explicitly sets this to 0.
2023-03-13 22:09:54 +01:00
Henri Verbeet
65b7154a22 vkd3d-shader/sm4: Set "dst_count" to 0 when we clear "dst" in shader_sm4_read_instruction().
VKD3D_SM4_OP_DCL_RESOURCE currently has 1 for "dst_count", but NULL for
"dst". This is largely harmless because we never attempt to access the
destination register of VKD3DSIH_DCL instructions, but nevertheless not
quite proper.
2023-03-13 22:09:49 +01:00
Zebediah Figura
da2435707b vkd3d-shader/hlsl: Fix some memory leaks in the function call rule. 2023-03-09 22:11:06 +01:00
Nikolay Sivov
193692bbcb vkd3d-shader/hlsl: Use array element type for array's regset.
Currently this affects SM1 compilation only, with a minimal example like this:

float4 var[3];
float4 main() : sv_target
{
    return var[1];
}
2023-03-09 22:10:39 +01:00
Nikolay Sivov
2880be647e vkd3d-shader/sm4: Write sample count field for multisampled texture declaration.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-03-08 20:15:11 +01:00
Nikolay Sivov
ae2f777a4d vkd3d-shader/hlsl: Parse multisample texture type names. 2023-03-08 20:15:09 +01:00
Nikolay Sivov
ee52ad8106 vkd3d-shader/trace: Output sample count for multisampled resources. 2023-03-08 20:15:06 +01:00
Conor McCarthy
9f6e6d3fcd vkd3d-shader/dxbc: Validate and skip the signature section header size.
Silences a very common warning.
2023-03-08 20:14:59 +01:00
Conor McCarthy
3b5316be82 vkd3d-shader/dxbc: Emit a shader error for an invalid signature data size. 2023-03-08 20:14:57 +01:00
Conor McCarthy
83e39e2650 vkd3d-shader/dxbc: Pass a message context to for_each_dxbc_section(). 2023-03-08 20:14:55 +01:00
Giovanni Mascellani
bb2fa97c33 vkd3d: Do not keep the CS queue locked while processing it.
d3d12_command_queue_flush_ops() can renter itself while processing signal
events. Since we don't use recursive mutexes, we currently have to check
some of the queue variables without holding the mutex, which is not safe.

This is solved by allowing the queue to release its mutex while it is
processing entries: when flushing, the queue is briefly locked, the
is_flushing flag is set, the queue content is copied away and the
queue is unlocked again. After having processed the entries, the
queue is locked again to check is something else was added in the
meantime. This is repeated until the queue is empty (or a wait operation
is blocking it).

This should also remove some latency when a thread pushes to the queue
while another one is processing it, but I didn't try to measure any
impact. While it is expected that with this patch the queue mutex
will be locked and unlocked more frequently, it should also remain
locked for less time, hopefully creating little contention.
2023-03-08 20:14:39 +01:00
Giovanni Mascellani
09d2c8d190 vkd3d: Always enqueue wait operations, even when they can be executed right away. 2023-03-08 20:14:39 +01:00
Giovanni Mascellani
9eba44396a vkd3d: Always enqueue signal operations, even when they can be executed right away. 2023-03-08 20:14:39 +01:00
Giovanni Mascellani
0d329ba168 vkd3d: Always enqueue execute operations, even when they can be executed right away.
The goal is to simplify the CS queue handling: with this and the following
changes operations are always started by d3d12_command_queue_flush_ops(),
in order to make further refactoring easier.

Notice that while with this change executing an operation on an empty CS
queue is a bit less efficient, it doesn't require more locking. On the other
hand, this change paves the road for executing CS operations without holding
the queue lock.
2023-03-08 20:14:35 +01:00
Giovanni Mascellani
0c6df49560 vkd3d: Hold the queue mutex when adding the queue to a blocked list.
Otherwise it could be added more than once.

Note that the deleted comment is wrong: between when d3d12_command_queue_flush_ops()
returns and when the queue is added back to the blocked list, the queue
might have been pushed to and flushed an arbitrary number of times.
2023-03-08 20:14:31 +01:00
Giovanni Mascellani
ef8d272507 vkd3d: Mention the correct mutex in a comment. 2023-03-08 20:14:31 +01:00
Nikolay Sivov
a18f3d4dd5 vkd3d-shader/hlsl: Support distance() intrinsic. 2023-03-08 20:14:22 +01:00
Nikolay Sivov
d6b656641c vkd3d-shader/hlsl: Support rsqrt() intrinsic. 2023-03-08 20:14:20 +01:00
Zebediah Figura
a28ecaa135 vkd3d-shader/hlsl: Get rid of the check_invalid_matrix_modifiers() helper. 2023-02-28 22:07:01 +01:00
Zebediah Figura
5838364886 vkd3d-shader/hlsl: Apply latent majority modifiers to typedefs as well. 2023-02-28 22:07:00 +01:00
Zebediah Figura
322963add8 vkd3d-shader/hlsl: Do not set an initial latent matrix majority.
This change does nothing by itself.
2023-02-28 22:06:59 +01:00
Zebediah Figura
75ab9d31ef vkd3d-shader/hlsl: Store the matrix majority as a type modifiers bitmask. 2023-02-28 22:06:58 +01:00