6987 Commits

Author SHA1 Message Date
Giovanni Mascellani
343022cdc1 vkd3d-shader/spirv: Interpret the write mask as a destination swizzle for double comparison operations.
This fixes a failure on a shader in Wild hearts.
2025-01-22 14:51:16 +01:00
Francisco Casas
4d18fb39b6 vkd3d-shader/hlsl: Don't forbid first base type cast on var assignments. 2025-01-22 14:46:02 +01:00
Francisco Casas
0a15ab702f vkd3d-shader/hlsl: Don't count cast to param type on IN as part of OUT var's lhs.
If the parameter is HLSL_STORAGE_IN, we add a cast from the arg to the
param type so that it can enter the function, however this cast should
not be considered part of the lhs on the implicit assignment that happens
if the var is also HLSL_STORAGE_OUT.
2025-01-22 14:39:20 +01:00
Francisco Casas
b55fe1950e vkd3d-shader/hlsl: Support non-size-changing lhs casts. 2025-01-22 14:38:10 +01:00
Francisco Casas
c2e224c5fb vkd3d-shader/hlsl: Delay lowering complex casts until after parse time.
While so far it has been posible to do this at parse time, this must
happen after knowing if the complex cast is on the lhs or not.

The modified tests show that before this patch we are currently
miscompiling when this happens, because a complex lhs cast is transformed
into a load, and add_assigment() just stores to the generated "cast"
temp.
2025-01-22 14:34:19 +01:00
Francisco Casas
dc37d90190 tests/hlsl: Add more function cast tests. 2025-01-22 14:29:54 +01:00
Francisco Casas
60f75cc542 tests/hlsl: Test partial assignments due to lhs casts. 2025-01-22 14:27:57 +01:00
Francisco Casas
51db232368 tests/hlsl: Add lhs cast tests. 2025-01-22 14:23:29 +01:00
Anna (navi) Figueiredo Gomes
c7b209124b vkd3d-shader/hlsl: Consider conversions across all parameters in function_compare().
For example, given two arguments, half3 and float, and two functions,
func(float, float) and func(float3, float3), fxc/d3dcompiler prefers to
widen both arguments to float3.
2025-01-22 14:18:54 +01:00
Anna (navi) Figueiredo Gomes
de57afd672 tests/hlsl: Add mixed argument size tests. 2025-01-22 14:17:17 +01:00
Elizabeth Figura
004a381d9c tests: Adjust abs.shader_test to pass with 1.x.
Pixel shader 1.x constants must be between -1 and 1, or they will be clamped,
even constants defined in the shader.

Also mark 1.x-specific features if any.
2025-01-22 13:43:38 +01:00
Elizabeth Figura
e805fe3e36 tests: Adjust array-size-expr.shader_test to pass with 1.x.
Pixel shader 1.x constants must be between -1 and 1, or they will be clamped,
even constants defined in the shader.

Also mark 1.x-specific features if any.
2025-01-22 13:43:38 +01:00
Elizabeth Figura
e5ec52d63b tests: Adjust array-parameters.shader_test to pass with 1.x.
Pixel shader 1.x constants must be between -1 and 1, or they will be clamped,
even constants defined in the shader.

Also mark 1.x-specific features if any.
2025-01-22 13:43:38 +01:00
Elizabeth Figura
e40b191943 tests: Adjust arithmetic-int.shader_test to pass with 1.x.
Pixel shader 1.x constants must be between -1 and 1, or they will be clamped,
even constants defined in the shader.

Also mark 1.x-specific features if any.
2025-01-22 13:43:38 +01:00
Elizabeth Figura
fb75c0530a tests: Adjust arithmetic-float-uniform.shader_test to pass with 1.x.
Pixel shader 1.x constants must be between -1 and 1, or they will be clamped,
even constants defined in the shader.

Also mark 1.x-specific features if any.
2025-01-22 13:43:38 +01:00
Elizabeth Figura
8b4f0f348a tests: Adjust arithmetic-float.shader_test to pass with 1.x.
Pixel shader 1.x constants must be between -1 and 1, or they will be clamped,
even constants defined in the shader.

Also mark 1.x-specific features if any.
2025-01-22 13:43:38 +01:00
Elizabeth Figura
5f55f5adc7 tests: Adjust angle-unit.shader_test to pass with 1.x.
Pixel shader 1.x constants must be between -1 and 1, or they will be clamped,
even constants defined in the shader.

