Commit Graph

399 Commits

Author SHA1 Message Date
Edward Li eab13e85bc minor fixes 2025-08-12 15:40:14 +02:00
scribam 109e084e18
deps: update glslang (#1920) 2025-06-24 16:54:29 +02:00
Flyinghead 9bdb90e605 vk: add missing pp_Texture vertex param (naomi 2) 2025-06-19 17:48:20 +02:00
xander-will 71341a27e4
Integer Scaling + Screen-Level Linear Interpolation Options (#1976) 2025-06-13 11:59:15 +02:00
Flyinghead 27f19a5b54 rend: fix dithering kernel
Use the actual PVR2 dithering kernel (standard 4x4 Bayer matrix) used on
real hardware.
Fixes the screen melt effect of Doom64 (per-pixel only).
Issue #1939
2025-05-26 19:27:02 +02:00
scribam c3275d3c6f ci: update bsd workflows 2025-05-21 23:22:47 +02:00
Flyinghead c57b2e1aa7 oit: incorrect color used when src=OTHER_COLOR if dest is 2nd accum
Using src=OTHER_COLOR with destination secondary accumulator should use
the secondary accumulator color, not the final one.
Fixes dark gun in Doom 64 with Ultra graphics (bump mapping).
Issue #1771
2025-05-03 11:05:59 +02:00
Flyinghead 9cc3d1030d vk: (mali) add subpass dependency from subpass 2 to external
Add subpass dependency from the last subpass to external/top of pipe.
Fix glitches in upper left corner when using OIT on Mali GPUs.
Issue #1014
Issue #1234
Issue #1356
Issue #1497
Issue #1852
2025-05-03 11:05:49 +02:00
Flyinghead 48e964235c vk: (mali) add memory barrier in GetLastFrame
Add memory barrier between drawing and transfer.
Fix savestate thumbnail image corruption.
Issue #1922
2025-05-03 11:05:40 +02:00
Flyinghead 03f2ef6df0 libretro: fix crash when terminating vulkan context early
Issue #1906
2025-05-03 10:57:34 +02:00
Xphalnos 240be07bbb Misc: Remove Duplicated Semicolons 2025-04-10 11:30:33 +02:00
Flyinghead 786ccf4139 vulkan: fix crash when fast-forwarding with libretro core
Issue #1901
2025-04-10 11:29:52 +02:00
Isaac Marovitz 5a110fd666
Replace sprintf with snprintf (#1884)
Signed-off-by: Isaac Marovitz <isaacryu@icloud.com>
2025-03-25 18:47:07 +01:00
Flyinghead 0bf9c64b1b Merge remote-tracking branch 'origin/dev' 2025-02-18 09:27:07 +01: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
oltolm 20ba79668f fix compiler warnings 2025-01-09 13:59:21 +01:00
Flyinghead 1bd894f941 rend: reset scissoring before drawing final modvol quad
See d618abc320
Issue #1797
2025-01-05 22:06:37 +01:00
Flyinghead e18ada7225 rend: reset scissoring before drawing final modvol quad
See d618abc320
Issue #1797
2024-12-31 18:22:07 +01:00
Flyinghead 3f8d645c42 rend: last frame was sometimes presented after the game is stopped
When the clearLastFrame flag is set, renderers should return false from
Present() and RenderLastFrame() until a new frame is rendered.
2024-12-15 15:55:28 +01:00
Flyinghead e5b1d56a7c rend: split texture conversion routines into their own file 2024-12-14 19:07:18 +01:00
Flyinghead d789b57412 rend: get rid of globals for fog/palette updates & tex cache flush
Add state vars to Renderer
Use events to detect loading a state and terminating the game.
Don't present last rendered frame after game terminated.
2024-12-14 17:00:51 +01:00
Flyinghead 421245aeba lightgun xhair: centralize logic in crosshairNeeded() 2024-12-13 17:21:32 +01:00
Flyinghead 354d649ebd Merge remote-tracking branch 'origin/master' into dev 2024-12-07 20:38:55 +01:00
Flyinghead 78fa3ee09e vulkan: delay updating imgui texture when driver has just been reset
Fixes crash when selecting a custom gamepad layout .png (android)
2024-12-03 20:42:54 +01:00
Flyinghead d0584b8652 vk: defer deleting framebuffers in ScreenDrawer and lr context
Defer deleting framebuffers and attachments in ScreenDrawer and lr
context when resizing.
Fixes crash when starting 240pSuite on the lr core.
2024-11-23 13:47:19 +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
Flyinghead d618abc320 rend: modifier volumes must be clipped
Modifier volumes should also be clipped when needed.
Implement outside clipping for non-OIT renderers.
OIT renderers are less affected since the shadowed polys themselves are
usually also clipped after shadow is applied.
Fixes overflowing shadows in baserunner cams in WSB 2K1.
2024-11-17 12:09:40 +01:00
Flyinghead 3efb87ba6d vk: fix crash when enabling/disabling EmulateFramebuffer
Make sure to end the current render pass with the previous setting.
Fix initial layout of color attachments in OIT.
Fix missing initial transition after Term/Init in !OIT.
Issue #1734
2024-11-11 22:15:57 +01:00
Alexandre Bouvier 32d11dd89c fix missing include 2024-10-26 19:28:20 +02:00
Flyinghead fd475bdd8e vk: some pipelines don't need the provoking vertex extension
ModVol and OIT Final and Clear pipelines don't need it.
2024-10-14 17:19:41 +02:00
Flyinghead 5aec6d05b0 vk: (lr) use one vk::DeviceQueueCreateInfo when possible
Using 2 with the same queue index causes a validation error and crash.
2024-10-14 16:39:33 +02:00
Flyinghead a50164a91b vk: missing some changes to use VK_FORMAT_R8G8B8A8_UNORM
Fixes Naomi 2 games and android on-screen gamepad.
2024-10-13 14:22:50 +02:00
Wunkolo 595842f606 vk: Remove naomi2 vertex attributes when not needed
Disables the naomi2 vertex input attribute when emitting non-naomi2 pipelines.
This addresses some validation messages involving unused vertex inputs and optimizes the bandwidth of the input assembler a little bit for non-naomi2 games.
2024-10-13 13:26:42 +02:00
Wunkolo 8f74f7883a vk: Use `VK_FORMAT_R8G8B8A8_UNORM` for vertex colors
Rather than using `VK_FORMAT_R8G8B8A8_UINT` for these vertex attributes and then dividing by `255.0` in each of the shaders, the `VK_FORMAT_R8G8B8A8_UNORM` format will automatically remap byte components into the `0.0-1.0` range and removes the need to do the extra divisions or castings within the shader.
2024-10-13 13:25:40 +02:00
Wunkolo ea1cd9d31b vk: Fix undefined push-constant data
The full push-constant region is 24 bytes(6 floats), but some of these push-constant writes only wrote 20 bytes of data(5 floats).
Causing 4 bytes at the end to be left undefined.
Resolved by pushing an extra zero.
2024-10-13 13:24:27 +02:00
Flyinghead b2c6159b10 Merge remote-tracking branch 'origin/dev' 2024-10-11 15:28:19 +02: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
Wunk b20db6a8bb
vk: Disable LOD clamping in samplers (#1674)
This addresses the `BestPractices-Arm-vkCreateSampler-lod-clamping` message from ARM:
65b79bac61/layers/best_practices/bp_descriptor.cpp (L103-L110)

Rather than clamping the LOD in the samplers, instead rely on the Image-View's `vk::ImageSubresourceRange` to limit the number of sampled LODs.

Currently, only game-textures actually have MipMaps, so this does not introduce any additional mip-map sampling or filtering anywhere. If any code want's to actually limit the number of LODs sampled, then they would allocate an additional ImageView for the range of MipMaps to be sampled.

Co-authored-by: flyinghead <flyinghead@users.noreply.github.com>
2024-10-09 19:46:36 +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 b94acb70a6 vk: Use matching u/v/w sampler address-mode when possible
This addresses the `BestPractices-Arm-vkCreateSampler-different-wrapping-modes` message from ARM:
65b79bac61/layers/best_practices/bp_descriptor.cpp (L95-L100)

The `W`-axis for these samplers is always unused, it's never the case that these samplers are going to be used for 3D textures.
ARM suggests trying to keep all of the wrapping-modes the same if possible for performance.

`wRepeat` will be set to the same value as `vRepeat` to try and encourage all three wrapping-modes to be the same.
2024-10-09 19:40:20 +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
Wunkolo ff6a3119b0 vk: Determine object type enum when setting object name
Uses compile-time type-information provided by vulkan-hpp to automatically determine a vulkan-object's `objectType` when calling `setObjectName`.
2024-10-08 17:05:32 +02:00
Flyinghead f37e43b26f vk: don't set scissoring in final OIT subpass
If scissoring is enabled, previous framebuffer background isn't drawn
outside of scissor region.
Fixes blinking in Soul Calibur battle loading screen.
Issue #1668
2024-10-08 11:49:34 +02:00
Flyinghead 30bb864b37 vulkan: check image usage flags if image already exists during RTT
Recreate image if usage flags are incorrect.
Fixes vk validation error in Virtua Tennis player list selection screen.
Issue #1664
2024-10-07 18:47:52 +02:00
Flyinghead 55e0211a57 android: use ASS to select custom adreno driver 2024-10-04 16:36:56 +02:00
Flyinghead 2dd4cbe33d vk oit: draw transparent polys in the first frame after (re)init
Fixes missing background in progress window in Fighting Force 2
Issue #1652
2024-09-29 16:42:38 +02:00
Flyinghead 2653c5ed73 naomi2: fix modifier volumes clipping
Don't clip modifier volumes but tesselate triangles intersecting the
near plane. Then project clipped vertices onto it in the vertex shader.
Issue #1651
2024-09-29 16:42:38 +02:00