Commit Graph

2433 Commits

Author SHA1 Message Date
Herman S.
6057b0a7c7 [Vulkan] Implement ClearCache to clear upload_buffer_pool 2026-02-17 21:10:38 +09:00
Herman S.
4d15f0afea [Vulkan] Implement same vastcpy upload_buffer optimization as d3d12 2026-02-17 21:10:13 +09:00
Herman S.
ef505fbe3d [Vulkan] add no_discard_stencil_in_transfer_pipelines support 2026-02-17 17:54:01 +09:00
Herman S.
24f90c0efc [Vulkan] Fix stencil bit transfer shaders not discarding pixels
"packed" was never set because source_depth_texture isn't created for
stencil bit output. This caused the discard logic to be skipped
resulting in stencil being incorrectly incremented on every transfer
draw until it saturated at 0xFF.

Fixes many remaining Vulkan rendering issues, e.g. Brothers, Orange Box,
Arkham Origins, many others.
2026-02-17 17:44:23 +09:00
Herman S.
878de4c352 [Vulkan] Fix sampler params 2026-02-17 17:44:08 +09:00
Herman S.
dc66d67a31 [Vulkan] Use VK_FORMAT_A2B10G10R10 for xenos::ColorRenderTargetFormat::k_2_10_10_10
Aligns with D3D12's DXGI_FORMAT_R10G10B10A2_UNORM
2026-02-17 17:43:55 +09:00
Herman S.
1a4b78e377 [Vulkan] Invalidate descriptor set bindings for incompatible sets
The code to do this was set up but it seems it was never implemented.
2026-02-17 17:43:45 +09:00
Herman S.
a716dc6fac [Vulkan] Fix kComputeWrite access mask
Access mask was incorrectly set to VK_ACCESS_SHADER_READ_BIT
2026-02-17 17:41:21 +09:00
Herman S.
5be503da77 [Vulkan] Don't try to create geometry shader for rectangle list 2026-02-17 17:40:59 +09:00
Herman S.
ec5816a278 [Vulkan] Use vertex_fetch_bitmap instead of vertex_bindings()
Avoids using cached/stale vertex binding indices
2026-02-17 17:40:26 +09:00
Herman S.
434644c301 Merge commit 'f2fabfdf0' into canary_experimental
Sync changes from master up to before the recent GPU changes, those will be
merged later
2026-02-17 16:59:38 +09:00
Herman S.
20b226dbdf [Vulkan] Update glslang to 16.0.0 and introduce compat layer 2026-02-17 15:34:23 +09:00
Herman S.
f722b6b85f [Vulkan] Workaround for glslang 11.6.0+ change in accesschain semantics 2026-02-17 14:58:10 +09:00
Herman S.
f9d4dbc8e9 [Build] Use clang 20 for clang format consistently across Win/Lin 2026-02-15 01:25:43 +09:00
goldislead
1a9613705d Rework max anisotropy override to sampler creation (D3D12/Vulkan)
Revert ac6fd65 fetch additions and implement context-sensitive AF override.
2026-02-07 17:47:12 +01:00
Stayd
ac6fd65385 [GPU] Add anisotropic filtering override 2026-01-28 08:28:53 +01:00
Triang3l
c7f61342d7 [GPU/D3D12] Convert gamma-as-linear red to gamma in transfers to stencil
Co-authored-by: Herman S. <429230+has207@users.noreply.github.com>
2026-01-20 12:53:20 +03:00
Triang3l
0a19234b4e [GPU/D3D12] Add forgotten gamma conversion format check 2026-01-19 21:08:15 +03:00
Triang3l
cec9ca0ef2 [GPU] 8-bit PWL gamma RT as linear 16-bit UNorm on the host
With render target HLE, directly store linear values as R16G16B16A16_UNORM
without gamma conversion, as this format provides more than enough bits
(need at least 11 per component due to the maximum scale being 2^3 in the
piecewise linear gamma curve) to represent linear values without precision
loss.

This makes blending work correctly in linear space, improving quality of
transparency, lighting passes, and fixing issues such as transparent parts
of impact and footstep decals in 4D5307E6 being bright instead.

The new behavior is enabled by default, as it hugely improves the accuracy
of emulation of this format, that is pretty commonplace in Xbox 360 games,
with likely just a small GPU memory and bandwidth usage increase, compared
to the alternatives that were previously available on the HLE RB path.

