Commit Graph

3282 Commits

Author SHA1 Message Date
Henri Verbeet
466c8bfbb7 vkd3d-shader/glsl: Implement VKD3DSIH_LTO. 2024-09-26 17:40:07 +02:00
Henri Verbeet
44e96ad4d6 vkd3d-shader/glsl: Implement VKD3DSIH_EXP. 2024-09-26 17:40:07 +02:00
Henri Verbeet
d68e60a78a vkd3d-shader/glsl: Implement VKD3DSIH_IEQ. 2024-09-26 17:40:07 +02:00
Henri Verbeet
55de9ea405 vkd3d-shader/glsl: Implement VKD3DSIH_DCL_INPUT_PS. 2024-09-26 17:40:07 +02:00
Henri Verbeet
f0c8b4a3c5 vkd3d-shader/glsl: Implement VKD3DSIH_SQRT. 2024-09-26 17:40:07 +02:00
Giovanni Mascellani
5ad83a05ff vkd3d-shader/dxil: Release memory on exceptional paths in sm6_parser_read_signature(). (Valgrind) 2024-09-26 01:05:35 +02:00
Henri Verbeet
92a7cc3420 vkd3d-shader/glsl: Implement VKD3DSIH_DP2. 2024-09-26 01:04:32 +02:00
Henri Verbeet
b9d8b84b06 vkd3d-shader/glsl: Implement VKD3DSIH_DP4. 2024-09-26 01:04:32 +02:00
Henri Verbeet
93cd63bc93 vkd3d-shader/glsl: Implement VKD3DSIH_DP3. 2024-09-26 01:04:32 +02:00
Henri Verbeet
929010ffd7 vkd3d-shader/glsl: Implement support for the VKD3DSPR_DEPTHOUT register. 2024-09-26 01:04:32 +02:00
Henri Verbeet
459f141e81 vkd3d-shader/glsl: Implement VKD3DSIH_ROUND_Z. 2024-09-26 01:04:32 +02:00
Feifan He
e8b14d765d vkd3d-shader/msl: Implement support for VKD3DSPR_TEMP registers. 2024-09-24 13:56:11 +02:00
Henri Verbeet
f37be27bdc vkd3d-shader/ir: Properly check the register bounds in shader_signature_find_element_for_reg().
Perhaps the existing code is safe in practice, but doing the check
properly avoids having to make that determination.
2024-09-24 13:39:43 +02:00
Henri Verbeet
8e39783770 vkd3d-shader/glsl: Implement VKD3DSIH_ROUND_PI. 2024-09-24 13:38:26 +02:00
Henri Verbeet
58472e7404 vkd3d-shader/glsl: Implement VKD3DSIH_FTOU. 2024-09-24 13:38:26 +02:00
Atharva Nimbalkar
f441d3e112 vkd3d-shader/glsl: Implement VKD3DSIH_UTOF. 2024-09-24 13:38:26 +02:00
Henri Verbeet
a3d06c8f12 vkd3d-shader/glsl: Implement VKD3DSIH_FTOI. 2024-09-24 13:38:26 +02:00
Atharva Nimbalkar
b81cdcb488 vkd3d-shader/glsl: Implement VKD3DSIH_ITOF. 2024-09-24 13:38:26 +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
Arkadiusz Hiler
a3017fe9d5 vkd3d-shader/preproc: Support namespaces in macro identifiers. 2024-09-24 13:17:24 +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
Elizabeth Figura
650bf4d83f vkd3d-shader/hlsl: Fix a corner case in ternary type conversion.
If the condition and argument types are compatible, i.e. there is no broadcast,
the resulting shape should be the shape of the arguments, not the shape of the
condition.
2024-09-23 15:43:15 +02:00
Elizabeth Figura
b2cddecfc5 vkd3d-shader/hlsl: Use add_cast() in append_conditional_break().
Instead of creating a cast node directly.

