Commit Graph

403 Commits

Author SHA1 Message Date
Francisco Casas
5e3515f191 vkd3d-shader/d3dbc: Support SM1 if conditionals.
According to the documentation, if_comp is available from 2_x pixel
and vertex shaders and, unlike "if bool" it doesn't expect a constant
boolean register (from the input signature), so:

if_neq cond -cond

seems like a convenient way to write these, for profiles above 2.0.
2024-04-24 23:48:06 +02:00
Francisco Casas
74c998a2a4 tests: Add additional conditional tests for shader model 3.0. 2024-04-24 23:48:04 +02:00
Nikolay Sivov
836fe05916 tests: Add some tests for string variables.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-04-23 22:37:19 +02:00
Giovanni Mascellani
6b841486d4 vkd3d-shader/ir: Materialize SSAs in each function of a hull shader. 2024-04-23 22:36:17 +02:00
Conor McCarthy
eae1411cdc tests/hlsl: Add tests for texture UAV signed atomics. 2024-04-23 22:36:08 +02:00
Conor McCarthy
ee8ca0e9c2 tests/hlsl: Add tests for texture UAV atomics. 2024-04-23 22:36:06 +02:00
Conor McCarthy
1c73ac668f tests/hlsl: Add a test for UAV InterlockedExchange(). 2024-04-23 22:36:05 +02:00
Conor McCarthy
7e4fee658b tests/hlsl: Add a test for a structured UAV scalar store. 2024-04-23 22:36:02 +02:00
Conor McCarthy
0f7095d2aa tests/hlsl: Add tests for min() and integer max(). 2024-04-23 22:35:51 +02:00
Conor McCarthy
d5c6e12dd3 tests/hlsl: Add wave op tests. 2024-04-22 23:13:20 +02:00
Zebediah Figura
6cf065e7fd tests: Add tests for register space reservation syntax. 2024-04-22 23:13:16 +02:00
Zebediah Figura
f7a79517ae tests: Add tests for profile syntax in register reservations. 2024-04-22 23:13:16 +02:00
Conor McCarthy
3205e08fb1 vkd3d-shader/dxil: Support SV_Depth, SV_DepthGreaterEqual and SV_DepthLessEqual. 2024-04-19 22:23:43 +02:00
Conor McCarthy
7eeca3fa39 tests/hlsl: Add tests for SV_DepthLessEqual and SV_DepthGreaterEqual. 2024-04-19 22:23:42 +02:00
Conor McCarthy
b68a9ae3ec tests/hlsl: Add tests for SV_Depth. 2024-04-19 22:23:40 +02:00
Giovanni Mascellani
7196484e59 tests: Check that derivatives are still computed after discarding. 2024-04-19 22:23:35 +02:00
Giovanni Mascellani
12c457b43f tests: Avoid using a different UAV for SM<6 and SM>=6. 2024-04-19 22:23:35 +02:00
Conor McCarthy
d9f42b2c51 vkd3d-shader/dxil: Implement the DXIL CMPXCHG instruction. 2024-04-17 22:51:41 +02:00
Conor McCarthy
f13c65abb0 tests/hlsl: Add an InterlockedCompareExchange() TGSM test. 2024-04-17 22:51:40 +02:00
Conor McCarthy
99996ed5b5 vkd3d-shader/dxil: Implement DX intrinsic RenderTargetGetSampleCount. 2024-04-17 22:51:34 +02:00
Conor McCarthy
fe5e821cca vkd3d-shader/dxil: Implement DX intrinsics Texture2DMSGetSamplePosition and RenderTargetGetSamplePosition. 2024-04-17 22:51:32 +02:00
Conor McCarthy
696fc12061 tests/hlsl: Add tests for GetSamplePosition() and GetSampleCount(). 2024-04-17 22:51:30 +02:00
Conor McCarthy
2379bda36f tests/hlsl: Add a tessellation test. 2024-04-16 22:18:12 +02:00
Conor McCarthy
425e0aa6c3 tests/hlsl: Supply data for all mip levels in calculate-lod.shader_test.
Fixes invalid read in the GL runner.
2024-04-15 21:33:40 +02:00
Conor McCarthy
23db066922 vkd3d-shader/ir: Implement MAD in two operations if flagged as precise.
With some changes by Giovanni Mascellani.
2024-04-15 21:33:35 +02:00
Petrichor Park
1fb9e7526b vkd3d-shader/hlsl: Implement tanh. 2024-04-15 21:32:59 +02:00
Petrichor Park
c4182cc272 vkd3d-shader/hlsl: Implement hyperbolic sin and cos. 2024-04-15 21:32:56 +02:00
Giovanni Mascellani
e29706d366 tests: Check that side effects do not happen after discard. 2024-04-10 08:55:33 -05:00
Nikolay Sivov
8d78e3a821 vkd3d-shader/hlsl: Support refract() intrinsic.
With some changes by Giovanni Mascellani.
2024-04-10 08:55:27 -05:00
Nikolay Sivov
fd9e1a87ff vkd3d-shader/hlsl: Test refract() intrinsic.
With some changes by Giovanni Mascellani.
2024-04-10 08:55:26 -05:00
Conor McCarthy
cb5411408a vkd3d-shader/dxil: Implement DX intrinsic CalculateLOD. 2024-04-10 08:54:23 -05:00
Conor McCarthy
bdfa14d219 tests/hlsl: Add tests for CalculateLevelOfDetail().
Includes improvements made by Giovanni Mascellani.
2024-04-10 08:54:23 -05:00
Francisco Casas
e9559c394b vkd3d-shader/hlsl: Allow KW_PIXELSHADER and KW_VERTEXSHADER as stateblock lhs. 2024-04-10 08:54:23 -05:00
Francisco Casas
ef9ae22ed0 vkd3d-shader/hlsl: Store state block on pass variables. 2024-04-10 08:54:23 -05:00
Francisco Casas
a99bcb1196 vkd3d-shader/hlsl: Parse list of state blocks. 2024-04-10 08:54:23 -05:00
Francisco Casas
ee0d439a1b vkd3d-shader/hlsl: Parse and store state blocks on variables. 2024-04-10 08:54:23 -05:00
Francisco Casas
73ef6907bc tests: Add tests for "compile" and CompileShader() syntax. 2024-04-10 08:54:23 -05:00
Francisco Casas
83f4b46fb1 tests: Add tests for fxgroup syntax. 2024-04-10 08:54:23 -05:00
Francisco Casas
00c8cf1bcc tests: Test function call syntax for state blocks. 2024-04-10 08:54:23 -05:00
Francisco Casas
9ede222714 tests: Add more state block syntax tests. 2024-04-10 08:54:23 -05:00
Zebediah Figura
269cdad7b9 vkd3d-shader/hlsl: Consider any valid register reservation to invoke manual packing.
Regardless of the type of the variable.
2024-04-09 12:27:53 -05:00
Zebediah Figura
bdbf5e7d74 tests: Add more tests for manual packing. 2024-04-09 12:27:53 -05:00
Zebediah Figura
ce50c3a186 vkd3d-shader/hlsl: Use hlsl_type_is_resource() for unbounded array checks.
Not all objects can be unbounded descriptors.
2024-04-09 12:27:51 -05:00
Zebediah Figura
083a58767a tests: Test HLSL unbounded array syntax.
Change the shader in test_unbounded_samplers() to also test a nested array.
Note that the changed shader compiles to the same bytecode.
2024-04-09 12:27:49 -05:00
Conor McCarthy
e72c3bab71 vkd3d-shader/spirv: Ensure the data register is UINT in spirv_compiler_emit_store_tgsm(). 2024-04-09 12:27:30 -05:00
Francisco Casas
53e4d6eedb vkd3d-shader/hlsl: Use LOGIC_OR instead of BIT_OR in any().
Note that BIT_OR is not available for SM1 bools, so we must prefer
LOGIC_OR when possible.
2024-04-09 12:27:07 -05:00
Francisco Casas
2621fc9572 vkd3d-shader/ir: Add missing src swizzle in vsir_program_lower_texkills(). 2024-04-09 12:27:06 -05:00
Francisco Casas
808ec288cf tests: Add failing test for clip.shader_test in SM1.
We are not properly translating texkill to spir-v since it is only
considering the first component.
2024-04-09 12:27:04 -05:00
Francisco Casas
3a0a4b625f vkd3d-shader/hlsl: Merge HLSL_OP3_MOVC into HLSL_OP3_TERNARY. 2024-04-09 12:27:02 -05:00
Francisco Casas
19fd43214b vkd3d-shader/hlsl: Ensure that TERNARY condition is always bool.
Also, properly casting it to float in lower_ternary() for SM1
avoids creating ABS and NEG on bool types.
2024-04-09 12:26:59 -05:00
Nikolay Sivov
4b0a328a2b vkd3d-shader/hlsl: Allow 'export' modifier on functions.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-04-03 22:24:15 +02:00
Nikolay Sivov
c509c85f63 vkd3d-shader/hlsl: Allow annotations on constant buffers.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-04-02 23:10:40 +02:00
Conor McCarthy
d72d5c35d1 vkd3d-shader/dxil: Implement DX intrinsics Dot2, Dot3 and Dot4. 2024-04-02 23:09:28 +02:00
Conor McCarthy
2909a5aacc vkd3d-shader/dxil: Implement DX intrinsic MakeDouble. 2024-04-02 23:09:23 +02:00
Conor McCarthy
cf6e518f1e tests/hlsl: Add tests for asdouble(). 2024-04-02 23:09:20 +02:00
Conor McCarthy
11ee92ed7e vkd3d-shader/dxil: Implement DX intrinsic Discard. 2024-03-27 22:37:42 +01:00
Nikolay Sivov
b382d1843d vkd3d-shader/fx: Accept texture types when writing fx_2_0 effects.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-27 22:37:29 +01:00
Nikolay Sivov
b09f919673 vkd3d-shader/hlsl: Treat "texture" type name as case-insensitive.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-27 22:37:28 +01:00
Nikolay Sivov
17dc23269e vkd3d-shader/fx: Handle "uint" type for fx_2_0 parameters.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-27 22:37:27 +01:00
Nikolay Sivov
9117629e35 vkd3d-shader/fx: Handle "half" type for fx_2_0 parameters.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-27 22:37:25 +01:00
Nikolay Sivov
3fdf674a4d tests: Rename effect test files to make them easier to find.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-27 22:37:25 +01:00
Francisco Casas
11e7265815 vkd3d-shader/spirv: Throw compiler error on unrecognized register.
This codepath path is currently triggered when transpiling d3dbc shaders
that use vPos (or other of these special registers).

