Commit Graph

224 Commits

Author SHA1 Message Date
Evan Tang
628acb6b96 tests: Add some tests for rasteriser-ordered views. 2024-02-14 21:48:53 +01:00
Conor McCarthy
7d51a7d99c tests/shader-runner: Add a 64-bit switch test. 2024-02-14 21:48:44 +01:00
Conor McCarthy
5a76cedf87 vkd3d-shader/dxil: Implement DX intrinsic SampleGrad. 2024-02-14 21:48:08 +01:00
Conor McCarthy
5178fb7364 vkd3d-shader/dxil: Implement DX intrinsic Sample. 2024-02-14 21:48:06 +01:00
Francisco Casas
6a8939e19f tests: Remove [require] directives for tests that use int and bool uniforms.
These tests should actually compile and run in SM1, which is possible
if we pass the int and uint uniforms in the expected IEEE 754 float
format for SM1 shaders.

Also, bools should be passed as 1.0f or 0.0f to SM1.
2024-02-13 22:51:23 +01:00
Francisco Casas
22c47e57f5 tests/shader-runner: Introduce "if" qualifier.
When the "if" qualifier is added to a directive, the directive is
skipped if the shader->minimum_shader_model is not included in the
range.

This can be used on the "probe" directives for tests that have different
expected results on different shader models, without having to resort to
[require] blocks.
2024-02-13 22:51:22 +01:00
Francisco Casas
faec42e8a1 tests: Don't ignore SM1 on a non-const-indexing.shader_test test.
The previous [require] block makes us skip the test for SM4.
2024-02-13 22:51:20 +01:00
Giovanni Mascellani
4ba324d37c tests: Work around a Metal bug.
This test currently hit a Metal bug when run on Apple Silicon with
MoltenVK and fails. We don't have an easy way to mark shader runner
tests as buggy and we're not interested in tracking that bug anyway,
so I'm just working around it.
2024-02-07 22:59:27 +01:00
Conor McCarthy
625e289574 vkd3d-shader/dxil: Handle hyperbolic trigonometric functions in sm6_parser_emit_dx_unary(). 2024-02-07 22:59:23 +01:00
Conor McCarthy
c2f6985454 tests/shader-runner: Add hyperbolic trigonometry tests. 2024-02-07 22:59:22 +01:00
Conor McCarthy
c35ec4f820 vkd3d-shader/dxil: Implement DX intrinsic TextureStore. 2024-02-07 22:59:18 +01:00
Conor McCarthy
cf4ed988d0 tests/shader-runner: Add shader model 6 texture UAV tests.
The UAV default register allocation rules changed with SM 5.1.
2024-02-07 22:59:16 +01:00
Conor McCarthy
805a4bc1e8 tests/shader-runner: Emit descriptor ranges for consecutive resources.
Shader models >= 5.1 support descriptor indexing, and emit arrayed
resource declarations.
2024-02-07 22:59:15 +01:00
Conor McCarthy
7f87a3e5fc vkd3d-shader/spirv: Handle the ACOS, ASIN and ATAN instructions in spirv_compiler_emit_ext_glsl_instruction(). 2024-02-06 23:09:55 +01:00
Petrichor Park
e6746cbbdc tests/shader-runner: Add tests for atan and atan2 trig intrinsics.
Extracted by Conor McCarthy from an HLSL patch, with ulp values
doubled in some cases to cover SM 6 results.
2024-02-06 23:09:48 +01:00
Petrichor Park
92044d5e41 tests/shader-runner: Add tests for acos and asin trig intrinsics.
Extracted by Conor McCarthy from an HLSL patch, and modified to include
SM 6 variations.
2024-02-06 23:09:46 +01:00
Giovanni Mascellani
51f13391e6 vkd3d-shader/ir: Introduce a simple control flow graph structurizer.
The structurizer is implemented along the lines of what is usually called
the "structured program theorem": the control flow is completely
virtualized by mean of an additional TEMP register which stores the
block index which is currently running. The whole program is then
converted to a huge switch construction enclosed in a loop, executing
at each iteration the appropriate block and updating the register
depending on block jump instruction.

