Commit Graph

2130 Commits

Author SHA1 Message Date
Zebediah Figura
7d9b24fe11 vkd3d-shader/hlsl: Pass hlsl_constant_value and hlsl_type pointers to fold_neg(). 2023-05-23 21:08:19 +02:00
Zebediah Figura
eb04829e66 vkd3d-shader/hlsl: Pass hlsl_constant_value and hlsl_type pointers to fold_cast(). 2023-05-23 21:08:17 +02:00
Ethan Lee
24d4ab7fb3 vkd3d-shader/hlsl: Add support for SampleGrad() method.
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
2023-05-23 21:07:49 +02:00
Nikolay Sivov
cf8cacd336 vkd3d-shader/hlsl: Improve UAV format type checking for buffer types.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-05-22 22:03:27 +02:00
Nikolay Sivov
cff22ecde8 vkd3d-shader/hlsl: Add support for writing RWStructuredBuffer declarations.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-05-22 22:03:26 +02:00
Nikolay Sivov
3de824bfd8 vkd3d-shader/hlsl: Add support for RWBuffer object.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-05-22 22:03:24 +02:00
Nikolay Sivov
44a90f5d41 vkd3d-shader: Fix dcl_uav_typed_* formatting.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-05-22 22:03:24 +02:00
Ethan Lee
fb9328d030 vkd3d-shader/hlsl: Fold constant integral abs().
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
2023-05-22 22:03:18 +02:00
Nikolay Sivov
dfa0076473 vkd3d-shader/hlsl: Add support for sample index argument in Load(). 2023-05-22 22:03:12 +02:00
Nikolay Sivov
dc41444941 vkd3d-shader/hlsl: Convert ternary operator true/false values to a common type. 2023-05-09 21:51:46 +02:00
Conor McCarthy
be4a71da7d vkd3d-shader/tpf: Validate input and output index ranges for default control point phases. 2023-05-09 21:51:33 +02:00
Conor McCarthy
3e50c4d13b vkd3d-shader/tpf: Remove an unnecessary carriage return from a parser error message. 2023-05-09 21:51:32 +02:00
Conor McCarthy
6dd1b01284 vkd3d-shader/tpf: Validate index range declarations. 2023-05-09 21:51:31 +02:00
Conor McCarthy
d565fbdcd6 vkd3d-shader/tpf: Validate input/output registers. 2023-05-09 21:51:29 +02:00
Conor McCarthy
2166088b0b vkd3d-shader/tpf: Validate signature element masks. 2023-05-09 21:51:28 +02:00
Conor McCarthy
b8e6482365 vkd3d-shader/tpf: Validate signature element register indices. 2023-05-09 21:51:19 +02:00
Conor McCarthy
adf7db021c vkd3d-shader/tpf: Validate input/output register index counts. 2023-05-09 21:51:17 +02:00
Zebediah Figura
b1bc4044ae vkd3d-shader/hlsl: Use %option nodefault in the lexer. 2023-05-09 21:51:09 +02:00
Zebediah Figura
600fdcd112 vkd3d-shader/hlsl: Lex invalid characters in #line directives.
Avoid letting them fall through to the default rule.
2023-05-09 21:51:08 +02:00
Zebediah Figura
7b8845474d vkd3d-shader/preproc: Use %option nodefault in the lexer. 2023-05-09 21:51:06 +02:00
Zebediah Figura
871cf0b4b5 vkd3d-shader/preproc: Ignore newlines in C comments.
Avoid letting them fall through to the default rule.
2023-05-09 21:51:05 +02:00
Zebediah Figura
ddbfd88e74 vkd3d-shader/preproc: Lex whitespace and invalid characters in #include and #line directives.
Avoid letting them fall through to the default rule.

A syntax error will be emitted by the parser.
2023-05-09 21:51:01 +02:00
Zebediah Figura
da7670f7c8 vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from add_conditional(). 2023-05-09 21:50:37 +02:00
Zebediah Figura
39bbac3cca vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_uint_constant(). 2023-05-09 21:50:36 +02:00
Zebediah Figura
b991f98e2f vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_swizzle(). 2023-05-09 21:50:35 +02:00
Zebediah Figura
306ae40696 vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_store_index(). 2023-05-09 21:50:34 +02:00
Zebediah Figura
29a2b87f54 vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_simple_store(). 2023-05-09 21:50:33 +02:00
Zebediah Figura
145a2dfd2d vkd3d-shader/hlsl: Return bool from hlsl_new_store_component(). 2023-05-09 21:50:31 +02:00
Francisco Casas
fd38c58112 vkd3d-shader/hlsl: Introduce hlsl_calloc().
This is just a wrapper of vkd3d_calloc(), that has the advantage of
checking for multiplication overflow.
2023-05-08 20:24:15 +02:00
Francisco Casas
ef7cf9b1ad vkd3d-shader/hlsl: Support resource arrays when writting SM4.
The new fixmes can be triggered in presence of object components within
structs (for SM5).

In shaders such as this one:

    struct apple
    {
        Texture2D tex : TEX;
        float4 color : COLOR;
    };

    float4 main(struct apple input) : sv_target
    {
        return input.tex.Load(int3(1, 2, 3));
    }

Or this one:

    struct
    {
        Texture2D tex;
        float4 color;
    } s;

    float4 main() : sv_target
    {
        return s.tex.Load(int3(1, 2, 3));
    }
2023-05-08 20:24:15 +02:00
Francisco Casas
a91e6d4563 vkd3d-shader/hlsl: Write resource loads in SM1. 2023-05-08 20:24:15 +02:00
Francisco Casas
96c844ffb8 vkd3d-shader/hlsl: Write sampler declarations in SM1. 2023-05-08 20:24:15 +02:00
Francisco Casas
3e9a9c5051 vkd3d-shader/hlsl: Track objects sampling dimension. 2023-05-08 20:24:15 +02:00
Francisco Casas
4dba38e6c8 vkd3d-shader/hlsl: Track object components usage and allocate registers accordingly. 2023-05-08 20:24:14 +02:00
Francisco Casas
6f71077e3e vkd3d-shader/hlsl: Skip object components when creating input/output copies. 2023-05-08 20:22:19 +02:00
Francisco Casas
4413f6b64b vkd3d-shader/hlsl: Add fixme for uniform copies for objects within structs. 2023-05-08 20:22:17 +02:00
Francisco Casas
69ff249ef4 vkd3d-shader/hlsl: Support multiple-register variables in object regsets.
Variables that contain more than one object (arrays or structs) require
the allocation of contiguous registers in the respective object
register spaces.
2023-05-08 20:22:14 +02:00
Nikolay Sivov
7516adeeae vkd3d-shader/hlsl: Add support for fmod() intrinsic. 2023-05-08 20:21:52 +02:00
Zebediah Figura
8b57a612d7 vkd3d-shader/hlsl: Map the colour output for ps_1_* to r0. 2023-05-03 21:12:39 +02:00
Zebediah Figura
b2959739ed vkd3d-shader/hlsl: Rewrite the register allocator to allow allocating in multiple passes.
We will need this in order to allocate some "special" registers: ps_1_* output, sincos output, etc.
2023-05-03 21:12:38 +02:00
Zebediah Figura
71d8ff85c6 vkd3d-shader/hlsl: Avoid leaking the allocator register map in allocate_const_registers(). 2023-05-03 21:12:37 +02:00
Zebediah Figura
c57ac0b207 vkd3d-shader/hlsl: Rename struct liveness to struct register_allocator. 2023-05-03 21:12:34 +02:00
Conor McCarthy
a0a18b1620 vkd3d-shader: Introduce an internal shader signature structure.
A register count is required for Shader Model 6 signatures, including
those normalised from earlier models.
2023-05-03 21:12:07 +02:00
Conor McCarthy
5ae068168c vkd3d-shader/tpf: Return an error from vkd3d_shader_sm4_parser_create() if the parser failed. 2023-05-03 21:12:06 +02:00
Conor McCarthy
85eb231492 vkd3d-shader/d3dbc: Return an error from vkd3d_shader_sm1_parser_create() if the parser failed. 2023-05-03 21:12:03 +02:00
Francisco Casas
34ddc13390 vkd3d-shader/hlsl: Don't keep the implicit mipmap level on hlsl_ir_index. 2023-05-03 21:11:59 +02:00
Francisco Casas
4aaf6b8895 vkd3d-shader/hlsl: Use hlsl_ir_index for resource access.
This patch makes index expressions on resources hlsl_ir_index nodes
instead of hlsl_ir_resource_load nodes, because it is not known if they
will be used later as the lhs of an hlsl_ir_resource_store.

For now, the only benefit is consistency.
2023-05-03 21:11:56 +02:00
Nikolay Sivov
87037d3748 vkd3d-shader/hlsl: Implement asfloat().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-05-02 20:46:16 +02:00
Nikolay Sivov
7d41cf4440 vkd3d-shader/hlsl: Partially implement static expressions evaluation. 2023-05-02 20:46:08 +02:00
Zebediah Figura
6de904b448 vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_resource_store(). 2023-05-02 20:46:03 +02:00
Zebediah Figura
3cc18f1e9f vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_resource_load(). 2023-05-02 20:46:02 +02:00
Zebediah Figura
8485b2ee95 vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_loop(). 2023-05-02 20:46:00 +02:00
Zebediah Figura
3ca9656e84 vkd3d-shader/hlsl: Pass an hlsl_block pointer to hlsl_new_loop(). 2023-05-02 20:45:59 +02:00
Zebediah Figura
e848c57b46 vkd3d-shader/hlsl: Reuse the "init" instruction list if possible in create_loop(). 2023-05-02 20:45:57 +02:00
Henri Verbeet
3f8aa0e272 vkd3d-shader/d3d-asm: Rename trace.c to d3d_asm.c. 2023-05-02 20:45:33 +02:00
Henri Verbeet
73dc62aebf vkd3d-shader: Get rid of the unused vkd3d_shader_src_param_entry structure. 2023-05-02 20:45:27 +02:00
Francisco Casas
abb207fab0 vkd3d-shader/hlsl: Always specify resource on intrinsic_tex().
Otherwise, in the added test, we get:

