Commit Graph

486 Commits

Author SHA1 Message Date
Shaun Ren
1ed5f1a4d0 vkd3d-shader/tpf: Write the patch constant function in hull shaders.
We use a single hs_fork_phase here for the patch constant function.
2024-10-16 21:40:40 +02:00
Shaun Ren
147f8898ca vkd3d-shader/hlsl: Process the patch constant function in hlsl_emit_bytecode().
Also, support patch constant function semantics in sm4_sysval_semantic_from_semantic_name().
2024-10-16 21:10:24 +02:00
Francisco Casas
7eee877dd4 vkd3d-shader/tpf: Make hlsl_sm4_register_from_semantic() independent of HLSL IR. 2024-10-16 21:07:51 +02:00
Francisco Casas
a243862b8c vkd3d-shader/tpf: Make sysval_semantic_from_hlsl() independent of HLSL IR. 2024-10-16 21:05:10 +02:00
Francisco Casas
3601397703 vkd3d-shader/d3dbc: Remove the "hlsl_" prefix from external functions.
They no longer rely on HLSL IR.

Also, rename them from "_from_semantic" to "from_semantic_name".
2024-10-16 16:52:45 +02:00
Nikolay Sivov
6801ad9b7a vkd3d-shader/fx: Introduce a parser/disassembler.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-10-14 15:20:41 +02:00
Elizabeth Figura
6ee17cf77e vkd3d-shader/spirv: Implement shader point size. 2024-10-10 22:14:45 +02:00
Giovanni Mascellani
831a797837 vkd3d-shader/ir: Validate minimum precision in shader signatures. 2024-10-10 19:58:00 +02:00
Feifan He
2d7832e738 vkd3d-shader/msl: Generate shader descriptor structure declarations. 2024-10-10 19:40:34 +02:00
Giovanni Mascellani
7202e6e2f3 vkd3d-shader/ir: Allow a patch constant signature only for Hull and Domain Shaders. 2024-10-09 13:13:00 +02:00
Giovanni Mascellani
cd74461d6d vkd3d-shader/ir: Set the signature sort indices in shader_signature_merge().
Since the sort index is just a convenience field it is more
appropriate to only set it where it is required, instead of
requiring all frontends and passes to retain sensible values for
it.
2024-10-08 22:05:38 +02:00
Giovanni Mascellani
1256b4f862 vkd3d-shader/d3d-asm: Rename vkd3d_shader_trace() to vsir_program_trace(). 2024-10-08 22:04:59 +02:00
Henri Verbeet
cf92d9f398 vkd3d-shader/ir: Store the thread group size in struct vsir_program. 2024-10-08 22:03:05 +02:00
Henri Verbeet
eb10f0897e vkd3d-shader/glsl: Implement VKD3DSIH_LD. 2024-10-03 19:14:43 +02:00
Francisco Casas
caa2a9d314 vkd3d-shader/hlsl: Parse sampler_state. 2024-10-02 22:07:34 +02:00
Elizabeth Figura
4400315c4b vkd3d-shader: Allow controlling clip planes through vkd3d-shader parameters. 2024-10-02 21:49:54 +02:00
Giovanni Mascellani
0f91149260 vkd3d-shader/d3d-asm: Dump all indices when tracing VSIR code.
Our ASM dumper currently hides or interprets some register indices
in order to match users expectations. This can be inconvenient for
developers, though, because it makes it harder to understand what's
really going on in the VSIR code when reading logs. With this change
the whole index structure is dumped.
2024-09-30 20:22:53 +02:00
Giovanni Mascellani
8d85ea2dc5 vkd3d-shader: Get rid of the RESOURCE data type. 2024-09-26 17:42:16 +02:00
Giovanni Mascellani
e58726310b vkd3d-shader: Get rid of the UAV data type. 2024-09-26 17:42:16 +02:00
Giovanni Mascellani
2934f820a9 vkd3d-shader: Get rid of the SAMPLER data type. 2024-09-26 17:42:16 +02:00
Giovanni Mascellani
a2aeb3a142 vkd3d-shader/spirv: Cache numeric types without through the general declaration cache.
Numeric types are used very frequently, and doing a tree search
each time one is needed tends to waste a lot of time.

I ran the compilation of ~1000 DXBC-TPF shaders randomly taken from
my collection and measured the performance using callgrind and the
kcachegrind "cycle count" estimation.

BEFORE:
 * 1,764,035,136 cycles
 * 1,767,948,767 cycles
 * 1,773,927,734 cycles

AFTER:
 * 1,472,384,755 cycles
 * 1,469,506,188 cycles
 * 1,470,191,425 cycles

So callgrind would estimate a 16% improvement at least.
2024-09-23 15:48:35 +02:00
Giovanni Mascellani
637a3cabe7 vkd3d-shader/ir: Allow failure in shader_signature_find_element_for_reg().
shader_signature_find_element_for_reg() is also used in the TPF parser,
where the program has not been validated yet, so it must not crash
on errors.

The I/O normaliser can instead assume that the shader is already
validated.

