Commit Graph

407 Commits

Author SHA1 Message Date
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
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
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
8e5aefb309 vkd3d-shader/hlsl: Parse length() intrinsic. 2022-10-17 17:58:09 +02:00
Zebediah Figura
20fc4375ad vkd3d-shader/hlsl: Introduce a hlsl_new_expr() helper. 2022-10-12 21:58:01 +02:00
Zebediah Figura
2d4d2e1244 vkd3d-shader/hlsl: Parse the asuint() intrinsic. 2022-10-12 21:57:57 +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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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