The algorithm's generality is also its major weakness: it accepts any
input program, even if its CFG is not reducible, but the output
program lacks any useful convergence information. It satisfies the
letter of the SPIR-V requirements, but it is expected that it will
be very inefficient to run on a GPU (unless a downstream compiler is
able to devirtualize the control flow and do a proper convergence
analysis pass). The algorithm is however very simple, and good enough
to at least pass tests, enabling further development. A better
alternative is expected to be upstreamed incrementally.

Side note: the structured program theorem is often called the
Böhm-Jacopini theorem; Böhm and Jacopini did indeed prove a variation
of it, but their algorithm is different from what is commontly attributed
to them and implemented here, so I opted for not using their name.
2024-02-06 23:07:07 +01:00
Conor McCarthy
95e4222cc6 vkd3d-shader/spirv: Emit a vector bitcast if necessary in spirv_compiler_emit_load_ssa_reg(). 2024-02-01 22:25:04 +01:00
Conor McCarthy
ebec0aa434 vkd3d-shader/dxil: Implement DX intrinsic TextureLoad. 2024-02-01 22:25:02 +01:00
Conor McCarthy
e6d52861e9 vkd3d-shader/dxil: Implement DX intrinsic SplitDouble. 2024-02-01 22:24:58 +01:00
Conor McCarthy
254e812b12 tests/shader-runner: Add an asuint() test to the 64-bit cast tests. 2024-02-01 22:24:57 +01:00
Francisco Casas
13f713f74b vkd3d-shader/hlsl: Turn register(cX) reservations into buffer offset for SM4. 2024-01-29 22:33:27 +01:00
Francisco Casas
c7f7636534 vkd3d-shader/hlsl: Make register(cX) reservations work for SM1. 2024-01-29 22:33:25 +01:00
Francisco Casas
4791c7c23b tests: Test register(cX) reservations. 2024-01-29 22:33:25 +01:00
Francisco Casas
d7d4c9bc90 tests: Rename register-reservations.shader_test to register-reservations-resources.shader_test. 2024-01-29 22:33:25 +01:00
Conor McCarthy
f954724870 vkd3d-shader/spirv: Handle the TAN instruction in spirv_compiler_emit_ext_glsl_instruction(). 2024-01-25 22:24:44 +01:00
Conor McCarthy
2a260b8d56 vkd3d-shader/dxil: Implement DX intrinsics Cos and Sin. 2024-01-25 22:24:41 +01:00
Conor McCarthy
e973271a40 vkd3d-shader/spirv: Handle the ISINF and ISNAN instructions in spirv_compiler_emit_alu_instruction(). 2024-01-24 22:38:04 +01:00
Conor McCarthy
cd674d593e vkd3d-shader/spirv: Implement the ISFINITE instruction. 2024-01-24 22:38:03 +01:00
Conor McCarthy
35d46cf3d9 tests/shader-runner: Add tests for floating point special values. 2024-01-24 22:38:00 +01:00
Francisco Casas
1c73513425 tests: Use the vulkan runner to run SM1 compilation tests.
At the current moment this is a little odd because for SM1 [test]
directives are skipped, and the [shader] directives are not executed by
the shader_runner_vulkan.c:compile_shader() but by the general
shader_runner.c:compile_shader(). So in principle it is a little weird
that we go through the vulkan runner.