This fixes a crash with a shader used by The Falconeer. The bug is still
present, because the shader will be incorrectly rejected, but at least
the vkd3d-shader will fail gracefully.
2024-09-20 17:01:29 +02:00
Henri Verbeet
ae40184631 vkd3d-shader/glsl: Implement support for VKD3DSPR_CONSTBUFFER registers. 2024-09-19 14:29:46 +02:00
Francisco Casas
ffc1449412 vkd3d-shader/hlsl: Allow effect calls on default value initializers. 2024-09-14 16:09:12 +02:00
Giovanni Mascellani
866f138875 vkd3d-shader/ir: Record the control flow type in the program. 2024-09-12 18:31:32 +02:00
Giovanni Mascellani
dcee148b1a vkd3d-shader/ir: Move the control flow type enumeration to vkd3d_shader_private.h. 2024-09-12 18:27:20 +02:00
Nikolay Sivov
ec644b395b vkd3d-shader/tpf: Create a stub STAT section.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-12 18:26:08 +02:00
Feifan He
5df81049aa vkd3d-shader/msl: Call vsir_program_transform() before generating code. 2024-09-12 18:09:00 +02:00
Feifan He
47981def0d vkd3d-shader/msl: Generate comments for unhandled instructions.
Similar to commit 8a60814476 for the GLSL
target.
2024-09-12 18:04:44 +02:00
Feifan He
23ba1a5e07 vkd3d-shader: Introduce VKD3D_SHADER_TARGET_MSL. 2024-09-12 17:03:32 +02:00
Giovanni Mascellani
096f133b09 vkd3d-shader/ir: Rename vsir_program_normalise() to vsir_program_transform(). 2024-09-11 15:13:14 +02:00
Francisco Casas
d70342d66d vkd3d-shader/hlsl: Save per-component hlsl_ir_exprs in the vsir_program for SM1. 2024-09-11 15:07:35 +02:00
Giovanni Mascellani
d8c41cc270 vkd3d-shader/ir: Run validation after normalising Hull Shader control points I/O registers. 2024-09-10 21:43:14 +02:00
Shaun Ren
41cb29c4c8 vkd3d-shader/hlsl: Parse the partitioning attribute. 2024-09-04 18:28:59 +02:00
Shaun Ren
615ffb823b vkd3d-shader/hlsl: Parse the outputtopology attribute. 2024-09-04 18:28:57 +02:00
Shaun Ren
dae88bab52 vkd3d-shader/hlsl: Parse the outputcontrolpoints attribute. 2024-09-04 18:28:46 +02:00
Shaun Ren
4dfd682446 vkd3d-shader/hlsl: Parse the domain attribute. 2024-09-04 18:21:15 +02:00
Francisco Casas
45f18a7838 vkd3d-shader/hlsl: Parse the shader 'compile' syntax.
The hlsl_ir_compile node is introduced to represent the "compile"
syntax, and later the CompileShader() and ConstructGSWithSO()
constructs.

It basically represents a function call that remembers its arguments
using hlsl_srcs and keeps its own instruction block, which is discarded
when working on non-effect shaders.

For shader compilations it can be asserted that args_count is 1, and
that this argument (and the last node in hlsl_ir_effect_call.instrs)
is a regular hlsl_ir_call pointing to the declaration of the function
to be compiled.
2024-09-04 17:58:56 +02:00
Francisco Casas
23e3ec84f7 vkd3d-shader/hlsl: Save hlsl_ir_constants in the vsir_program for SM1. 2024-09-04 17:51:30 +02:00
Francisco Casas
a61846c28a vkd3d-shader/hlsl: Store SM1 sampler dcls on the vsir_program. 2024-09-04 17:47:47 +02:00
Francisco Casas
9a564872c5 vkd3d-shader/hlsl: Store SM1 constant dcls on the vsir_program. 2024-09-04 17:44:46 +02:00
Giovanni Mascellani
527966580e vkd3d-shader: Dump the converted shader too. 2024-08-29 19:17:07 +02:00
Giovanni Mascellani
1a0d6a4db4 vkd3d-shader: Use a hash to build the filename when dumping shaders.
This way the same shader is always dumped to the same path and when
launching the same program over and over we avoid both creating new
copies of the same file each time and overwriting different dumped
shaders.
2024-08-29 19:14:27 +02:00
Henri Verbeet
114578fc8a vkd3d-shader/fx: Replace assert() with VKD3D_ASSERT(). 2024-08-13 21:20:28 +02:00
Giovanni Mascellani
8b6ab9627d vkd3d-shader: Replace assert() with VKD3D_ASSERT() in vkd3d_shader_private.h. 2024-08-08 23:39:23 +02:00
Elizabeth Figura
f6dd6d52b3 vkd3d-shader: Factor out a vsir_program_get_parameter() helper. 2024-07-23 21:10:00 +02:00
Elizabeth Figura
806363b765 vkd3d-shader: Allow controlling alpha test through vkd3d-shader parameters. 2024-07-11 17:02:11 +02:00
Elizabeth Figura
98def3214b vkd3d-shader: Introduce struct vkd3d_shader_parameter_info and struct vkd3d_shader_parameter1.
As the newly added documentation describes, this reroll serves two purposes:

* to allow shader parameters to be used for any target type (which allows using
  parameters for things like Direct3D 8-9 alpha test),

* to allow the union in struct vkd3d_shader_parameter to contain types larger
  than 32 bits (by specifying them indirectly through a pointer).
2024-07-11 16:48:09 +02:00
Victor Chiletto
2034a8bab9 vkd3d-shader/hlsl: Implement loop unrolling.
Based on a patch by Nikolay Sivov.

Co-authored-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-07-11 00:32:53 +02:00
Francisco Casas
60c8a813a3 vkd3d-shader/hlsl: Validate state block function calls. 2024-07-09 20:38:08 +02:00