Francisco Casas
81be47c00b
vkd3d-shader/hlsl: Introduce hlsl_deref_is_lowered() helper.
...
Some functions work with dereferences and need to know if they are
lowered yet.
This can be known checking if deref->offset.node is NULL or
deref->data_type is NULL. I am using the latter since it keeps working
even after the following patches that split deref->offset into
constant and variable parts.
2023-10-31 21:59:12 +01:00
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
Nikolay Sivov
e242b46922
vkd3d-shader/tpf: Convert some of the semantic names to system values names when in compatibility mode.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-10-19 23:03:23 +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
Francisco Casas
4ab6572be7
vkd3d-shader/hlsl: Replace hlsl_type_get_regset() uses with hlsl_deref_get_regset().
2023-10-05 16:15:37 +02:00
Francisco Casas
dfce1e7f4a
vkd3d-shader/hlsl: Make regset an output argument in hlsl_type_get_component_offset().
...
Components only span across a single regset, so instead of expecting the
regset as input for the offset, hlsl_type_get_component_offset() can
actually retrieve it.
2023-10-05 16:15:26 +02:00
Giovanni Mascellani
f251da574c
vkd3d-shader/hlsl: Remove HLSL_OP3_LERP.
...
It is unused, and it's not clear whether it would be of any help to
have it.
2023-09-14 20:28:54 +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
Zebediah Figura
9ab77658f2
vkd3d-shader/hlsl: Define smoothstep() in HLSL.
2023-08-30 22:49:01 +02:00
Zebediah Figura
d396c4ce27
vkd3d-shader/hlsl: Store the internal name counter in struct hlsl_ctx.
...
This is minutely more efficient than using a global variable and atomic instructions.
2023-08-30 22:48:59 +02:00
Zebediah Figura
63e056512d
vkd3d-shader/hlsl: Introduce an hlsl_sprintf_alloc() helper.
2023-08-30 22:48:55 +02:00
Zebediah Figura
cf6bc95a3d
vkd3d-shader/hlsl: Use hlsl_block_add_instr() in clone_block().
2023-08-08 21:15:16 +09:00
Zebediah Figura
4ae00cea43
vkd3d-shader/hlsl: Clean up the static_initializers block when the context is destroyed (Valgrind).
...
This is currently leaked if we fail parsing before reaching codegen.
2023-08-08 21:15:13 +09:00
Zebediah Figura
b22e2113a6
vkd3d-shader/hlsl: Pass a hlsl_block pointer to dump_instr_list().
2023-08-08 21:15:10 +09: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
Nikolay Sivov
d50b5fe767
vkd3d-shader/hlsl: Parse GetDimensions() method.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-07-31 21:07:48 +09:00
Nikolay Sivov
bd3d4a6c06
vkd3d-shader: Add compiler option to specify matrix majority.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-07-24 22:41:09 +02:00
Zebediah Figura
44bf5556ae
vkd3d-shader/hlsl: Free the constant defs array in hlsl_ctx_cleanup().
...
Spotted by Francisco Casas.
2023-07-17 22:56:19 +02:00
Zebediah Figura
a55973d695
vkd3d-shader/hlsl: Lower combined samplers to separate sampler and texture objects for SM4.
...
Co-authored-by: Francisco Casas <fcasas@codeweavers.com>
2023-07-17 22:55:51 +02:00
Francisco Casas
c4f074d25d
vkd3d-shader/hlsl: Introduce hlsl_new_synthetic_var_named().
2023-07-17 22:55:46 +02:00
Francisco Casas
c58d666d1b
vkd3d-shader/hlsl: Handle resource components individually for SM 5.0.
2023-07-17 22:55:40 +02:00
Francisco Casas
ae6bc398d6
vkd3d-shader/hlsl: Allow derefs to provide the data_type.
...
After lowering the derefs path to a single offset node, there was no way
of knowing the type of the referenced part of the variable. This little
modification allows to avoid having to pass the data type everywhere and
it is required for supporting instructions that reference objects
components within struct types.
Since deref->data_type allows us to retrieve the type of the deref,
deref->offset_regset is no longer necessary.
2023-07-17 22:55:36 +02:00
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
Nikolay Sivov
69f32796b0
vkd3d-shader: Unify static string arrays initialization pattern.
2023-06-28 21:40:21 +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
Stefan Dösinger
5e88ab22aa
vkd3d-shader/hlsl: Make sure variants is initialized in declare_predefined_types().
...
MSVC is too stupid to see it is unused when n_variants=0.
2023-06-27 22:33:31 +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
Francisco Casas
ebf7573571
vkd3d-shader/hlsl: Support non-constant vector indexing.
...
Non-constant vector indexing is not solved with relative addressing
in the register indexes because this indexation cannot be at the level
of register-components.
Mathematical operations must be used instead.
2023-06-07 20:48:59 +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
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
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
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
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
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
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
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
0a44e6043e
vkd3d-shader/hlsl: Put the hlsl_ir_constant value in a structure.
2023-05-01 22:18:33 +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
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
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
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
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
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
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
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
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
Nikolay Sivov
4110f1e547
vkd3d-shader: Fix a few typos in the comments.
2023-03-15 20:13:27 +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
ae2f777a4d
vkd3d-shader/hlsl: Parse multisample texture type names.
2023-03-08 20:15:09 +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
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
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
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
Giovanni Mascellani
7c3dadce6b
vkd3d-shader/hlsl: Write SM4 break instructions.
2023-02-15 21:53:21 +01:00
Zebediah Figura
4b944517b7
vkd3d-shader/hlsl: Inline function calls.
2023-02-13 22:16:53 +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
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
Nikolay Sivov
06f300ec59
vkd3d-shader/hlsl: Support dot() for SM1.
2023-02-02 20:51:12 +01:00
Francisco Casas
f33ca836d7
vkd3d-shader/hlsl: Make single-component swizzles retrieve a scalar.
2023-01-26 21:52:18 +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