But fret not, because in the future we plan to make the parser agnostic
to the language of the tests, so we will get rid of the general
shader_runner.c:compile_shader() function and instead call a
runner->compile_shader() function, defined for each runner. Granted,
most of these may call a generic implementation that uses native
compiler in Windows, and vkd3d-shader on Linux, but it would be more
conceptually correct.
2024-01-24 22:37:44 +01:00
Zebediah Figura
57c4a13024 tests: Add tests for valid conditional types. 2024-01-23 20:26:47 +01:00
Conor McCarthy
b3903636f7 vkd3d-shader/dxil: Implement DX intrinsic Binary. 2024-01-23 20:26:29 +01:00
Nikolay Sivov
2c1905b780 vkd3d-shader/hlsl: Allow annotations on techniques.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-01-23 20:26:19 +01:00
Nikolay Sivov
341963bbec tests/hlsl: Add some tests for annotations. 2024-01-23 20:26:14 +01:00
Conor McCarthy
55c7cd5c22 vkd3d-shader/dxil: Handle semantic kind ISFRONTFACE. 2024-01-22 22:18:33 +01:00
Conor McCarthy
9f409b67d7 vkd3d-shader/dxil: Handle semantic kind VERTEXID. 2024-01-22 22:18:32 +01:00
Zebediah Figura
9ad48f16ea vkd3d-shader/hlsl: Forbid mismatched argument types in ternaries. 2024-01-18 23:15:44 +01:00
Zebediah Figura
275901557c vkd3d-shader/hlsl: Handle scalar values in ternaries. 2024-01-18 23:15:43 +01:00
Zebediah Figura
11112798c8 vkd3d-shader/hlsl: Handle scalar conditions in ternaries. 2024-01-18 23:15:42 +01:00
Zebediah Figura
2c8751478f vkd3d-shader/hlsl: Forbid objects in ternary conditions. 2024-01-18 23:15:41 +01:00
Giovanni Mascellani
93100edb4b tests: Test a couple of degenerate switch instances. 2024-01-18 23:15:35 +01:00
Giovanni Mascellani
6cb7487fb0 tests: Add a test with non-trivial control flow. 2024-01-18 23:15:35 +01:00
Zebediah Figura
16962ac6f1 vkd3d-shader/hlsl: Allow non-numeric types in the ternary operator. 2024-01-17 22:28:51 +01:00
Zebediah Figura
9ac210eb1e tests: Add many more tests for ternary expressions. 2024-01-17 22:28:50 +01:00
Nikolay Sivov
e7d65d39ba vkd3d-shader/fx: Initial support for fx_5_0 output. 2024-01-15 19:57:42 +01:00
Francisco Casas
43ff28b00b vkd3d-shader/hlsl: Emit fixmes on non-constant vector addressing.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56162

Storing to a vector component using a non-constant index is not allowed
on profiles lower than 6.0. Unless this happens inside a loop that can be
unrolled, which we are not doing yet.

For this reason, a validate_nonconstant_vector_store_derefs pass is
added to detect these cases.

Ideally we would want to emit an hlsl_error on this pass, but before
implementing loop unrolling, we could reach this point on valid HLSL.

