Commit Graph

149 Commits

Author SHA1 Message Date
Flyinghead 9bdb90e605 vk: add missing pp_Texture vertex param (naomi 2) 2025-06-19 17:48:20 +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
Flyinghead e1ab9af89d 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-02 17:46:29 +02:00
Flyinghead 3330225de4 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-02 15:37:29 +02: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 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
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
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
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
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 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 915532f946 vk: don't depend on current clamping values when compiling shader
Fog clamping values may change so the shader shouldn't depend on the
current value when compiling.
Fixes Red Dog Superior Firepower glitch.
Issue #1642
2024-09-18 11:34:35 +02:00
Flyinghead 8cb847940b vk oit: attachment 0 must be loaded too
Issue #1614
2024-09-01 18:41:37 +02:00
Flyinghead 757732d0f8 vk oit: load correct attachment. Only reset pipelines when needed
Fixes partial renders: ECCO initial sequence.
Issue #1614
Don't reset pipelines when resizing framebuffer.
2024-08-29 12:57:10 +02:00
Flyinghead 7a27a43ba4 vulkan: Fix multipass RTT in OIT mode
Use correct temp attachment depending on pass count. Keep attachment
index to bind the correct one before final subpass.
Use correct initial layout for OP+PT attachment 1 (was eUndefined) when
creating the RTT render pass.
Fixes Alone in the Dark cutscenes.
Issue #1609

Recreate RTT attachments if switching CopyToVRAM on/off.
2024-08-24 16:37:52 +02:00
Flyinghead cc56b0fbae vk: multi render support
Fixes Quake III split screen vs. and MSR rear view mirror.
Issue #1511
2024-05-15 14:01:58 +02:00
Flyinghead 36684bf82c vk: share shader code between regular and oit renderers 2024-02-01 18:19:03 +01:00
Flyinghead e714e94510 rend: do bilinear filtering of palette textures on the GPU
All renderers updated.
2024-01-31 16:46:25 +01:00
Flyinghead 88fd2641d9 pvr: allow blending for opaque polys of list continuations
Fixes Crackin'DJ invisible background animation and Monkey Ball grey map
background.
2024-01-23 19:20:40 +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
Flyinghead e96b38ff5c rend: support vscalefactor > 1 for RTT
SCALER_CTL.vscalefactor also applies to RTT and values > 1 will increase
the texture height.
dx11: initialize abufferPointers to avoid issues with first frame
rendered.
Fixes pause menu/battle animation with Skies of Arcadia (PAL)
Issue #1127
2023-10-16 14:51:27 +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 38d4689b63 gl,vk,dx: use nearest filtering for mipmap with PT polys
Interpolating between LoDs produces unexpected alpha values.
dx,vk: add negative LoD bias
Fixes "Press Start" text in Trizeal title screen

dx11: get rid of bogus nearest wrap hack
Can't reproduce original issue with daytona
Fixes Virtua Tennis title screen
Issue #1230
2023-10-09 21:09:03 +02:00
Flyinghead 78b44919c5 vk, gl: ignore fb_enable and blank_video during normal render
Fixes some screen missing. Already handled in renderFB. Should be
handled at Present time.
gl4: first frame after renderFB was missing

Issue #1217
2023-10-07 15:46:28 +02:00
Flyinghead a915f185f8 Merge remote-tracking branch 'origin/master' into dev 2023-09-25 22:17:29 +02:00
Flyinghead 0f6e1752e3 rend: clear framebuffer when vram address changes
Fixes top and bottom leftovers from BIOS boot in San Francisco Rush
2049.
Issue #1197
2023-09-25 18:23:26 +02:00
Flyinghead 79bbd86c2f rend: Fix PT polygons alpha test
Alpha test for PT polys is done after mixing texture and vertex colors
and clamping. Revert db0534d5dd. See
86235bb4a3.
Fixes visible triangle arrows after selecting a character in Langrisser
Millenium.
Issue #1201

vk oit: OP polygons don't support blending
2023-09-23 14:01:26 +02:00
Flyinghead 39a212140a vk: add bumpmap flag to pipeline hash
Fixes disappearing pause menu text and green wooden boxes in Mat
Hoffmann's Pro BMX
Issue #878
2023-09-23 11:13:14 +02:00
Flyinghead f4835a89d3 implement dithering in full FB mode
gl, vk, dx11, dx9: implement ordered dithering in GLSL/HLSL
refactor framebuffer and texture writes to vram
don't expand color data when reading planar textures
2023-09-10 16:25:19 +02:00
Flyinghead ffc0a42c18 std::vector::operator[index] with index >= size is UB 2023-06-04 12:48:50 +02:00
Flyinghead 7108358ebd Merge remote-tracking branch 'origin/master' into dev 2023-03-30 17:31:22 +02:00
Flyinghead 5df9127add vk: enable depth writing in oit pass so
Make sure both depth attachments are the same at the end of each pass.
Get rid of unneeded depth dependency/transition.
Issue #996
2023-03-28 21:20:37 +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
Flyinghead 9f2ffd102c oit: Can't discard pixel in pixel shader when using 2ndary accumulator
When using the secondary accumulator as source or destination, pixel
must not be discarded even if blending results in a nop. Doing so
cancels the transfer to/from the accumulator.
Issue #979

dx11 oit: use FAILED to detect pixel shader creation error. Log error
codes when Buffers::init fails.
2023-03-21 11:22:04 +01:00
Flyinghead afc1f5f4e1 Merge remote-tracking branch 'origin/master' into dev 2023-03-15 21:09:47 +01:00
Flyinghead 90269d5204 vk oit: reset all pipelines on init/reset
Avoid validation errors when switching to/from RTT Copy to VRAM
2023-03-12 16:00:49 +01:00
Flyinghead 4f65d45e55 rend: don't access first poly if list is empty. dx11 oit: resize error
fix crash with dx11 and gl4 when tr poly count is 0
quick exit if nothing to do
2023-02-18 13:33:38 +01: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 811bf6f449 Revert "vk oit: tentative workaround for AMD crash"
This reverts commit 084066bde7.
2023-02-07 11:28:14 +01:00
Flyinghead 084066bde7 vk oit: tentative workaround for AMD crash
Issue #908
2023-02-05 21:56:08 +01:00
Flyinghead 99d5266aa0 Merge remote-tracking branch 'origin/master' into dev
# Conflicts:
#	core/hw/holly/sb_mem.cpp
#	core/hw/naomi/naomi.cpp
#	core/hw/naomi/naomi_flashrom.cpp
#	core/hw/pvr/ta_ctx.h
#	core/rend/gui.cpp
2023-01-27 15:41:45 +01:00
Flyinghead e18a4afcbb vk and pvr fixes. Renderer::Process returns void. N2 light 0 is no-light
pvr: Heap use after free due to PolyParam vector reallocation
vk: fix wrong buffer size calculation
Renderer::Process now returns void since it can't fail anymore
naomi2: light model at index 0 is "no light"
dx9, gles: throw if naomi 2 not supported
2023-01-27 11:16:25 +01:00