vkd3d-compiler: vkd3d-shader/hlsl.c:452: hlsl_init_deref_from_index_chain: Assertion `chain' failed.

because on the path that triggers the following error:

E5002: Wrong type for argument 1 of 'tex3D': expected 'sampler' or 'sampler3D', but got 'sampler2D'.

a NULL params.resource is passed to hlsl_new_resource_load() and
then to hlsl_init_deref_from_index_chain().
2023-05-01 22:18:46 +02:00
Ethan Lee
5d735f3b0e vkd3d-shader/hlsl: Add support for sign() intrinsic.
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
2023-05-01 22:18:41 +02:00
Zebediah Figura
6e677def71 vkd3d-shader/hlsl: Normalize bools when loading from uniforms or vertex input. 2023-05-01 22:18:36 +02:00
Zebediah Figura
834497d5ac vkd3d-shader/hlsl: Introduce an sm4_src_from_constant_value() helper. 2023-05-01 22:18:35 +02:00
Zebediah Figura
0a44e6043e vkd3d-shader/hlsl: Put the hlsl_ir_constant value in a structure. 2023-05-01 22:18:33 +02:00
Francisco Casas
dcd991deda vkd3d-shader/hlsl: Consider duplicated input semantic types equivalent in SM1. 2023-05-01 22:18:27 +02:00
Francisco Casas
34431239a5 vkd3d-shader/hlsl: Handle possibly different types in input semantic var load.
Since in SM1 all vector types use 4 register components, and since SM1
doesn't consider vectors of different dimx incompatible, it is necessary
to ensure that the semantic var is created with dimx=4, and to add a
cast node.
2023-05-01 22:18:26 +02:00
Francisco Casas
537d7c27a2 vkd3d-shader/hlsl: Error out when a semantic is used with incompatible types.
Considering row vectors from row_major matrices as having a different
layout as regular vectors, and error out in that case, is left as todo.
2023-05-01 22:18:24 +02:00
Francisco Casas
d96e9665b1 vkd3d-shader/hlsl: Error out when an output semantic is used more than once.
The use of the hlsl_semantic.reported_duplicated_output_next_index field
allows reporting multiple overlapping indexes, such as in the following
vertex shader:

    void main(out float1x3 x : OVERLAP0, out float1x3 y : OVERLAP1)
    {
        x = float3(1.0, 2.0, 3.2);
        y = float3(5.0, 6.0, 5.0);
    }

    apple.hlsl:1:41: E5013: Output semantic "OVERLAP1" is used multiple times.
    apple.hlsl:1:13: First use of "OVERLAP1" is here.
    apple.hlsl:1:41: E5013: Output semantic "OVERLAP2" is used multiple times.
    apple.hlsl:1:13: First use of "OVERLAP2" is here.

While at the same time avoiding reporting overlaps more than once for
large arrays:

    struct apple
    {
        float2 p : sv_position;
    };

    void main(out apple aps[4])
    {
    }

    apple.hlsl:3:8: E5013: Output semantic "sv_position0" is used multiple times.
    apple.hlsl:3:8: First use of "sv_position0" is here.
2023-05-01 22:18:22 +02:00
Francisco Casas
edc72fdefc vkd3d-shader/hlsl: Support semantics for array types. 2023-05-01 22:18:21 +02:00
Francisco Casas
a488889494 vkd3d-shader/hlsl: Don't create semantic vars more than once. 2023-05-01 22:18:20 +02:00
Francisco Casas
b589c2b32d vkd3d-shader/hlsl: Move get_array_size() and get_array_type() to hlsl.c. 2023-05-01 22:18:19 +02:00
Francisco Casas
61c72a4fd1 vkd3d-shader/hlsl: Avoid invalid input/output copies for non-numeric types. 2023-05-01 22:18:17 +02:00
Nikolay Sivov
7ba373946b vkd3d-shader/hlsl: Implement D3DCOLORtoUBYTE4() function. 2023-04-28 21:04:13 +02:00
Nikolay Sivov
4b3707aeb4 vkd3d-shader/hlsl: Partially implement trunc().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-28 21:04:11 +02:00
Ethan Lee
138c32ce88 vkd3d-shader/hlsl: Add support for ddx(), ddy() intrinsics.
SPIR-V already handled DSX/DSY, so only D3DBC/TPF needed new case blocks.

Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
2023-04-28 21:03:40 +02:00
Nikolay Sivov
af4bb03795 vkd3d-shader/hlsl: Implement SampleBias() method.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-26 22:46:55 +02:00
Nikolay Sivov
c166ab9727 vkd3d-shader/hlsl: Add separate helpers to generate object methods.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-26 22:46:53 +02:00
Nikolay Sivov
59c63ec584 vkd3d-shader/hlsl: Handle discard statement.
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-26 22:46:50 +02:00
Nikolay Sivov
6da7d16d4c vkd3d-shader/trace: Add separate id for discard.
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
2023-04-26 22:46:49 +02:00
Zebediah Figura
b46df551eb vkd3d-shader/tpf: Return unsigned int from hlsl_sm4_register_from_semantic().
Fix a compile warning:

../vkd3d/libs/vkd3d-shader/hlsl_codegen.c: In function 'allocate_semantic_register':
../vkd3d/libs/vkd3d-shader/hlsl_codegen.c:2947:85: error: passing argument 4 of 'hlsl_sm4_register_from_semantic' from incompatible pointer type [-Werror=incompatible-pointer-types]
 2947 |         if ((builtin = hlsl_sm4_register_from_semantic(ctx, &var->semantic, output, &type, NULL, &has_idx)))
      |                                                                                     ^~~~~
      |                                                                                     |
      |                                                                                     unsigned int *
In file included from ../vkd3d/libs/vkd3d-shader/hlsl_codegen.c:21:
../vkd3d/libs/vkd3d-shader/hlsl.h:1171:52: note: expected 'enum vkd3d_sm4_register_type *' but argument is of type 'unsigned int *'
 1171 |         bool output, enum vkd3d_sm4_register_type *type, enum vkd3d_sm4_swizzle_type *swizzle_type, bool *has_idx);
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
2023-04-21 20:55:56 +02:00
Nikolay Sivov
317b8aa039 vkd3d-shader/hlsl: Ignore "unroll" attribute for loops. 2023-04-21 20:55:48 +02:00
Henri Verbeet
8e0df3f720 vkd3d-shader/sm1: Merge hlsl_sm1.c into d3dbc.c. 2023-04-20 22:54:32 +02:00
Henri Verbeet
99bc07ccf5 vkd3d-shader/sm4: Merge sm4.h into tpf.c. 2023-04-20 22:54:31 +02:00
Henri Verbeet
7800c7b40f vkd3d-shader/sm4: Rename hlsl_sm4.c to tpf.c. 2023-04-20 22:54:30 +02:00
Henri Verbeet
804e315b68 vkd3d-shader/sm4: Move the TPF parser from dxbc.c to hlsl_sm4.c. 2023-04-20 22:54:28 +02:00
Zebediah Figura
0959c6663f vkd3d-shader/hlsl: Remove an unused local variable from create_loop(). 2023-04-20 22:54:13 +02:00
Zebediah Figura
39a03cfd22 vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_load_component(). 2023-04-20 22:54:12 +02:00
Zebediah Figura
a98686ed78 vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from add_load_component(). 2023-04-20 22:54:11 +02:00
Zebediah Figura
e5ec431784 vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_jump(). 2023-04-20 22:54:10 +02:00
Zebediah Figura
dfe056596a vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_int_constant(). 2023-04-20 22:54:09 +02:00
Ethan Lee
0668d32631 vkd3d-shader/hlsl: Add support for any() intrinsic.
For now, this is limited to float and bool, scalar and vector. All other types are unsupported.

Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
2023-04-19 20:46:53 +02:00
Francisco Casas
3f9cd58f5b vkd3d-shader/hlsl: Fix missing extern resource names. 2023-04-19 20:46:53 +02:00
Nikolay Sivov
827a359b45 vkd3d-shader/hlsl: Handle uppercase regset names in packoffset().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-19 20:45:50 +02:00
Nikolay Sivov
0cea4d352e vkd3d-shader/hlsl: Handle uppercase regset names in register(). 2023-04-19 20:45:48 +02:00
Zebediah Figura
d8ef0c69a8 vkd3d-shader/spirv: Do not declare resources as multisampled if the sample count is 1.
It is illegal to match a SPIR-V multisampled resource to a Vulkan resource which
is not multisampled. Vulkan considers a resource to be multisampled if its
sample count is greater than 1 (and SPIR-V does not care about the sample count).

This fixes validation errors in the case where the sample count does actually
match the resource. In order to provide correct behaviour when there is a
mismatch, or when the sample count is missing, we will need yet another
additional interface. In the absence of that it seems best to provide a best
guess.

This fixes a validation error with the not-yet-committed merge request 135, when
the d3d11 runner is run through Wine with the Vulkan backend.
2023-04-19 20:45:39 +02:00
Nikolay Sivov
dfe923ea1d vkd3d-shader: Consistently pass location structure by pointer. 2023-04-19 20:45:31 +02:00
Zebediah Figura
7ee66351c8 vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_if(). 2023-04-18 21:59:49 +02:00
Zebediah Figura
50f0ae1b21 vkd3d-shader/hlsl: Pass hlsl_block pointers to hlsl_new_if(). 2023-04-18 21:59:45 +02:00
Zebediah Figura
5a3fe1609b vkd3d-shader/hlsl: Initialize the block in clone_block(). 2023-04-18 21:59:44 +02:00
Zebediah Figura
733141720a vkd3d-shader/hlsl: Introduce a hlsl_block_cleanup() helper. 2023-04-18 21:59:42 +02:00
Zebediah Figura
dc7514afc9 vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_float_constant(). 2023-04-18 21:59:39 +02:00
Zebediah Figura
b23ef3ca3b vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_cast() and hlsl_new_copy(). 2023-04-18 21:59:37 +02:00
Zebediah Figura
1bf3aa9275 vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_bool_constant(). 2023-04-18 21:59:34 +02:00
Zebediah Figura
0654d88edd vkd3d-shader/hlsl: Allow VPOS and VFACE to be specified in sm3 pixel shaders.
We were previously (accidentally) rejecting them because they didn't have a
usage.
2023-04-18 21:59:22 +02:00
Zebediah Figura
b19105eaeb vkd3d-shader/hlsl: Do not write DCL instructions for ps_1_* shaders. 2023-04-18 21:59:17 +02:00
Zebediah Figura
99d413206b vkd3d-shader/hlsl: Map ps_1_* color and texcoord semantics to registers. 2023-04-18 21:59:15 +02:00
Zebediah Figura
98e2461392 vkd3d-shader/hlsl: Sort only uniforms by name in the sm1 backend. 2023-04-18 21:59:13 +02:00
Zebediah Figura
8ed7437708 vkd3d-shader/hlsl: Evaluate index before array.
Co-authored-by: Francisco Casas <fcasas@codeweavers.com>
2023-04-13 23:05:43 +02:00
Francisco Casas
af1aa63ace vkd3d-shader/hlsl: Support column-major matrix indexing in the lhs. 2023-04-13 23:05:41 +02:00
Francisco Casas
dc2a34824d vkd3d-shader/hlsl: Always load from a synthetic copy in add_load_component(). 2023-04-13 23:05:39 +02:00
Francisco Casas
82ff408451 vkd3d-shader/hlsl: Remove add_load_index(). 2023-04-13 23:05:34 +02:00
Francisco Casas
5c285adc6b vkd3d-shader/hlsl: Use hlsl_ir_index for array and record access.
From this point on, it is no longer true that only hlsl_ir_loads can
return objects, because an object can also come from chain of
hlsl_ir_indexes that ends in an hlsl_ir_load.

The lower_index_loads pass takes care of lowering all hlsl_ir_indexes
into hlsl_ir_loads.

For this reason, hlsl_resource_load_params now expects both the resource
as the sampler to be just an hlsl_ir_node pointer instead of a pointer
to a more specific hlsl_ir_load.
2023-04-13 23:05:32 +02:00
Francisco Casas
741c9e5893 vkd3d-shader/hlsl: Introduce hlsl_ir_index.
This node type is intended for use during parse-time.

While we parse an indexing expression such as "a[3]", we don't know if
it will end up as part of an expression (in which case it must be folded
into a load) or it is for the lhs of a store (in which case it must be
folded into the store's deref).
2023-04-13 23:05:25 +02:00
Francisco Casas
0ceecd1225 vkd3d-shader/hlsl: Fix numeric offset of object fields. 2023-04-13 23:05:07 +02:00
Nikolay Sivov
ca59a3c35b vkd3d-shader/hlsl: Handle SV_IsFrontFace semantic. 2023-04-13 23:04:58 +02:00
Nikolay Sivov
a1bd4e080e vkd3d-shader/hlsl: Support log() intrinsic.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-13 23:04:44 +02:00
Nikolay Sivov
210caa931d vkd3d-shader/hlsl: Support log10() intrinsic.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-13 23:04:42 +02:00
Nikolay Sivov
49b63fbeba vkd3d-shader/hlsl: Support log2() intrinsic. 2023-04-13 23:04:40 +02:00
Nikolay Sivov
c93dac3620 vkd3d-shader/hlsl: Write 'log' instruction for SM1. 2023-04-13 23:04:37 +02:00
Henri Verbeet
0c05f2409c vkd3d-shader/sm4: Get rid of shader_sm4_is_end(). 2023-04-12 21:54:57 +02:00
Henri Verbeet
1e448b0b71 vkd3d-shader/sm4: Pass a vkd3d_shader_sm4_parser structure to shader_sm4_read_instruction(). 2023-04-12 21:54:56 +02:00
Henri Verbeet
1b7b694190 vkd3d-shader/sm1: Pass a vkd3d_shader_sm1_parser structure to shader_sm1_is_end(). 2023-04-12 21:54:55 +02:00
Henri Verbeet
df6a34e1bd vkd3d-shader/sm1: Pass a vkd3d_shader_sm1_parser structure to shader_sm1_read_instruction(). 2023-04-12 21:54:54 +02:00
Henri Verbeet
09566e2c25 vkd3d-shader: Get rid of the "ptr" field from struct vkd3d_shader_parser.
This is an implementation detail.
2023-04-12 21:54:53 +02:00
Henri Verbeet
c4d307a08d vkd3d-shader: Get rid of the "instruction_idx" field from struct vkd3d_shader_parser.
This is unused now.
2023-04-12 21:54:51 +02:00
Conor McCarthy
98b5e2c6e0 vkd3d-shader/ir: Insert hull shader control point input declarations if no control point phase is defined.
The SPIR-V backend will emit a default control point phase. Inserting
inputs into the IR allows handling of declarations via the usual path
instead of an ad hoc implementation which may not match later changes
to input handling.
2023-04-12 21:54:28 +02:00
Conor McCarthy
14295a224d vkd3d-shader/ir: Normalise control point phase output registers to include the control point id.
In SPIR-V the address must include the invocation id, but in TPF it
is implicit. Move the register index up one slot and insert an
OUTPOINTID relative address.
2023-04-12 21:54:27 +02:00
Zebediah Figura
616c4bf51f vkd3d-shader/hlsl: Always align section sizes.
This fixes disassembly using native D3DDisassemble() of shaders generated with vkd3d-shader.

Fixes: d6d9aab31c
2023-04-06 17:52:16 +02:00
Zebediah Figura
a60c47ff39 vkd3d-shader: Explicitly align the size in bytecode_get_next_offset() and rename it accordingly. 2023-04-06 17:52:16 +02:00
Zebediah Figura
1514755043 vkd3d-shader/hlsl: Make a string array const. 2023-04-06 17:52:07 +02:00
Zebediah Figura
09cda98deb vkd3d-shader: Factor out vkd3d_shader_parser_compile(). 2023-04-06 17:52:02 +02:00
Zebediah Figura
507e8644ae vkd3d-shader: Reuse the existing parser for scanning in compile_dxbc_tpf(). 2023-04-06 17:52:02 +02:00
Zebediah Figura
28774b3649 vkd3d-shader/spirv: Move spirv_compiler_destroy() to avoid forward declarations. 2023-04-06 17:52:01 +02:00
Zebediah Figura
70cfd58be6 vkd3d-shader/spirv: Introduce a spirv_compile() helper. 2023-04-06 17:51:59 +02:00
Nikolay Sivov
24c1eb562f vkd3d-shader/hlsl: Treat half as float for casts.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-06 17:51:55 +02:00
Nikolay Sivov
c190c184ce vkd3d-shader/hlsl: Add support for ternary operator. 2023-04-06 17:51:46 +02:00
Zebediah Figura
725d408974 vkd3d-shader/hlsl: Introduce an hlsl_block_init() helper. 2023-04-06 17:51:40 +02:00
Zebediah Figura
1da5a9a490 vkd3d-shader/hlsl: Introduce an hlsl_block_add_block() helper. 2023-04-06 17:51:38 +02:00
Zebediah Figura
ceac81b816 vkd3d-shader/hlsl: Introduce an hlsl_block_add_instr() helper. 2023-04-06 17:51:36 +02:00
Henri Verbeet
d6d9aab31c vkd3d-shader: Align the start offset instead of the size in bytecode_put_bytes().
The practical effect this has is that we avoid potential trailing padding at
the end of DXBC blobs. Unfortunately this also means we need to be more
careful about using bytecode_get_size() to find the offset where subsequent
data would get written, although in many cases this follows a put_u32() call.
2023-04-04 22:01:36 +02:00
Francisco Casas
f3e81327dc vkd3d-shader/hlsl: Consider register() as manual packing for resource fields. 2023-04-04 21:59:49 +02:00
Francisco Casas
bf4a125087 vkd3d-shader/hlsl: Ignore packoffset() contents for SM1. 2023-04-04 21:59:47 +02:00
Francisco Casas
60237cb773 vkd3d-shader/hlsl: Don't allow manual and automatic cbuffer offset packing. 2023-04-04 21:59:45 +02:00
Francisco Casas
4448d114ad vkd3d-shader/hlsl: Detect overlaps in cbuffer offsets. 2023-04-04 21:59:43 +02:00
Francisco Casas
7777c32cac vkd3d-shader/hlsl: Support packoffset(). 2023-04-04 21:59:42 +02:00
Francisco Casas
4aca335f42 vkd3d-shader/hlsl: Parse packoffset(). 2023-04-04 21:59:40 +02:00
Francisco Casas
9b70971696 vkd3d-shader/hlsl: Rename struct hlsl_reg_reservation fields. 2023-04-04 21:59:39 +02:00
Nikolay Sivov
eb71c5f20d vkd3d-shader/hlsl: Handle round() for SM1. 2023-04-03 18:00:03 +02:00
Zebediah Figura
7a9e393ea0 vkd3d-shader/hlsl: Rename the "type" field of struct hlsl_type to "class".
To be consistent with enum hlsl_type_class and HLSL_CLASS_*.
2023-04-03 17:59:24 +02:00
Nikolay Sivov
b172f4c257 vkd3d-shader/hlsl: Improve handling of builtin alias type "vector".
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-03 17:59:08 +02:00
Nikolay Sivov
5b5c020ade vkd3d-shader/hlsl: Improve handling of builtin alias type "matrix". 2023-04-03 17:59:06 +02:00
Conor McCarthy
c61f9f477c vkd3d-shader/spirv: Declare the phase SPIR-V function in spirv_compiler_enter_shader_phase().
The convoluted code path is no longer needed.
2023-04-03 17:58:26 +02:00
Conor McCarthy
b8472d2270 vkd3d-shader/spirv: Remove the hull shader phase array.
With no more than one phase each of control point and fork/join type,
an array is not required.
2023-04-03 17:58:24 +02:00
Conor McCarthy
16a7de4b38 vkd3d-shader/trace: Trace the normalised instruction array after tracing the input. 2023-04-03 17:58:23 +02:00
Conor McCarthy
eabdccb117 vkd3d-shader/ir: Merge all shader IR fork and join phases into a single phase.
Normalise the incoming vkd3d_shader_instruction IR to the shader model 6
pattern. This allows generation of a single patch constant function in
SPIR-V.
2023-04-03 17:58:21 +02:00
Henri Verbeet
57d92a15cf Release 1.7. 2023-03-24 11:22:28 +01:00
Nikolay Sivov
4110f1e547 vkd3d-shader: Fix a few typos in the comments. 2023-03-15 20:13:27 +01:00
Henri Verbeet
8509ec1e72 vkd3d-shader/spirv: Update the current source location in spirv_compiler_generate_spirv(). 2023-03-13 22:10:00 +01:00
Henri Verbeet
0a73c75db8 vkd3d-shader/glsl: Update the current source location in vkd3d_glsl_generator_generate().
Since the introduction of instruction arrays, the parser location no
longer matches the location of the current instruction. Ultimately we'll
likely want to add some kind of explicit location information to struct
vkd3d_shader_instruction_array, because we might do transformations that
change the order of the original instructions.
2023-03-13 22:09:58 +01:00
Henri Verbeet
685abf9c2d vkd3d-shader/sm4: Do not specify a destination register for VKD3D_SM4_OP_DCL_RESOURCE in opcode_table[].
We do not set one in shader_sm4_read_dcl_resource(), and
shader_sm4_read_instruction() explicitly sets this to 0.
2023-03-13 22:09:54 +01:00
Henri Verbeet
65b7154a22 vkd3d-shader/sm4: Set "dst_count" to 0 when we clear "dst" in shader_sm4_read_instruction().
VKD3D_SM4_OP_DCL_RESOURCE currently has 1 for "dst_count", but NULL for
"dst". This is largely harmless because we never attempt to access the
destination register of VKD3DSIH_DCL instructions, but nevertheless not
quite proper.
2023-03-13 22:09:49 +01:00
Zebediah Figura
da2435707b vkd3d-shader/hlsl: Fix some memory leaks in the function call rule. 2023-03-09 22:11:06 +01:00
Nikolay Sivov
193692bbcb vkd3d-shader/hlsl: Use array element type for array's regset.
Currently this affects SM1 compilation only, with a minimal example like this:

float4 var[3];
float4 main() : sv_target
{
    return var[1];
}
2023-03-09 22:10:39 +01:00
Nikolay Sivov
2880be647e vkd3d-shader/sm4: Write sample count field for multisampled texture declaration.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-03-08 20:15:11 +01:00
Nikolay Sivov
ae2f777a4d vkd3d-shader/hlsl: Parse multisample texture type names. 2023-03-08 20:15:09 +01:00
Nikolay Sivov
ee52ad8106 vkd3d-shader/trace: Output sample count for multisampled resources. 2023-03-08 20:15:06 +01:00
Conor McCarthy
9f6e6d3fcd vkd3d-shader/dxbc: Validate and skip the signature section header size.
Silences a very common warning.
2023-03-08 20:14:59 +01:00
Conor McCarthy
3b5316be82 vkd3d-shader/dxbc: Emit a shader error for an invalid signature data size. 2023-03-08 20:14:57 +01:00
Conor McCarthy
83e39e2650 vkd3d-shader/dxbc: Pass a message context to for_each_dxbc_section(). 2023-03-08 20:14:55 +01:00
Nikolay Sivov
a18f3d4dd5 vkd3d-shader/hlsl: Support distance() intrinsic. 2023-03-08 20:14:22 +01:00
Nikolay Sivov
d6b656641c vkd3d-shader/hlsl: Support rsqrt() intrinsic. 2023-03-08 20:14:20 +01:00
Zebediah Figura
a28ecaa135 vkd3d-shader/hlsl: Get rid of the check_invalid_matrix_modifiers() helper. 2023-02-28 22:07:01 +01:00
Zebediah Figura
5838364886 vkd3d-shader/hlsl: Apply latent majority modifiers to typedefs as well. 2023-02-28 22:07:00 +01:00
Zebediah Figura
322963add8 vkd3d-shader/hlsl: Do not set an initial latent matrix majority.
This change does nothing by itself.
2023-02-28 22:06:59 +01:00
Zebediah Figura
75ab9d31ef vkd3d-shader/hlsl: Store the matrix majority as a type modifiers bitmask. 2023-02-28 22:06:58 +01:00
Zebediah Figura
b3c620954b vkd3d-shader/hlsl: Apply latent type modifiers to matrix array typedefs. 2023-02-28 22:06:56 +01:00
Francisco Casas
af25d5bf96 vkd3d-shader/hlsl: Don't map src swizzles for SM1 dp3 and dp4 ops.
Without this patch, dp3 and dp4 map src swizzles to the dst writemask,
which is not correct.

Before b84f560bdf, these ops worked
despite this, because the dst register had, incorrectly, the full
writemask.

To solve this problem, write_sm1_binary_op_dot() is introduced,
similarly to write_sm4_binary_op_dot().
2023-02-27 22:12:38 +01:00
Giovanni Mascellani
a1c6bb85ad vkd3d-shader: Do not pass client-given strings as printf()-style format strings. 2023-02-27 22:12:26 +01:00
Henri Verbeet
b1e13d6e33 vkd3d-shader/dxbc: Introduce API for serialising DXBC blobs. 2023-02-23 21:47:27 +01:00
Henri Verbeet
c87492ed21 vkd3d-shader/dxbc: Introduce API for parsing DXBC blobs. 2023-02-23 21:47:26 +01:00
Henri Verbeet
d0d2130f74 vkd3d-shader/dxbc: Rename parse_dxbc() to for_each_dxbc_section(). 2023-02-23 21:47:23 +01:00
Henri Verbeet
a06320c1fc vkd3d-shader/dxbc: Pass a vkd3d_shader_code structure to parse_dxbc(). 2023-02-23 21:47:22 +01:00
Henri Verbeet
2f762465a6 vkd3d-shader/dxbc: Pass a vkd3d_shader_code structure to shader_extract_from_dxbc(). 2023-02-23 21:47:21 +01:00
Henri Verbeet
3a3acb5b7d vkd3d-shader/dxbc: Pass a vkd3d_shader_code structure to shader_parse_input_signature(). 2023-02-23 21:47:20 +01:00
Henri Verbeet
e2825f7658 vkd3d-shader/dxbc: Pass a vkd3d_shader_dxbc_section_desc structure to the parse_dxbc() section handler. 2023-02-23 21:47:19 +01:00
Henri Verbeet
5020781f76 vkd3d-shader/dxbc: Pass a vkd3d_shader_dxbc_section_desc structure to shader_parse_root_signature(). 2023-02-23 21:47:18 +01:00
Henri Verbeet
6c64f8a217 vkd3d-shader/dxbc: Pass a vkd3d_shader_dxbc_section_desc structure to shader_parse_signature(). 2023-02-23 21:47:16 +01:00
Henri Verbeet
bf3c012834 vkd3d-shader/dxbc: Rename the dxbc_writer_section structure to vkd3d_shader_dxbc_section_desc.
In preparation of exposing it in the public API.
2023-02-23 21:47:15 +01:00
Henri Verbeet
b59de4de5c vkd3d-shader/dxbc: Store DXBC section data as a vkd3d_shader_code structure. 2023-02-23 21:47:13 +01:00
Nikolay Sivov
dd36215a00 vkd3d-shader/hlsl: Support case-insensitive lookup for builtin 'float' type.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-02-23 21:46:42 +01:00
Nikolay Sivov
df2d6d35e2 vkd3d-shader/hlsl: Use unsigned type for the 'dword' alias.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-02-23 21:46:40 +01:00
Nikolay Sivov
891217664a vkd3d-shader/hlsl: Support case-insensitive lookup for builtin 'dword' type. 2023-02-23 21:46:38 +01:00
Zebediah Figura
e10e12a10c vkd3d-shader: Avoid underflowing the indentation level.
Any shader that would underflow is invalid, but it is helpful to allow tracing even invalid shaders.
2023-02-22 18:28:19 +01:00
Francisco Casas
f8338ef089 vkd3d-shader/hlsl: Allocate register reservations in a separate pass.
This refactoring is required for improving the allocation strategy so it
works with multiple-register variables.
2023-02-22 18:28:19 +01:00
Francisco Casas
75359e6dbd vkd3d-shader/hlsl: Respect object reservations even if the object is unused. 2023-02-22 18:28:19 +01:00
Francisco Casas
c5384b38ee vkd3d-shader/hlsl: Allocate objects according to register set. 2023-02-22 18:28:19 +01:00
Francisco Casas
e0031d2a1f vkd3d-shader/hlsl: Keep an hlsl_reg for each register set in hlsl_ir_var. 2023-02-22 18:28:19 +01:00
Francisco Casas
5272c5f86a vkd3d-shader/hlsl: Obtain extern resources as a separate array in SM4. 2023-02-22 18:28:19 +01:00
Francisco Casas
d07247249a vkd3d-shader/hlsl: Store the type's register size for each register set. 2023-02-22 18:28:19 +01:00
Francisco Casas
315966dc21 vkd3d-shader/hlsl: Leave offset empty for array and struct derefs. 2023-02-22 18:28:19 +01:00
Zebediah Figura
7c1c2e6cc4 vkd3d-shader/hlsl: Parse the tex3D() intrinsic. 2023-02-22 18:28:19 +01:00
Zebediah Figura
645ec0167a vkd3d-shader/hlsl: Parse the tex2D() intrinsic. 2023-02-22 18:28:19 +01:00
Francisco Casas
9fdff25a3b vkd3d-shader/hlsl: Avoid segfault on missing sampler. 2023-02-22 18:28:19 +01:00
Nikolay Sivov
d86db8bcbe vkd3d-shader/hlsl: Support lit() intrinsic. 2023-02-21 21:09:52 +01:00
Francisco Casas
7f009f59ce vkd3d-shader/hlsl: Add a more specific error for missing compatible fn. definitions. 2023-02-20 21:59:54 +01:00
Francisco Casas
f08c0a7c03 vkd3d-shader/hlsl: Find compatible function overloads.
But still throw hlsl_fixme() when there is more than one.
Prioritizing among multiple compatible function overloads in the same way
as the native compiler would require systematic testing.
2023-02-20 21:59:53 +01:00
Francisco Casas
d279d34801 vkd3d-shader/hlsl: Parse array types in function parameters. 2023-02-20 21:59:51 +01:00
Francisco Casas
2a9b9f7530 vkd3d-shader/hlsl: Rename compatible_data_types() to be more specific. 2023-02-20 21:59:50 +01:00
Zebediah Figura
6767b7abbf vkd3d-shader/hlsl: Avoid warning for each variable when in/out modifiers are specified on non-parameters. 2023-02-20 21:59:45 +01:00
Zebediah Figura
72ec5563f8 vkd3d-shader/hlsl: Remove a redundant warning for mutually exclusive majority modifiers.
We will warn subsequently in apply_type_modifiers() or add_typedef().
2023-02-20 21:59:43 +01:00
Zebediah Figura
af65287423 vkd3d-shader/hlsl: Check for majority modifiers on non-matrices in apply_type_modifiers(). 2023-02-20 21:59:42 +01:00
Nikolay Sivov
e5b40092c2 vkd3d-shader/hlsl: Support all() intrinsic. 2023-02-20 21:59:37 +01:00
Francisco Casas
2142d31f13 vkd3d-shader/hlsl: Fix number of components when creating a swizzle in copy-prop.
Otherwise we may create nodes of different dimensions than the ones we
are replacing.

"count" is the number of components of the source deref (without
considering the swizzle), while "instr_component_count" is the actual
number of components of the instruction to be replaced.
2023-02-20 21:59:31 +01:00
Nikolay Sivov
e7bc634307 vkd3d-shader/hlsl: Support reflect() intrinsic.
Tests authored by Giovanni.
2023-02-20 21:59:23 +01:00
Giovanni Mascellani
7c3dadce6b vkd3d-shader/hlsl: Write SM4 break instructions. 2023-02-15 21:53:21 +01:00
Nikolay Sivov
99acf5038e vkd3d-shader/hlsl: Use mul only for two scalars for dot(). 2023-02-15 21:53:15 +01:00
Zebediah Figura
0e60f4cc69 vkd3d-shader/hlsl: Always set ctx->cur_function in the func_prototype_no_attrs rule.
Fixes: 4c46075d86
2023-02-14 21:52:59 +01:00
Zebediah Figura
cd6e8b5540 vkd3d-shader/hlsl: Allow empty parameter lists to be specified as "(void)". 2023-02-14 21:52:57 +01:00
Zebediah Figura
58445da64b vkd3d-shader/hlsl: Allow the final expression in a for loop initializer to be omitted. 2023-02-13 22:16:56 +01:00
Zebediah Figura
38964214cd vkd3d-shader/hlsl: Handle early return after a CF block only if there was actually a return somewhere in the CF block. 2023-02-13 22:16:55 +01:00
Zebediah Figura
4b944517b7 vkd3d-shader/hlsl: Inline function calls. 2023-02-13 22:16:53 +01:00
Zebediah Figura
6177cea31f vkd3d-shader/hlsl: Emit a hlsl_fixme() for unhandled instruction types when writing bytecode.
This was originally left alone in order to allow functions without early return
to succeed, since in that case we would already emit the correct bytecode
despite not handling the HLSL_IR_JUMP_RETURN instruction.

Now that we lower return statements, however, any unhandled instructions are
either definitely going to result in invalid bytecode, or rare enough that it's
not worth returning success anyway.
2023-02-13 22:16:52 +01:00
Zebediah Figura
8bdee6681b vkd3d-shader/hlsl: Lower return statements. 2023-02-13 22:16:51 +01:00
Zebediah Figura
0cf39f3c63 vkd3d-shader/hlsl: Emit a hlsl_fixme() if multiple valid entry point definitions are given. 2023-02-13 22:16:49 +01:00
Zebediah Figura
bb41c3b5fe vkd3d-shader/hlsl: Skip functions that don't have a body when looking for the entry point. 2023-02-13 22:16:48 +01:00
Nikolay Sivov
240b2f966f vkd3d-shader/hlsl: Support abs() for SM1. 2023-02-09 18:03:19 +01:00
Francisco Casas
902ddee557 vkd3d-shader/hlsl: Fix SM1 dp2add swizzles.
SM1 dp2add doesn't map src swizzles to the dst writemask, also it
expects the last argument to have a replicate swizzle.

Before this patch we were writing the operation as:
```
dp2add r0.x, r1.x, r0.x, r2.x
```

and now it is:
```
dp2add r0.x, r1.xyxx, r0.xyxx, r2.x
```

dp2add now has its own function, write_sm1_dp2add(), since it seems to
be the only instruction with this structure.

Ideally we would be using the default swizzles for the first two src
arguments:
```
dp2add r0.x, r1, r0, r2.x
```
since, according to native's documentation, these are supported for all
sm < 4.

But this change -- along with following the convention of repeating the
last component of the swizzle when fewer than 4 components are to be
specified -- would require more global changes, probably in
hlsl_swizzle_from_writemask() and hlsl_map_swizzle().
2023-02-08 22:09:42 +01:00
Francisco Casas
d01729921c vkd3d-shader/hlsl: Map SM1 src swizzles outside write_sm1_instruction().
Not every instruction expects src swizzles to be mapped according to the
dst writemasks, so this logic must be outside this function.
2023-02-08 22:09:41 +01:00
Francisco Casas
b84f560bdf vkd3d-shader/hlsl: Set writemasks correctly for SM1 scalar and vector types.
Because of the change introduced in

f21693b2 vkd3d-shader/hlsl: Use reg_size as component count when allocating a single register.

SM1 scalars and vectors were not longer getting the correct writemask
when they are allocated.

This happened because they have to reserve the whole register even if
they only use some of its components, so their reg_size may differ from
the number of components.

This commit fixes that.
2023-02-08 22:09:39 +01:00
Francisco Casas
6b4a4c4c6d vkd3d-shader/hlsl: Expect component count in allocate_register().
This in order to set the correct writemasks for SM1 registers.
2023-02-08 22:09:38 +01:00
Francisco Casas
0ecac994d0 vkd3d-shader/hlsl: Rename 'component_count' arguments to 'reg_size'.
component_count will be used in the next patch for the actual number of
components of the type and not its register size.
2023-02-08 22:09:36 +01:00
Zebediah Figura
ab601d65cd vkd3d-shader: Initialize the parameter allocator head.
This fixes a memory leak.

Fixes: 007f894b94
2023-02-07 22:15:08 +01:00
Nikolay Sivov
91a70c7dda vkd3d-shader/hlsl: Handle saturate() for SM1.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-02-07 22:15:06 +01:00
Zebediah Figura
77d716c811 vkd3d-shader/hlsl: Add functions to the global list inside the func_prototype rule. 2023-02-07 22:15:06 +01:00
Zebediah Figura
4c46075d86 vkd3d-shader/hlsl: Use the original hlsl_ir_function_decl struct rather than allocating a new one for each definition.
We need to make sure every invocation points to the same hlsl_ir_function_decl
and the same parameters.

This fixes some invalid memory accesses.
2023-02-07 22:15:06 +01:00
Zebediah Figura
25d49b518d vkd3d-shader/hlsl: Put synthetic variables into a dummy scope.
Prevent them from being ever looked up.

Our naming scheme for synthetic variables already effectively prevents this, but
this is better for clarity. We also will need to be able to move some named
variables into a dummy scope to account for complexities around function
definition and declarations.
2023-02-07 22:15:06 +01:00
Zebediah Figura
8755a92196 vkd3d-shader/hlsl: Add a hlsl_cleanup_semantic() helper. 2023-02-07 22:15:06 +01:00
Zebediah Figura
cb2c89a589 vkd3d-shader/hlsl: Store function parameters in an array. 2023-02-07 22:15:06 +01:00
Zebediah Figura
8fc8d34ea0 vkd3d-shader/spirv: Introduce an option to control whether point size is written. 2023-02-02 20:51:18 +01:00
Nikolay Sivov
06f300ec59 vkd3d-shader/hlsl: Support dot() for SM1. 2023-02-02 20:51:12 +01:00
Zebediah Figura
aa3badbd9d vkd3d-shader/hlsl: Emit a hlsl_fixme() for HLSL_IR_CALL instructions.
Avoid outputting invalid shaders.
2023-01-31 22:27:00 +01:00
Nikolay Sivov
8bb023e5af vkd3d-shader/hlsl: Support exp() intrinsic. 2023-01-26 21:52:28 +01:00
Nikolay Sivov
8ca2f65bc1 vkd3d-shader/hlsl: Support exp2() intrinsic. 2023-01-26 21:52:26 +01:00
Nikolay Sivov
fa971f32bc vkd3d-shader/hlsl: Write 'exp' instructions for SM1. 2023-01-26 21:52:25 +01:00
Nikolay Sivov
335f741630 vkd3d-shader/hlsl: Add a helper to write per-component unary instructions. 2023-01-26 21:52:24 +01:00
Francisco Casas
f33ca836d7 vkd3d-shader/hlsl: Make single-component swizzles retrieve a scalar. 2023-01-26 21:52:18 +01:00
Giovanni Mascellani
d2f8a576a8 vkd3d-shader/hlsl: Avoid infinite loop and invalid derefs in copy-prop.
Co-authored-by: Francisco Casas <fcasas@codeweavers.com>
Co-authored-by: Zebediah Figura <zfigura@codeweavers.com>

Because copy_propagation_transform_object_load() replaces a deref
instead of an instruction, it is currently prone to two problems:

1- It can replace a deref with the same deref, returning true every
time and getting the compilation stuck in an endless loop of
copy-propagation iterations.

2- When performed multiple times in the same deref, the second time it
can replace the deref with a deref from a temp that is only valid in
another point of the program execution, resulting in an incorrect value.

This patch preempts this by avoiding replacing derefs when the new deref
doesn't point to a uniform variable. Because, uniform variables cannot
be written to.
2023-01-26 21:52:07 +01:00
Zebediah Figura
653cc02f4c vkd3d-shader/hlsl: Write SM4 thread ID registers. 2023-01-25 22:47:46 +01:00
Francisco Casas
404a2d6a3d vkd3d-shader/hlsl: Reinterpret minimum precision types as their regular counterparts.
Reinterpret min16float, min10float, min16int, min12int, and min16uint
as their regular counterparts: float, float, int, int, uint,
respectively.

A proper implementation would require adding minimum precision
indicators to all the dxbc-tpf instructions that use these types.
Consider the output of fxc 10.1 with the following shader:

    uniform int i;

    float4 main() : sv_target
    {
        min16float4 a = {0, 1, 2, i};
        min16int2 b = {4, i};
        min10float3 c = {6.4, 7, i};
        min12int d = 9.4;
        min16uint4x2 e = {14.4, 15, 16, 17, 18, 19, 20, i};

        return mul(e, b) + a + c.xyzx + d;
    }

However, if the graphics driver doesn't have minimum precision support,
it ignores the minimum precision indicators and runs at 32-bit
precision, which is equivalent as working with regular types.
2023-01-25 22:10:23 +01:00
Nikolay Sivov
3c23e1713c vkd3d-shader/hlsl: Implement sqrt() for SM1. 2023-01-25 22:10:15 +01:00
Nikolay Sivov
b84b9349bf vkd3d-shader/hlsl: Handle RSQ output for SM1. 2023-01-25 22:10:13 +01:00
Nikolay Sivov
3e6fccdbf9 vkd3d-shader/hlsl: Support frac() intrinsic.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=34242
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-01-25 22:10:05 +01:00
Conor McCarthy
d14f42be9d vkd3d-shader/spirv: Pass a parser pointer to spirv_compiler_generate_spirv(). 2023-01-24 18:11:16 +01:00
Conor McCarthy
2a5ae0a8c6 vkd3d-shader/sm4: Use the instruction array interface in compile_dxbc_tpf(). 2023-01-24 18:11:14 +01:00
Conor McCarthy
2d3f05184f vkd3d-shader/glsl: Use the instruction array interface in vkd3d_glsl_generator_generate(). 2023-01-24 18:11:13 +01:00
Conor McCarthy
2559d622de vkd3d-shader: Use the instruction array interface in scan_with_parser(). 2023-01-24 18:11:12 +01:00
Conor McCarthy
e9a2642d6a vkd3d-shader/trace: Use the instruction array interface in vkd3d_dxbc_binary_to_text(). 2023-01-24 18:11:10 +01:00
Conor McCarthy
e8cb90608d vkd3d-shader: Initialise the instruction array in vkd3d_shader_parser_init(). 2023-01-24 18:11:10 +01:00
Conor McCarthy
a9aaa59df0 vkd3d-shader/sm4: Store parsed instructions in an array. 2023-01-24 18:11:08 +01:00
Conor McCarthy
007f894b94 vkd3d-shader/sm1: Store parsed instructions in an array. 2023-01-24 18:11:06 +01:00
Francisco Casas
6b82ba9488 vkd3d-shader/hlsl: Fold swizzle chains. 2023-01-24 18:10:53 +01:00
Zebediah Figura
b7d34e8307 vkd3d-shader/hlsl: Apply copy propagation to swizzled loads. 2023-01-24 18:10:50 +01:00
Francisco Casas
18adf0d726 vkd3d-shader/hlsl: Use aoffimmis when writing gather resource loads.
If the offset of a gather resource load can be represented as an
aoffimmi (vectori of ints from -8 to 7), use one.
This is of particular importance for 4.0 profiles, where this is the only
valid way of representing offsets for this operation.
2023-01-24 18:10:49 +01:00
Francisco Casas
c2a7a40d3a vkd3d-shader/hlsl: Replace loads with constants in copy prop.
If a hlsl_ir_load loads a variable whose components are stored from different
instructions, copy propagation doesn't replace it.

But if all these instructions are constants (which currently is the case
for value constructors), the load could be replaced with a constant value.
Which is expected in some other instructions, e.g. texel_offsets when
using aoffimmi modifiers.

For instance, this shader:

```
sampler s;
Texture2D t;

