Commit Graph

2017 Commits

Author SHA1 Message Date
Francisco Casas
014960b64b vkd3d-shader/tpf: Use lookup table for opcode_info_from_sm4().
Makes get_opcode_info() and thus, tpf reading a little faster.
2023-10-05 16:16:27 +02:00
Francisco Casas
88b644a11d vkd3d-shader/tpf: Don't store sm4 instruction extra bits in the opcode.
Adding extra bits to instr->opcode doesn't seem correct, given that it
is an enum.

For instance, get_opcode_info() would return NULL if additional bits are
added to instr->opcode. This is not a problem now because that function
is called when reading and not writing.
2023-10-05 16:16:24 +02:00
Francisco Casas
0a5fa80f02 vkd3d-shader/tpf: Apply mask to swizzle when swizzle type is scalar.
In native's output, for scalar swizzles only the first component of the
swizzle is written, the others are left as zero.
2023-10-05 16:16:21 +02:00
Francisco Casas
f06169afc5 vkd3d-shader/tpf: Don't calculate instruction size in advance.
Co-authored-by: Henri Verbeet <hverbeet@codeweavers.com>
2023-10-05 16:16:19 +02:00
Nikolay Sivov
7c378cc6f9 vkd3d-shader/hlsl: Remove conditional branching when condition is a compile time constant.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-10-05 16:16:09 +02:00
Nikolay Sivov
f3389789b2 vkd3d-shader: Add constant folding for 'rsq'.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-10-05 16:16:03 +02:00
Nikolay Sivov
a58c659b10 vkd3d-shader/hlsl: Add constant folding for binary complement operator.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-10-05 16:15:56 +02:00
Nikolay Sivov
8ebccad3c9 vkd3d-shader/hlsl: Add constant folding for rshift.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-10-05 16:15:54 +02:00
Nikolay Sivov
6e74819eb7 vkd3d-shader/hlsl: Add constant folding for lshift.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-10-05 16:15:52 +02:00
Nikolay Sivov
8c9d65d6b3 vkd3d-shader/hlsl: Add constant folding for logical 'not', for bools.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-10-05 16:15:50 +02:00
Francisco Casas
4ab6572be7 vkd3d-shader/hlsl: Replace hlsl_type_get_regset() uses with hlsl_deref_get_regset(). 2023-10-05 16:15:37 +02:00
Francisco Casas
a214b7374b vkd3d-shader/hlsl: Avoid hlsl_type_get_regset() in allocate_register_reservations(). 2023-10-05 16:15:34 +02:00
Francisco Casas
cd0e3786c3 vkd3d-shader/hlsl: Avoid hlsl_type_get_regset() in sm4_get_extern_resources(). 2023-10-05 16:15:28 +02:00
Francisco Casas
dfce1e7f4a vkd3d-shader/hlsl: Make regset an output argument in hlsl_type_get_component_offset().
Components only span across a single regset, so instead of expecting the
regset as input for the offset, hlsl_type_get_component_offset() can
actually retrieve it.
2023-10-05 16:15:26 +02:00
Nikolay Sivov
b5c0c9c22f vkd3d-shader/hlsl: Add fwidth() function.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-10-05 16:15:10 +02:00
Alistair Leslie-Hughes
71715cc434 vkd3d-shader: Fix compiler warning.
vkd3d-shader/tpf.c:3810:39: warning: passing argument 2 of ‘sm4_register_from_node’ from incompatible pointer type [-Wincompatible-pointer-types]
vkd3d-shader/tpf.c:4750:59: warning: passing argument 3 of ‘sm4_register_from_deref’ from incompatible pointer type [-Wincompatible-pointer-types]

Change to use uint32_t as requested.
2023-10-05 16:14:44 +02:00
Francisco Casas
c92772657f vkd3d-shader/tpf: Replace sm4_src_register with vkd3d_shader_src_param. 2023-10-03 21:27:48 +02:00
Francisco Casas
13f62e60e1 vkd3d-shader/tpf: Remove sm4_src_register.swizzle_type. 2023-10-03 21:27:47 +02:00
Francisco Casas
32f03468fc vkd3d-shader/tpf: Make sm4_src_register.mod a vkd3d_shader_src_modifier enum. 2023-10-03 21:27:45 +02:00
Francisco Casas
f50d0ae2cb vkd3d-shader/tpf: Store vkd3d-shader swizzles in sm4_src_register.swizzle. 2023-09-28 23:13:16 +02:00
Francisco Casas
ef9ec28eb0 vkd3d-shader/tpf: Replace sm4_dst_register with vkd3d_shader_dst_param. 2023-09-28 23:13:14 +02:00
Francisco Casas
d41d8f8771 vkd3d-shader/tpf: Rename sm4_dst_register.writemask to write_mask. 2023-09-28 23:13:12 +02:00
Francisco Casas
123e399b89 vkd3d-shader/d3d-asm: Don't print offset for DEPTHOUT registers.
This register is unique and thus is not accompanied with an offset in
the native disassembler output.
2023-09-27 22:34:48 +02:00
Francisco Casas
ef1567c17b vkd3d-shader/d3d-asm: Use vkd3d_shader_register.dimension to know when to dump writemask.
This change ensures that we don't dump the writemask for registers that
have a scalar dimension.

For instance, for this shader:

    float r;

    float4 main(out float d : DEPTH) : sv_target
    {
        d = r;
        return 0;
    }

we now correctly dump

    dcl_output oDepth

instead of

    dcl_output oDepth.x
