Commit Graph

2433 Commits

Author SHA1 Message Date
Gliniak
d1ad597939 [GPU] Vulkan: Fixed FSI render target path
AlphaToMask was causing crashes on linux due to missing SelectionMerge
2026-03-09 21:52:00 +01:00
Herman S.
64e51c544e [GPU] Add vulkan shader disk storage / startup loading
Big refactor of the shader storage to allow both backends to share code
2026-03-10 00:49:56 +09:00
Herman S.
5845f3437b [GPU] Async shader compilation for D3D12 and Vulkan
Adds async_shader_compilation cvar (default true) that forces new
pipelines to be created async from the main thread, skips draws entirely
on D3D12 and on vulkan replaces pixel shader with placeholder until the
real one is ready. Causes some visual artifacts on first load but
greatly reduces load times and stutter.
2026-03-10 00:24:26 +09:00
Herman S.
ccf8fb66f5 [Vulkan] Add thread pool for async shader compilation
Uses priority queue with higher priority on shaders with visible
render targets
2026-03-10 00:21:10 +09:00
Herman S.
19c5401eda [GPU] Revert SPIR-V version back to 1.0 for internal shaders 2026-03-09 21:34:22 +09:00
Herman S.
37fabb9346 [GPU] Ensure vsync works correctly on Linux.
Linux scheduler quantum is 4-10ms so requesting 15ms sleep ends
up sleeping 16-19ms and overshoots our target causing games to run
at 57fps
2026-03-09 12:41:53 +09:00
Herman S.
2912da02fe [D3D12] Fix gamma_unorm16 render target transfer shaders
Gamma stored as R16G16B16A16_UNORM is 64bpp in host memory but
represents a single 32bpp pixel, unlike true 64bpp formats which pack
two 32bpp pixels together. Separate dest_is_gamma_unorm16 from
dest_is_64bpp to avoid incorrect coordinate transforms.

Add output paths for gamma_unorm16 destinations:
- gamma→gamma: direct passthrough (already linear in R16G16B16A16)
- k_8_8_8_8→gamma: convert gamma-encoded source to linear
- Cross-format packed EDRAM: midpoint encoding to survive UNORM16
  quantization round-trip through PreSaturatedLinearToPWLGamma

Fixes red bleeding in Halo Reach, image halving in Just Cause 2,
Portal not rendering, and black rock/plant textures in Halo Reach.
2026-03-06 23:05:39 +09:00
Herman S.
65d42843b6 Merge remote-tracking branch 'xenia-master/master' into canary_experimental 2026-03-06 23:05:24 +09:00
Herman S.
16d2cc05c5 [GPU] Use UNorm not signed EDRAM encoding in k_16_16 resolve packing.
The original commit (2eea146b) correctly added kXenosFormat_16_16_EDRAM
case labels and fixed the unpack clamp from -1.0 to -32.0, but
incorrectly changed the resolve pack functions from UNorm to signed EDRAM
encoding. The resolve destination is a regular texture sampled as UNorm
[0,1], not EDRAM. Using EDRAM packing double-encodes the [-32,32]
scaling, crushing all values by ~64x and caused visual issues
particularly in UE3 titles.

