Commit Graph

143 Commits

Author SHA1 Message Date
xander-will 71341a27e4
Integer Scaling + Screen-Level Linear Interpolation Options (#1976) 2025-06-13 11:59:15 +02:00
scribam c3275d3c6f ci: update bsd workflows 2025-05-21 23:22:47 +02:00
Flyinghead 58ce9a4159 vk: (mali) add memory barrier in GetLastFrame
Add memory barrier between drawing and transfer.
Fix savestate thumbnail image corruption.
Issue #1922
2025-05-02 15:30:45 +02:00
Wunkolo da9f030a0e vk: Refactor swapchain format selection
Use a series of stable-partitions to sort the list of available formats
to find the best candidate surface-format/color-space that is a non-sRGB
format being presented in an sRGB color-space. Vulkan mandates that all
surface formats that have SRGB forms must also support a UNORM form.

This is basically just RGBA8/BGRA8 on all platforms still, but in a way
that is still capable of falling back to secondary formats in a stable
way in the case that the primary choice is not available.  Mobile
devices especially have a LOT of secondary HDR surface formats and other
weird formats that can be used to present such as RGBA16 or RGBA565.
With stable partitions, if we can't get our best option then there is
always a "next best thing" to fall back on rather than relying on the
driver-order.
2025-01-22 18:28:55 +01:00
Wunkolo a0e1eb0005 vulkan: Allow native `RGB8` screenshot framebuffers when available
Some notable devices support native RGB8 color-attachments:
https://vulkan.gpuinfo.org/listdevicescoverage.php?optimaltilingformat=R8G8B8_UNORM&featureflagbit=COLOR_ATTACHMENT

This removes the need to do a manual RGBA->RGB format conversion on the CPU in favor of a direct memcpy from the downloaded texture, when available.
2025-01-22 18:27:20 +01:00
Flyinghead b4dcc64ef6 android: draw onscreen gamepad with imgui
Get rid of Renderer::DrawOSD.
gl: make a GlQuadDrawer class.
Draw on-screen gamepad using imgui.
Clean up vgamepad interface.
2024-11-22 14:42:51 +01:00
Wunk 4d73cc8e13
vk: Add `VK_EXT_provoking_vertex` optimization (#1681)
* vk: Add `VK_EXT_provoking_vertex` optimization

The dreamcast uses the last vertex as the provoking vertex, while vulkan uses the first vertex.
This requires an additional call to `setFirstProvokingVertex` to reorder the vertices for all incoming geometry.
With `VK_EXT_provoking_vertex`, the pipeline can designate that the provoking vertex is to be the last vertex, which removes the need to re-order incoming geometry on the CPU.

* vk: Propagate physical device API version to VMA

Allows VMA to make assumptions such as using the `*KHR` or non-`KHR` versions of certain function names.

* vk: Refactor libretro device initialization for `VK_EXT_provoking_vertex`

* vk: Top out at vulkan API version to VMA to 1.1

Despite the physical device possibly being 1.2 or 1.3, we only want up to 1.1. Otherwise we will be responsible for other API functions being resolved and loaded when passing to VMA.

* vk: Enable `VK_EXT_provoking_vertex` usage for ModVol and Final(OIT) pipeline

* vk: Enable `VK_EXT_provoking_vertex` for ModVol(OIT) pipeline

Pretty much anything handling dreamcast-geometry should use this extension when available

* vk: Additional `VK_EXT_provoking_vertex` pipeline fixes
2024-10-11 10:23:48 +02:00
Wunkolo 5b343562b9 vk: Add `CommandBufferDebugScope` utility-type
Adds a new RAII-based utility type for adding diagnostic information to command buffers.
Enabled only when `VK_DEBUG` is set to `1`.
2024-10-09 19:47:14 +02:00
Wunkolo a8bc1c12f4 vk: Optimize redundant `QuadBuffer` uploads
Hashes the contents of the `QuadBuffer` vertex-data such that data is only uploaded when the vertices actually change rather than every frame.
2024-10-09 19:40:59 +02:00
Wunkolo 0c3f5c7a76 vk: Refactor device/instance extension enablement
* Uses a utility-lambda for repeated extension-adding logic
* Uses an `std::set` for the list of available extensions for quick queries
* `VK_EXT_DEBUG_REPORT` and `VK_EXT_DEBUG_UTILS` aren't device extensions and don't need to be here. They are instance extensions
* Each extension that is tested to be added has a corresponding log message for if it was enabled or if it was unavailable

```
00:00:162 rend\vulkan\vulkan_context.cpp:427 N[RENDERER]: Device extension enabled: VK_KHR_swapchain
00:00:162 rend\vulkan\vulkan_context.cpp:427 N[RENDERER]: Device extension enabled: VK_KHR_get_memory_requirements2
00:00:162 rend\vulkan\vulkan_context.cpp:427 N[RENDERER]: Device extension enabled: VK_KHR_dedicated_allocation
00:00:162 rend\vulkan\vulkan_context.cpp:430 N[RENDERER]: Device extension unavailable: VK_KHR_portability_subset
00:00:162 rend\vulkan\vulkan_context.cpp:430 N[RENDERER]: Device extension unavailable: VK_EXT_debug_marker
```
2024-10-09 19:39:49 +02:00
Wunk 556e2ead56
vk: Refactor physical device selection (#1671)
Rather than electing the first physical device it finds, and falling back on the first-listed GPU: a series of stable-partitions are done so that the "least compromising" GPU is selected based on a series of criteria.

It will now maximally try to find a GPU that(in order of priority):
* Is a discrete GPU
* Supports `fragmentStoresAndAtomics`
* Supports `R5G5B5`/`R5G6B5A1`/`R4G4B4A4`

In the case that a system has two dGPUs and one of them supports optimal-formats, the optimal-format one is selected

In the case that a system has an iGPU and the dGPU and they both support optimal formats, the dGPU is selected.

In the case that a system has an iGPU and the dGPU and the dGPU doesn't support optimal formats, the dGPU is still selected.
2024-10-08 17:07:09 +02:00
Flyinghead 368bd17ae0 vk: use swap_chain_size + 1 semaphores
Fixes validation error VUID-vkAcquireNextImageKHR-semaphore-01779
introduced in vulkan sdk 1.3.275
Issue #1620
2024-08-29 13:01:11 +02:00
scribam 56b8bb1245 vk: cleanup
* Use constants for extension names
* Prefer VK_USE_PLATFORM_* constants
* Remove IOS_MVK/MACOS_MVK deprecated code
2024-07-28 20:02:34 +02:00
Flyinghead 35acb7e62c ui: load savestate thumbnails asynchronously. limit thumbnail size
GetLastFrame can take max width or height.
Limit width of savestate screenshot to 640.
Load savestate thumbnail in async task.
2024-05-14 14:23:40 +02:00
Flyinghead 6f0581032b save screenshot. add screenshot to savestates
Retrieve last frame rgb data (gl, vk, dx9, dx11).
Specific save screenshot code for android, iOS and UWP.
Add Save Screenshot emu key (F12 by default)
vk: defer deletion of in-flight textures when texture cache is cleared.
vk: fix issue when updating imgui textures after a render pass has begun
(achievements)
vk: palette texture not updated after a state has been loaded.
gl: Move opengl-specific stuff into opengl imgui driver.
savestate: Add non compressed header, following by screenshot png data,
before actual savestate.

Issue #842
2024-05-13 15:47:34 +02:00
Flyinghead 13302b87c8 move ui to its own folder 2024-05-07 22:23:51 +02:00
Flyinghead 43ba8953a2 vk: don't delete the ImGui driver when recreating the swap chain
It might be drawing at this point so just reset it.
2024-05-04 19:24:02 +02:00
Flyinghead 108c8a4b5d vk: move macOS video routing code from context to renderer 2024-04-10 17:31:23 +02:00
Flyinghead a6c4530e22 vulkan: allow custom GPU driver loading with libadrenotools
Issue #1471
2024-04-07 12:27:54 +02:00
scribam 0c5e79d618 deps: update imgui to version 1.90.3 2024-02-17 17:40:22 +01:00
vkedwardli 790f5b1ad2
Video Routing Revamp (#1323)
* Update Spout2 dep
* Remove all `initVideoRouting` call from `GraphicContext`
* Fix MinGW build error
2023-12-21 14:19:57 +01:00
Flyinghead 939e2bc68f vk: better deferred deletion. fix validation layer issues
Use raii-like mechanism to delete resources when not in use.
Fix several issues reported by validation layers (vtennis rtt, main
buffer size resizing, ...)
2023-12-03 19:18:16 +01:00
scribam f3a774ab4e imgui: use fonts upload code from v1.90 2023-12-01 15:02:43 +01:00
scribam 105ab95efa deps: update imgui and implot 2023-11-25 17:08:01 +01:00
Flyinghead c58ae4daac vulkan: terminate context if init fails
Avoids crash on exit
2023-10-16 14:19:47 +02:00
Flyinghead 2cd3ffb33f Revert "vk oit: add sync event between renderer and vk context on Mali
gpu"

This reverts commit abd9219347.
Issue #1234
2023-10-11 14:13:34 +02:00
Flyinghead abd9219347 vk oit: add sync event between renderer and vk context on Mali gpu
Use vk event to wait for renderer pipeline to finish before rendering
the final frame in vk context. This seems to help Mali gpus.
Issue #1234
2023-10-11 09:35:18 +02:00
Flyinghead c637ae8281 Merge remote-tracking branch 'origin/master' into dev 2023-07-30 18:05:38 +02:00
Flyinghead 3bf817aea1 vk: reset semaphore index to 0 when recreating the swap chain
When frame dupe is enabled and switching to fast forward, the current
semaphore index might end up pointing past the end of the semaphore
array, causing a crash.
Issue #1138
2023-07-10 12:41:13 +02:00
scribam a3ebe02f85 vk: modernize device properties retrieval 2023-07-09 18:51:44 +02:00
vkedwardli 7cd308fcae
Realtime Video Routing (#1126)
* Syphon video routing with OpenGL and Vulkan (MacOS)
* Spout video routing with DX11 and OpenGL (Windows)
* Fix Xcode detection
2023-06-26 11:56:56 +02:00
scribam 220fd51b27 deps: gather backends under imgui/backends directory
stay consistent with upstream
2023-05-04 09:26:01 +02:00
Flyinghead b94200233d vk: video shift support. refactor lr vk context
Shift the framebuffer according to VO_STARTX and VO_STARTY.
Issue #594
lr: draw overlay and manage shifting in vk context
2023-03-27 16:38:15 +02:00
scribam d8137a967c
C++17 (#926)
* cmake: use c++17

* Use std::size

* Use std::make_unique

* Use std::clamp

* Use structured binding

* Use [[fallthrough]]

* Use enable_if_t/is_enum_v/is_integral_v/is_same_v

* Use if constexpr

* Use try_emplace

* Use auto for iterators

* Use inline variables
2023-02-18 13:24:34 +01:00
Flyinghead 90e9f70a1a vk: fix resizing on wayland. validation errors with framebuffer render
wayland doesn't return the current surface dimensions in
getSurfaceCapabilities so we defaulted to 640x480. Instead use the
current display dimension as set by SDL.
Issue #648
Issue #898 (partial fix)

Vulkan validation errors when doing direct framebuffer rendering if fb
slots are skipped, since the corresponding fence isn't waited on.
Instead use an independent index to use them in sequential order.
2023-02-03 11:19:41 +01:00
Flyinghead aa79196d38 vk: only destroy surface if instance and surface aren't null
Don't request Arm debug layer VK_LAYER_ARM_AGA
Fix for MINIDUMP-5G
2023-01-23 12:11:43 +01:00
Flyinghead 285655f52d vk: check if vkEnumerateInstanceVersion is null before calling it
vkEnumerateInstanceVersion is only available in vk 1.1 so it might be
null after dynamic loading of entry points.

tentative fix for MINIDUMP-1Z, MINIDUMP-20 and MINIDUMP-21
2023-01-10 09:58:56 +01:00
Flyinghead 13df32ba3f vk: check vkGetInstanceProcAddr value before use and report error
Tentative fix for MINIDUMP-1F
2023-01-08 11:06:47 +01:00
Flyinghead 659ffa4406 vk: catch vulkan dyn loader exception when driver can't be loaded
Fixes MINIDUMP-R
2023-01-03 11:08:28 +01:00
Flyinghead 802f70fedd pvr: recover from renderer init failure
issue MINIDUMP-V
fix some warnings
2022-12-29 19:18:19 +01:00
scribam 5acfa7d3d6 vulkan: return an error if no physical devices found 2022-12-29 19:12:53 +01:00
Flyinghead b5d8cecd91 android: delay sentry upload to avoid broken pipe. Log more stuff
tentative fix for the broken pipe error when uploading to sentry on
android.
init log and sleep for 5 secs before upload
log git version, gpu name and version, renderer type and game id
2022-12-21 16:49:08 +01:00
Flyinghead d417237e64 Merge remote-tracking branch 'origin/master' into dev
# Conflicts:
#	core/emulator.cpp
2022-12-06 21:47:50 +01:00
Flyinghead 5b8e932509 move steam deck hack to sdl/sdl.cpp 2022-11-14 15:59:19 +01:00
scribam 993b705d8b vulkan: use dynamic dispatch loader 2022-11-09 17:20:05 +01:00
vkedwardli 605dc59f8d
Fix Steam Deck's Game Mode also 2022-11-04 16:01:06 +01:00
Flyinghead 94f3d80a75 Merge remote-tracking branch 'origin/master' into dev
# Conflicts:
#	CMakeLists.txt
#	core/hw/pvr/Renderer_if.cpp
#	core/oslib/audiobackend_alsa.cpp
#	core/rend/vulkan/desc_set.h
#	core/rend/vulkan/oit/oit_drawer.cpp
2022-11-02 20:12:34 +01:00
vkedwardli 0cbf6f6601
Fixing Steam Deck's wrong dpi caused by incorrect 60mm * 60mm EDID (#796) 2022-10-27 22:00:22 +02:00
Flyinghead c1f0dd81d2 pvr: copy pvr regs at start_render time to avoid concurrent update
copy TA_GLOB_TILE_CLIP and SCALER_CTL to rend context when starting
render. Use rend context copy to calculate framebuffer size.
Fixes framebuffer size glitches in vf4 water stages.
lr: pass aspect ratio when resizing.

dx11: Wrong sizing of rotated games.

gl: test automation fixes.
2022-10-25 15:00:04 +02:00
Flyinghead 5722dc90f0 Full framebuffer emulation. Renderer interface changes
Helps for:
Densha de Go! 2, Issue #171
Vigilante 8, Issue #275
Xtreme Sports
Sonic Shuffle
The Ring of the Nibelungen
2022-10-23 16:32:42 +02:00