Commit Graph

83 Commits

Author SHA1 Message Date
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
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
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
c1d9e776e2 vkd3d-shader/tpf: Use vsir_register_init() in shader_sm4_read_param(). 2023-09-26 22:07:01 +02:00
Giovanni Mascellani
c052cd8998 vkd3d-shader/ir: Introduce a boilerplate to validate the generated IR.
For the moment the validator is trivial, it never fails. Checks will
be added incrementally.
2023-09-22 11:06:13 +02:00
Giovanni Mascellani
cf871d2cb2 vkd3d-shader: Embed the parsing location in vkd3d_shader_instruction.
So that it can be used for printing meaningful error locations by
downstream processors.
2023-09-22 11:06:12 +02:00
Giovanni Mascellani
78220ed07e vkd3d-shader/tpf: Destroy the SM4 parser on parsing errors. 2023-09-22 11:06:10 +02:00
Giovanni Mascellani
05af25eecb vkd3d-shader: Rename shader_instruction_init(). 2023-09-22 11:06:05 +02:00
Nikolay Sivov
1002a6b357 vkd3d-shader/tpf: Use 'movc' to implement ternary operator.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-09-07 19:15:25 +02:00
Conor McCarthy
61841e9423 vkd3d-shader/tpf: Handle the swizzle type bitfield in dst param tokens. 2023-08-28 20:39:49 +02:00
Conor McCarthy
eddae47062 vkd3d-shader/tpf: Handle the dimension bitfield in dst param tokens.
A zero mask is still emitted for some scalar registers. This has no
effect on current tests, but keeping the correction is probably a good
idea.
2023-08-28 20:39:48 +02:00
Conor McCarthy
92021b7a3c vkd3d-shader/tpf: Use the default vec4 swizzle if a src param contains a mask. 2023-08-28 20:39:46 +02:00
Conor McCarthy
7e5d9e3b6f vkd3d-shader/tpf: Handle the dimension bitfield in src param tokens. 2023-08-28 20:39:45 +02:00
Conor McCarthy
5c706152fa vkd3d-shader/tpf: Validate the src register of case conditions.
Case values are constants in TPF.
2023-08-28 20:39:43 +02:00
Francisco Casas
ed9e236b01 vkd3d-shader/tpf: Avoid reading constant value components beyond type's width (Valgrind).
We are passing map writemasks that may have more components than the
constant's data type, so a (j < width) check is added to avoid reading
components from the constant that are not intended to be used.

Remaining values in the register are initialized to zero.
2023-08-24 21:43:55 +02:00
Francisco Casas
81afe43569 vkd3d-shader/tpf: Put the actual bind count in the RDEF table. 2023-08-15 21:51:29 +02:00
Francisco Casas
7eba063136 vkd3d-shader/hlsl: Rename hlsl_reg.bind_count to hlsl_reg.allocation_size.
We have to distinguish between the "bind count" and the "allocation size"
of variables.

The "allocation size" affects the starting register id for the resource to
be allocated next, while the "bind count" is determined by the last field
actually used. The former may be larger than the latter.

What we are currently calling hlsl_reg.bind_count is actually the
"allocation size", so a rename is in order.

The real "bind count", which will be introduced in following patches,
is important because it is what should be shown in the RDEF table and
some resource allocation rules depend on it.

For instance, for this shader:

    texture2D texs[3];
    texture2D tex;

    float4 main() : sv_target
    {
        return texs[0].Load(int3(0, 0, 0)) + tex.Load(int3(0, 0, 0));
    }

the variable "texs" has a "bind count" of 1, but an "allocation size" of
3:

    // Resource Bindings:
    //
    // Name                                 Type  Format         Dim      HLSL Bind  Count
    // ------------------------------ ---------- ------- ----------- -------------- ------
    // texs                              texture  float4          2d             t0      1
    // tex                               texture  float4          2d             t3      1