The bytecode submitted with the change was actually correct, but the
source had additional incorrect pieces that only manifested when shaders
were rebuilt.
2026-03-05 15:11:22 +09:00
Herman S.
4bd93883ac [Build] Convert buildshaders to custom build rules 2026-03-04 20:57:42 +09:00
Herman S.
71c5702ee8 [Build] Convert build system to raw cmake and remove premake layer 2026-03-04 17:37:36 +09:00
Herman S.
dbfe216754 [Vulkan] Implement extended range for f32 to f16 conversion in memexport 2026-03-03 17:16:37 +09:00
Ylederman153
02c6bc6e61 [D3D12] Implement extended range for f32 to f16 conversion in memexport (#899)
Resolves TODO(Triang3l) by implementing a mathematical workaround to allow exponent 31 for extended float16 range up to +/-131008.0f as expected by the native Xbox 360 hardware, bypassing standard D3D12 f32tof16 boundaries which incorrectly clamp/inf values.
2026-03-03 17:16:05 +09:00
Herman S.
f2ac39cfd9 [Build] Generate shaders on build instead of having them checked in 2026-03-03 16:21:30 +09:00
Ylederman153
2eea146b1b [GPU] Fix k_16_16 and k_16_16_16_16 EDRAM packing clamping (#898)
Replaces the UNorm packing functions with custom Edram functions to preserve the native [-32.0, 32.0] float range and scale mathematically instead of using saturate(). Fixes displaced water meshes in games like Mercenaries 2.
2026-03-03 14:27:04 +09:00
Herman S.
48111e8fba [D3D12] Fix device lost with resolution scaling in 3D-as-2D textures 2026-03-01 16:41:50 +09:00
Herman S.
125b4c8c05 [GPU] Ensure force_special_view checks swizzle signs before using signed
This was causing unnecessary logspam in Blue Dragon due to
incorrectly trying to request signed when the fetch constants are
unsigned
2026-02-26 14:36:08 +09:00
Herman S.
0c8d1b763f [D3D12] Pre-create 3D-as-2D textures before draw setup 2026-02-26 14:22:46 +09:00
Herman S.
0e2967cdb0 [D3D12] Fix 3D-to-2D texture crash under Wine/VKD3D 2026-02-26 14:22:46 +09:00
Herman S.
e7941b0c7d [GPU] 3d-to-2d textures default enable
Replaced the modal cvar with bool gpu_3d_to_2d_texture with "mode 2" now enabled by
default and "mode 1" removed as unnecessary
2026-02-26 14:22:46 +09:00
Herman S.
90c48e1d21 [GPU] 3d-to-d2 texture implementation
Adds vulkan version of mode 1 and 2 and fixes related crashes by keeping
the 2d texture views from the texture cache.
2026-02-26 14:22:46 +09:00
Herman S.
7c9b5af236 [D3D12] add cvar to control 3d-to-2d texture mode 2026-02-26 14:22:46 +09:00
Raffaele
fc5ab60a88 [D3D12] Fix 4D5307DF fur textures
- Fixes issue https://github.com/xenia-canary/game-compatibility/issues/6
- Implements a load texture logic
2026-02-26 14:22:46 +09:00
Raffaele
26824edcfa [D3D12] Fix 4D5307DF fur textures
- Fixes issue https://github.com/xenia-canary/game-compatibility/issues/6
- Implements a copy texture logic
2026-02-26 14:22:46 +09:00
Herman S.
9c37af4621 [Vulkan] Add proper tracking to swap gamma correction render pass 2026-02-25 12:31:18 +09:00
Herman S.
6de637b794 [Vulkan] Smear scalar bools.
Addresses some shader validation warnings
2026-02-25 12:31:18 +09:00
Herman S.
74ce1c812f [Vulkan] Fix VUID-FragDepth-FragDepth-04216 validation issue 2026-02-25 12:31:18 +09:00
Herman S.
77852914ff [GPU] TextureCache lockless pre-check
lockless accessors for base_outdated/mips_outdated and skip lock
acquisition when textures appear up to date
2026-02-25 12:31:18 +09:00
Herman S.
067641668f [GPU] Fix min/max blend operations to properly apply factors
Applies factors before the MIN/MAX operation - in FSI/ROV via runtime
blending, in FBO/RTV by pre-multiplying shader output when dstFactor is
ONE only, as we don't have access to dest to provide full support as we
do in the FSI/ROV paths.
2026-02-25 09:39:03 +09:00
Herman S.
966d8f0925 [Vulkan] fix FBO path reading from output variables for alpha test
Makes FBO follow the same pattern as FSI by using function scoped
intermediate variables
2026-02-25 09:38:58 +09:00
Herman S.
2d7ca4fb39 [GPU] Remove log spam for empty region resolve issues.
Affects Forza Horizon 1 and 2, does not seem to be related to any
actual rendering issues but makes it very difficult to debug real
problems.
2026-02-25 09:11:03 +09:00
Herman S.
1e23aaf4fc Improve error handling in graphics memory init 2026-02-25 09:10:48 +09:00
Triang3l
95a5c3ee25 [GPU/WGF] Bind EDRAM to resolve dumping via ByteAddressBuffer
Simplifies binding by eliminating the need to switch between 32-bit and
64-bit views, and makes it possible to bind the EDRAM via a root descriptor
on Direct3D 12.
2026-02-18 22:40:20 +03:00
Triang3l
17bc5b48e3 [GPU/D3D12] Remove now-unused typed shared memory descriptors
All usage instances changed to ByteAddressBuffer.
2026-02-18 16:41:36 +03:00
Triang3l
80dad41454 [GPU/WGF] Use ByteAddressBuffer in precompiled shaders
Drivers and hardware may provide more optimal paths for untyped buffers
compared to typed.

Also, ByteAddressBuffer may be bound via a root descriptor in Direct3D 12,
greatly simplifying the binding logic.

ByteAddressBuffer also doesn't have the 128 * 2^20 element count limit that
typed and structured buffers have, and doesn't require the structure stride
to be specified at resource creation time in Direct3D 11.
2026-02-17 23:28:42 +03:00
Herman S.
83d776fa39 [Vulkan] Add tesselation support
Pretty much just following the D3D12 implementation
2026-02-18 00:02:21 +09:00
Herman S.
3e3aee1ef2 [App] Update title to show apu and remove vulkan incomplete warning 2026-02-17 23:50:40 +09:00
Herman S.
48c13be2d5 [Vulkan] Add gamma_render_target_as_srgb support 2026-02-17 23:35:59 +09:00
Herman S.
5d74d69aa8 [Vulkan] Alpha to coverage FSI implementation 2026-02-17 22:46:18 +09:00
Herman S.
792e61f6e2 [Vulkan] Alpha to coverage improvements
Refactor redundant code, fix 2x MSAA sample mapping and
only declare gl_FragCoord when alpha to coverage can run
2026-02-17 22:46:14 +09:00
Herman S.
cba315cf38 [Vulkan] Implement alpha to coverage (FBO)
Fixes the foliage rendering in places like Red Dead Redemption menu
2026-02-17 22:43:27 +09:00
Herman S.
75589de0a4 [Vulkan] Ensure descriptor sets always initialized for user_clip_planes 2026-02-17 22:18:21 +09:00
Herman S.
f13ee6ec38 [Vulkan] Add support for user clip planes 2026-02-17 22:18:02 +09:00
Herman S.
0b7abf0241 [Vulkan] Add resolution scaling mips support 2026-02-17 21:46:50 +09:00
Herman S.
cd7b47235d [GPU] Properly handle scaled textures and weights
Fix d3d12 logic wrt scaling weights, add vulkan impelementation for using
scaled texture offsets and fix resolution-scaled texture detection
2026-02-17 21:44:18 +09:00
Herman S.
55f0333182 [Vulkan] Fix incorrect scaling EDRAM tile span parameters
These parameters are EDRAM tile coordinates in guest space and shouldn't
be scaled. Fixes visual issues in certain games when upscaling.
2026-02-17 21:43:05 +09:00
Herman S.
5897de3eaf [Vulkan] Implement tiled_shared_memory for resolution scaling
Adds support for >3x resolution scaling to vulkan by implementing
sparse scaled resolve similar to the d3d12 implementation.
2026-02-17 21:31:25 +09:00
Herman S.
a092551735 [Vulkan/D3D12] Validate upload range bounds before vastcpy
The D3D12 backend's existing check only validated the last page of the
range. The Vulkan backend had no check at all and did not respect the
gpu_allow_invalid_upload_range cvar. Both now verify start and
end pages are mapped before copying, preventing access violations when
games reference unmapped guest physical memory during transitions.
2026-02-17 21:22:48 +09:00
Herman S.
3e1b0c715a [Vulkan] Vertex buffer residency caching
Cache vertex buffer address/size per fetch constant, invalidate on fetch
constant write, reset at frame boundaries
2026-02-17 21:22:00 +09:00
Herman S.
2ad412a141 [Vulkan] Add support for vkPipelineCache 2026-02-17 21:21:56 +09:00