Also mark 1.x-specific features if any.
2025-01-22 13:43:38 +01:00
Giovanni Mascellani
5b2d62e59a vkd3d: Explicitly call the appropriate waiting function in the fence worker.
Avoid using an indirect call that makes the code less clear for no
real advantage.
2025-01-21 14:09:29 +01:00
Shaun Ren
f3f2880261 vkd3d-shader/d3d-asm: Print vocp registers with subscript. 2025-01-21 14:05:21 +01:00
Shaun Ren
f0070cd595 tests: Test invalid out const parameters. 2025-01-21 14:03:44 +01:00
Shaun Ren
a9d7c65eb8 vkd3d-shader/hlsl: Forbid declaring parameters as both out and const.
Note that inout const parameters are allowed.
2025-01-21 14:03:44 +01:00
Giovanni Mascellani
22d0841412 vkd3d: Support signalling a fence once all outstanding work is submitted to Vulkan.
When the client acquires the Vulkan queue it has to ensure that
it is not submitting work before other work it depends on already
submitted through the Direct3D 12 API but currently in the internal
vkd3d queue. Currently we suggest to enqueue signalling a fence and
than wait for it before acquiring the Vulkan queue, which is
correct but excessive: it will wait not just for the work currently
in the queue to be submitted, but for it to be executed too,
introducing useless dependencies.

By adding a way to enqueue signalling a fence on the CPU side we
allow the client to wait for the currently outstanding work to
be submitted to Vulkan, but nothing more.
2025-01-21 14:02:22 +01:00
Giovanni Mascellani
bdb8291f6c vkd3d: Release queued fences when stopping the fence worker. 2025-01-21 13:45:33 +01:00
Giovanni Mascellani
ed7a846e2e vkd3d: Only call d3d12_fence_garbage_collect_vk_semaphores_locked() when using binary semaphores.
The function is specific to binary semaphores, and will unconditionally
access the "u.binary" field of struct vkd3d_signaled_semaphore.
2025-01-21 13:45:27 +01:00
Shaun Ren
4fbfb44681 vkd3d-shader/spirv: Emit the tessellator domain for domain shaders.
Commit 1ed8d907b3998b847daa26154ca0261f55f0de23 inadvertently dropped
emitting the tessellator domain for domain shaders. Although Vulkan
environments allow us to write the tessellator domain from the hull
shader, the domain shader, or both, that's not generally true for OpenGL
environments.
2025-01-20 15:50:04 +01:00
Shaun Ren
802d7317cb vkd3d-shader/hlsl: Implement the InterlockedXor() intrinsic. 2025-01-20 15:42:45 +01:00
Shaun Ren
cbd504e888 vkd3d-shader/hlsl: Implement the InterlockedOr() intrinsic. 2025-01-20 15:42:45 +01:00
Shaun Ren
5b9634a7b7 vkd3d-shader/hlsl: Implement the InterlockedMin() intrinsic. 2025-01-20 15:42:43 +01:00
Shaun Ren
63fbe161f2 vkd3d-shader/hlsl: Implement the InterlockedMax() intrinsic. 2025-01-20 15:42:07 +01:00
Shaun Ren
b447fdce51 vkd3d-shader/hlsl: Implement the InterlockedExchange() intrinsic. 2025-01-20 15:41:07 +01:00
Shaun Ren
3fb47373a1 vkd3d-shader/hlsl: Implement the InterlockedCompareStore() intrinsic. 2025-01-20 15:41:07 +01:00
Shaun Ren
22ab08f4d8 vkd3d-shader/hlsl: Implement the InterlockedCompareExchange() intrinsic. 2025-01-20 15:41:07 +01:00
Shaun Ren
3b19a4aaf3 vkd3d-shader/hlsl: Implement the InterlockedAnd() intrinsic. 2025-01-20 15:41:07 +01:00
Shaun Ren
660a71ef22 vkd3d-shader/hlsl: Implement the InterlockedAdd() intrinsic. 2025-01-20 15:40:34 +01:00
Shaun Ren
5f943e9110 tests/hlsl: Add tests for valid destination types of atomic operations. 2025-01-20 15:30:54 +01:00
Shaun Ren
b3c13b443f tests/hlsl: Add tests to check the void return type of atomic ops. 2025-01-20 15:26:10 +01:00
Shaun Ren
728cf1dcfe tests/hlsl: Add tests to check the types of the value arguments of atomic ops. 2025-01-20 15:26:10 +01:00
Shaun Ren
c8b87f9bd9 tests/hlsl: Add a test for UAV InterlockedCompareExchange(). 2025-01-20 15:26:10 +01:00
Shaun Ren
24653b88f3 tests/shader_runner_gl: Bind buffer UAVs for compute shaders. 2025-01-20 15:25:56 +01:00
Shaun Ren
9fab6e4383 tests/shader_runner_gl: Add "opengl" tag. 2025-01-20 15:23:09 +01:00
Shaun Ren
31c3d46925 tests/shader_runner_vulkan: Check if create_shader_stage() fails in create_compute_pipeline(). 2025-01-20 14:59:12 +01:00
Conor McCarthy
10edcec030 vkd3d: Do not require the ALLOW_DEPTH_STENCIL flag for depth/stencil formats in GetCopyableFootprints(). 2025-01-20 14:37:13 +01:00
Conor McCarthy
e99906f05d vkd3d: Return correctly aligned depth/stencil sizes from GetCopyableFootprints(). 2025-01-20 13:59:46 +01:00
Conor McCarthy
1a4dedbc8d vkd3d: Return the correct depth/stencil plane format from GetCopyableFootprints(). 2025-01-20 13:45:16 +01:00
Giovanni Mascellani
17adde7f73 vkd3d: Describe DXGI_UNKNOWN as having one plane.
We're explicitly replacing zero with one in the only place where the
plane count being zero or one makes a difference. It also make sense:
UNKNOWN is used for buffers, which for all intents and purposes have one
plane.
2025-01-20 13:43:36 +01:00
Nikolay Sivov
a082daeb56 vkd3d-shader/hlsl: Implement the isinf() intrinsic.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2025-01-16 19:25:02 +01:00
Henri Verbeet
ce4f2728ba vkd3d-shader/msl: Get rid of a stray vkd3d_string_buffer_printf() in the VEC4 UINT immediate constant handling.
Uncovered by the ininf() test in the next commit. This is why we insist
on test coverage; unfortunately this one slipped through in
fd1beedc07becc7e5e49b64273f7bde7f9a8b2a0.
2025-01-16 19:18:08 +01:00
Francisco Casas
cf19b4da49 vkd3d-shader/hlsl: Specialize lowering SM1 casts to int for vertex shaders.
Vertex shaders do not have CMP, so we use SLT and MAD.