2023-08-15 21:51:27 +02:00
Francisco Casas
8484bd59a6 vkd3d-shader/tpf: Separate dst register write function. 2023-08-14 18:38:08 +02:00
Francisco Casas
d1c45fe2f0 vkd3d-shader/tpf: Separate src register write function. 2023-08-14 18:38:07 +02:00
Francisco Casas
2258e9d0f3 vkd3d-shader/tpf: Make register_type_table an array of structs with lookup tables. 2023-08-14 18:38:06 +02:00
Francisco Casas
c77e5f1c1f vkd3d-shader/tpf: Introduce struct tpf_writer to group sm4 write arguments.
We will add register information lookup tables on this struct later.
They will be used by sm4_encode_register(), and thus, they will be
required by write_sm4_instruction().
2023-08-14 18:38:05 +02:00
Francisco Casas
a584499c8a vkd3d-shader/tpf: Use struct vkd3d_shader_register_index in sm4_register.idx[]. 2023-08-14 18:38:04 +02:00
Francisco Casas
fc589add49 vkd3d-shader/tpf: Allow passing NULL register type on hlsl_sm4_register_from_semantic(). 2023-08-14 18:38:03 +02:00
Francisco Casas
8a6a620ee2 vkd3d-shader/tpf: Use enum vkd3d_shader_register_type in sm4_register.type. 2023-08-14 18:38:01 +02:00
Zebediah Figura
9a80ff28e4 vkd3d-shader/tpf: Check buffer->status in add_section(). 2023-08-02 20:19:00 +09:00
Nikolay Sivov
bfdd5c142d vkd3d-shader/tpf: Add support for writing 'resinfo' instruction.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-07-31 21:07:50 +09:00
Nikolay Sivov
78719dc814 vkd3d-shader/tpf: Add support for writing 'sampleinfo' instruction.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-07-31 21:07:49 +09:00
Nikolay Sivov
d50b5fe767 vkd3d-shader/hlsl: Parse GetDimensions() method.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-07-31 21:07:48 +09:00
Nikolay Sivov
63631a8fd4 vkd3d-shader/tpf: Support some of the UAV types when writing RDEF records.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-07-17 22:56:05 +02:00
Zebediah Figura
a55973d695 vkd3d-shader/hlsl: Lower combined samplers to separate sampler and texture objects for SM4.
Co-authored-by: Francisco Casas <fcasas@codeweavers.com>
2023-07-17 22:55:51 +02:00
Francisco Casas
c58d666d1b vkd3d-shader/hlsl: Handle resource components individually for SM 5.0. 2023-07-17 22:55:40 +02:00
Francisco Casas
8f8c7a02ee vkd3d-shader/tpf: Introduce struct extern_resource.
This struct is required for handling both whole-variable resources for
SM < 5 and single-component resources for SM 5 in the same way, when
writting the RDEF block and resource declarations within the shader.
2023-07-17 22:55:39 +02:00
Francisco Casas
ae6bc398d6 vkd3d-shader/hlsl: Allow derefs to provide the data_type.
After lowering the derefs path to a single offset node, there was no way
of knowing the type of the referenced part of the variable. This little
modification allows to avoid having to pass the data type everywhere and
it is required for supporting instructions that reference objects
components within struct types.

Since deref->data_type allows us to retrieve the type of the deref,
deref->offset_regset is no longer necessary.
2023-07-17 22:55:36 +02:00
Zebediah Figura
e489098878 vkd3d-shader: Record a global temporary count per sm4 shader.
Store it in the shader_desc, and declare temps from that when compiling SPIR-V,
instead of parsing dcl_instructions.

As part of this change, we declare a single, global temps array (with Private
scope instead of Function) which is as large as the maximum of all dcl_temps
instructions. It is not clear to me whether this will improve, hurt, or have no
significant effect on the lower-level compiler. An alternative is to still
redeclare a new temps array every time (although still with a smaller size).
2023-07-04 22:39:45 +02:00
Francisco Casas
e4d94d955c vkd3d-shader/hlsl: Support fine derivates. 2023-07-04 22:39:12 +02:00
Francisco Casas
ff31284f8d vkd3d-shader/hlsl: Support coarse derivates. 2023-07-04 22:39:10 +02:00
Conor McCarthy
6775f7ba66 vkd3d-shader/dxil: Read and validate DXIL bitcode unabbreviated blocks. 2023-06-28 21:40:34 +02:00
Nikolay Sivov
4ed60cda13 vkd3d-shader: Remove extra newlines from compiler messages. 2023-06-27 22:34:19 +02:00
Nikolay Sivov
8d84e206ab vkd3d-shader/hlsl: Parse clip() function.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-06-27 22:33:48 +02:00
Nikolay Sivov
b40179da3a vkd3d-shader/hlsl: Add a parameter for jump nodes and use it for 'discard'. 2023-06-27 22:33:47 +02:00
Zebediah Figura
974528cbe3 vkd3d-shader/hlsl: Only read used coordinates in encode_texel_offset_as_aoffimmi().
The V and W offsets may be uninitialized, which may spuriously trigger "out of range" errors.
2023-06-08 18:50:28 +02:00
Zebediah Figura
7b476573ff vkd3d-shader/hlsl: Use the writemask to map the coords swizzle for load instructions.
Instead of modifying the swizzle after calling sm4_src_from_node().

This fixes the case where sm4_src_from_node() returns an immediate constant.

Fixes: a471c5567a
2023-06-08 18:50:26 +02:00
Giovanni Mascellani
7c360330d7 vkd3d-shader/tpf: Do not emit HLSL_IR_CONSTANT instructions.
Since constants are now inlined.
2023-05-29 20:21:29 +02:00
Giovanni Mascellani
a471c5567a vkd3d-shader/tpf: Emit constant values inline. 2023-05-29 20:21:27 +02:00