Also, as pointed out by Nikolay in the mentioned bug, currently
new_offset_from_path_index() fails an assertion when this happens,
because it expects an hlsl_ir_constant, so a check is added.
It also felt correct to emit an hlsl_fixme there, despite the
redundancy.
2024-01-15 19:57:12 +01:00
Nikolay Sivov
a0207436f2 vkd3d-shader/tpf: Add initial support for writing fx_4_0/fx_4_1 binaries.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-01-11 23:04:48 +01:00
Nikolay Sivov
e527d7c1e7 vkd3d-shader/hlsl: Handle effect group statement.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-01-11 23:04:46 +01:00
Nikolay Sivov
f7a02a5da2 vkd3d-shader/hlsl: Add variables for techniques.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-01-11 23:04:45 +01:00
Nikolay Sivov
c3af1f9989 vkd3d-shader/hlsl: Add 'fxgroup' token.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-01-11 23:04:42 +01:00
Nikolay Sivov
ffae369748 tests: Add some tests for effects groups syntax.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-01-11 23:04:42 +01:00
Conor McCarthy
812f01c2e2 vkd3d-shader/spirv: Handle ITOI and UTOU in spirv_compiler_map_alu_instruction().
These instructions perform integer casts to/from 64 bits.
2024-01-02 23:03:07 +01:00
Conor McCarthy
99924d913b vkd3d-shader/spirv: Support 64-bit sources in spirv_compiler_emit_int_div(). 2024-01-02 23:03:05 +01:00
Conor McCarthy
13459a55f1 vkd3d-shader/spirv: Introduce a UINT64 component type. 2024-01-02 23:03:04 +01:00
Conor McCarthy
cc43ef3bca vkd3d: Pass int64 capability info to vkd3d-shader. 2024-01-02 23:03:00 +01:00
Zebediah Figura
6a514ebe8e tests: Avoid using "SV_Position" as a name for the vertex shader input.
We use vkd3d_shader_find_signature_element() in the Vulkan runner, and
vkd3d-shader translates SM1 position to "POSITION".
2023-12-14 23:19:30 +01:00
Giovanni Mascellani
09235d9e09 tests: Test assigning multisampled textures with different sample counts. 2023-12-13 22:32:38 +01:00
Conor McCarthy
af731024d7 tests/shader-runner: Fix the arithmetic-int-uniform int64 abs expected results. 2023-12-13 22:32:31 +01:00
Conor McCarthy
108941fce0 tests/shader-runner: Add 64-bit bitwise tests. 2023-12-12 22:50:52 +01:00
Conor McCarthy
27d4ccf225 tests/shader-runner: Add 64-bit arithmetic tests. 2023-12-12 22:50:51 +01:00
Conor McCarthy
8a1eb306e8 tests/shader-runner: Introduce a 'float64' requirement directive. 2023-12-12 22:50:50 +01:00
Conor McCarthy
95c48eb98e tests/shader-runner: Introduce an 'int64' requirement directive. 2023-12-12 22:50:49 +01:00
Conor McCarthy
af86cdf713 tests/shader-runner: Add a non-const-indexing test for asfloat() result storage. 2023-12-11 23:18:54 +01:00
Conor McCarthy
3db7c2a62d vkd3d-shader/dxil: Implement the DXIL STORE instruction. 2023-12-11 23:18:51 +01:00
Conor McCarthy
df82c61482 tests/shader-runner: Test an uninitialised indexable temp. 2023-12-11 23:18:49 +01:00
Conor McCarthy
a33a9127ca vkd3d-shader/dxil: Implement DX intrinsic Unary. 2023-12-07 21:56:53 +01:00
Conor McCarthy
16cb6fdbad vkd3d-shader/spirv: Support constant initialisers in indexable temps. 2023-12-07 21:56:44 +01:00
Francisco Casas
736f3ae2df vkd3d-shader/hlsl: Use values at the time of the swizzle's load in copy-propagation.
This preempts us from replacing a swizzle incorrectly, as in the
following example:

    1: A.x = 1.0
    2: A
    3: A.x = 2.0
    4: @2.x

were @4 ends up being 2.0 instead of 1.0, because that's the value stored in
A.x at time 4, and we should be querying it at time 2.

This also helps us to avoid replacing a swizzle with itself in copy-prop
which can result in infinite loops, as with the included tests this commit.

Consider the following sequence of instructions:

    1 : A
    2 : B = @1
    3 : B
    4 : A = @3
    5 : @1.x

Current copy-prop would replace 5 so it points to @3 now:

    1 : A
    2 : B = @1
    3 : B
    4 : A = @3
    5 : @3.x

But in the next iteration it would make it point back to @1, keeping it
spinning infinitively.

