Commit Graph

565 Commits

Author SHA1 Message Date
Nikolay Sivov
ec8dfa467f vkd3d-shader/hlsl: Add initial support for parsing 'switch' statements.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-10-31 21:58:57 +01:00
Henri Verbeet
96556a8834 vkd3d-shader/hlsl: Add support for RWTexture2DArray. 2023-10-19 23:07:31 +02:00
Henri Verbeet
2c71c18879 vkd3d-shader/hlsl: Add support for RWTexture1DArray. 2023-10-19 23:07:30 +02:00
Nikolay Sivov
1930b51d97 vkd3d-shader/hlsl: Allow interpolation modifiers on structure fields.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-10-09 21:58:27 +02:00
Nikolay Sivov
de860c3cbf vkd3d-shader/hlsl: Parse 'centroid' and 'noperspective' modifiers.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-10-09 21:58:24 +02:00
Nikolay Sivov
e4b423d6b5 vkd3d-shader/hlsl: Handle 'continue' statements.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-10-09 21:58:14 +02:00
Nikolay Sivov
0e5749e78e vkd3d-shader/hlsl: Allow 'break' instructions in loops.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-10-09 21:58:12 +02:00
Nikolay Sivov
b5c0c9c22f vkd3d-shader/hlsl: Add fwidth() function.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-10-05 16:15:10 +02:00
Petrichor Park
976fd67f51 vkd3d-shader/hlsl: Implement intrinsic tan.
This commit also extends the trigonometry tests a little bit to make
sure that tan works right.
2023-09-25 22:07:13 +02:00
Nikolay Sivov
177ea3bcbd vkd3d-shader/hlsl: Produce 2D resource declarations and loads for tex1D().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-09-13 23:11:11 +02:00
Nikolay Sivov
fc2aaee224 vkd3d-shader: Use ternary operator in fmod() implementation.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-09-07 19:15:26 +02:00
Nikolay Sivov
1002a6b357 vkd3d-shader/tpf: Use 'movc' to implement ternary operator.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-09-07 19:15:25 +02:00
Nikolay Sivov
c5d680d141 vkd3d-shader/hlsl: Add tex1D() function.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-09-07 19:15:06 +02:00
Zebediah Figura
a597dc8755 vkd3d-shader/hlsl: Define lit() in HLSL. 2023-08-30 22:49:03 +02:00
Zebediah Figura
9ab77658f2 vkd3d-shader/hlsl: Define smoothstep() in HLSL. 2023-08-30 22:49:01 +02:00
Zebediah Figura
f22e52f358 vkd3d-shader/hlsl: Separate an add_user_call() helper. 2023-08-30 22:48:57 +02:00
Nikolay Sivov
c39c5b3907 vkd3d-shader/hlsl: Add texCUBE() function.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-29 22:07:56 +02:00
Nikolay Sivov
18c1477464 vkd3d-shader/hlsl: Ignore 'inline' modifier for functions.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-28 20:39:53 +02:00
Nikolay Sivov
89eda51855 vkd3d-shader/hlsl: Change warning code for unknown loop attributes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-24 21:43:50 +02:00
Nikolay Sivov
1153f6bb34 vkd3d-shader/hlsl: Parse "if" statement attributes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-24 21:43:49 +02:00
Nikolay Sivov
4f2e07a45d vkd3d-shader/hlsl: Allow 'const' modifier without initializer in the global scope.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-08-15 21:51:50 +02:00
Zebediah Figura
0652bb1950 vkd3d-shader/hlsl: Store the "instrs" field of struct hlsl_attribute as a hlsl_block. 2023-08-08 21:15:08 +09:00
Zebediah Figura
372ddd1f29 vkd3d-shader/hlsl: Pass an hlsl_block pointer to add_load_component(). 2023-08-08 21:15:05 +09:00
Nikolay Sivov
d50b5fe767 vkd3d-shader/hlsl: Parse GetDimensions() method.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-07-31 21:07:48 +09:00
Zebediah Figura
819c5f1943 vkd3d-shader/hlsl: Pass an hlsl_block pointer to add_expr(). 2023-07-27 17:17:48 +09:00
Zebediah Figura
9d94506313 vkd3d-shader/hlsl: Pass an hlsl_block pointer to add_cast(). 2023-07-27 17:17:47 +09:00
Zebediah Figura
fe70ee2158 vkd3d-shader/hlsl: Pass an hlsl_block pointer to add_implicit_conversion(). 2023-07-27 17:17:46 +09:00
Zebediah Figura
21d5ee4df2 vkd3d-shader/hlsl: Pass an hlsl_block pointer to add_array_access(). 2023-07-27 17:17:41 +09:00
Zebediah Figura
c861a937e8 vkd3d-shader/hlsl: Pass an hlsl_block pointer to add_method_call(). 2023-07-27 17:17:37 +09:00
Zebediah Figura
f95ab2a5e8 vkd3d-shader/hlsl: Pass an hlsl_block pointer to add_assignment(). 2023-07-24 22:41:16 +02:00
Zebediah Figura
7e7a6d3691 vkd3d-shader/hlsl: Pass a hlsl_block pointer to hlsl_add_conditional(). 2023-07-24 22:41:15 +02:00
Zebediah Figura
cdabe172cb vkd3d-shader/hlsl: Return a hlsl_block from the "declaration" and "struct_declaration" rules. 2023-07-20 22:33:00 +02:00
Zebediah Figura
54bd6f7b4b vkd3d-shader/hlsl: Return a hlsl_block from the "declaration_statement" rule. 2023-07-20 22:32:59 +02:00
Zebediah Figura
77e1c5893e vkd3d-shader/hlsl: Return a hlsl_block from the "primary_expr" rule. 2023-07-20 22:32:57 +02:00
Zebediah Figura
aec9ea085e vkd3d-shader/hlsl: Return a hlsl_block from the "postfix_expr" rule. 2023-07-11 22:44:15 +02:00
Zebediah Figura
e222a786a1 vkd3d-shader/hlsl: Return a hlsl_block from binary and ternary expression rules. 2023-07-11 22:44:12 +02:00
Zebediah Figura
3079c874e3 vkd3d-shader/hlsl: Return a hlsl_block from the "unary_expr" rule. 2023-07-11 22:44:10 +02:00
Zebediah Figura
28dff58fb5 vkd3d-shader/hlsl: Return a hlsl_block from the "initializer_expr" rule. 2023-07-11 22:44:09 +02:00
Zebediah Figura
53d5ea639c vkd3d-shader/hlsl: Return a hlsl_block from the "assignment_expr" rule. 2023-07-11 22:44:06 +02:00
Zebediah Figura
6e303af519 vkd3d-shader/hlsl: Free the "iter" block pointer on success in create_loop().
Spotted by Giovanni Mascellani.
2023-07-05 22:32:48 +02:00
Zebediah Figura
b0ac77b44d vkd3d-shader/hlsl: Return a hlsl_block from the "expr_statement" and "expr" rules. 2023-07-05 22:32:47 +02:00
Zebediah Figura
07ce711583 vkd3d-shader/hlsl: Return a hlsl_block from the "jump_statement" rule. 2023-07-05 22:32:46 +02:00
Zebediah Figura
e4bf5933b9 vkd3d-shader/hlsl: Return a hlsl_block from the "selection_statement" rule. 2023-07-05 22:32:45 +02:00
Zebediah Figura
79dd9544b7 vkd3d-shader/hlsl: Return a hlsl_block from the "loop_statement" rule. 2023-07-05 22:32:43 +02:00
Zebediah Figura
23ff83e8a0 vkd3d-shader/hlsl: Return a hlsl_block from the "statement" rule.
As well as from the "statement_list" and "compound_statement" rules, which
trivially pass through from "statement".
2023-07-05 22:32:41 +02:00
Nikolay Sivov
06040d2a30 vkd3d-shader/hlsl: Disallow certain instruction types from constant expressions.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-07-04 22:39:57 +02:00
Nikolay Sivov
a65c0b0e22 vkd3d-shader/hlsl: Support evaluated expressions for sample count in multisampled textures declarations.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-07-04 22:39:55 +02:00
Francisco Casas
01800942a9 vkd3d-shader/hlsl: Declare vars individually when parsing struct declarations.
A struct declaration with variables is now absorbed into the 'declaration'
rule, like any other variable declaration.