It's currently implemented only on Direct3D 12, as most of the current GPU
emulation code is planned to be phased out and redone, and no methods other
than 8-bit with pre-conversion were implemented on Vulkan previously.

To implement on Vulkan later, same conversion as in the Direct3D 12
implementation will need to be done in ownership transfer and resolve
shaders. Currently it's somewhat inconvenient to decouple the conversion
functions in `SpirvShaderTranslator` from an instance of the translator due
to vector constant usage. Later, simpler SPIR-V generation functions may be
added (`spv::Builder` usage in general is overly verbose).

The previously default method (8-bit storage with pre-conversion in shaders
and incorrect blending) can be re-enabled by setting the
"gamma_render_target_as_unorm16" configuration option to `false`. This may
be useful if the game, for instance, switches between 8_8_8_8_GAMMA and
8_8_8_8 formats for the same data frequently, as switching will result in
EDRAM range ownership transfer data copying now. Also, the old path is
preserved for Vulkan devices not supporting R16G16B16A16_UNORM with
blending.

The other workaround that was available previously, replacing the PWL
encoding with host hardware sRGB with linear-space blending in render
target management and in texture fetching, was also inherently inaccurate
in many ways (especially when games have their own PWL encoding math, like
4541080F that displayed incorrect colors on the loading screen), and
required tracking of the encoding needed for ranges in the memory.

The sRGB workaround therefore was deleted in this commit, greatly
simplifying the code in the parts of render target, texture and memory
management and shader generation that were involved in it.
2026-01-18 16:22:22 +03:00
Triang3l
f2fabfdf04 [GPU] Change "bpe" to "bpb" (bytes per block) in comments
Forgotten in the other "element" to "block" change.
2026-01-15 20:48:26 +03:00
Triang3l
88f95a8bd6 [GPU] Change "element" name back to "block" in texture addressing
The 32_32_32_FLOAT format seems to be vertex-only, so it looks like there
can't be storage elements smaller than a single texel.

So, use a more precise name that can't be confused with "picture element"
(pixel) or "texture element" (texel) that represents a single logical pixel
rather than a storage block of pixels.
2026-01-15 11:56:45 +03:00
Triang3l
9535e610b0 [GPU] Change texture address local X offsetting back to addition
More likely to be emitted as an immediate load/store offset in host
hardware shaders.
2026-01-14 00:15:08 +03:00
Triang3l
6db6192170 [GPU] Use XOR to flip X texel group in all load/resolve shaders
For visual consistency (missed in the commit that added LocalXAddressXor).
2026-01-13 23:37:01 +03:00
Triang3l
7db772bfeb [GPU] XeResolveLocalXAddressXor comment typo correction 2026-01-13 23:22:30 +03:00
Triang3l
0f23f05683 [GPU] Simplify local X offsetting with resolution scaling
Switch between even and odd 16-byte element sequences along X by simply
flipping a bit rather than going to a different resolution-scaled group of
pixels, by increasing the size of the group within the constraints imposed
by tiling.
2026-01-13 23:14:15 +03:00
Triang3l
76c531bff2 [GPU] Rename AddressTiled in TiledAddress in shaders
There will possibly be more `XenosTextureTiled*` functions in the future
where the word "Address" would make the names excessively long.
2026-01-13 21:20:26 +03:00
Triang3l
80a9af4277 [GPU] Add macro tile size constants to texture addressing headers 2026-01-13 21:18:25 +03:00
Triang3l
ea8ae81bfd [GPU] Remove now-unused texture_conversion.cc/h 2026-01-06 17:59:20 +03:00
Triang3l
28b69c21be [GPU] Document tiled texture address bits
Will be useful for calculating memory extents more precisely in the future.
2026-01-06 17:47:19 +03:00
Triang3l
cbbaae8ead [Vulkan] Recompile internal shaders with Vulkan SDK 1.4.335.0
spirv-remap was replaced with spirv-opt --canonicalize-ids, and debug
information is preserved now.
2026-01-04 17:03:37 +03:00
Herman S.
fcebdfb255 [GPU] Fix scaled resolve tracking for blocks outside write range 2025-12-27 19:02:29 +01:00
Gliniak
c42aeacf25 [Vulkan] Ensure entire scaled range fits within the buffer.
Fixes devices lost errors when using resolution scaling

