Commit Graph

1056 Commits

Author SHA1 Message Date
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
Henri Verbeet
81a13b9902 vkd3d-shader/spirv: Pass a vsir_data_type to spirv_compiler_emit_store_dst_components(). 2025-10-07 13:11:22 +02:00
Henri Verbeet
b7b62c9f03 vkd3d-shader/spirv: Pass a vsir_data_type to spirv_compiler_emit_store_scalar(). 2025-10-06 15:21:03 +02:00
Henri Verbeet
384f07a140 vkd3d-shader/spirv: Pass a vsir_data_type to spirv_compiler_emit_vector_shuffle(). 2025-10-06 15:21:03 +02:00
Henri Verbeet
beb0b7bcfc vkd3d-shader/spirv: Pass a vsir_data_type to spirv_compiler_emit_swizzle(). 2025-10-06 15:21:03 +02:00
Henri Verbeet
94990717f9 vkd3d-shader/spirv: Pass a vsir_data_type to spirv_compiler_emit_array_variable(). 2025-10-06 15:21:03 +02:00
Henri Verbeet
8923847ed0 vkd3d-shader/spirv: Use vsir_data_type in struct vkd3d_shader_output_info. 2025-10-06 15:21:03 +02:00
Henri Verbeet
0f9a2bdf34 vkd3d-shader/spirv: Use vsir_data_type in struct vkd3d_shader_image. 2025-10-03 00:14:03 +02:00
Henri Verbeet
0f504be1e8 vkd3d-shader/spirv: Use vsir_data_type in struct vkd3d_symbol_resource_data. 2025-10-03 00:14:03 +02:00
Henri Verbeet
9623ca4a6f vkd3d-shader/spirv: Use vsir_data_type in struct vkd3d_shader_register_info. 2025-10-03 00:14:03 +02:00