This specifically handles the 1x1 matrix case, which currently the backend code does not expect.
2024-09-23 15:43:15 +02:00
Henri Verbeet
1e97e1203f vkd3d-shader/d3dbc: Write the actual constant info offset in write_sm1_uniforms(). 2024-09-23 15:42:25 +02:00
Atharva Nimbalkar
ee8e005209 vkd3d-shader/glsl: Implement VKD3DSIH_MOVC. 2024-09-23 15:41:07 +02:00
Henri Verbeet
7b99c33510 vkd3d-shader/glsl: Implement VKD3DSIH_FRC. 2024-09-23 15:41:07 +02:00
Henri Verbeet
36c08b47e9 vkd3d-shader/glsl: Implement VKD3DSIH_GEO. 2024-09-23 15:41:07 +02:00
Henri Verbeet
28ef331704 vkd3d-shader/glsl: Implement support for VKD3DSPSM_NEG modifiers. 2024-09-23 15:41:07 +02:00
Henri Verbeet
b9366def96 vkd3d-shader/glsl: Implement VKD3DSIH_DIV. 2024-09-23 15:41:07 +02:00
Elizabeth Figura
43b714d896 vkd3d-shader/hlsl: Handle error expressions in unary expressions. 2024-09-23 15:28:47 +02:00
Elizabeth Figura
7e3231c749 vkd3d-shader/hlsl: Return an "error" expression when constructing an arithmetic expression from incompatible types. 2024-09-23 15:28:47 +02:00
Elizabeth Figura
c43e5c8eb5 vkd3d-shader/hlsl: Introduce the "error" type.
Currently, if an expression successfully parses according to the bison grammar,
but for one reason or another cannot generate a meaningful IR instruction, we
abort parsing with YYABORT. This includes, for example, an undefined variable or
function, invalid swizzle or field reference, or a constructor with a complex or
non-numeric data type.

Aborting parsing is unfortunate, however, because it means that any further
errors in the program cannot be caught by the programmer, increasing the number
of times they will need to fix errors and recompile.

The idea of this patch is that any such expression will instead generate an IR
node whose data type is of HLSL_CLASS_ERROR. Any further expression which would
consume an "error" typed instruction will instead immediately return an
expression of type "error" (probably the same one) instead of aborting or doing
any other type-checking.

Currently these "error" instructions should not pass the parsing stage, since
hlsl_compile_shader() will immediately notice that compilation has failed and
skip any optimization, lowering, or bytecode-writing.

A further direction to take this is to pre-allocate one "error" expression
immediately when creating the HLSL parser, and return that expression when we
fail to allocate an hlsl_ir_node of any type. This means we do not need to
handle allocation errors when constructing nodes, saving us quite a lot of error
handling (which is not only tedious but currently often broken, if nothing else
by virtue of neglecting cleanup of local variables).
2024-09-23 15:28:47 +02:00
Elizabeth Figura
7daaaf6386 vkd3d-shader/hlsl: Clarify a comment. 2024-09-23 15:28:47 +02:00
Elizabeth Figura
010aa53bfa vkd3d-shader/hlsl: Do not handle HLSL_CLASS_CONSTANT_BUFFER in copy_propagation_transform_load(). 2024-09-23 15:28:47 +02:00
Elizabeth Figura
f73a23f735 vkd3d-shader/hlsl: Do not create a copy in add_assignment(). 2024-09-23 15:28:47 +02:00
Elizabeth Figura
eb7f5f7f68 vkd3d-shader/hlsl: Return bool from add_assignment(). 2024-09-23 15:28:47 +02:00
Elizabeth Figura
8975933aff vkd3d-shader/hlsl: Store a pointer to the block's "value" instruction in the block. 2024-09-23 15:28:47 +02:00
Nikolay Sivov
799e6105a4 vkd3d-shader/d3dbc: Add an option to treat doubles as floats.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55448
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-23 15:26:35 +02:00
Nikolay Sivov
d7def84253 vkd3d-shader/hlsl: Remove the 'double' keyword.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-23 15:26:35 +02:00
Nikolay Sivov
b5c5783293 vkd3d-shader: Explicitly set indices for the numeric type names array.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-23 15:25:36 +02:00
Nikolay Sivov
f64689eed8 vkd3d-shader/tpf: Set temps count in the STAT section.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-20 17:20:02 +02:00
Nikolay Sivov
478e28ea79 vkd3d-shader/tpf: Move STAT fields update to a separate helper.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-09-20 17:20:02 +02:00
Henri Verbeet
bc70d575ae vkd3d-shader/glsl: Implement VKD3DSIH_OR. 2024-09-20 17:16:33 +02:00
Henri Verbeet
e289c3999d vkd3d-shader/glsl: Implement VKD3DSIH_INE. 2024-09-20 17:16:33 +02:00
Henri Verbeet
3b3fe1da2c vkd3d-shader/glsl: Implement VKD3DSIH_MUL. 2024-09-20 17:16:33 +02:00
Atharva Nimbalkar
2fc35da940 vkd3d-shader/glsl: Implement support for VSIR_DIMENSION_VEC4 immediate constants. 2024-09-20 17:16:33 +02:00
Henri Verbeet
2409966ff2 vkd3d-shader/glsl: Implement VKD3DSIH_NEU. 2024-09-20 17:16:33 +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