For example, this vertex shader:

    uniform float4 f;

    void main(inout float4 pos : position, out float4 t1 : TEXCOORD1)
    {
        t1 = (int4)f;
    }

results in:

    vs_2_0
    dcl_position v0
    slt r0, c0, -c0
    frc r1, c0
    add r2, -r1, c0
    slt r1, -r1, r1
    mad oT1, r0, r1, r2
    mov oPos, v0

while we have the lower_cmp() pass, each time it is applied many
instructions are generated, so this patch introduces a specialized
version of the cast-to-int lowering for efficiency.
2025-01-16 18:48:35 +01:00
Francisco Casas
2d91bd9200 vkd3d-shader/hlsl: Properly lower casts to int for negative numbers.
While it looks complicated, it is what fxc/d3dcompiler does.

A shader as simple as:

    float4 f;

    float4 main() : sv_target
    {
        return (int4)f;
    }

results in the following instructions:

    ps_2_0
    def c1, 0, 1, 0, 0
    frc r0, c0
    cmp r1, -r0, c1.x, c1.y
    add r0, -r0, c0
    mov r2, c0
    cmp r1, r2, c1.x, r1
    add r0, r0, r1
    mov oC0, r0
2025-01-16 18:46:49 +01:00
Francisco Casas
4f7c117296 tests: Test casting negative floats to int.
Turns out we are not doing this correctly in SM1, because the rounding
should be to the number that is closer to zero and lower_casts_to_int()
doesn't do that.

A vertex shader test is added since in SM1 they must rely on the SLT
operation instead of the CMP operation.
2025-01-16 18:43:12 +01:00