float4 main() : sv_target
{
    return t.Gather(s, float2(0.6, 0.6), int2(0, 0));
}
```

results in the following IR before applying the patch:
```
  float | 6.00000024e-01
  float | 6.00000024e-01
   uint | 0
        | = (<constructor-2>[@4].x @2)
   uint | 1
        | = (<constructor-2>[@6].x @3)
 float2 | <constructor-2>
    int | 0
    int | 0
   uint | 0
        | = (<constructor-5>[@11].x @9)
   uint | 1
        | = (<constructor-5>[@13].x @10)
   int2 | <constructor-5>
 float4 | gather_red(resource = t, sampler = s, coords = @8, offset = @15)
        | return
        | = (<output-sv_target0> @16)
```

and this IR afterwards:
```
 float2 | {6.00000024e-01 6.00000024e-01 }
   int2 | {0 0 }
 float4 | gather_red(resource = t, sampler = s, coords = @2, offset = @3)
        | return
        | = (<output-sv_target0> @4)
```
2023-01-24 18:10:45 +01:00
Zebediah Figura
8c2b8ff245 vkd3d-shader/hlsl: Synthesize the swizzle and replace the instruction inside of copy_propagation_compute_replacement().
Rename it to copy_propagation_replace_with_single_instr() accordingly.

The idea is to introduce a constant vector replacement pass which will do the
same thing.
2023-01-24 18:10:41 +01:00
Zebediah Figura
5d34790402 vkd3d-shader/hlsl: Call copy_propagation_get_value() directly in copy_propagation_transform_object_load().
copy_propagation_compute_replacement() is not doing very much for us, and
conceptually is a bit of an odd fit anyway, since it's meant to deal with
multi-component types.
2023-01-24 18:10:40 +01:00
Zebediah Figura
8fd30aa87d vkd3d-shader/hlsl: Add some swizzle manipulation definitions. 2023-01-24 18:10:39 +01:00
Francisco Casas
cf17882189 vkd3d-shader/hlsl: Support offset argument for the texture Load() method. 2023-01-24 18:10:36 +01:00
Zebediah Figura
9c817e5e6d vkd3d-shader/hlsl: Forbid recursive calls. 2023-01-19 19:16:27 +01:00
Zebediah Figura
521f22e57a vkd3d-shader/hlsl: Store a non-constant hlsl_ir_function_decl pointer in struct hlsl_ir_call. 2023-01-19 19:16:25 +01:00
Zebediah Figura
447463e590 vkd3d-shader/hlsl: Remove the unused "intrinsic" argument from hlsl_add_function(). 2023-01-19 19:16:24 +01:00
Zebediah Figura
6c2472ce16 vkd3d-shader/hlsl: Remove some unnecessary YYABORTs from the func_prototype_no_attrs rule. 2023-01-19 19:16:22 +01:00
Francisco Casas
13c8e8b856 vkd3d-shader/hlsl: Parse step() intrinsic. 2023-01-19 19:16:17 +01:00
Francisco Casas
6fbf2b3e75 vkd3d-shader/hlsl: Parse sqrt() intrinsic. 2023-01-19 19:16:16 +01:00
Francisco Casas
8d5f16d803 vkd3d-shader/hlsl: Support cos() intrinsic. 2023-01-19 19:16:15 +01:00
Francisco Casas
3239ea5ff1 vkd3d-shader/hlsl: Support sin() intrinsic. 2023-01-19 19:16:14 +01:00
Francisco Casas
2b1ec0cfe5 vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_scope. 2023-01-19 19:16:08 +01:00
Francisco Casas
eabd742f3e vkd3d-shader/hlsl: Add field-level documentation to function structs. 2023-01-19 19:16:07 +01:00
Francisco Casas
c68d0ecfe0 vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_buffer. 2023-01-19 19:16:06 +01:00
Francisco Casas
ba56833bb5 vkd3d-shader/hlsl: Add documentation to small hlsl.h structs. 2023-01-19 19:16:04 +01:00
Francisco Casas
06b52c0343 vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_deref. 2023-01-19 19:15:59 +01:00
Francisco Casas
f33d433621 vkd3d-shader/hlsl: Add documentation to struct hlsl_reg. 2023-01-19 19:15:57 +01:00
Francisco Casas
aab9886021 vkd3d-shader/hlsl: Allow uninitialized static objects.
validate_static_object_references() validates that uninitialized static
objects are not referenced in the shader.

In case a static variable contains both numeric and object types, the
"Static variables cannot have both numeric and resource components."
error should preempt uninitialized numeric values to reach further
compilation steps.
2023-01-19 12:29:41 +01:00
Francisco Casas
17d6a4411e vkd3d-shader/hlsl: Validate that non-uniform objects are not referenced.
Note that in the future we should call
validate_static_object_references() after DCE and pruning branches,
because shaders such as these compile (at least in more modern versions
of the native compiler):

Branch pruning:
```
static RWTexture2D<float> tex;

