Conor McCarthy
ec5f195b6b
vkd3d-shader/spirv: Use the register index count in I/O registers in vkd3d_symbol_make_register().
2023-05-26 19:10:52 +02:00
Conor McCarthy
532fe01818
vkd3d-shader/spirv: Set the register index count in spirv_compiler_emit_default_control_point_phase().
2023-05-26 19:10:49 +02:00
Conor McCarthy
9c6040df02
vkd3d-shader/spirv: Set the register index count in spirv_compiler_emit_dcl_indexable_temp().
2023-05-26 19:10:47 +02:00
Conor McCarthy
bf1ecc0f60
vkd3d-shader/spirv: Set the register index count in spirv_compiler_emit_hull_shader_builtins().
2023-05-26 19:10:33 +02:00
Conor McCarthy
7e58511b76
vkd3d-shader/spirv: Set the register index count in spirv_compiler_get_invocation_id().
2023-05-26 19:10:30 +02:00
Ethan Lee
ea7d8c65bd
vkd3d-shader/tpf: Add support for emitting sample_l instructions.
...
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
2023-05-24 22:00:41 +02:00
Conor McCarthy
6835e8176f
vkd3d-shader/ir: Normalise signatures and input/output registers to the Shader Model 6 pattern.
...
In Shader Model 6 each signature element can span a range of register
indices, or 'rows', and system values do not share a register index with
non-system values. Inputs and outputs are referenced by element index
instead of register index. This patch merges multiple signature elements
into a single element under the following conditions:
- The register index in a load or store is specified dynamically by
including a relative address parameter with a base register index. The
dcl_index_range instruction is used to identify these.
- A register declaration is split across multiple elements which declare
different components of the register.
- A patch constant function writes tessellation factors. These are an
array in SPIR-V, but in SM 5.x each factor is declared as a separate
register, and these are dynamically indexed by the fork/join instance
id. Elimination of multiple fork/join phases converts the indices to
constants, but merging the signature elements into a single arrayed
element matches the SPIR-V output.
All references to input/output register indices are converted to element
indices. If a relative address is present, the element index is moved up
a slot so it cannot be confused with a constant offset. Existing code
only handles register index relative addressing for tessellation factors.
This patch adds generic support for it.
2023-05-24 22:00:29 +02:00
Conor McCarthy
110e48e54d
vkd3d-shader/ir: Eliminate struct vkd3d_shader_normaliser.
2023-05-24 22:00:28 +02:00
Conor McCarthy
31682c52c7
vkd3d-shader/spirv: Support emitting multi-dimensional array variables.
2023-05-24 22:00:27 +02:00
Francisco Casas
e060773c19
vkd3d-shader/hlsl: Extend the liveness of nodes produced outside loops.
...
Otherwise, it is possible that the register used by the temp is
overridden by a subsequent instruction within the same loop.
2023-05-24 22:00:21 +02:00
Zebediah Figura
855bb71f6d
vkd3d-shader/hlsl: Pass hlsl_constant_value and hlsl_type pointers to fold_nequal().
2023-05-23 21:08:22 +02:00
Zebediah Figura
d565caafb5
vkd3d-shader/hlsl: Pass hlsl_constant_value and hlsl_type pointers to fold_mul().
2023-05-23 21:08:21 +02:00
Zebediah Figura
623cd94997
vkd3d-shader/hlsl: Pass hlsl_constant_value and hlsl_type pointers to fold_add().
2023-05-23 21:08:20 +02:00
Zebediah Figura
7d9b24fe11
vkd3d-shader/hlsl: Pass hlsl_constant_value and hlsl_type pointers to fold_neg().
2023-05-23 21:08:19 +02:00
Zebediah Figura
eb04829e66
vkd3d-shader/hlsl: Pass hlsl_constant_value and hlsl_type pointers to fold_cast().
2023-05-23 21:08:17 +02:00
Ethan Lee
24d4ab7fb3
vkd3d-shader/hlsl: Add support for SampleGrad() method.
...
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
2023-05-23 21:07:49 +02:00
Nikolay Sivov
cf8cacd336
vkd3d-shader/hlsl: Improve UAV format type checking for buffer types.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-05-22 22:03:27 +02:00
Nikolay Sivov
cff22ecde8
vkd3d-shader/hlsl: Add support for writing RWStructuredBuffer declarations.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-05-22 22:03:26 +02:00
Nikolay Sivov
3de824bfd8
vkd3d-shader/hlsl: Add support for RWBuffer object.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-05-22 22:03:24 +02:00
Nikolay Sivov
44a90f5d41
vkd3d-shader: Fix dcl_uav_typed_* formatting.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-05-22 22:03:24 +02:00
Ethan Lee
fb9328d030
vkd3d-shader/hlsl: Fold constant integral abs().
...
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
2023-05-22 22:03:18 +02:00
Nikolay Sivov
dfa0076473
vkd3d-shader/hlsl: Add support for sample index argument in Load().
2023-05-22 22:03:12 +02:00
Nikolay Sivov
dc41444941
vkd3d-shader/hlsl: Convert ternary operator true/false values to a common type.
2023-05-09 21:51:46 +02:00
Conor McCarthy
be4a71da7d
vkd3d-shader/tpf: Validate input and output index ranges for default control point phases.
2023-05-09 21:51:33 +02:00
Conor McCarthy
3e50c4d13b
vkd3d-shader/tpf: Remove an unnecessary carriage return from a parser error message.
2023-05-09 21:51:32 +02:00
Conor McCarthy
6dd1b01284
vkd3d-shader/tpf: Validate index range declarations.
2023-05-09 21:51:31 +02:00
Conor McCarthy
d565fbdcd6
vkd3d-shader/tpf: Validate input/output registers.
2023-05-09 21:51:29 +02:00
Conor McCarthy
2166088b0b
vkd3d-shader/tpf: Validate signature element masks.
2023-05-09 21:51:28 +02:00
Conor McCarthy
b8e6482365
vkd3d-shader/tpf: Validate signature element register indices.
2023-05-09 21:51:19 +02:00
Conor McCarthy
adf7db021c
vkd3d-shader/tpf: Validate input/output register index counts.
2023-05-09 21:51:17 +02:00
Zebediah Figura
b1bc4044ae
vkd3d-shader/hlsl: Use %option nodefault in the lexer.
2023-05-09 21:51:09 +02:00
Zebediah Figura
600fdcd112
vkd3d-shader/hlsl: Lex invalid characters in #line directives.
...
Avoid letting them fall through to the default rule.
2023-05-09 21:51:08 +02:00
Zebediah Figura
7b8845474d
vkd3d-shader/preproc: Use %option nodefault in the lexer.
2023-05-09 21:51:06 +02:00
Zebediah Figura
871cf0b4b5
vkd3d-shader/preproc: Ignore newlines in C comments.
...
Avoid letting them fall through to the default rule.
2023-05-09 21:51:05 +02:00
Zebediah Figura
ddbfd88e74
vkd3d-shader/preproc: Lex whitespace and invalid characters in #include and #line directives.
...
Avoid letting them fall through to the default rule.
A syntax error will be emitted by the parser.
2023-05-09 21:51:01 +02:00
Zebediah Figura
da7670f7c8
vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from add_conditional().
2023-05-09 21:50:37 +02:00
Zebediah Figura
39bbac3cca
vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_uint_constant().
2023-05-09 21:50:36 +02:00
Zebediah Figura
b991f98e2f
vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_swizzle().
2023-05-09 21:50:35 +02:00
Zebediah Figura
306ae40696
vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_store_index().
2023-05-09 21:50:34 +02:00
Zebediah Figura
29a2b87f54
vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_simple_store().
2023-05-09 21:50:33 +02:00
Zebediah Figura
145a2dfd2d
vkd3d-shader/hlsl: Return bool from hlsl_new_store_component().
2023-05-09 21:50:31 +02:00
Francisco Casas
fd38c58112
vkd3d-shader/hlsl: Introduce hlsl_calloc().
...
This is just a wrapper of vkd3d_calloc(), that has the advantage of
checking for multiplication overflow.
2023-05-08 20:24:15 +02:00
Francisco Casas
ef7cf9b1ad
vkd3d-shader/hlsl: Support resource arrays when writting SM4.
...
The new fixmes can be triggered in presence of object components within
structs (for SM5).
In shaders such as this one:
struct apple
{
Texture2D tex : TEX;
float4 color : COLOR;
};
float4 main(struct apple input) : sv_target
{
return input.tex.Load(int3(1, 2, 3));
}
Or this one:
struct
{
Texture2D tex;
float4 color;
} s;
float4 main() : sv_target
{
return s.tex.Load(int3(1, 2, 3));
}
2023-05-08 20:24:15 +02:00
Francisco Casas
a91e6d4563
vkd3d-shader/hlsl: Write resource loads in SM1.
2023-05-08 20:24:15 +02:00
Francisco Casas
96c844ffb8
vkd3d-shader/hlsl: Write sampler declarations in SM1.
2023-05-08 20:24:15 +02:00
Francisco Casas
3e9a9c5051
vkd3d-shader/hlsl: Track objects sampling dimension.
2023-05-08 20:24:15 +02:00
Francisco Casas
4dba38e6c8
vkd3d-shader/hlsl: Track object components usage and allocate registers accordingly.
2023-05-08 20:24:14 +02:00
Francisco Casas
6f71077e3e
vkd3d-shader/hlsl: Skip object components when creating input/output copies.
2023-05-08 20:22:19 +02:00
Francisco Casas
4413f6b64b
vkd3d-shader/hlsl: Add fixme for uniform copies for objects within structs.
2023-05-08 20:22:17 +02:00
Francisco Casas
69ff249ef4
vkd3d-shader/hlsl: Support multiple-register variables in object regsets.
...
Variables that contain more than one object (arrays or structs) require
the allocation of contiguous registers in the respective object
register spaces.
2023-05-08 20:22:14 +02:00
Nikolay Sivov
7516adeeae
vkd3d-shader/hlsl: Add support for fmod() intrinsic.
2023-05-08 20:21:52 +02:00
Zebediah Figura
8b57a612d7
vkd3d-shader/hlsl: Map the colour output for ps_1_* to r0.
2023-05-03 21:12:39 +02:00
Zebediah Figura
b2959739ed
vkd3d-shader/hlsl: Rewrite the register allocator to allow allocating in multiple passes.
...
We will need this in order to allocate some "special" registers: ps_1_* output, sincos output, etc.
2023-05-03 21:12:38 +02:00
Zebediah Figura
71d8ff85c6
vkd3d-shader/hlsl: Avoid leaking the allocator register map in allocate_const_registers().
2023-05-03 21:12:37 +02:00
Zebediah Figura
c57ac0b207
vkd3d-shader/hlsl: Rename struct liveness to struct register_allocator.
2023-05-03 21:12:34 +02:00
Conor McCarthy
a0a18b1620
vkd3d-shader: Introduce an internal shader signature structure.
...
A register count is required for Shader Model 6 signatures, including
those normalised from earlier models.
2023-05-03 21:12:07 +02:00
Conor McCarthy
5ae068168c
vkd3d-shader/tpf: Return an error from vkd3d_shader_sm4_parser_create() if the parser failed.
2023-05-03 21:12:06 +02:00
Conor McCarthy
85eb231492
vkd3d-shader/d3dbc: Return an error from vkd3d_shader_sm1_parser_create() if the parser failed.
2023-05-03 21:12:03 +02:00
Francisco Casas
34ddc13390
vkd3d-shader/hlsl: Don't keep the implicit mipmap level on hlsl_ir_index.
2023-05-03 21:11:59 +02:00
Francisco Casas
4aaf6b8895
vkd3d-shader/hlsl: Use hlsl_ir_index for resource access.
...
This patch makes index expressions on resources hlsl_ir_index nodes
instead of hlsl_ir_resource_load nodes, because it is not known if they
will be used later as the lhs of an hlsl_ir_resource_store.
For now, the only benefit is consistency.
2023-05-03 21:11:56 +02:00
Nikolay Sivov
87037d3748
vkd3d-shader/hlsl: Implement asfloat().
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-05-02 20:46:16 +02:00
Nikolay Sivov
7d41cf4440
vkd3d-shader/hlsl: Partially implement static expressions evaluation.
2023-05-02 20:46:08 +02:00
Zebediah Figura
6de904b448
vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_resource_store().
2023-05-02 20:46:03 +02:00
Zebediah Figura
3cc18f1e9f
vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_resource_load().
2023-05-02 20:46:02 +02:00
Zebediah Figura
8485b2ee95
vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_loop().
2023-05-02 20:46:00 +02:00
Zebediah Figura
3ca9656e84
vkd3d-shader/hlsl: Pass an hlsl_block pointer to hlsl_new_loop().
2023-05-02 20:45:59 +02:00
Zebediah Figura
e848c57b46
vkd3d-shader/hlsl: Reuse the "init" instruction list if possible in create_loop().
2023-05-02 20:45:57 +02:00
Henri Verbeet
3f8aa0e272
vkd3d-shader/d3d-asm: Rename trace.c to d3d_asm.c.
2023-05-02 20:45:33 +02:00
Henri Verbeet
73dc62aebf
vkd3d-shader: Get rid of the unused vkd3d_shader_src_param_entry structure.
2023-05-02 20:45:27 +02:00
Francisco Casas
abb207fab0
vkd3d-shader/hlsl: Always specify resource on intrinsic_tex().
...
Otherwise, in the added test, we get:
vkd3d-compiler: vkd3d-shader/hlsl.c:452: hlsl_init_deref_from_index_chain: Assertion `chain' failed.
because on the path that triggers the following error:
E5002: Wrong type for argument 1 of 'tex3D': expected 'sampler' or 'sampler3D', but got 'sampler2D'.
a NULL params.resource is passed to hlsl_new_resource_load() and
then to hlsl_init_deref_from_index_chain().
2023-05-01 22:18:46 +02:00
Ethan Lee
5d735f3b0e
vkd3d-shader/hlsl: Add support for sign() intrinsic.
...
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
2023-05-01 22:18:41 +02:00
Zebediah Figura
6e677def71
vkd3d-shader/hlsl: Normalize bools when loading from uniforms or vertex input.
2023-05-01 22:18:36 +02:00
Zebediah Figura
834497d5ac
vkd3d-shader/hlsl: Introduce an sm4_src_from_constant_value() helper.
2023-05-01 22:18:35 +02:00
Zebediah Figura
0a44e6043e
vkd3d-shader/hlsl: Put the hlsl_ir_constant value in a structure.
2023-05-01 22:18:33 +02:00
Francisco Casas
dcd991deda
vkd3d-shader/hlsl: Consider duplicated input semantic types equivalent in SM1.
2023-05-01 22:18:27 +02:00
Francisco Casas
34431239a5
vkd3d-shader/hlsl: Handle possibly different types in input semantic var load.
...
Since in SM1 all vector types use 4 register components, and since SM1
doesn't consider vectors of different dimx incompatible, it is necessary
to ensure that the semantic var is created with dimx=4, and to add a
cast node.
2023-05-01 22:18:26 +02:00
Francisco Casas
537d7c27a2
vkd3d-shader/hlsl: Error out when a semantic is used with incompatible types.
...
Considering row vectors from row_major matrices as having a different
layout as regular vectors, and error out in that case, is left as todo.
2023-05-01 22:18:24 +02:00
Francisco Casas
d96e9665b1
vkd3d-shader/hlsl: Error out when an output semantic is used more than once.
...
The use of the hlsl_semantic.reported_duplicated_output_next_index field
allows reporting multiple overlapping indexes, such as in the following
vertex shader:
void main(out float1x3 x : OVERLAP0, out float1x3 y : OVERLAP1)
{
x = float3(1.0, 2.0, 3.2);
y = float3(5.0, 6.0, 5.0);
}
apple.hlsl:1:41: E5013: Output semantic "OVERLAP1" is used multiple times.
apple.hlsl:1:13: First use of "OVERLAP1" is here.
apple.hlsl:1:41: E5013: Output semantic "OVERLAP2" is used multiple times.
apple.hlsl:1:13: First use of "OVERLAP2" is here.
While at the same time avoiding reporting overlaps more than once for
large arrays:
struct apple
{
float2 p : sv_position;
};
void main(out apple aps[4])
{
}
apple.hlsl:3:8: E5013: Output semantic "sv_position0" is used multiple times.
apple.hlsl:3:8: First use of "sv_position0" is here.
2023-05-01 22:18:22 +02:00
Francisco Casas
edc72fdefc
vkd3d-shader/hlsl: Support semantics for array types.
2023-05-01 22:18:21 +02:00
Francisco Casas
a488889494
vkd3d-shader/hlsl: Don't create semantic vars more than once.
2023-05-01 22:18:20 +02:00
Francisco Casas
b589c2b32d
vkd3d-shader/hlsl: Move get_array_size() and get_array_type() to hlsl.c.
2023-05-01 22:18:19 +02:00
Francisco Casas
61c72a4fd1
vkd3d-shader/hlsl: Avoid invalid input/output copies for non-numeric types.
2023-05-01 22:18:17 +02:00
Nikolay Sivov
7ba373946b
vkd3d-shader/hlsl: Implement D3DCOLORtoUBYTE4() function.
2023-04-28 21:04:13 +02:00
Nikolay Sivov
4b3707aeb4
vkd3d-shader/hlsl: Partially implement trunc().
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-28 21:04:11 +02:00
Ethan Lee
138c32ce88
vkd3d-shader/hlsl: Add support for ddx(), ddy() intrinsics.
...
SPIR-V already handled DSX/DSY, so only D3DBC/TPF needed new case blocks.
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
2023-04-28 21:03:40 +02:00
Nikolay Sivov
af4bb03795
vkd3d-shader/hlsl: Implement SampleBias() method.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-26 22:46:55 +02:00
Nikolay Sivov
c166ab9727
vkd3d-shader/hlsl: Add separate helpers to generate object methods.
...
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-26 22:46:53 +02:00
Nikolay Sivov
59c63ec584
vkd3d-shader/hlsl: Handle discard statement.
...
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-04-26 22:46:50 +02:00
Nikolay Sivov
6da7d16d4c
vkd3d-shader/trace: Add separate id for discard.
...
Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
2023-04-26 22:46:49 +02:00
Zebediah Figura
b46df551eb
vkd3d-shader/tpf: Return unsigned int from hlsl_sm4_register_from_semantic().
...
Fix a compile warning:
../vkd3d/libs/vkd3d-shader/hlsl_codegen.c: In function 'allocate_semantic_register':
../vkd3d/libs/vkd3d-shader/hlsl_codegen.c:2947:85: error: passing argument 4 of 'hlsl_sm4_register_from_semantic' from incompatible pointer type [-Werror=incompatible-pointer-types]
2947 | if ((builtin = hlsl_sm4_register_from_semantic(ctx, &var->semantic, output, &type, NULL, &has_idx)))
| ^~~~~
| |
| unsigned int *
In file included from ../vkd3d/libs/vkd3d-shader/hlsl_codegen.c:21:
../vkd3d/libs/vkd3d-shader/hlsl.h:1171:52: note: expected 'enum vkd3d_sm4_register_type *' but argument is of type 'unsigned int *'
1171 | bool output, enum vkd3d_sm4_register_type *type, enum vkd3d_sm4_swizzle_type *swizzle_type, bool *has_idx);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
2023-04-21 20:55:56 +02:00
Nikolay Sivov
317b8aa039
vkd3d-shader/hlsl: Ignore "unroll" attribute for loops.
2023-04-21 20:55:48 +02:00
Henri Verbeet
8e0df3f720
vkd3d-shader/sm1: Merge hlsl_sm1.c into d3dbc.c.
2023-04-20 22:54:32 +02:00
Henri Verbeet
99bc07ccf5
vkd3d-shader/sm4: Merge sm4.h into tpf.c.
2023-04-20 22:54:31 +02:00
Henri Verbeet
7800c7b40f
vkd3d-shader/sm4: Rename hlsl_sm4.c to tpf.c.
2023-04-20 22:54:30 +02:00
Henri Verbeet
804e315b68
vkd3d-shader/sm4: Move the TPF parser from dxbc.c to hlsl_sm4.c.
2023-04-20 22:54:28 +02:00
Zebediah Figura
0959c6663f
vkd3d-shader/hlsl: Remove an unused local variable from create_loop().
2023-04-20 22:54:13 +02:00
Zebediah Figura
39a03cfd22
vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_load_component().
2023-04-20 22:54:12 +02:00
Zebediah Figura
a98686ed78
vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from add_load_component().
2023-04-20 22:54:11 +02:00
Zebediah Figura
e5ec431784
vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_jump().
2023-04-20 22:54:10 +02:00
Zebediah Figura
dfe056596a
vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_int_constant().
2023-04-20 22:54:09 +02:00