Commit Graph

7185 Commits

Author SHA1 Message Date
Henri Verbeet
73c0356861 tests: Add a shader model 6 signature reflection test for different types. 2025-02-24 15:10:08 +01:00
Henri Verbeet
fe4143ad19 vkd3d-shader/dxil: Generate I/O signatures with 16-bit component types for native 16-bit shaders.
Which incidentally matches the I/O signatures from the DXBC container.
2025-02-24 15:10:08 +01:00
Henri Verbeet
f5d702b09a vkd3d-shader/dxbc: Validate component types in shader_parse_signature(). 2025-02-24 15:10:08 +01:00
Henri Verbeet
b8d740ebfc vkd3d-shader/dxbc: Output messages for invalid semantic name references in shader_parse_signature(). 2025-02-24 15:10:08 +01:00
Henri Verbeet
3bcdb85ddc vkd3d-shader/dxbc: Set the "elements_capacity" field as well in shader_parse_signature().
Leaving it as 0 mostly ends up doing the right thing in practice, but isn't
quite right.
2025-02-24 15:10:08 +01:00
Giovanni Mascellani
2feb3a3bba vkd3d: Take the root signature from shaders when creating graphics pipelines.
If the root signature wasn't explicitly specified.

This fixes a failure in The Touryst.
2025-02-20 16:00:55 +01:00
Giovanni Mascellani
42b65e80cf tests: Test embedding the root signature in shaders for graphics pipelines. 2025-02-20 15:59:22 +01:00
Henri Verbeet
0796af7b4b vkd3d: Avoid vkd3d_shader_parse_input_signature(). 2025-02-20 15:57:26 +01:00
Henri Verbeet
2e62e9ea7e vkd3d-shader: Handle arrayed elements in vkd3d_shader_signature_from_shader_signature(). 2025-02-20 15:57:26 +01:00
Henri Verbeet
ce5164e26e tests: Add a signature reflection test for arrayed inputs and outputs. 2025-02-20 15:57:26 +01:00
Henri Verbeet
4e28d1c658 vkd3d-shader/dxbc: Do not extract I/O signatures for DXIL shaders.
The DXIL parser doesn't need them.
2025-02-20 15:57:26 +01:00
Henri Verbeet
f4a3d17269 vkd3d-shader/dxil: Avoid using the I/O signatures from the DXBC container.
We currently generate our own I/O signatures inside the DXIL parser, but
use the element counts from the DXBC container signatures to allocate
the input_params/output_params/patch_constant_params arrays. That
happens to work for well-behaved inputs, but it's asking for trouble.
2025-02-20 15:57:26 +01:00
Henri Verbeet
970a1a2b35 vkd3d-shader/dxbc: Update the vkd3d_shader_parse_input_signature() documentation for dxbc-dxil shaders. 2025-02-20 15:57:26 +01:00
Elizabeth Figura
d5a2ff5c12 vkd3d-shader/hlsl: Add a hlsl_block_add_int_constant() helper. 2025-02-20 15:56:31 +01:00
Elizabeth Figura
992d20def3 vkd3d-shader/hlsl: Add a hlsl_block_add_uint_constant() helper. 2025-02-20 15:50:13 +01:00
Elizabeth Figura
79ad8c9354 vkd3d-shader/hlsl: Handle error instructions in hlsl_new_swizzle().
We already check for error instructions when parsing swizzles, but if allocation
fails at codegen time we would like to avoid asserting when subsequently
constructing a swizzle.
2025-02-20 15:49:40 +01:00
Elizabeth Figura
4072aa4a4b vkd3d-shader/hlsl: Remove the type equality assertions in hlsl_new_ternary_expr().
Similar to d1c2ae3f0e, this is a bit too strict
and may prevent e.g. simultaneous use of float and float1 at codegen time.

However, in this case the inciting factor is that in the case of allocation
failure at codegen time, we would like to allow one or more arguments to have
error type.
2025-02-20 15:48:25 +01:00
Elizabeth Figura
ba868ed4a6 vkd3d-shader/hlsl: Skip transformation passes on error.
The primary motivation here is to avoid needing to worry about instructions
potentially pointing to the preallocated error instruction in the case of
allocation failure.

This doesn't cover all passes, but none of the other passes make assumptions
about instruction sources.
2025-02-20 15:48:24 +01:00
Francisco Casas
153b7c8460 vkd3d-shader/hlsl: Run folding passes again after lower_nonconstant_array_loads.
This is because lower_nonconstant_array_loads() can potentially turn
nonconstant loads into constant loads, allowing copy-prop to turn these
loads into previous instructions, which might help other passes as well.

This patch lowers the number of required temps for the following ps_2_0
shader from 19 to 16:

    int i;
    float3x3 mats[4];

    float4 main() : sv_target
    {
        return mul(mats[i], float3(1, 2, 3)).xyzz;
    }
2025-02-20 15:44:09 +01:00
Francisco Casas
e60c89c532 tests: Test unused invalid samples with a static sampler. 2025-02-20 15:44:09 +01:00
Francisco Casas
321fda9c26 vkd3d-shader/hlsl: Only use the temp copy for variables that are written.
This can save a significant amount of temp registers because it allows to
avoid referencing the temp (and having to store it) when not needed.

For instance, this patch lowers the number of required temps for the
following ps_2_0 shader from 24 to 19:

    int i;
    float3x3 mats[4];

    float4 main() : sv_target
    {
        return mul(mats[i], float3(1, 2, 3)).xyzz;
    }

Also, it is needed for SM1 vertex shader relative addressing since
non-constant loads are required to be directly on the uniform ('c'
registers) instead of the temp, and non-constant loads cannot be
transformed by copy propagation.
2025-02-20 15:44:09 +01:00
Elizabeth Figura
8e6ddb0c1a vkd3d-shader/hlsl: Don't mark extern variables with an explicit first_write or last_read.
Fix the last few places that care.
2025-02-20 15:44:09 +01:00
Francisco Casas
1d74ff075e vkd3d-make/hlsl: Trace the number of registers allocated in allocate_temp_registers(). 2025-02-20 15:44:04 +01:00
Nikolay Sivov
f830ac1206 vkd3d-shader/preproc: Do not attempt to load empty included files.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-02-20 15:40:34 +01:00
Giovanni Mascellani
07b7975d09 vkd3d: Put all root descriptors in a single Vulkan descriptor set when using Vulkan heaps.
Since 4a94bfc2f6 we segregate
different D3D12 descriptor types in different Vulkan descriptor sets.
This change was introduced to reduce descriptor wasting when
allocating a new descriptor pool; that can be very useful when
using virtual heaps, which have to often cycle through many
descriptors, but it is expected to have limited impact for Vulkan
heaps, given that in that case most descriptors are allocated through
the descriptor heap rather than through the command allocator.

Instead, it has a rather detrimental effect with Vulkan heaps,
because it tends to use many more Vulkan descriptor sets than
necessary, often with just a handful of descriptors each. This
causes a regression on some Vulkan implementations that support
too few descriptor sets.

With this change we revert to a situation similar to before,
stuffing all the descriptors that do not live in a root
descriptor table in as few descriptor sets as possible (at most
one or two, depending on whether push descriptors are used).
2025-02-19 17:58:23 +01:00