float4 main() : sv_target
{
    if (0)
    {
        tex[int2(0, 0)] = 2;
    }
    return 0;
}
```

DCE:
```
static Texture2D tex;
uniform uint i;

float4 main() : sv_target
{
    float4 unused = tex.Load(int3(0, 1, 2));

    return 0;
}
```

These are "todo" tests in hlsl-static-initializer.shader_test
that depend on this.
2023-01-19 12:29:39 +01:00
Francisco Casas
5cfc8d378f vkd3d-shader/hlsl: Initialize static variables to 0 by default.
We are currently not initializing static values to zero by default.

Consider the following shader:
```hlsl
static float4 va;

float4 main() : sv_target
{
  return va;
}
```
we get the following output:
```
ps_5_0
dcl_output o0.xyzw
dcl_temps 2
mov r0.xyzw, r1.xyzw
mov o0.xyzw, r0.xyzw
ret
```
where r1.xyzw is not initialized.

This patch solves this by assigning the static variable the value of an
uint 0, and thus, relying on complex broadcasts.

This seems to be the behaviour of the 9.29.952.3111 version of the native
compiler, since it retrieves the following error on a shader that lacks
an initializer on a data type with object components:

```
error X3017: cannot convert from 'uint' to 'struct <unnamed>'
```
2023-01-19 12:29:36 +01:00
Zebediah Figura
61f0d6d151 vkd3d-shader/hlsl: Get rid of the "intrinsic" field of struct hlsl_ir_function.
We have a different system of generating intrinsics, which makes it easier to
deal with "polymorphic" arithmetic functions.

Defining and storing intrinsics as hlsl_ir_function_decls would also require
more space in memory (and more optimization passes to get rid of the parameter
variables), and doesn't really save us any effort in terms of source code.
2023-01-13 17:32:44 +01:00
Zebediah Figura
9cc7aaf5a1 vkd3d-shader/hlsl: Forbid returning void expressions from void functions. 2023-01-13 17:32:43 +01:00
Zebediah Figura
b29d3489de vkd3d-shader/hlsl: Generate IR for user-defined function calls. 2023-01-13 17:32:42 +01:00
Zebediah Figura
30550c0831 vkd3d-shader/hlsl: Avoid assuming that expressions have at least one argument. 2023-01-13 17:32:40 +01:00
Francisco Casas
3fbe272659 vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_src. 2023-01-11 16:03:55 +01:00
Francisco Casas
04108c0e21 vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_ir_node. 2023-01-11 16:03:54 +01:00
Francisco Casas
9157a5e73f vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_ctx. 2023-01-11 16:03:52 +01:00
Francisco Casas
8ff3698699 vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_ir_var. 2023-01-11 16:03:51 +01:00
Francisco Casas
0a2732428c vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_struct_field. 2023-01-11 16:03:49 +01:00
Francisco Casas
3a53da7f5b vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_type. 2023-01-11 16:03:48 +01:00
Francisco Casas
cc811dc3c2 vkd3d-shader/hlsl: Rename hlsl_struct_field.modifiers to "storage_modifiers". 2023-01-11 16:03:47 +01:00
Francisco Casas
4dbbb8beb4 vkd3d-shader/hlsl: Rename hlsl_ir_var.modifiers to "storage_modifiers". 2023-01-11 16:03:45 +01:00
Francisco Casas
23bd2d9ad8 vkd3d-shader/hlsl: Rename HLSL_STORAGE_VOLATILE to HLSL_MODIFIER_VOLATILE. 2023-01-11 16:03:43 +01:00
Fabian Maurer
9519fcb562 vkd3d-shader/hlsl: Fix typo (Coverity).
I assume this is a typo, right now it doesn't make sense.

Signed-off-by: Fabian Maurer <dark.shadow4@web.de>
2023-01-11 16:03:16 +01:00
Francisco Casas
5b1030e0cb vkd3d-shader/hlsl: Use add_unary_arithmetic_expr() in intrinsic_pow().
Using add_unary_arithmetic_expr() instead of hlsl_new_unary_expr()
allows the intrinsic to work with matrices.

Otherwise we get:

E5017: Aborting due to not yet implemented feature: Copying from unsupported node type.

because an HLSL_IR_EXPR reaches split_matrix_copies().
2023-01-11 16:02:59 +01:00
Francisco Casas
6770ecbdf4 vkd3d-shader/hlsl: Introduce elementwise_intrinsic_float_convert_args(). 2023-01-11 16:02:57 +01:00
Francisco Casas
9ceed76a9c vkd3d-shader/hlsl: Convert elementwise intrinsics args to the proper common type. 2023-01-11 16:02:56 +01:00
Francisco Casas
a7bb5a0835 vkd3d-shader/hlsl: Support smoothstep() intrinsic. 2023-01-11 16:02:52 +01:00
Francisco Casas
09e7218539 vkd3d-shader/hlsl: Support transpose() intrinsic. 2023-01-11 16:02:50 +01:00
Henri Verbeet
1eaf73147c Release 1.6. 2022-12-07 16:08:16 +01:00
Conor McCarthy
1b11b57652 vkd3d-shader: Introduce DESCRIPTOR_INFO_FLAG_UAV_ATOMICS and always declare UAV images with known type for atomic ops.
Atomic ops on images with Unknown type will cause SPIR-V validation failure,
and assertion failure in Mesa debug builds. D3D12 allows atomics on typed
buffers, and this requires a distinction to be made between UAV reads and
atomic ops.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53874
2022-11-21 18:28:54 +01:00
Francisco Casas
43631bde4d vkd3d-shader/hlsl: Revert expr_compatible_data_types() args names to "t1" and "t2".
Unlike compatible_data_types() and implicit_compatible_data_types(),
this function is intended to be symmetrical. So it makes sense to
preserve the names "t1" and "t2" for the arguments.
2022-11-18 22:29:07 +01:00
Francisco Casas
bd501ce336 vkd3d-shader/hlsl: Don't produce a parse error on empty buffer_body. 2022-11-18 22:29:06 +01:00
Francisco Casas
f100f5b726 vkd3d-shader/hlsl: Check for non-static object references on resource stores. 2022-11-18 22:29:04 +01:00
Francisco Casas
f21693b284 vkd3d-shader/hlsl: Use reg_size as component count when allocating a single register.
Otherwise, for instance, the added test results in:

debug_hlsl_writemask: Assertion `!(writemask & ~VKD3DSP_WRITEMASK_ALL)' failed.

