Commit graph

342 commits

Author SHA1 Message Date
TheTurtle
1f9ac53c28
shader_recompiler: Improve divergence handling and readlane elimintation (#2667)
* control_flow_graph: Improve divergence handling

* recompiler: Simplify optimization passes

Removes a redudant constant propagation and cleans up the passes a little

* ir_passes: Add new readlane elimination pass

The algorithm has grown complex enough where it deserves its own pass. The old implementation could only handle a single phi level properly,
however this one should be able to eliminate vast majority of lane cases remaining. It first performs a traversal of the phi tree to ensure
that all phi sources can be rewritten into an expected value and then performs elimintation by recursively duplicating the phi nodes at each step,
in order to preserve control flow.

* clang format

* control_flow_graph: Remove debug code
2025-03-23 00:35:42 +02:00
TheTurtle
2a05af22e1
emit_spirv: Fix comparison type (#2658) 2025-03-19 23:20:00 +02:00
baggins183
c59d5eef45
Specialize vertex attributes on dst_sel (#2580)
* Specialize vertex attributes on dst_sel

* compare vs attrib specs by default, ignore NumberFmt when vertex input dynamic state is supported

* specialize data_format when attribute uses step rates

* use num_components in data fmt instead of fmt itself
2025-03-02 19:17:11 -08:00
Missake212
a583a9abe0
fixes to get in game (#2583) 2025-03-02 22:13:23 +02:00
baggins183
7a4244ac8b
Misc Cleanups (#2579)
-dont do trivial phi removal during SRT pass, that's now done in
ssa_rewrite
-remove unused variable when walking tess attributes
-fix some tess comments
2025-03-02 21:52:32 +02:00
Missake212
76483f9c7b
opcode implementation test (#2567) 2025-03-02 21:31:49 +02:00
Paris Oplopoios
fd3bfdae80
Implement some RDNA flags (#2510) 2025-02-24 19:52:57 +02:00
TheTurtle
76b4da6212
video_core: Various small improvements and bug fixes (#2525)
* ir_passes: Add barrier at end of block too

* vk_platform: Always assign names to resources

* texture_cache: Better overlap handling

* liverpool: Avoid resuming ce_task when its finished

* spirv_quad_rect: Skip default attributes

Fixes some crashes

* memory: Improve buffer size clamping

* liverpool: Relax binary header validity check

* liverpool: Stub SetPredication with a warning

* Better than outright crash

* emit_spirv: Implement round to zero mode

* liverpool: queue::pop takes the front element

* image_info: Remove obsolete assert

The old code assumed the mip only had 1 layer thus a right overlap could not return mip 0. But with the new path we handle images that are both mip-mapped and multi-layer, thus this can happen

* tile_manager: Fix size calculation

* spirv_quad_rect: Skip default attributes

---------

Co-authored-by: poly <47796739+polybiusproxy@users.noreply.github.com>
Co-authored-by: squidbus <175574877+squidbus@users.noreply.github.com>
2025-02-24 14:31:12 +02:00
squidbus
9424047214
shader_recompiler: Proper support for inst-typed buffer format operations. (#2469) 2025-02-21 03:01:18 -08:00
¥IGA
8447412c77
Bump to Clang 19 (#2434) 2025-02-18 15:55:13 +02:00
squidbus
fd3d3c4158
shader_recompiler: Implement AMD buffer bounds checking behavior. (#2448)
* shader_recompiler: Implement AMD buffer bounds checking behavior.

* shader_recompiler: Use SRT flatbuf for bounds check size.

* shader_recompiler: Fix buffer atomic bounds check.

* buffer_cache: Prevent false image-to-buffer sync.

Lowering vertex fetch to formatted buffer surfaced an issue where a CPU modified range may be overwritten with stale GPU modified image data.

* Address review comments.
2025-02-17 16:13:39 +02:00
TheTurtle
82cacec8eb
shader_recompiler: Remove special case buffers and add support for aliasing (#2428)
* shader_recompiler: Move shared mem lowering into emitter

* IR can be quite verbose during first stages of translation, before ssa and constant prop passes have run that drastically simplify it. This lowering can also be done during emission so why not do it then to save some compilation time

* runtime_info: Pack PsColorBuffer into 8 bytes

* Drops the size of the total structure by half from 396 to 204 bytes. Also should make comparison of the array a bit faster, since its a hot path done every draw

* emit_spirv_context: Add infrastructure for buffer aliases

* Splits out the buffer creation function so it can be reused when defining multiple type aliases

* shader_recompiler: Merge srt_flatbuf into buffers list

* Its no longer a special case, yay

* shader_recompiler: Complete buffer aliasing support

* Add a bunch more types into buffers, such as F32 for float reads/writes and 8/16 bit integer types for formatted buffers

* shader_recompiler: Remove existing shared memory emulation

* The current impl relies on backend side implementaton and hooking into every shared memory access. It also doesnt handle atomics. Will be replaced by an IR pass that solves these issues

* shader_recompiler: Reintroduce shared memory on ssbo emulation

* Now it is performed with an IR pass, and combined with the previous commit cleanup, is fully transparent from the backend, other than requiring workgroup_index be provided as an attribute (computing this on every shared memory access is gonna be too verbose

* clang format

* buffer_cache: Reduce buffer sizes

* vk_rasterizer: Cleanup resource binding code

* Reduce noise in the functions, also remove some arguments which are class members

* Fix gcc
2025-02-15 14:06:56 +02:00
squidbus
6e12642151
shader_recompiler: Lower non-compute shared memory into spare VGPRs. (#2403) 2025-02-12 20:10:13 -08:00
DanielSvoboda
98eb8cb741
Fix S_LSHR_B32 (#2405)
the shift value should be extracted from the 5 least significant bits of the second operand (S1.u[4:0]), to ensure that the shift is limited to values ​​from 0 to 31, suitable for 32-bit operations

Instruction S_LSHR_B32
Description D.u = S0.u >> S1.u[4:0]. SCC = 1 if result is non-zero.
2025-02-12 06:31:19 -08:00
squidbus
40eef6a066
shader_recompiler: Exclude defaulted fragment inputs from quad/rect passthrough. (#2383) 2025-02-10 21:33:30 -08:00
psucien
04fe3a79b9
fix: lower UBO max size to account buffer cache offset (#2388)
* fix: lower UBO max size to account buffer cache offset

* review comments

* remove UBO size from spec and always set it to max on shader side
2025-02-09 22:03:20 +01:00
squidbus
cfe249debe
shader_recompiler: Replace texel buffers with in-shader buffer format interpretation (#2363)
* shader_recompiler: Replace texel buffers with in-shader buffer format interpretation

* shader_recompiler: Move 10/11-bit float conversion to functions and address some comments.

* vulkan: Remove VK_KHR_maintenance5 as it is no longer needed for buffer views.

* shader_recompiler: Add helpers for composites and bitfields in pack/unpack.

* shader_recompiler: Use initializer_list for bitfield insert helper.
2025-02-06 20:40:49 -08:00
squidbus
b879dd59c6
shader_recompiler: Add workaround for drivers with unexpected unorm rounding behavior. (#2310) 2025-02-04 01:01:59 -08:00
makigumo
fffd373652
Fix shader type names (#2336)
Names didn't match definition in type.h
2025-02-03 23:24:56 -08:00
makigumo
f8f732e78c
fix ASSERT_MSG arguments (#2337) 2025-02-04 08:51:07 +02:00
squidbus
460c266e04 fix: Restore previous version of divergence PR. 2025-02-02 15:37:17 -08:00
squidbus
831903799b
shader_recompiler: Insert end of divergence scope at last relevant instruction. (#2325) 2025-02-02 14:51:45 -08:00
poly
eed4de1da9
renderer_vulkan: use LDS buffer as SSBO on unsupported shared memory size (#2245)
* renderer_vulkan: use LDS buffer as SSBO on unsupported shared memory size

* shader_recompiler: add `v_trunc_f64` on inst format table
2025-01-31 13:52:31 +02:00
squidbus
929e15260d
shader_recompiler: Fix cube sampling coordinates. (#2266) 2025-01-29 18:14:36 -08:00
squidbus
f1bc3b4f3d
shader_recompiler: Add another constant propagation pass near the end. (#2231) 2025-01-25 14:59:18 -08:00
squidbus
a51c8c17e0
shader_recompiler: Fix image write swizzles. (#2236) 2025-01-24 12:47:04 -08:00
squidbus
56f4b8a2b8
shader_recompiler: Implement shader export formats. (#2226) 2025-01-24 10:41:58 -08:00
squidbus
4d12de8149 hotfix: 64-bit shift fixups 2025-01-24 03:14:37 -08:00
Marcin Mikołajczyk
9dcf40e261
Handle more 64bit shifts in Translator (#1825) 2025-01-24 03:07:36 -08:00
Stephen Miller
0f93edb377
Implement IMAGE_ATOMIC_SWAP (#2194)
We already handle everything for this opcode in our IMAGE_ATOMIC function, so implementing this is fairly simple.
Should improve Wipeout 3.
2025-01-19 19:20:51 -08:00
Vladislav Mikhalin
7b8177f48e
renderer: handle disabled clipping (#2146)
Co-authored-by: IndecisiveTurtle <47210458+raphaelthegreat@users.noreply.github.com>
2025-01-18 09:20:38 +03:00
polybiusproxy
99a04357d1
don't compile cs with higher shared memory than supported (#2175) 2025-01-17 21:51:33 +01:00
baggins183
c13b29662e
handle control point strides that arent a multiple of 16 (#2172) 2025-01-17 10:14:54 +02:00
squidbus
3b474a12f9
shader_recompiler: Improvements to buffer addressing implementation. (#2123) 2025-01-16 18:40:03 -08:00
squidbus
da2b58f66e
resource_tracking_pass: Persist image resource atomic designation. (#2158) 2025-01-16 12:36:41 +02:00
DanielSvoboda
1c3048ccc2
Fix V_FRACT_F64 (#2156) 2025-01-15 16:45:02 +01:00
squidbus
82cb298c5c
shader_recompiler: Remove AMD native CubeFaceCoord. (#2129) 2025-01-11 13:57:49 -08:00
squidbus
5810c88c00 hotfix: Fix cube instructions. 2025-01-11 12:04:46 -08:00
squidbus
e656093d85
shader_recompiler: Fix some image view type issues. (#2118) 2025-01-10 12:35:03 -08:00
squidbus
725814ce01
shader_recompiler: Improvements to array and cube handling. (#2083)
* shader_recompiler: Account for instruction array flag in image type.

* shader_recompiler: Check da flag for all mimg instructions.

* shader_recompiler: Convert cube images into 2D arrays.

* shader_recompiler: Move image resource functions into sharp type.

* shader_recompiler: Use native AMD cube instructions when possible.

* specialization: Fix buffer storage mistake.
2025-01-10 10:48:12 +02:00
squidbus
65f9bbbfed
shader_recompiler: Ignore exec mask for scalar instructions. (#2097) 2025-01-08 19:14:06 +02:00
squidbus
b0d7feb292
video_core: Implement conversion for uncommon/unsupported number formats. (#2047)
* video_core: Implement conversion for uncommon/unsupported number formats.

* shader_recompiler: Reinterpret image sample output as well.

* liverpool_to_vk: Remove mappings for remapped number formats.

These were poorly supported by drivers anyway.

* resource_tracking_pass: Fix image write swizzle mistake.

* amdgpu: Add missing specialization and move format mapping data to types

* reinterpret: Fix U/SToF input type.
2025-01-07 12:21:49 +02:00
squidbus
86038e6a71
shader_recompiler: Fix V_CMP_U_F32 (#2082) 2025-01-07 11:36:14 +02:00
squidbus
8879380427
shader_recompiler: Implement S_BITSET(0/1)_B32 (#2039) 2025-01-06 01:08:27 +02:00
TheTurtle
dcc662ff1a
ir_passes: Integrate DS barriers in block (#2020) 2025-01-02 22:52:10 +02:00
squidbus
41d64a200d
shader_recompiler: Add swizzle support for unsupported formats. (#1869)
* shader_recompiler: Add swizzle support for unsupported formats.

* renderer_vulkan: Rework MRT swizzles and add unsupported format swizzle support.

* shader_recompiler: Clean up swizzle handling and handle ImageRead storage swizzle.

* shader_recompiler: Fix type errors

* liverpool_to_vk: Remove redundant clear color swizzles.

* shader_recompiler: Reduce CompositeConstruct to constants where possible.

* shader_recompiler: Fix ImageRead/Write and StoreBufferFormatF32 types.

* amdgpu: Add a few more unsupported format remaps.
2024-12-31 06:14:47 +02:00
squidbus
284f473a52
shader_recompiler: Fix BitCount64 and FindILsb64 (#1978) 2024-12-31 06:10:29 +02:00
baggins183
62780e4e43
Initialize V0 to PrimitiveId in hull shader (#1985) 2024-12-31 06:00:52 +02:00
baggins183
62c47cb1b7
recompiler: handle reads of output variables in hull shaders (#1962)
* Handle output control point reads in hull shader. Might need additional barriers

* output storage class
2024-12-29 12:37:15 +02:00
jas0n098
63d2d1ebe8
Handle RectList primitives in Geometry shaders (#1936) 2024-12-28 13:19:41 +02:00