2023-09-27 22:34:47 +02:00
Francisco Casas
a358722f71 vkd3d-shader/d3d-asm: Use vkd3d_shader_register.dimension to know when to dump swizzle.
The assumption that sampler registers never have a swizzle is not
totally correct.

For instance, for the following shader:

    Texture2D tex;
    sampler sam;

    float4 main() : sv_target
    {
        return tex.GatherGreen(sam, float2(0, 0));
    }

the gather instruction is being disassembled as

  gather4_indexable(texture2d) o0.xyzw, l(0.0, 0.0, 0.0, 0.0), t0.xyzw, s0

instead of

  gather4_indexable(texture2d)(float,float,float,float) o0.xyzw, l(0.0, 0.0, 0.0, 0.0), t0.xyzw, s0.y

(notice the missing swizzle in the last parameter s0).

This is because the Gather instructions give the sampler register a vec4
dimension (and scalar swizzle type) to indicate the channel for the
gather operation.

The solution is using the new vkd3d_shader_register.dimension instead of
checking the swizzle type.
2023-09-27 22:34:46 +02:00
Francisco Casas
8e0fe29bfc vkd3d-shader/tpf: Replace sm4_register with vkd3d_shader_register. 2023-09-27 22:34:31 +02:00
Francisco Casas
10bbc7eda5 vkd3d-shader/tpf: Move sm4_register.mod to sm4_src_register. 2023-09-27 22:34:30 +02:00
Francisco Casas
8124ba3a54 vkd3d-shader/tpf: Put sm4_register.immconst_uint inside a union. 2023-09-27 22:34:28 +02:00
Francisco Casas
0c8b74cb39 vkd3d-shader/tpf: Turn sm4_register.dim into an enum vkd3d_shader_dimension. 2023-09-27 22:34:26 +02:00
Conor McCarthy
f61c853f61 vkd3d-shader/dxil: Convert into an error the warning for an unhandled instrinsic. 2023-09-26 22:07:51 +02:00
Conor McCarthy
b30b95e824 vkd3d-shader/dxil: Do not access null code blocks on failure. 2023-09-26 22:07:50 +02:00
Francisco Casas
74d79c7e45 vkd3d-shader/d3dbc: Initialize register dimension for all register types. 2023-09-26 22:07:06 +02:00
Francisco Casas
33f47c5ae9 vkd3d-shader/tpf: Parse register dimension for all register types. 2023-09-26 22:07:04 +02:00
Francisco Casas
e904660497 vkd3d-shader: Turn vkd3d_shader_register.immconst_type into vkd3d_shader_register.dimension. 2023-09-26 22:07:04 +02:00
Francisco Casas
dc35125d73 vkd3d-shader/tpf: Use vsir_register_init() in shader_sm1_parse_dst_param(). 2023-09-26 22:07:03 +02:00
Francisco Casas
51aa5a45e9 vkd3d-shader/tpf: Use vsir_register_init() in shader_sm1_parse_src_param(). 2023-09-26 22:07:02 +02:00
Francisco Casas
c1d9e776e2 vkd3d-shader/tpf: Use vsir_register_init() in shader_sm4_read_param(). 2023-09-26 22:07:01 +02:00
Francisco Casas
6f5cb219f4 vkd3d-shader/spirv: Use vsir_register_init() in spirv_compiler_emit_default_control_point_phase(). 2023-09-26 22:07:00 +02:00
Francisco Casas
81802e27d0 vkd3d-shader/spirv: Use vsir_register_init() in spirv_compiler_emit_resource_declaration(). 2023-09-26 22:06:59 +02:00
Francisco Casas
314c6e4808 vkd3d-shader/spirv: Use vsir_register_init() in spirv_compiler_emit_sampler_declaration(). 2023-09-26 22:06:58 +02:00
Francisco Casas
b2f262467f vkd3d-shader/spirv: Use vsir_register_init() in spirv_compiler_emit_dcl_immediate_constant_buffer(). 2023-09-26 22:06:56 +02:00
Francisco Casas
67f0196c33 vkd3d-shader/spirv: Use vsir_register_init() in spirv_compiler_emit_cbv_declaration(). 2023-09-26 22:06:55 +02:00
Francisco Casas
04529bc0b7 vkd3d-shader/spirv: Use vsir_register_init() in spirv_compiler_emit_dcl_indexable_temp(). 2023-09-26 22:06:54 +02:00
Francisco Casas
e174f6b413 vkd3d-shader/spirv: Use vsir_register_init() in spirv_compiler_emit_hull_shader_builtins(). 2023-09-26 22:06:53 +02:00
Francisco Casas
89d7bd7a81 vkd3d-shader/spirv: Use vsir_register_init() in spirv_compiler_get_invocation_id(). 2023-09-26 22:06:52 +02:00
Francisco Casas
5d6899888d vkd3d-shader: Rename shader_register_init() to vsir_register_init(). 2023-09-26 22:06:50 +02:00
Giovanni Mascellani
d9c8b49ea0 vkd3d-shader/ir: Remove dead code during normalisation.
The SPIR-V backend generates invalid SPIR-V code when
VSIR has dead code (except for NOPs).
2023-09-25 22:07:27 +02:00
Zebediah Figura
fcda20a8c3 vkd3d-shader/hlsl: Use lower_ir() for lower_sqrt(). 2023-09-25 22:07:23 +02:00
Zebediah Figura
496a3a2093 vkd3d-shader/hlsl: Use lower_ir() for lower_division(). 2023-09-25 22:07:22 +02:00
Zebediah Figura
ecd781e809 vkd3d-shader/hlsl: Use lower_ir() for lower_int_abs(). 2023-09-25 22:07:21 +02:00