Which happens in allocate_variable_temp_register() when the variable's
type reg_size is <= 4 but its component count is larger, which may
happen if it contains objects.
2022-11-10 22:48:26 +01:00
Francisco Casas
90e6e418a3 vkd3d-shader/hlsl: Use the base type of the array elements in write_sm1_type(). 2022-11-10 22:48:23 +01:00
Francisco Casas
6873b71304 vkd3d-shader/hlsl: Validate that statics don't contain both resources and numerics. 2022-11-10 22:48:21 +01:00
Francisco Casas
2fa913ccaa vkd3d-shader/hlsl: Validate that extern structs don't contain objects SM < 5.
It is worth noting that these checks should also be included for
declarations inside cbuffers, once they are implemented.
2022-11-10 22:48:19 +01:00
Francisco Casas
3153ce3145 vkd3d-shader/hlsl: Don't allocate object types as constant registers. 2022-11-10 22:48:16 +01:00
Francisco Casas
6f6ba8aa56 vkd3d-shader/hlsl: Properly free new store node memory if init_deref() fails. 2022-11-10 22:48:11 +01:00
Zebediah Figura
3857ca06fa vkd3d-shader/hlsl: Write SM4 dcl_thread_group instructions. 2022-11-08 20:53:08 +01:00
Zebediah Figura
718c79b823 vkd3d-shader/hlsl: Parse the numthreads attribute. 2022-11-08 20:53:04 +01:00
Zebediah Figura
d6799bd5d3 vkd3d-shader/hlsl: Parse function attributes. 2022-11-08 20:53:03 +01:00
Zebediah Figura
da56f41ceb vkd3d-shader/hlsl: Use hlsl_new_synthetic_var() in hlsl_new_func_decl(). 2022-11-08 20:53:01 +01:00
Zebediah Figura
1019bbead6 vkd3d-shader/hlsl: Add a hlsl_fixme() for compute shader thread counts.
In particular so that we don't cause test crashes by outputting invalid compute
shaders.
2022-11-08 20:52:59 +01:00
Zebediah Figura
520c7457a9 vkd3d-shader/sm4: Use a flat array to store destination types.
This cuts about 12 kB off of the 64-bit build.
2022-11-08 20:52:36 +01:00
Zebediah Figura
4173158c8b vkd3d-shader/sm4: Use a flat array to store source types. 2022-11-08 20:52:34 +01:00
Zebediah Figura
e2aed38509 vkd3d-shader/spirv: Avoid using DXBC-specific definitions. 2022-11-08 20:52:32 +01:00
Zebediah Figura
ba08825ccd vkd3d-shader/sm4: Use the VKD3D_DXBC_MAX_SOURCE_COUNT macro where possible. 2022-11-08 20:52:31 +01:00
Zebediah Figura
35b48a8b04 vkd3d-shader/spirv: Rename struct vkd3d_dxbc_compiler to struct spirv_compiler.
We would like to generate SPIR-V for input formats other than DXBC.

