Commit Graph

549 Commits

Author SHA1 Message Date
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
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
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
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
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
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.
4644657e83 [Vulkan] Implement readback_resolve for vulkan 2025-10-23 07:54:38 +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
Gliniak
c4bd676c5e Merge branch 'master' of https://github.com/xenia-project/xenia into canary_experimental 2025-08-15 15:37:50 +02:00
Triang3l
b5432ab83f [Vulkan] Refactoring and fixes for VulkanProvider and related areas
Enable portability subset physical device enumeration.

Don't use Vulkan 1.1+ logical devices on Vulkan 1.0 instances due to the
VkApplicationInfo::apiVersion specification.

Make sure all extension dependencies are enabled when creating a device.

Prefer exposing feature support over extension support via the device
interface to avoid causing confusion with regard to promoted extensions
(especially those that required some features as extensions, but had those
features made optional when they were promoted).

Allow creating presentation-only devices, not demanding any optional
features beyond the basic Vulkan 1.0, for use cases such as internal tools
or CPU rendering.

Require the independentBlend feature for GPU emulation as working around is
complicated, while support is almost ubiquitous.

Move the graphics system initialization fatal error message to xenia_main
after attempting to initialize all implementations, for automatic fallback
to other implementations in the future.

Log Vulkan driver info.

Improve Vulkan debug message logging, enabled by default.

Refactor code, with simplified logic for enabling extensions and layers.
2025-08-14 23:44:21 +03:00
Triang3l
a06be03f1b [GPU] Cleanup definitions of some registers
VS/PS_NUM_REG is 6-bit on Adreno 200, and games aren't seen using the
bit 7 to indicate that no GPRs are used. It's not clear why Freedreno
configures it this way.

Some texture fetch fields were deprecated or moved during the development
of the Xenos, reflect that in the comments.

Add definitions of the registers configuring the conversion of vertex
positions to fixed-point. Although there isn't much that can be done with
it when emulating using PC GPU APIs, there are some places in Xenia that
wrongly (though sometimes deliberately, for results closer to the behavior
of the host GPU) assume that the conversion works like in Direct3D 10+,
however the Xenos supports only up to 4 subpixel bits rather than 8. The
effects of this difference are largely negligible, though.

Also add more detailed info about register references and differences from
other ATI/AMD GPUs for potential future contributors.
2025-08-06 13:21:19 +03:00
Margen67
3eef564ff8 [format] Require EOF newline 2025-07-19 14:42:21 -07:00
Margen67
4cb783bf22 Header cleanup 2025-07-19 14:42:21 -07:00
Gliniak
31d715d100 [Premake] Removed unused/unnecessary subprojects.
- Testing currently doesn't work
- VFS Dump is unused. You can use internal function for it
- Demos are only for fun
- Trace Dump & Trace Viewer (unsure, but ok)

You can re-enable them by changing values: enableTests and enableMiscSubprojects in main premake file.