Co-authored-by: Herman S. <429230+has207@users.noreply.github.com>
2025-12-25 14:40:33 +01:00
Triang3l
fe1fd36137 [D3D12/Vulkan] Simplify host GPU fence management
Replace the `SubmissionTracker`s with new `GPUCompletionTimeline`s with a
more unified interface (using a base class), and without the internal logic
for queue ownership transfers since that idea was scrapped during the
development of the `Presenter`.

Also use this fence management logic for GPU emulation, though without
architectural reworks for now, just on the bottom level.

Still very messy, but can be cleaned up in further GPU command processor
and presenter reworks.
2025-12-14 21:24:38 +03:00
Herman S.
4cbcae5b64 [Vulkan] Properly scale rectangle coordinates 2025-12-10 16:17:20 +01:00
yippeeeyay
2b77c4c08a [D3D12] Simplify Intel Arc GPU checking 2025-12-07 19:09:36 +01:00
Herman S
32889f51be Use fetch_contant_word3 for exponent bias
Previously was using word4 which is LOD bias, fixes many graphic issues
with Vulkan backend
2025-12-06 22:26:40 +01:00
Gliniak
038b11a537 [GPU] Removed nvapi
- According to reports d3d12_nvapi_use_driver_heap_priorities give no benefit
2025-12-05 21:54:06 +01:00
Gliniak
90a7cc4fee [GPU] Changed default readback_resolve to none 2025-12-04 20:12:34 +01:00
Gliniak
78e753ef52 [GPU] Added config option to enable/disable invalid memory uploads 2025-12-02 22:34:39 +01:00
Herman S.
e2c33686cc [GPU] Double-buffer readback_resolve.
Introduce "fast" readback resolve that reads from previous frame's
resolve buffers, quick swap between buffers each frame to avoid
copies so minimal performance impact and mostly correct bahavior.
Checks if previous frame had a buffer for the current resolve and
falls through to the slow path, which also allows to support
"screenshot" features in the games that do that without stalling
on normal resolve operations.

Re-enabled readback_memexport as separate feature, was previously
bundled with readback_resolve (probably not intentionally) and
ensures destination address is writeable to avoid memory access
related crashes and unnecessary work.

readback_resolve cvar changes from bool to string ternary with
"none", "fast" and "full" options, defaulting to the new "fast"
mode.
2025-12-01 17:38:34 +01:00
Herman S.
f2554eb742 [GPU] Fix variable shadowing for SV_SampleIndex semantic name 2025-11-29 09:52:04 +01:00
Gliniak
1bf98e9354 [D3D12] Restored memory access safeguard 2025-11-18 23:01:28 +01:00
Gliniak
51414f3e1e [Logging] Added ability to disable GPU related logs 2025-10-29 21:16:40 +01:00
Herman S.
4644657e83 [Vulkan] Implement readback_resolve for vulkan 2025-10-23 07:54:38 +02:00
Gliniak
777c394e25 [Kernel] Added VdQueryRealVideoMode 2025-10-17 09:24:06 +02:00
Herman S.
d430342d93 [Vulkan] Add resolution scaling support to Vulkan backend.
Largely similar to D3D12 implementation but more simple buffer
management and no mips scaling. Includes both FBO and FSI
rendering paths.

Tested on Linux with 2x2 and 3x3 running smoothly.
2025-10-14 19:08:06 +02:00
Triang3l
0b2ffa3148 [GPU] Change texture load cbuffer to push constants
Simplify the code, eliminating the need for supporting requesting cbuffers
for anything other than guest draw command execution.
2025-08-20 12:46:26 +03:00
Triang3l
04d5c40d0d [GPU/UI] XeSL readability improvements + float suffix
Use the _xe suffix instead of the xesl_ prefix for quicker visual
recognition of identifiers, also switch to snake_case for consistency.

Also add the f suffix to float32 literals because the Metal Shading
Language is based on C++.
2025-08-19 21:36:06 +03:00
Adrian
a9fb32a2fd [GPU] More post merge fixes 2025-08-15 22:38:56 +02:00
Gliniak
419c0149c9 [Base] Post merge fixes 2025-08-15 18:06:57 +02:00