The "vkd3d_" prefix is dropped, partly to make names shorter, and partly to help
clarify what is an internal function.

I prefer avoiding the vkd3d_* prefix on all internal functions, for these
reasons. However, I'm open to restoring it.
2022-11-08 20:52:29 +01:00
Zebediah Figura
c416627e64 vkd3d-shader/hlsl: Propagate copies for resource store instructions. 2022-10-31 22:07:47 +01:00
Zebediah Figura
9bdae4dfaa vkd3d-shader/hlsl: Write SM4 UAV store instructions. 2022-10-31 22:07:45 +01:00
Zebediah Figura
03f9d16047 vkd3d-shader/hlsl: Parse UAV stores. 2022-10-31 22:07:44 +01:00
Zebediah Figura
0a2aaa690e vkd3d-shader/hlsl: Implement typed UAV loads. 2022-10-31 22:07:43 +01:00
Zebediah Figura
12e397de9a vkd3d-shader/hlsl: Write SM4 UAV declarations. 2022-10-31 22:07:41 +01:00
Zebediah Figura
2ec67e0f10 vkd3d-shader/hlsl: Allocate UAVs. 2022-10-31 22:07:40 +01:00
Francisco Casas
5af7316a12 vkd3d-shader/hlsl: Support explicit cast between component-wise compatible types. 2022-10-25 21:25:58 +02:00
Francisco Casas
d21fd584b1 vkd3d-shader/hlsl: Support implicit casts between component-wise equal types. 2022-10-25 21:25:57 +02:00
Francisco Casas
1c77811648 vkd3d-shader/hlsl: Remove incorrect criteria for accepting implicit casts. 2022-10-25 21:25:55 +02:00
Francisco Casas
d93ce28995 vkd3d-shader/hlsl: Handle complex types in add_cast().
This extends the support of this function, whether doing broadcasts or
component-wise casts, to struct and array types.
2022-10-25 21:25:51 +02:00
Francisco Casas
0a345a2b73 vkd3d-shader/hlsl: Rename "t1" and "t2" arguments as "src" and "dst". 2022-10-25 21:25:49 +02:00
Zebediah Figura
0ef04659c7 vkd3d-shader/hlsl: Parse UAV types. 2022-10-19 21:59:55 +02:00
Zebediah Figura
fea50d243c vkd3d-shader/hlsl: Parse texture index expressions. 2022-10-19 21:59:55 +02:00
Zebediah Figura
7115a94063 vkd3d-shader/hlsl: Cast array indices inside of add_array_load().
Mostly in the interest of keeping the yacc code as simple as possible.
2022-10-19 21:59:55 +02:00
Giovanni Mascellani
0a07ac6f88 vkd3d-shader/hlsl: Lower float modulus.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-10-19 21:59:17 +02:00
Giovanni Mascellani
eb119878f7 vkd3d-shader/hlsl: Lower int modulus.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-10-19 21:59:15 +02:00
Giovanni Mascellani
85856473f6 vkd3d-shader/hlsl: Write SM4 fractional part instructions.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-10-19 21:59:13 +02:00
Francisco Casas
5a1b0dbf44 vkd3d-shader/hlsl: Always go through implicit conversion in assignments.
Otherwise we silently skip some type checks.
2022-10-17 17:58:56 +02:00
Giovanni Mascellani
eb7b594002 vkd3d-shader/hlsl: Lower int division. 2022-10-17 17:58:17 +02:00
Giovanni Mascellani
4c13ae5764 vkd3d-shader/hlsl: Lower int absolute value. 2022-10-17 17:58:14 +02:00
Giovanni Mascellani
5442f4236c vkd3d-shader/hlsl: Write SM4 square root instructions. 2022-10-17 17:58:12 +02:00
Giovanni Mascellani
8e5aefb309 vkd3d-shader/hlsl: Parse length() intrinsic. 2022-10-17 17:58:09 +02:00
Zebediah Figura
6b45f290f7 vkd3d-shader/hlsl: Pass a location pointer to init_node().
Instead of a flat location structure.
2022-10-12 21:58:03 +02:00
Zebediah Figura
20fc4375ad vkd3d-shader/hlsl: Introduce a hlsl_new_expr() helper. 2022-10-12 21:58:01 +02:00
Zebediah Figura
1e10b5e616 vkd3d-shader/hlsl: Write SM4 reinterpret instructions. 2022-10-12 21:57:59 +02:00
Zebediah Figura
2d4d2e1244 vkd3d-shader/hlsl: Parse the asuint() intrinsic. 2022-10-12 21:57:57 +02:00
Giovanni Mascellani
1655d309bd vkd3d-shader/hlsl: Write SM4 rsq instructions. 2022-10-10 21:13:04 +02:00
Giovanni Mascellani
d600f0488e vkd3d-shader/hlsl: Parse normalize intrinsic.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-10-10 21:13:03 +02:00
Zebediah Figura
b74a546034 vkd3d-shader/hlsl: Use hlsl_new_constant() in more places. 2022-09-28 19:11:08 +02:00
Zebediah Figura
f8da100052 vkd3d-shader/hlsl: Use hlsl_new_int_constant() in the "primary_expr" rule. 2022-09-28 19:11:05 +02:00
Zebediah Figura
3fc2fdc37f vkd3d-shader/hlsl: Introduce a hlsl_new_bool_constant() helper. 2022-09-28 19:11:02 +02:00
Zebediah Figura
4c5fd9c7b9 vkd3d-shader/hlsl: Introduce a hlsl_new_float_constant() helper. 2022-09-28 19:10:58 +02:00
Zebediah Figura
15a0b44ada vkd3d-shader/hlsl: Pass the arguments to hlsl_new_resource_load() as an indirect structure.
The function has far too many arguments, including multiple different arguments
with the same type. Use a structure for clarity and to avoid errors.

Merge hlsl_new_sample_lod() into hlsl_new_resource_load() accordingly.
2022-09-27 20:14:54 +02:00
Zebediah Figura
fb724d60e3 vkd3d-shader/hlsl: Make the source parameter to hlsl_copy_deref() const. 2022-09-27 20:14:53 +02:00
Zebediah Figura
e3123f5bd0 vkd3d-shader/hlsl: Pass only a template string to hlsl_new_synthetic_var().
Synthesize the internal name from the template inside of this function.
2022-09-27 20:14:51 +02:00
Zebediah Figura
991cddd139 vkd3d-shader/hlsl: Handle failure from hlsl_copy_deref(). 2022-09-27 20:14:49 +02:00
Giovanni Mascellani
d5fd309ef8 vkd3d: Add a macro to mark unreachable code.
This should silence warnings about some branches non returning any value
without requiring additional "return 0" statement or similar.

