Commit Graph

870 Commits

Author SHA1 Message Date
Elizabeth Figura
54092286be vkd3d-shader/ir: Allow controlling FFP point size through a vkd3d-shader parameter. 2024-10-10 22:25:09 +02:00
Elizabeth Figura
6ee17cf77e vkd3d-shader/spirv: Implement shader point size. 2024-10-10 22:14:45 +02:00
Elizabeth Figura
56e5fca501 vkd3d-shader/spirv: Always write the point size in vertex shaders.
Vulkan requires that point size be written.

There should be no backwards compatibility concern here, since the vertex shader
supplies point size with the lowest priority.
2024-10-10 21:50:30 +02:00
Henri Verbeet
845d6f9134 vkd3d-shader/ir: Remove VKD3DSIH_DCL_UAV_TYPED instructions. 2024-10-10 20:00:45 +02:00
Giovanni Mascellani
9cb4207c92 vkd3d-shader/spirv: Write spirv_compiler_emit_variable() in terms of spirv_compiler_emit_array_variable().
Essentially for code clarity, so that it's more obvious that a
non-array variable is indeed an array variable with no indices.
2024-10-09 13:15:25 +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
Evan Tang
c571a45e65 vkd3d-shader/ir: Don't shift register write masks by the component index in shader_dst_param_io_normalise().
This loses information about which source elements they want, making
"o.yzw = reg.xxyz" compile to "o = reg.xxy" instead of "o = reg.xyz".
2024-10-07 17:36:11 +02:00
Giovanni Mascellani
ae27fded1a vkd3d-shader/spirv: Handle all possible destination modifiers.
Historically the SPIR-V backend was only fed by the TPF parser,
which only generates _sat destination modifiers. Now it is fed
by the D3DBC parser too (among others), so it mustn't assert on
other modifiers.