In the future there should be xb command support to overwrite them
2025-04-15 09:04:16 +02:00
Gliniak
7298536d46 [HID] Added support for Xbox 360 Skylanders Portal
- This requires Zadig for installation of WinUSB driver for portal
2025-04-14 21:44:49 +02:00
Xphalnos
47f327e848 [Misc] Replaced const with constexpr where possible 2025-04-08 19:32:17 +02:00
Xphalnos
5f918ef28d [Misc] Replaced const with constexpr where possible 2025-03-25 19:50:37 +01:00
Gliniak
3ac98ebfba [Static Analysis] Resolved some issues mentioned in Alexandr-u report 2024-11-02 19:08:34 +01:00
NicknineTheEagle
c4e930ed4c Proper 4:3 support 2024-07-01 08:55:15 +02:00
Gliniak
b3f2ab0e96 Merge branch 'master' of https://github.com/xenia-project/xenia into canary_experimental 2024-05-31 22:43:59 +02:00
Triang3l
3d30b2eec3 [Vulkan] Shader memory export (#145) 2024-05-25 16:31:50 +03:00
Triang3l
8e7301f4d8 [SPIR-V] Use a helper class for most if/else branching
Simplifies emission of the blocks themselves (including inserting blocks
into the function's block list in the correct order), as well as phi after
the branching.

Also fixes 64bpp storing with blending in the fragment shader interlock
render backend implementation (had a typo that caused the high 32 bits to
overwrite the low ones).
2024-05-16 23:05:49 +03:00
Triang3l
376bad5056 [GPU] Remove register reinterpret_casts + WAIT_REG_MEM volatility
Hopefully prevents some potential #1971-like situations.

WAIT_REG_MEM's implementation also allowed the compiler to load the value
only once, which caused an infinite loop with the other changes in the
commit (even in debug builds), so it's now accessed as volatile. Possibly
it would be even better to replace it with some (acquire/release?) atomic
load/store some day at least for the registers actually seen as
participating in those waits.

Also fixes the endianness being handled only on the first wait iteration in
WAIT_REG_MEM.
2024-05-12 17:28:17 +03:00
Gliniak
b115823735 Merge branch 'master' of https://github.com/xenia-project/xenia into canary_experimental 2024-05-10 08:59:17 +02:00
Triang3l
a90f83d44c [Vulkan] Non-seamless cube map filtering 2024-05-05 15:20:23 +03:00
Triang3l
e9f7a8bd48 [Vulkan] Optional functionality usage improvements
Functional changes:
- Enable only actually used features, as drivers may take more optimal
  paths when certain features are disabled.
- Support VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE.
- Fix the separateStencilMaskRef check doing the opposite.
- Support shaderRoundingModeRTEFloat32.
- Fix vkGetDeviceBufferMemoryRequirements pointer not passed to the Vulkan
  Memory Allocator.

Stylistic changes:
- Move all device extensions, properties and features to one structure,
  especially simplifying portability subset feature checks, and also making
  it easier to request new extension functionality in the future.
- Remove extension suffixes from usage of promoted extensions.
2024-05-04 22:47:14 +03:00
Gliniak
b9061e6292 [LINT] Linted files + Added lint job to CI 2024-03-12 19:19:30 +01:00
yeah-its-gloria
57a23cf192 Fix typing for output stencil ref 2023-12-05 09:37:57 +01:00
Gliniak
ce9a82ccf8 Merge branch 'master' of https://github.com/xenia-project/xenia into canary_experimental 2023-09-01 18:20:29 +02:00
Gliniak
2a4d7feaae [GPU] Unified clear_memory_page_state to be used in D3D12 & Vulkan 2023-08-06 21:56:35 +02:00
Triang3l
ed64e3072b [GPU] Remove implicit bool cast in memexport checks 2023-05-05 21:38:45 +03:00
Triang3l
53f98d1fe6 [GPU/D3D12] Memexport from anywhere in control flow + 8/16bpp memexport
There's no limit on the number of memory exports in a shader on the real
Xenos, and exports can be done anywhere, including in loops. Now, instead
of deferring the exports to the end of the shader, and assuming that export
allocs are executed only once, Xenia flushes exports when it reaches an
alloc (allocs terminate memory exports on Xenos, as well as individual ALU
instructions with `serialize`, but not handling this case for simplicity,
it's only truly mandatory to flush memory exports before starting a new
one), the end of the shader, or a pixel with outstanding exports is killed.

To know which eM# registers need to be flushed to the memory, traversing
the successors of each exec potentially writing any eM#, and specifying
that certain eM# registers might have potentially been written before each
reached control flow instruction, until a flush point or the end of the
shader is reached.

Also, some games export to sub-32bpp formats. These are now supported via
atomic AND clearing the bits of the dword to replace followed by an atomic
OR inserting the new byte/short.
2023-05-05 21:32:02 +03:00