Also, in theory this might enable to compiler to optimize the program
a little bit more, though that's unlikely to have any measurable effect.
2022-09-27 20:14:27 +02:00
Henri Verbeet
56b2f56b86 Release 1.5. 2022-09-21 16:47:49 +02:00
Francisco Casas
8e07423ba1 vkd3d-shader/hlsl: Add offset parameter to 'Load' method.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
609632279f vkd3d-shader/hlsl: Properly check argument count in gather methods. 2022-08-23 15:57:54 -05:00
Francisco Casas
32e6f594f2 vkd3d-shader/hlsl: Properly check argument count in SampleLevel method.
Also, TextureCube and TextureCubeArray don't support the offset
argument, so this check is updated here too.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
15b19b15c0 vkd3d-shader/hlsl: Use proper dimensions on SampleLevel method offset parameter. 2022-08-23 15:57:54 -05:00
Francisco Casas
c4be4a4ebf vkd3d-shader/hlsl: Properly check argument count in Sample method.
Also, TextureCube and TextureCubeArray don't support the offset
argument, so this check is updated.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
562f647c2a vkd3d-shader/hlsl: Use proper dimensions on gather methods offset parameter. 2022-08-23 15:57:54 -05:00
Francisco Casas
652906aea7 vkd3d-shader/hlsl: Use proper dimensions on Sample method offset parameter.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Zebediah Figura
d6f45b730f vkd3d-shader/hlsl: Parse the SampleLevel method. 2022-08-23 15:57:54 -05:00
Francisco Casas
3d9baef321 vkd3d-shader/hlsl: Support initialization of implicit size arrays.
HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT (zero) is used as a temporal value
for elements_count for implicit size arrays.
This value is replaced by the correct one after parsing the initializer.

In case the implicit array is not initialized correctly, hlsl_error()
is called but the array size is kept at 0. So the rest of the code
must handle these cases.

In shader model 5.1, unlike in 5.0, declaring a multi-dimensional
object-type array with the last dimension implicit results in
an error. This happens even in presence of an initializer.

So, both gen_struct_fields() and declare_vars() first check if the
shader model is 5.1, the array elements are objects, and if there is
at least one implicit array size to handle the whole type as an
unbounded resource array.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
96a7236700 vkd3d-shader/hlsl: Set objects' register size back to 0.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
6989266e76 vkd3d-shader/hlsl: Check for non-static object references.
It is responsibility of the shader's programmer to ensure that
object references can be solved statically.

Resource arrays for ps_5_1 and vs_5_1 are an exception which is not
properly handled yet. They probably deserve a different object type.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
1bba18aa75 vkd3d-shader/hlsl: Invalidate components more precisely in copy propagation.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
b5b08bd8a0 vkd3d-shader/hlsl: Replace register offsets with index paths in copy propagation.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
10bd0c48f8 vkd3d-shader/hlsl: Print halfs in dump_ir_constant().
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
a8b77b85ca vkd3d-shader/hlsl: Skip implicit conversion if types are equal.
Otherwise we get false in implicit_compatible_data_types() when passing
types that are equal but not convertible according to
convertible_data_type(); e.g. getting:

"Can't implicitly convert from Texture2D<float4> to Texture2D<float4>."

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
732f1737f4 vkd3d-shader/hlsl: Set component count for objects to 1.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
f3432966da vkd3d-shader/hlsl: Emit a fixme on complex resource load object derefs.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Francisco Casas
f843a7babb vkd3d-shader/hlsl: Rename 'inner_type' to 'element_type' in function name.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
2022-08-23 15:57:54 -05:00
Martin Storsjö
1c61b20616 vkd3d-shader/spirv: Fix the signature of vkd3d_spirv_build_op_type_image.
Don't assume that enums and uint32_t parameters are identical. Clang
16 changes the diagonstic for incompatible function pointer types
from a warning into an error by default.

This fixes the following error, when built (for aarch64, but probably
also for other architectures) in MSVC mode:

../src/libs/vkd3d/libs/vkd3d-shader/spirv.c:1083:13: error: incompatible function pointer types passing 'uint32_t (struct vkd3d_spirv_builder *, uint32_t, SpvDim, uint32_t, uint32_t, uint32_t, uint32_t, SpvImageFormat)' (aka 'unsigned int (struct vkd3d_spirv_builder *, unsigned int, enum SpvDim_, unsigned int, unsigned int, unsigned int, unsigned int, enum SpvImageFormat_)') to parameter of type 'vkd3d_spirv_build7_pfn' (aka 'unsigned int (*)(struct vkd3d_spirv_builder *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)') [-Wincompatible-function-pointer-types]
            vkd3d_spirv_build_op_type_image);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/libs/vkd3d/libs/vkd3d-shader/spirv.c:612:68: note: passing argument to parameter 'build_pfn' here
        SpvOp op, const uint32_t *operands, vkd3d_spirv_build7_pfn build_pfn)
                                                                   ^

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-08-15 21:59:38 +02:00
Francisco Casas
577014c017 vkd3d-shader/hlsl: Replace register offsets with index paths in split copies.
hlsl_new_store() and hlsl_new_load() are deleted, so now there are no more
direct ways to create derefs with offsets in hlsl.c and hlsl.h.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:34:19 +02:00
Francisco Casas
d7d2fe145f vkd3d-shader/hlsl: Replace register offsets with index paths in input/output copies.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:34:08 +02:00
Francisco Casas
1b69adbd13 vkd3d-shader/hlsl: Add input and output variables using the same function.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:34:05 +02:00
Francisco Casas
c572adbf2a vkd3d-shader/hlsl: Move register offset functions to hlsl_codegen.c.
This can be done now, to ensure that register offsets are no longer used
in hlsl.c and hlsl.h.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:34:01 +02:00
Francisco Casas
349aab2a6a vkd3d-shader/hlsl: Replace register offsets with index paths in resource loads initialization.
At this point, the parse code is free of offsets; it only uses index
paths.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:33:58 +02:00
Francisco Casas
5b664c7a5c vkd3d-shader/hlsl: Introduce hlsl_new_store_index().
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:33:55 +02:00
Francisco Casas
f3289e1661 vkd3d-shader/hlsl: Introduce hlsl_new_store_component().
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:33:51 +02:00
Francisco Casas
7515b8255b vkd3d-shader/hlsl: Print index paths in dump_deref().
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:33:46 +02:00
Francisco Casas
4fede46c9a vkd3d-shader/hlsl: Replace register offsets with index paths in load initializations.
The transform_deref_paths_into_offsets pass turns these index paths back
into register offsets.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:33:37 +02:00
Francisco Casas
2dcfc888fb vkd3d-shader/hlsl: Unify type minor/major size functions.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:33:29 +02:00
Francisco Casas
039b69ace9 vkd3d-shader/hlsl: Introduce add_load_index().
At this point add_load() is split into add_load_component() and
add_load_index(); register offsets are hidden for these functions.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:33:25 +02:00
Francisco Casas
a32157f586 vkd3d-shader/hlsl: Introduce add_load_component().
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
2022-08-10 21:33:19 +02:00
Conor McCarthy
3dbd2ceca6 vkd3d-shader: Introduce a compile option to use Unknown format for typed UAV loads.
Specifying R32 for UAVs created with a vector format, e.g. R32G32B32A32_FLOAT,
results in only the red being loaded/stored, potentially causing images to
contain only the red component.

Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
2022-08-09 22:14:28 +02:00
Stefan Dösinger
aae4e31ba8 vkd3d-shader: Initialize counter_var_info unconditionally. 2022-07-25 21:09:30 +02:00
Francisco Casas
a7a4eb95e5 vkd3d-shader/hlsl: Introduce function to clean up hlsl_derefs.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-07-18 22:07:42 +02:00
Francisco Casas
b9435fb1ff vkd3d-shader/hlsl: Pass field to add_record_load() via index.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-07-18 22:07:33 +02:00
Francisco Casas
300a6c8fc3 vkd3d-shader/hlsl: Handle errors in recursive calls in hlsl_type_clone().
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-07-18 22:07:30 +02:00
Zebediah Figura
e5905bbf0f vkd3d-shader/hlsl: Store the struct fields as an array.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-07-18 22:07:26 +02:00
Giovanni Mascellani
448f856c09 vkd3d-shader/hlsl: Write SM4 logic or instructions.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-07-05 22:43:28 +02:00
Giovanni Mascellani
15e4b9bafb vkd3d-shader/hlsl: Write SM4 logic and instructions.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-07-05 22:43:25 +02:00
Giovanni Mascellani
02d92c9af6 vkd3d-shader/hlsl: Write SM4 logic not instructions.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-07-05 22:43:22 +02:00
Giovanni Mascellani
3e88a46d4c vkd3d-shader/hlsl: Write SM4 casts from bool.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-07-05 22:43:18 +02:00
Giovanni Mascellani
98ebe9b69c vkd3d-shader/hlsl: Fold constant integral bitwise or.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-28 22:20:27 +02:00
Giovanni Mascellani
06c22b6a65 vkd3d-shader/hlsl: Fold constant integral bitwise and.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-28 22:20:24 +02:00
Giovanni Mascellani
4016ddff77 vkd3d-shader/hlsl: Fold constant integral bitwise xor.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-28 22:20:22 +02:00
Giovanni Mascellani
4a692dca4e vkd3d-shader/hlsl: Fold constant integral min().
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-28 22:20:17 +02:00
Giovanni Mascellani
8cb865d65a vkd3d-shader/hlsl: Fold constant integral max().
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-28 22:20:11 +02:00
Zebediah Figura
0ddaa80616 vkd3d-shader/hlsl: Fold constant swizzles.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-28 22:20:08 +02:00
Giovanni Mascellani
7682da58a8 vkd3d-shader/hlsl: Parse lerp() intrinsic.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-27 21:23:33 +02:00
Zebediah Figura
bb32ffad18 vkd3d-shader/hlsl: Parse the ldexp() intrinsic.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-27 21:23:31 +02:00
Giovanni Mascellani
c7198bc964 vkd3d-shader/hlsl: Write SM4 dot product instructions.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-27 21:23:28 +02:00
Giovanni Mascellani
58d017ccc1 vkd3d-shader/hlsl: Parse dot() intrinsic.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-27 21:23:26 +02:00
Henri Verbeet
9d4df5e704 Release 1.4.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-22 18:31:51 +02:00
Giovanni Mascellani
10917a7f47 vkd3d-shader/hlsl: Parse the mul() intrinsic.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-09 19:13:29 +02:00
Giovanni Mascellani
62fa53f9b6 vkd3d-shader/hlsl: Split matrix operations.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-09 19:13:27 +02:00
Giovanni Mascellani
3a755cb0e2 vkd3d-shader/hlsl: Lower matrix casts.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-09 19:13:22 +02:00
Giovanni Mascellani
76bb1b7439 vkd3d-shader/hlsl: Have add_expr() return hlsl_ir_node*.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-08 18:51:38 +02:00
Giovanni Mascellani
e37ac63813 vkd3d-shader/hlsl: Introduce add_cast() helper.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-08 18:51:32 +02:00
Giovanni Mascellani
8cd4995958 vkd3d-shader/hlsl: Allocate enough space for temporary matrices.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-08 18:51:28 +02:00
Zebediah Figura
ea38ecc4ff vkd3d-shader/hlsl: Split matrices into multiple variables in prepend_input_copy().
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-08 18:51:03 +02:00
Zebediah Figura
d2d4bc24e9 vkd3d-shader/hlsl: Split matrices into multiple variables in append_output_copy().
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-08 18:50:52 +02:00
Zebediah Figura
14f77294b1 vkd3d-shader/spirv: Do not print a warning for VKD3D_SHADER_COMPILE_OPTION_API_VERSION.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-07 19:39:52 +02:00
Zebediah Figura
174172887b vkd3d-shader: Allow writing log output via a custom callback.
When using PE vkd3d through Wine, debug output may be swallowed by writing to
Win32 stderr. Avoid this by providing a way to hook up vkd3d log output to Wine
output.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-07 19:38:49 +02:00
Giovanni Mascellani
bb49bdba6a vkd3d-shader/hlsl: Allow majority modifiers on function declarations.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-13 18:21:15 +02:00
Giovanni Mascellani
e39559690b vkd3d-shader/hlsl: Offset register id for input/ouput variables.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-13 18:21:12 +02:00
Matteo Bruni
228f7ab5cd vkd3d-shader/hlsl: Handle over/underflow when parsing integer literals.
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-12 19:33:56 +02:00
Giovanni Mascellani
e6ce077ad4 vkd3d-shader/hlsl: Handle loops in copy propagation.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-04 18:32:35 +02:00
Giovanni Mascellani
ec85eb538b vkd3d-shader/hlsl: Remove the location parameter from initialize_var_components().
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-04 18:32:26 +02:00
Giovanni Mascellani
9ad6ad7065 vkd3d-shader/hlsl: Use a more sensible source location in add_constructor().
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-04 18:32:22 +02:00
Giovanni Mascellani
6167b3a4e2 vkd3d-shader/hlsl: Handle branches in copy propagation.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-02 11:30:21 +02:00
Giovanni Mascellani
38d7913f5f vkd3d-shader/hlsl: Allow storing to matrices.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-02 11:30:18 +02:00
Francisco Casas
a58c0e7c9d vkd3d-shader/hlsl: Detect missing loads on rhs when splitting copies of non-numeric types.
Otherwise we can get failed assertions:
assert(node->type == HLSL_IR_LOAD);
because broadcasts to these types are not implemented yet.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-02 11:29:54 +02:00
Giovanni Mascellani
cf7cf05cb7 vkd3d-shader/hlsl: Parse matrix constructors.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-27 21:45:45 +02:00
Giovanni Mascellani
ff3ec5d4a5 vkd3d-shader/hlsl: Support matrix indexing.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-27 21:45:43 +02:00
Francisco Casas
246ff14511 vkd3d-shader/hlsl: Support all complex initalizers.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-27 21:45:41 +02:00
Giovanni Mascellani
e2b4f01a9f vkd3d-shader/hlsl: Simplify flow in add_array_load().
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-27 21:45:39 +02:00
Giovanni Mascellani
c5c50a8b9b vkd3d-shader/hlsl: Do not generate useless swizzles.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-27 21:45:37 +02:00
Giovanni Mascellani
4d181bc622 vkd3d-shader/hlsl: Do not allow NaNs in SM1.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-27 21:45:32 +02:00
Zebediah Figura
9839850b87 vkd3d-shader: Remove the workaround for sample_c.
The current workaround is broken for texture cube arrays, which already have 4
components.