Modifier _pp can be trivially ignored. Modifier _centroid would
probably require some handling, but I'm not immediately sure of
what should happen and it doesn't look like a very urgent thing
anyway, so I'm degrading the assertion to FIXME().
2024-10-02 22:31:50 +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
e2c6058734 vkd3d-shader/spirv: Do not specify depth for SPIR-V images.
SPIR-V images have a "depth" parameter that, as far as I understand
(the spec doesn't look terribly clear in that regard), specifies
whether the image can be used for depth-comparison operations.

In TPF (and therefore in VSIR) the same information is specified
on the sampler type instead of on the image type. This puts us in
a hard spot, because in principle an image can be used with
many different samplers, and the mapping might even be unknown
at compilation time, so it's not clear how we should define our
images.

We currently have some algorithms to deal with that, but they are
incomplete and lead to SPIR-V validation errors like:

    Expected Image to have the same type as Result Type Image
      %63 = OpSampledImage %62 %59 %61

The problem here is that the image has a non-depth type, but is
being sampled as a depth image. This check was added recently to
SPIRV-Tools, so we became aware of the problem.

As I said, it's not easy in general to decide whether an image is
going to be sampled with depth-comparison operators or not.
Fortunately the SPIR-V spec allow to mark the depth parameter as
unknown (using value 2), so until we come up with something better
we use that for all images to please the validator and avoid
giving misleading hints to the driver.
2024-09-24 13:19:17 +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
3a21daa49e vkd3d-shader/spirv: Rewrite vkd3d_spirv_get_type_id_for_data_type() in terms of vkd3d_spirv_get_type_id(). 2024-09-23 15:48:35 +02:00
Giovanni Mascellani
9777c8bc65 vkd3d-shader/spirv: Do not reallocate the SPIR-V program.
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,846,641,596 cycles
 * 1,845,635,336 cycles
 * 1,841,335,225 cycles

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

So callgrind would estimate a 3.6% improvement at least.

The counterpoint is that the caller might get an allocation that
is potentially bigger than necessary. I would expect that allocation
to be rather short-lived anyway, so that's probably not a problem.
2024-09-20 17:14:49 +02:00
Giovanni Mascellani
35d3161f9d vkd3d-shader/spirv: Propagate errors from vkd3d_spirv_stream_append(). 2024-09-20 17:04:31 +02:00
Giovanni Mascellani
096f133b09 vkd3d-shader/ir: Rename vsir_program_normalise() to vsir_program_transform(). 2024-09-11 15:13:14 +02:00
Anna (navi) Figueiredo Gomes
3d8fc1a467 vkd3d-shader/spirv: Break long assembly lines.
Avoid overflowing the (Wine) debug log buffer when output lines are too
long, and keep spirv-text output more legible. The output is still valid
SPIR-V asm, as the assembler does not care for which kind of whitespace
is used.
2024-09-03 17:06:20 +02:00
Anna (navi) Figueiredo Gomes
f5205da8e9 vkd3d-shader/spirv: Pass a vkd3d_shader_descriptor_info1 structure to spirv_compiler_build_descriptor_variable(). 2024-09-02 19:10:19 +02:00
Anna (navi) Figueiredo Gomes
672a8f5ce9 vkd3d-shader/spirv: Pass a vkd3d_shader_descriptor_info1 structure to spirv_compiler_emit_sampler_declaration(). 2024-09-02 18:59:37 +02:00
Anna (navi) Figueiredo Gomes
22aad955ec vkd3d-shader/spirv: Pass a vkd3d_shader_descriptor_info1 structure to spirv_compiler_emit_cbv_declaration(). 2024-09-02 18:58:29 +02:00
Anna (navi) Figueiredo Gomes
2a52ccf2c6 vkd3d-shader/spirv: Pass a vkd3d_shader_descriptor_info1 structure to spirv_compiler_emit_resource_declaration(). 2024-09-02 18:54:19 +02:00
Henri Verbeet
0e72aba0bc Release 1.13. 2024-08-29 12:08:46 +02:00
Henri Verbeet
f318e565f2 vkd3d-shader/spirv: Decorate non-array descriptor variables as well.
Commits 343c7942e1 and
94c74d2c00 moved applying the NonReadable
and Coherent decorations from spirv_compiler_emit_resource_declaration()
to spirv_compiler_build_descriptor_variable(), but unfortunately missed
the non-array path in the latter function.

The missing NonReadable decoration causes segmentation faults in
rasteriser-ordered-views.shader_test (among others) on my Intel SKL GT2
setup in particular.
2024-08-26 11:24:01 +02:00
Conor McCarthy
738ecc9eb1 vkd3d-shader/spirv: Free the spirv parameter info. 2024-08-20 21:27:58 +02:00
Anna (navi) Figueiredo Gomes
94c74d2c00 vkd3d-shader/spirv: Avoid decorating variables multiple times with Coherent. 2024-08-20 21:25:15 +02:00
Anna (navi) Figueiredo Gomes
a47c23fa1f vkd3d-shader/spirv: Use unique SPIR-V variables for descriptors where visibility differs.
In the case two uav descriptors are mapped to the same variable, and one is
read from while the other is not, the variable would get the NonReadable
decorator, while being read from later.
2024-08-20 21:23:31 +02:00
Anna (navi) Figueiredo Gomes
343c7942e1 vkd3d-shader/spirv: Avoid decorating variables multiple times with NonReadable.
The existing code reuses the same SPIR-V variable for all descriptors mapped to
the same Vulkan binding, and applies the NonReadable decoration based on the
VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_READ only. This potentially causes the
decoration to be applied twice, should two non-read descriptors be mapped to
the same variable, which isn't allowed in SPIR-V, and the validator complains.
2024-08-20 21:20:33 +02:00
Giovanni Mascellani
d5126b4d98 vkd3d-shader: Replace assert() with VKD3D_ASSERT() in spirv.c. 2024-08-08 23:36:23 +02:00
Henri Verbeet
c7589d8f19 vkd3d-shader/ir: Remove VKD3DSIH_DCL_SAMPLER instructions. 2024-07-30 16:31:44 +02:00
Henri Verbeet
fffe521b80 vkd3d-shader/ir: Remove VKD3DSIH_DCL instructions. 2024-07-30 16:31:44 +02:00
Elizabeth Figura
d20d0fc69f vkd3d-shader: Use the program parameters in spirv_compiler_alloc_spec_constant_id(). 2024-07-24 16:07:13 +02:00
Elizabeth Figura
1db7c03185 vkd3d-shader/spirv: Pass a vkd3d_data_type to spirv_compiler_emit_shader_parameter(). 2024-07-23 21:11:15 +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
6b58b6f261 vkd3d-shader/spirv: Allocate output_info after normalization.
Normalization may change the signatures.
2024-07-23 21:09: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
c2ce15b623 vkd3d-shader/spirv: Respect VKD3D_SHADER_CONDITIONAL_OP_Z when discard has a bool argument. 2024-07-11 16:59:06 +02:00
Elizabeth Figura
e8bdac8147 vkd3d-shader/spirv: Support passing shader parameters through uniform buffers. 2024-07-11 16:58:52 +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
Conor McCarthy
9b070edf01 vkd3d-shader/spirv: Implement the QUAD_READ_LANE_AT instruction. 2024-06-11 15:48:21 +02:00
Conor McCarthy
c298493e4f vkd3d-shader/spirv: Implement the QUAD_READ_ACROSS_* instructions. 2024-06-11 15:48:21 +02:00
Henri Verbeet
1fe7a6581b vkd3d-shader/ir: Rename the "handler_idx" field of struct vkd3d_shader_instruction to "opcode". 2024-05-30 19:57:01 +02:00
Henri Verbeet
36c123c005 Release 1.12. 2024-05-29 22:05:28 +02:00
Conor McCarthy
e1c774bfeb vkd3d-shader/spirv: Implement the WAVE_READ_LANE_FIRST instruction. 2024-05-14 20:44:10 +02:00
Conor McCarthy
936d8e4f61 vkd3d-shader/spirv: Implement the WAVE_READ_LANE_AT instruction. 2024-05-14 20:44:04 +02:00
Conor McCarthy
f47ac703ab vkd3d-shader/spirv: Emit a trace instead of a warning message for ignored alignment. 2024-05-13 22:27:13 +02:00
Conor McCarthy
e340855122 vkd3d-shader/spirv: Do not warn if no global flags are unhandled. 2024-05-13 22:27:13 +02:00
Conor McCarthy
77259da1ad vkd3d-shader/spirv: Implement the WAVE_PREFIX_BIT_COUNT instruction. 2024-05-13 11:50:23 +02:00
Conor McCarthy
065ef0c5e4 vkd3d-shader/spirv: Implement the WAVE_IS_FIRST_LANE instruction. 2024-05-13 11:50:21 +02:00
Conor McCarthy
feef2577ef vkd3d-shader/spirv: Implement the WAVE_ALL_BIT_COUNT instruction. 2024-05-13 11:50:19 +02:00
Conor McCarthy
cfcc789b42 vkd3d-shader/spirv: Implement the WAVE_OP_* instructions. 2024-05-06 22:12:27 +02:00
Conor McCarthy
fef5760af0 vkd3d-shader/spirv: Implement the WAVE_ACTIVE_BIT_* instructions. 2024-05-06 22:12:24 +02:00