A struct declaration without variables is now reduced to the
'struct_declaration_without_vars' rule.

They both are reduced to a 'declaration_statement' in the end.
2023-07-04 22:39:24 +02:00
Francisco Casas
62c891b796 vkd3d-shader/hlsl: Declare vars individually when parsing regular declarations.
In a declaration with multiple variables, the variables must be created
before the initializer of the next variable is parsed. This is required
for initializers such as:

    float a = 1, b = a, c = b + 1;

A requisite for this is that the type information is parsed in the same
rule as the first variable (as a variable_def_typed) so it is
immediately available to declare the first variable. Then, the next
untyped variable declaration is parsed, and the type from the first
variable can be used to declare the second, before the third is parsed,
and so on.
2023-07-04 22:39:21 +02:00
Francisco Casas
a34cf2e64e vkd3d-shader/hlsl: Split declare_vars().
Basically, declare_vars() is separated in three functions:

1. check_invalid_in_out_modifiers(), which is to be called once per
   declaration and emits an error when in or out modifiers are used for
   these non-parameter variables.

2. declare_var(), which now handles one variable at the time and doesn't
   free any memory.

3. initialize_vars(), which takes care of preparing the initialization
   instructions of several variables and frees their struct
   parse_variable_def, using exclusively free_parse_variable_def().

This allows to declare variables individually before the initializer of
the next variable in the same declaration is parsed, which is used in
the following patches.