While vPos gets added to the input signature and gets assigned an INPUT
register, the registers in the shader instructions are still of
VKD3DSPR_MISCTYPE type and are not propperly mapped yet. This gives
invalid results.

Some SM1 tests must be set back to "todo" but they only work because, by
coincidence, we are assigning vPos the input register with index 0.
Propper mapping of these registers is still required.
2024-03-27 22:37:15 +01:00
Zebediah Figura
172cb75872 vkd3d-shader/spirv: Implement VKD3DSIH_ABS. 2024-03-27 22:37:10 +01:00
Francisco Casas
9a222d2be1 vkd3d-shader/d3dbc: Implement HLSL_OP2_LOGIC_AND for SM1. 2024-03-27 22:37:09 +01:00
Francisco Casas
90e8a541fb tests: Add tests for LOGIC_NOT on uniforms. 2024-03-27 22:37:06 +01:00
Conor McCarthy
9e0b9c3a7a vkd3d-shader/dxil: Implement the DXIL ATOMICRMW instruction. 2024-03-27 22:36:59 +01:00
Conor McCarthy
b708a9b3b5 vkd3d-shader/dxil: Implement DX instructions ThreadId, GroupId, ThreadIdInGroup and FlattenedThreadIdInGroup. 2024-03-27 22:36:58 +01:00
Conor McCarthy
c7dcfc2a04 tests/shader-runner: Add TGSM tests. 2024-03-27 22:36:57 +01:00
Zebediah Figura
0b1f11dd33 vkd3d-shader/hlsl: Allocate register reservations for structs as well. 2024-03-27 22:36:34 +01:00
Henri Verbeet
0715734dfb tests/shader_runner: Add GLSL support to the GL runner. 2024-03-19 22:57:50 +01:00
Conor McCarthy
0c01a55c7d vkd3d-shader/dxil: Implement DX intrinsic Saturate. 2024-03-18 23:07:40 +01:00
Conor McCarthy
4599d3c1cf vkd3d-shader/dxil: Implement DX intrinsic FAbs. 2024-03-18 23:07:39 +01:00
Conor McCarthy
33694f08fc vkd3d-shader/dxil: Implement DX intrinsics FMa, FMad, IMad and UMad. 2024-03-18 23:07:38 +01:00
Conor McCarthy
08cc5027cf tests/hlsl: Add tests for mad() and fma(). 2024-03-18 23:07:35 +01:00
Nikolay Sivov
4fc15d4b4a vkd3d-shader/fx: Add initial support for writing fx_2_0 parameters.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-18 23:07:30 +01:00
Conor McCarthy
3f99719ff2 vkd3d-shader/dxil: Implement DX intrinsic BufferUpdateCounter. 2024-03-18 23:07:23 +01:00
Conor McCarthy
52a831ba0d tests/hlsl: Add UAV counter tests. 2024-03-18 23:07:21 +01:00
Francisco Casas
4c40deaac1 vkd3d-shader/hlsl: Use hlsl_fixme() on missing SM1 matrix writemask lowering.
Instead of FIXME(). Otherwise we compile invalid d3dbc.
2024-03-14 22:49:29 +01:00
Francisco Casas
5c986b9cde vkd3d-shader/hlsl: Lower SLT instructions for pixel shaders.
Properly passing the inverse-trig.shader_test tests whose qualifiers
have been removed requires making spirv.c capable of handling ABS.
The same happens for the ps_3_0 equality test in
float-comparison.shader_test.
2024-03-14 22:49:29 +01:00
Francisco Casas
4133c4d801 tests: Test equality between tiny and between large numbers on ps_2_0. 2024-03-14 22:49:29 +01:00
Francisco Casas
e9a4758648 vkd3d-shader/hlsl: Implement SM1 comparison operators. 2024-03-14 22:49:29 +01:00
Conor McCarthy
b6c41d5287 tests/hlsl: Add tests for countbits() and firstbit{high|low}(). 2024-03-13 21:50:39 +01:00
Nikolay Sivov
e0ef45c0a3 vkd3d-shader: Parse a 'single' modifier.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-12 22:14:50 +01:00
Nikolay Sivov
cf7c05f431 vkd3d-shader: Remove a token for 'precise' modifier.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-12 22:14:50 +01:00
Nikolay Sivov
7f1fdd447c vkd3d-shader/fx: Add initial support for writing uninitialized vertex/pixel shader objects.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-12 22:14:40 +01:00
Evan Tang
03a80cde2e vkd3d: Enable VK_EXT_fragment_shader_interlock if available. 2024-03-11 22:10:25 +01:00
Giovanni Mascellani
5e43f99809 tests: Relax precision a bit for an interpolation test.
Otherwise the test fails on Intel, NVIDIA and llvmpipe.
2024-03-11 22:10:14 +01:00
Conor McCarthy
4f0e5b9069 vkd3d-shader/dxil: Support 16-bit types. 2024-03-11 22:10:06 +01:00
Conor McCarthy
581939f1ef tests/shader-runner: Add tests for minimum-precision constants.
Values in DXIL have no signedness, so it is ambiguous whether 16-bit
constants should or should not be sign-extended when 16-bit execution
is not supported.
2024-03-11 22:10:01 +01:00
Francisco Casas
2b06bcc615 tests: Check that -0.0f is not less than 0.0f. 2024-03-11 22:09:44 +01:00
Francisco Casas
308c7941d4 tests: Test comparison and logic operators on SM1 vertex shaders.
Currently these are failing for SM1 because VKD3DSIH_SLT is not being
handled by spirv.c.
2024-03-11 22:09:43 +01:00
Conor McCarthy
5a6fd010ac vkd3d-shader/dxil: Implement DX intrinsic TextureGather. 2024-03-11 22:09:18 +01:00
Conor McCarthy
8337b99a2c tests/shader-runner: Add a Gather test with non-constant offset. 2024-03-11 22:09:16 +01:00
Conor McCarthy
7fcf1b6ca2 tests/shader-runner: Add sampler comparison tests. 2024-03-11 22:09:08 +01:00
Evan Tang
4553b2a0dc vkd3d-shader/spirv: Implement support for rasteriser-ordered views.
Using SPV_EXT_fragment_shader_interlock.
2024-03-08 23:36:35 +01:00
Conor McCarthy
e65055b435 vkd3d-shader/spirv: Handle the ORD and UNO instructions. 2024-03-08 23:36:14 +01:00
Conor McCarthy
94583815bc tests/shader-runner: Add a test for FCMP_ORD (is ordered). 2024-03-08 23:36:12 +01:00
Nikolay Sivov
b13d60d805 vkd3d-shader/hlsl: Add determinant() function.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-08 23:35:23 +01:00
Nikolay Sivov
a0d52dc385 vkd3d-shader/hlsl: Improve VertexShader/PixelShader types handling.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-06 23:04:25 +01:00
Nikolay Sivov
4dd1bbae40 tests: Add some tests for shader object type names.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-06 23:04:25 +01:00
Nikolay Sivov
8c5db57ea7 vkd3d-shader/fx: Reject fx_2_0 output without techniques.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-06 23:04:19 +01:00
Nikolay Sivov
dd5e42d347 vkd3d-shader/hlsl: Allow technique10 {} blocks for fx_2_0.
Such techniques are ignored later, but do not cause compilation errors.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2024-03-06 23:04:18 +01:00
Conor McCarthy
5082893e5d vkd3d-shader/spirv: Always use a 64-bit write mask for IMMCONST64 src params.
There is no way to tell in spirv_compiler_emit_load_reg() if the write
mask is 64-bit. All loads are 32-bit except for IMMCONST64 and SSA, and
the latter ignores the mask, so the only issue lies with IMMCONST64.
2024-03-06 23:04:12 +01:00
Conor McCarthy
13143700b7 tests/shader-runner: Add raw UAV tests. 2024-03-06 23:04:11 +01:00
Francisco Casas
58c456ff2b vkd3d-shader/d3dbc: Implement bool to float cast as MOV.
In SM1, bools are always represented as either 0.0f or 1.0f at runtime.
2024-03-06 23:04:07 +01:00
Francisco Casas
747511131d vkd3d-shader/hlsl: Lower non-float operators for SM1. 2024-03-06 23:04:05 +01:00
Giovanni Mascellani
500b61c383 tests: Test how constant folding works on SM1. 2024-02-26 23:04:08 +01:00
Conor McCarthy
c083b1d0fc vkd3d-shader/dxil: Implement DX intrinsic GetDimensions. 2024-02-26 23:03:48 +01:00
Conor McCarthy
2330ffdeda vkd3d-shader/dxil: Implement DX intrinsics SampleBias and SampleLevel. 2024-02-22 22:45:34 +01:00
Conor McCarthy
cab8b781ab vkd3d-shader/dxil: Handle raw and structured buffers in sm6_parser_emit_dx_buffer_store(). 2024-02-22 22:45:07 +01:00
Conor McCarthy
ce1875c435 vkd3d-shader/dxil: Implement DX intrinsic BufferStore. 2024-02-22 22:45:06 +01:00
Conor McCarthy
b447a725ec tests/shader-runner: Add a test for a signed int structured buffer UAV.
Check for backend type mismatches resulting from the absence of
signedness in SM 6.
2024-02-22 22:45:05 +01:00
Conor McCarthy
9180ea6591 tests/shader-runner: Add a test for a signed int typed buffer UAV.
Check for backend type mismatches resulting from the absence of
signedness in SM 6.
2024-02-22 22:45:04 +01:00
Conor McCarthy
081c9dbc96 tests/shader-runner: Support structured buffer UAVs. 2024-02-22 22:45:02 +01:00
Petrichor Park
02a3667822 vkd3d-shader/hlsl: Implement atan and atan2.
Also narrows some more todos on the tests.
2024-02-21 23:23:13 +01:00
Petrichor Park
69294c290b vkd3d-shader/hlsl: Implement acos and asin trig intrinsics.
Tests have already been implemented in 92044d5e; this commit also reduces
the scope of some of the todos (because now they're implemented!).

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55154
2024-02-21 23:23:11 +01:00
Conor McCarthy
96a0685ba6 vkd3d-shader/dxil: Implement DX intrinsic AtomicCompareExchange. 2024-02-20 22:50:16 +01:00
Conor McCarthy
560c9413c3 vkd3d-shader/dxil: Implement DX intrinsic AtomicBinOp. 2024-02-20 22:50:15 +01:00
Conor McCarthy
3906c12476 tests/shader-runner: Add tests for UAV atomic ops. 2024-02-20 22:50:13 +01:00
Evan Tang
7b41abaa1b vkd3d-shader/hlsl: Support SV_PrimitiveID in pixel shaders. 2024-02-19 21:12:23 +01:00
Francisco Casas
8df34fce62 vkd3d-shader/hlsl: Emit fixme on non-direct resource stores.
Co-authored-by: Giovanni Mascellani <gmascellani@codeweavers.com>

These may happen when storing to structured buffers, and we are not
handling them properly yet. The included test reaches unreacheable code
before this patch.

Storing to buffers is complicated since we need to split the index
chain in two paths:
- The path within the variable where the resource is.
- The subpath to the part of the resource element that is being stored
  to.

For now, we will emit a fixme when the index chain in the lhs is not a
direct resource access.
2024-02-19 21:12:14 +01:00
Francisco Casas
c249461e97 vkd3d-shader/hlsl: Parse Buffer types. 2024-02-19 21:11:55 +01:00
Francisco Casas
4fe9ab0a90 tests/shader-runner: Change probe directive syntax on shader_test files.
For consistency with the previous commit.
2024-02-19 21:11:53 +01:00
Francisco Casas
b08be04465 tests/shader-runner: Change resource declaration syntax on shader_test files.
On shader_test files, now resources should be declared this way:

    [texture n]       -> [srv n]
    [srv buffer n]    -> [srv n]
    [uav n]           -> [uav n]
    [uav buffer n]    -> [uav n]
    [vertex buffer n] -> [vb n]
    [render target n] -> [rtv n]

The dimension (buffer or 2D) is now specified as an additional parameter
in the "size" directive:

  For 2D resources:
  size (n, m)         -> size (2d, n, m)

  For buffers:
  size (n, 1)         -> size (buffer, n)
2024-02-19 21:11:52 +01:00
Francisco Casas
4d855611b7 tests/shader-runner: Support SRV buffers. 2024-02-19 21:11:51 +01:00
Evan Tang
ee867bd470 vkd3d-shader/hlsl: Parse rasteriser-ordered view types. 2024-02-15 23:29:46 +01:00
Francisco Casas
e3ed5ac77e vkd3d-shader/hlsl: Lower casts to int for SM1. 2024-02-15 23:29:39 +01:00
Francisco Casas
e62bd1927e tests: Add simple test for implicit cast to int. 2024-02-15 23:29:39 +01:00
Francisco Casas
4b5c7e3721 vkd3d-shader/d3dbc: Implement casts from ints to floats as a MOV.
For temporary registers, SM1-SM3 integer types are internally
represented as floating point, so, in order to perform a cast
from ints to floats we need a mere MOV.

For constant integer registers "iN" there is no operation for casting
from a floating point register to them. For address registers "aN", and
the loop counting register "aL", vertex shaders have the "mova" operation
but we haven't used these registers in any way yet.

We probably would want to introduce these as synthetic variables
allocated in a special register set. In that case we have to remember to
use MOVA instead of MOV in the store operations, but they shouldn't be src
or dst of CAST operations.

Regarding constant integer registers, in some shaders, constants are
expected to be received formatted as an integer, such as:

    int m;
    float4 main() : sv_target
    {
        float4 res = {0, 0, 0, 0};

        for (int k = 0; k < m; ++k)
            res += k;
        return res;
    }

which compiles as:

    // Registers:
    //
    //   Name         Reg   Size
    //   ------------ ----- ----
    //   m            i0       1
    //

    ps_3_0
    def c0, 0, 1, 0, 0
    mov r0, c0.x
    mov r1.x, c0.x
    rep i0
      add r0, r0, r1.x
      add r1.x, r1.x, c0.y
    endrep
    mov oC0, r0

but this only happens if the integer constant is used directly in an
instruction that needs it, and as I said there is no instruction that
allows converting them to a float representation.

Notice how a more complex shader, that performs operations with this
integer variable "m":

    int m;
    float4 main() : sv_target
    {
        float4 res = {0, 0, 0, 0};

        for (int k = 0; k < m * m; ++k)
            res += k;
        return res;
    }

gives the following output:

    // Registers:
    //
    //   Name         Reg   Size
    //   ------------ ----- ----
    //   m            c0       1
    //

    ps_3_0
    def c1, 0, 0, 1, 0
    defi i0, 255, 0, 0, 0
    mul r0.x, c0.x, c0.x
    mov r1, c1.y
    mov r0.y, c1.y
    rep i0
      mov r0.z, r0.x
      break_ge r0.y, r0.z
      add r1, r0.y, r1
      add r0.y, r0.y, c1.z
    endrep
    mov oC0, r1

Meaning that the uniform "m" is just stored as a floating point in
"c0", the constant integer register "i0" is just set to 255 (hoping
it is a high enough value) using "defi", and the "break_ge"
involving c0 is used to break from the loop.

We could potentially use this approach to implement loops from SM3
without expecting the variables being received as constant integer
registers.

According to the D3D documentation, for SM1-SM3 constant integer
registers are only used by the 'loop' and 'rep' instructions.
2024-02-15 23:29:37 +01:00
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