Sampling with the components not packed together apparently succeeds with newer
NVidia drivers, so just remove the workaround. Tested with 470.103.01 on a GTX
1060.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52886
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-26 16:02:09 +02:00
Giovanni Mascellani
74273ccadd vkd3d-shader/hlsl: Do not handle vector types in major_size() and minor_size().
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-25 22:12:55 +02:00
Giovanni Mascellani
d2ba10a696 vkd3d-shader/hlsl: Update split_copy()'s introductory comment.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-25 22:12:39 +02:00
Giovanni Mascellani
0e8098ccfe vkd3d-shader/hlsl: Add trailing dots to warning messages.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-25 22:12:23 +02:00
Giovanni Mascellani
c680b674d6 vkd3d-shader/hlsl: Do not generate infinities in SM1.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-25 22:12:17 +02:00
Giovanni Mascellani
e38ee49e99 vkd3d-shader/hlsl: Split matrix copies.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-20 23:02:14 +02:00
Giovanni Mascellani
d1fac2660c vkd3d-shader/hlsl: Support vector indexing.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-20 23:02:11 +02:00
Zebediah Figura
aaa743033a vkd3d-shader/hlsl: Return bool from add_record_load() and add_array_load().
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-20 23:02:00 +02:00
Giovanni Mascellani
2b23b7329c vkd3d-shader/hlsl: Fold constant modulus.
This commit includes work by Francisco Casas.

Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-15 21:18:20 +02:00
Giovanni Mascellani
40b299c727 vkd3d-shader/hlsl: Fold constant division.
This commit includes work by Francisco Casas.

Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-15 21:18:17 +02:00
Francisco Casas
aefadb87b6 vkd3d-shader/hlsl: Support complex numeric initializers.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-15 21:18:15 +02:00
Francisco Casas
9c518b45d1 vkd3d-shader/hlsl: Handle static struct initializer instructions.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-15 21:18:13 +02:00
Francisco Casas
7cee81cf3e vkd3d-shader/hlsl: Remove instruction list parameter in struct_var_initializer().
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-15 21:18:11 +02:00
Francisco Casas
7d31fd1788 vkd3d-shader/hlsl: Ensure that SM4 endif has 0 source registers.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-11 22:45:59 +02:00
Giovanni Mascellani
53d7433054 vkd3d-shader/hlsl: Write SM4 right shift instructions.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-07 18:32:13 +02:00
Giovanni Mascellani
95df144c69 vkd3d-shader/hlsl: Assert that bool values are not bit-shifted.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-07 18:32:10 +02:00
Giovanni Mascellani
ed921151b0 vkd3d-shader/hlsl: Write SM4 uint modulus instructions.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-07 18:32:07 +02:00
Giovanni Mascellani
e37f1ed26d vkd3d-shader/hlsl: Write SM4 uint division instructions.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-07 18:32:04 +02:00
Giovanni Mascellani
f3e81645be vkd3d-shader/hlsl: Write SM4 uint negation instructions.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-07 18:32:00 +02:00
Giovanni Mascellani
c92897ffd2 vkd3d-shader/hlsl: Write SM4 int multiplication instructions.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-07 18:31:55 +02:00
Giovanni Mascellani
8c086b5c91 vkd3d-shader/hlsl: Lower casts to bool to comparisons.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-07 18:31:52 +02:00
Matteo Bruni
8fa196cf51 vkd3d-shader/hlsl: Handle HLSL_TYPE_DOUBLE in sm4_base_type().
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-07 18:31:46 +02:00
Matteo Bruni
233157649c vkd3d-shader/hlsl: Drop extra '\n' from hlsl_error() messages.
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-07 18:31:44 +02:00
Matteo Bruni
4ab4d42468 vkd3d-shader/hlsl: Drop extra '\n' from hlsl_fixme() messages.
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-07 18:31:42 +02:00
Giovanni Mascellani
1ec00d8eba vkd3d-shader/hlsl: Fold constant not-equal expressions.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-05 17:51:07 +02:00
Giovanni Mascellani
d9dc79de66 vkd3d-shader/hlsl: Store boolean constants as unsigned.
With this change it is possible to store booleans as 0xffffffff,
similarly as what happens at runtime.

Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-05 17:51:07 +02:00
Giovanni Mascellani
5b24f7a06c vkd3d-shader/hlsl: Add a helper to create constants of arbitrary type.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-05 17:51:07 +02:00
Giovanni Mascellani
39bd9b0943 vkd3d-shader/hlsl: Pass a pointer to the location to hlsl_new_*_constant().
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-05 17:51:07 +02:00
Giovanni Mascellani
58956922df vkd3d-shader/hlsl: Abort on inconsistent types in fold_cast().
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-05 17:51:07 +02:00
Giovanni Mascellani
c63fbbda06 vkd3d-shader/hlsl: Abort on inconsistent types in write_sm4_cast().
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-05 17:51:07 +02:00
Giovanni Mascellani
4739cf1d33 vkd3d-shader/hlsl: Check types when folding constants.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-05 17:51:07 +02:00
Giovanni Mascellani
bc7c89bc1f vkd3d-shader/hlsl: Use an unsigned variable for iteration.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-05 17:51:07 +02:00
Zebediah Figura
6e966bcf23 vkd3d-shader/hlsl: Allow "nointerpolation" to be specified on struct fields.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-05 17:50:19 +02:00
Matteo Bruni
428a6b4033 vkd3d-shader/hlsl: Report failure when encountering matrix instructions.
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-05 17:50:17 +02:00
Zebediah Figura
ea93c5c767 vkd3d-shader/hlsl: Write SM4 integer addition instructions.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-04 21:12:57 +02:00
Zebediah Figura
c9b7669240 vkd3d-shader/hlsl: Declare integer semantics as having constant interpolation.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-04 21:12:52 +02:00
Zebediah Figura
e6dabf22bf vkd3d-shader/hlsl: Respect the 'nointerpolation' modifier.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-04 21:12:47 +02:00
Zebediah Figura
8e07f65595 vkd3d-shader/hlsl: Allow mixing "in" and "out" with other modifiers.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-04 21:12:41 +02:00
Giovanni Mascellani
8e6c526779 vkd3d-shader/hlsl: Write SM4 bitwise NOT instructions.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-04 21:12:38 +02:00
Giovanni Mascellani
2959ad74f7 vkd3d-shader/hlsl: Write SM4 bitwise XOR instructions.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-04 21:12:34 +02:00
Giovanni Mascellani
f22d866cee vkd3d-shader/hlsl: Write SM4 bitwise OR instructions.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-04 21:12:30 +02:00
Matteo Bruni
d2104522fe vkd3d-shader/preproc: Don't add additional spaces after whitespace tokens.
This is especially a problem when e.g. it introduces a whitespace
before a #pragma directive, breaking shader compilation.

Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-31 21:24:56 +02:00
Francisco Casas
a75560af3d vkd3d-shader/hlsl: Treat all braceless initializers as assignments.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-31 21:24:53 +02:00
Francisco Casas
6284cf7d57 vkd3d-shader/hlsl: Don't check exact number of components for braceless initialization of numeric types.
The implicit conversion in add_assignment() takes responsability now.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-31 21:24:49 +02:00
Francisco Casas
22f0b1df77 vkd3d-shader/hlsl: Properly free parse_variable_def memory.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-31 21:24:46 +02:00
Francisco Casas
426c08eba4 vkd3d-shader/hlsl: Add 'braces' flag to parse initializers.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-31 21:24:43 +02:00
Francisco Casas
d9dc1a4554 vkd3d-shader/hlsl: Concatenate nested initializers.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-31 21:24:39 +02:00
Francisco Casas
bed085cf9a vkd3d-shader/hlsl: Avoid leaks on memory allocation failures when parsing initializers.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-31 21:24:35 +02:00
Zebediah Figura
41d75fde22 vkd3d-shader/hlsl: Write SM4 left shift instructions.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-18 22:20:36 +01:00
Zebediah Figura
ccb3326516 vkd3d-shader/hlsl: Write SM4 bitwise AND instructions.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-18 22:20:36 +01:00
Zebediah Figura
5251ecff89 vkd3d-shader/hlsl: Parse the sv_vertexid semantic.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-18 22:20:36 +01:00
Zebediah Figura
6569b37e97 vkd3d-shader/hlsl: Reverse the switch order in write_sm4_expr().
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-18 22:20:36 +01:00
Zebediah Figura
8fe4d7d37e vkd3d-shader/hlsl: Cast pow() input to float.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-18 22:20:36 +01:00
Francisco Casas
a7e6d6b9d2 vkd3d-shader/hlsl: Remove redundant type check in declare_vars().
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-18 22:20:36 +01:00
Giovanni Mascellani
84059d61c3 vkd3d-shader/hlsl: Allow offsets for scalar and vector variables.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-18 22:20:36 +01:00
Zebediah Figura
ee764359d0 vkd3d-shader/hlsl: Correctly calculate offsets for array elements.
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-18 22:20:32 +01:00
Zebediah Figura
fa17a170b1 vkd3d-shader/sm4: Recognise the msad opcode.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-14 18:31:08 +01:00
Francois Gouget
b64482e7c7 vkd3d-shader/spirv: Fix the spelling of some comments.
Signed-off-by: Francois Gouget <fgouget@free.fr>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-07 16:39:09 +01:00
Henri Verbeet
d1d9e713f2 Release 1.3.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-02 21:32:57 +01:00
Henri Verbeet
f0479f08bd vkd3d-shader/glsl: Disable support for the GLSL target.
Regrettably, support for the GLSL target is not mature enough for the
upcoming 1.3 release.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-02 19:53:59 +01:00
Matteo Bruni
e1865cf98a vkd3d-shader/hlsl: Remove trivial swizzles after each copy prop pass.
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-02 18:41:15 +01:00
Francisco Casas
94e8442355 vkd3d-shader/hlsl: Fix order of matrix dimensions in hlsl_type_to_string().
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-02 18:40:54 +01:00
Giovanni Mascellani
be5668382e vkd3d-shader/hlsl: Fix typing rules for logical NOT.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-02 18:40:50 +01:00