Also, simplifies memory management.
2023-07-04 22:39:18 +02:00
Francisco Casas
e4d94d955c vkd3d-shader/hlsl: Support fine derivates. 2023-07-04 22:39:12 +02:00
Francisco Casas
ff31284f8d vkd3d-shader/hlsl: Support coarse derivates. 2023-07-04 22:39:10 +02:00
Zebediah Figura
9ccba35dde vkd3d-shader/hlsl: Store the fields of struct parse_if_body as hlsl_block pointers. 2023-06-28 21:40:18 +02:00
Zebediah Figura
8fa1750206 vkd3d-shader/hlsl: Store the "instrs" field of struct parse_initializer as a hlsl_block pointer. 2023-06-28 21:40:16 +02:00
Zebediah Figura
7d521db3db vkd3d-shader/hlsl: Merge the "discard_statement" rule into "jump_statement". 2023-06-28 21:40:15 +02:00
Zebediah Figura
588784e4dc vkd3d-shader/hlsl: Use add_unary_arithmetic_expr() in the subtraction rule. 2023-06-28 21:40:14 +02:00
Zebediah Figura
b4bf5af475 vkd3d-shader/hlsl: Factor out add_binary_expr_merge(). 2023-06-28 21:40:12 +02:00
Nikolay Sivov
4ed60cda13 vkd3d-shader: Remove extra newlines from compiler messages. 2023-06-27 22:34:19 +02:00
Nikolay Sivov
9ccf291971 vkd3d-shader/hlsl: Use profile version testing helpers in more places. 2023-06-27 22:34:05 +02:00
Nikolay Sivov
5c02e12187 vkd3d-shader/hlsl: Make sample count optional for SM4.1+.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-06-27 22:34:03 +02:00
Nikolay Sivov
861078d63a vkd3d-shader/hlsl: Handle 'texkill' discard type for sm4+.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-06-27 22:33:50 +02:00
Nikolay Sivov
8d84e206ab vkd3d-shader/hlsl: Parse clip() function.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-06-27 22:33:48 +02:00
Nikolay Sivov
b40179da3a vkd3d-shader/hlsl: Add a parameter for jump nodes and use it for 'discard'. 2023-06-27 22:33:47 +02:00
Nikolay Sivov
d856be0519 vkd3d-shader/hlsl: Handle static constants in array size expressions. 2023-06-12 22:50:12 +02:00
Nikolay Sivov
99314b6340 vkd3d-shader/hlsl: Store static initialization instructions in a block. 2023-06-12 22:50:11 +02:00
Zebediah Figura
f34b107faf vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_constant(). 2023-06-08 18:50:35 +02:00
Zebediah Figura
740b0ad807 vkd3d-shader/hlsl: Pass a hlsl_constant_value pointer to hlsl_new_constant(). 2023-06-08 18:50:34 +02:00
Nikolay Sivov
82ddc6b417 vkd3d-shader/hlsl: Fix sampler type used for samplerCUBE. 2023-06-05 22:27:36 +02:00
Nikolay Sivov
a2e85a8a76 vkd3d-shader/hlsl: Parse SampleCmpLevelZero() method. 2023-05-29 20:21:17 +02:00
Nikolay Sivov
2fd3550ba6 vkd3d-shader/hlsl: Parse SampleCmp() method. 2023-05-29 20:21:14 +02:00
Nikolay Sivov
7c94705c54 vkd3d-shader/hlsl: Parse SamplerComparisonState objects. 2023-05-29 20:21:11 +02:00
Nikolay Sivov
efe107d231 vkd3d-shader/hlsl: Use a function table for object methods handlers. 2023-05-29 20:21:10 +02:00
Nikolay Sivov
87cd3f872b vkd3d-shader/hlsl: Move object type checks to methods handlers. 2023-05-29 20:21:07 +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
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
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
3e9a9c5051 vkd3d-shader/hlsl: Track objects sampling dimension. 2023-05-08 20:24:15 +02:00
Nikolay Sivov
7516adeeae vkd3d-shader/hlsl: Add support for fmod() intrinsic. 2023-05-08 20:21:52 +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
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
0a44e6043e vkd3d-shader/hlsl: Put the hlsl_ir_constant value in a structure. 2023-05-01 22:18:33 +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
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
317b8aa039 vkd3d-shader/hlsl: Ignore "unroll" attribute for loops. 2023-04-21 20:55:48 +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
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
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
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
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
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
c190c184ce vkd3d-shader/hlsl: Add support for ternary operator. 2023-04-06 17:51:46 +02:00
Zebediah Figura
ceac81b816 vkd3d-shader/hlsl: Introduce an hlsl_block_add_instr() helper. 2023-04-06 17:51:36 +02:00
Francisco Casas
bf4a125087 vkd3d-shader/hlsl: Ignore packoffset() contents for SM1. 2023-04-04 21:59:47 +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
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
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
ae2f777a4d vkd3d-shader/hlsl: Parse multisample texture type names. 2023-03-08 20:15:09 +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
Nikolay Sivov
891217664a vkd3d-shader/hlsl: Support case-insensitive lookup for builtin 'dword' type. 2023-02-23 21:46:38 +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
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
Nikolay Sivov
e7bc634307 vkd3d-shader/hlsl: Support reflect() intrinsic.
Tests authored by Giovanni.
2023-02-20 21:59:23 +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
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
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
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
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
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
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
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
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
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
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
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
Zebediah Figura
d6799bd5d3 vkd3d-shader/hlsl: Parse function attributes. 2022-11-08 20:53:03 +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