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