The solution is to index the instructions and don't replace the swizzle
if the new load happens after the current load.
2023-11-29 22:53:24 +01:00
Francisco Casas
e6b7b38a29 tests: Test current failure when propagating swizzles.
The included test fails because copy_propagation_transform_swizzle()
is using the value recorded for the variable when the swizzle is being
read, and not the swizzle's load.
2023-11-29 22:53:16 +01:00
Francisco Casas
4e1bf5e163 vkd3d-shader/hlsl: Discern between signed and unsigned ints when parsing. 2023-11-22 22:08:05 +01:00
Francisco Casas
1ee9e23e00 tests: Test overloads with signed and unsigned numeric values. 2023-11-22 22:08:05 +01:00
Francisco Casas
9a8f6e0edb vkd3d-shader/hlsl: Parse integers with the 'u' postfix. 2023-11-22 22:08:04 +01:00
Francisco Casas
3f09cdcaa1 tests: Test integers with the 'u' postfix. 2023-11-22 22:08:04 +01:00
Conor McCarthy
eb05e434ff vkd3d-shader/dxil: Implement the DXIL LOAD instruction. 2023-11-22 22:07:59 +01:00
Akihiro Sagawa
aed2d142cf vkd3d-shader/hlsl: Add degrees() function. 2023-11-20 22:07:19 +01:00
Akihiro Sagawa
e493627130 vkd3d-shader/hlsl: Add radians() function. 2023-11-20 22:07:17 +01:00
Conor McCarthy
3c4631a4d4 vkd3d-shader/dxil: Implement the DXIL VSELECT instruction. 2023-11-15 21:48:35 +01:00
Conor McCarthy
130e7bdf0f tests/shader-runner: Add tests for 64-bit casts. 2023-11-15 21:48:33 +01:00
Conor McCarthy
38e85079aa tests/shader-runner: Add a test for float comparisons. 2023-11-15 21:48:30 +01:00
Conor McCarthy
d3b90cc877 vkd3d-shader/dxil: Implement the DXIL CMP2 instruction. 2023-11-10 20:23:50 +01:00
Zebediah Figura
514d179b70 vkd3d-shader/hlsl: Do not consider scalars and 1-dimensional vectors to be equivalent in function parameters. 2023-11-09 21:15:14 +01:00
Zebediah Figura
3e35570221 tests: Add some more tests for function overloads. 2023-11-09 21:15:08 +01:00
Conor McCarthy
90d178bf12 vkd3d-shader/dxil: Implement the DXIL CAST instruction. 2023-11-09 21:14:42 +01:00
Nikolay Sivov
4778d051df vkd3d-shader: Add constant folding for 'floor'.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-08 22:49:40 +01:00
Nikolay Sivov
494f681bf6 vkd3d-shader/tpf: Add support for ceil().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-08 22:49:38 +01:00
Nikolay Sivov
e57bf3db0b tests: Add some tests for ceil().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-08 22:49:37 +01:00
Nikolay Sivov
522a0dfb56 vkd3d-shader/hlsl: Add tex2Dlod() function.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-08 22:49:26 +01:00
Francisco Casas
0ef25ad137 vkd3d-shader/tpf: Support relative addressing for indexable temps in SM4.
For relative addressing, the vkd3d_shader_registers must point to
another vkd3d_shader_src_param. For now, use the sm4_instruction to save
them, since the only purpose of this struct is to be used as paramter
for write_sm4_instruction.
2023-11-07 22:25:49 +01:00
Francisco Casas
915f9f1373 tests: Add aditional relative addressing tests. 2023-11-07 22:25:44 +01:00
Francisco Casas
3deb3b5a21 tests: Rename array-index-expr.shader_test as non-const-indexing.shader_test. 2023-11-07 22:25:42 +01:00
Conor McCarthy
749df8dec2 vkd3d-shader/dxil: Implement the DXIL BINOP instruction. 2023-11-06 23:09:03 +01:00
Conor McCarthy
7419f4e31d vkd3d-shader/dxil: Allow empty struct types. 2023-11-02 18:23:12 +01:00
Nikolay Sivov
dbcc4c4e40 vkd3d-shader/hlsl: Parse empty technique declarations.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-02 18:23:07 +01:00
Nikolay Sivov
53b0101a53 vkd3d-shader/hlsl: Use case-insensitive match for the "technique" keyword.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-02 18:23:06 +01:00
Nikolay Sivov
ea8ff5394c vkd3d-shader/hlsl: Add a keyword for fx_5_0 techniques.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-02 18:23:05 +01:00
Nikolay Sivov
c588f33822 tests: Add some tests for using technique blocks when compiling for pixel/vertex profiles.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-02 18:23:04 +01:00
Nikolay Sivov
ecdc3f39d4 vkd3d-shader: Accept 'loop' attribute, on loops.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-01 21:47:49 +01:00
Nikolay Sivov
26784672d8 vkd3d-shader: Check loop [unroll] attribute for conflict with other attributes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-01 21:47:49 +01:00
Nikolay Sivov
b8047fd650 tests: Add some tests for loop attributes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2023-11-01 21:47:49 +01:00