Commit Graph

1065 Commits

Author SHA1 Message Date
Elizabeth Figura
24d84e2ee2 vkd3d-shader/spirv: Allow swizzling parameters.
This was previously not a concern, since all of our parameter usage involved
trivial swizzles and write masks, but bump parameters will not.
2025-10-27 17:35:14 +01:00
Giovanni Mascellani
86b8f2de35 vkd3d-shader/ir: Error out on unsupported source modifiers. 2025-10-16 15:15:05 +02:00
Giovanni Mascellani
c99c729513 vkd3d-shader/ir: Error out on unsupported destination modifiers. 2025-10-16 15:10:39 +02:00
Giovanni Mascellani
8a100fa06d vkd3d-shader/ir: Ignore and drop PARTIALPRECISION modifiers. 2025-10-16 14:57:56 +02:00
Giovanni Mascellani
737158e7b8 vkd3d-shader/ir: Remove SATURATE modifiers after lowering them. 2025-10-16 14:55:51 +02:00
Henri Verbeet
346b62bc70 vkd3d-shader/spirv: Free the output on failure in spirv_compiler_generate_spirv(). 2025-10-16 14:31:18 +02:00
Conor McCarthy
3943f9aca6 vkd3d-shader/spirv: Handle VSIR_DATA_SNORM and VSIR_DATA_UNORM in image_format_for_image_read().
Typed UAVs can be declared snorm or unorm.
2025-10-15 12:41:49 +02:00
Conor McCarthy
1586c2294a vkd3d-shader/spirv: Handle VSIR_DATA_SNORM and VSIR_DATA_UNORM in spirv_get_type_id(). 2025-10-15 12:41:49 +02:00
Henri Verbeet
808191eb8e vkd3d-shader/spirv: Emit an error for unhandled types in spirv_get_type_id(). 2025-10-15 12:41:49 +02:00
Giovanni Mascellani
835044dd8e vkd3d-shader/ir: Introduce VSIR_OP_SATURATE to represent floating-point clamping to [0, 1]. 2025-10-14 15:53:26 +02:00
Henri Verbeet
11e5b83e79 vkd3d-shader/spirv: Handle VSIR_DATA_MIXED in spirv_get_type_id().
For example, a HLSL shader like this:

    tbuffer t0
    {
        float4 data;
    };

    float4 main() : sv_target
    {
        return data;
    }

would be compiled to the following:

    ps_4_0
    dcl_resource_buffer (mixed,mixed,mixed,mixed) t0
    dcl_output o0.xyzw
    dcl_temps 1
    ld r0.xyzw, l(0, 0, 0, 0), t0.xyzw
    mov o0.xyzw, r0.xyzw
    ret

VSIR_DATA_MIXED used to be mapped to VKD3D_SHADER_COMPONENT_UINT by
vkd3d_component_type_from_data_type(), but we no longer use that.
Found by Giovanni Mascellani.
2025-10-14 15:48:36 +02:00
Giovanni Mascellani
b5b5c67b34 vkd3d-shader/ir: Lower ABSNEG modifiers to instructions. 2025-10-13 19:25:51 +02:00
Giovanni Mascellani
968eb7467c vkd3d-shader/ir: Use VSIR_OP_NEG in insert_fragment_fog_before_ret(), in the common part.
The NEG source modifier is not generated any more during vsir
transformation, so it can be dropped in backends.
2025-10-13 19:13:05 +02:00
Giovanni Mascellani
79736ae6ff vkd3d-shader/ir: Introduce VSIR_OP_NEG to represent floating-point negation. 2025-10-13 19:06:34 +02:00
Henri Verbeet
9de229925d vkd3d-shader/ir: Handle integer division by zero in vsir_program_lower_udiv().
This achieves two things:
  - The GLSL backend no longer needs to handle this by itself. Likwise, the
    MSL backend won't have to either.
  - We no longer handle division by zero for DXIL UDiv and URem instructions,
    which leave this undefined.
2025-10-13 19:00:05 +02:00
Henri Verbeet
90cbe25d1e vkd3d-shader/spirv: Do not handle division by zero for VSIR_OP_IDIV or VSIR_OP_IREM.
These correspond to the DXIL SDiv and SRem instructions, for which division by
zero is undefined. Division by zero is also undefined for DXIL UDiv and URem;
addressing those is slightly more involved.
2025-10-13 19:00:05 +02:00
Henri Verbeet
32a6967778 vkd3d-shader/dxil: Ignore ORDERING_SEQCST.
More recent versions of the Vulkan/SPIR-V validation layers have started
to complain about our usage of "SequentiallyConsistent" in our SPIR-V
output. Specifically, VUID-StandaloneSpirv-MemorySemantics-10866 "Memory
Semantics with SequentiallyConsistent memory order must not be used in
the Vulkan API".

The SPIR-V specification says: "If the declared memory model is Vulkan,
SequentiallyConsistent must not be used." However, we're using the
GLSL450 memory model with SPIR-V 1.3, and "Vulkan" is not available
before SPIR-V 1.5.

The Vulkan specification says "Sequentially consistent atomics and
barriers are not supported and SequentiallyConsistent is treated as
AcquireRelease. SequentiallyConsistent should not be used." in the
"Shader Memory Access Ordering" section.

Those don't quite add up to the "... must not be used in the Vulkan
API", from the validation layers, but it does seem clear that
SequentiallyConsistent isn't actually supported. On the DXIL side, when
targetting SPIR-V with dxc, the generated SPIR-V uses the
"None"/"Relaxed" memory semantics. I wasn't immediately able to find a
reference for what seq_cst is supposed to mean in the context of DXIL,
but "None"/"Relaxed" does seem consistent with how the HLSL
atomic/interlocked intrinsics are expected to behave, as well as with
our behaviour for tpf shaders.
2025-10-09 15:39:41 +02:00
Henri Verbeet
d50503f116 vkd3d-shader/spirv: Pass a vsir_data_type to spirv_compiler_emit_interpolation_decorations(). 2025-10-08 13:32:42 +02:00
Henri Verbeet
8bf97a27bf vkd3d-shader/spirv: Pass a vsir_data_type to spirv_compiler_emit_store_dst_swizzled(). 2025-10-08 13:32:42 +02:00
Henri Verbeet
408eb145a6 vkd3d-shader/spirv: Pass a vsir_data_type to spirv_compiler_emit_load_src_with_type(). 2025-10-08 13:32:42 +02:00
Giovanni Mascellani
112bbbb161 vkd3d-shader/ir: Lower ABS modifiers to instructions. 2025-10-08 13:30:17 +02:00
Henri Verbeet
6b7e4453d5 vkd3d-shader/spirv: Use spirv_get_type_id() in spirv_compiler_emit_atomic_instruction(). 2025-10-07 13:11:22 +02:00
Henri Verbeet
cd5e1b0e20 vkd3d-shader/spirv: Use spirv_get_type_id() in spirv_compiler_emit_store_uav_raw_structured(). 2025-10-07 13:11:22 +02:00
Henri Verbeet
7ffcbaaf66 vkd3d-shader/spirv: Use spirv_get_type_id() in spirv_compiler_emit_ld_raw_structured_srv_uav(). 2025-10-07 13:11:22 +02:00
Henri Verbeet
8f688afc83 vkd3d-shader/spirv: Pass a vsir_data_type to spirv_compiler_get_image_type_id(). 2025-10-07 13:11:22 +02:00