Commit Graph
168 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5.5 ae68a7e73f Coded Arms: Contagion: Read back the stencil the crosshair checks
The crosshair turns red, and lock-on works, when stencil bit 3 is set at
the centre of the frame, which the game tests by reading the pixel from
VRAM with the CPU (#17936). Hook that and read back the stencil of that
row into the alpha bytes in RAM. The alpha the hardware backends keep
doesn't follow stencil everywhere, so reading color isn't enough.

Adds PerformReadbackStencilToMemory for this (8888 only for now).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-12 12:15:56 +02:00
Henrik RydgårdandClaude Opus 5.5 75865683bb Upload video frames written partway into a framebuffer
Buzz! Master Quiz converts its question videos (sceMpegBaseCscAvcRange)
straight into the middle of the frame it has drawn, at 84,69. The
framebuffer upload only matched writes starting at a framebuffer's
address, so the hardware backends never showed the video. Pass the
written width along and draw just that rectangle into the framebuffer.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-11 22:50:57 +02:00
Henrik RydgårdandClaude Opus 5.5 50696c5b1f Remove the "game uses sequential copies" readback heuristic
After more than three partial readbacks of one buffer in a frame,
ReadFramebufferToMemory read the whole buffer instead for the rest of the
session, writing rows the game never asked for.

Everybody's Golf 2 reads back four portraits' color and depth per frame, which
turned it on. The whole 480x273 depth buffer then got written to VRAM, and its
last row is where the game keeps its texture heap. A texture header was
overwritten: the portrait showed the scene behind it, and the next time the
portraits were built the game crashed writing through a null pointer.

It was added for speed in Grand Knights History (c42d04829f), which copies many
slivers of a framebuffer, so that game may now do more readbacks.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-11 14:50:19 +02:00
Henrik RydgårdandClaude Opus 5.5 4202368b1e Vulkan: Look up multisampled framebuffers through a CLUT by their first sample
With MSAA, a framebuffer textured as CLUT indices was read resolved, so the
indices along edges were averages of the samples and looked up wrong colors.
Dragon Ball Z: Tenkaichi Tag Team draws its outlines from a CLUT32 lookup of
its framebuffer, and they came out noisy and miscolored. Copy each pixel's
first sample with texelFetch into a temporary buffer and look up that.

This needs the multisampled color images to be sampled, and transitioned
back to attachment layout before rendering to them again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 15:49:15 +02:00
Henrik RydgårdandClaude Opus 5.5 35de8e5d97 Screenshot the display from wherever in a framebuffer it is
The display can point inside a larger framebuffer: Silent Hill flips
between two halves of a 1024-wide 565 buffer. Presenting it found the
framebuffer and the offset, but screenshots looked up only an exact
address match, and otherwise read RAM, which with a hardware renderer
holds something stale (Silent Hill: Origins' savestate thumbnails showed
the loading screen). Screenshots of the display now use the same lookup
and read back the 480x272 at the offset.

Headless screenshots go the same way: eight Silent Hill frame dumps
(Origins and Shattered Memories) now match the PSP exactly on Vulkan and
OpenGL, from 0.8k-104k differing pixels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 11:15:46 +02:00
Henrik RydgårdandClaude Opus 5.5 6cbba6ee24 Fix Silent Hill: Origins' flashlight shadows on the hardware backends
The game does shadow mapping without depth textures (#16126):
- It renders the scene once into 44170000 with depth, then draws it again
  into 44170400 (the same buffer 256 pixels to the right) with the same
  depth address and an EQUAL depth test. We render 44170400 into the
  same framebuffer at an X offset, which moves the depth test along with
  the color, so it compared against the wrong depth and the shadow pass
  drew nothing. Copy the depth over to the offset once per pass.
- It reads its 256x256 565 light-depth map as CLUT32. The reinterpret to
  8888 went into an existing 8888 buffer at the same address that was
  only 128x128, which cut the map off below row 128. Grow it first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 11:15:46 +02:00
Henrik RydgårdandClaude Opus 5.5 89fabe21fb Rebuild the stencil from alpha after reinterpreting a framebuffer
On the PSP the stencil is the alpha bits, so after the colors of another
format are reinterpreted into a 5551, 4444 or 8888 buffer, its stencil has to
follow the new alpha. Ultimate Ghosts 'n Goblins sets 5551 alpha with a masked
565 blue write and then stencil tests on it; Vulkan drew its glow through a
stale stencil. The memory stencil upload's pipeline and passes are shared.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 10:45:57 +02:00
Henrik RydgårdandClaude Opus 5.5 93f57a4f38 GPU: Delete copy operations on classes that own resources
These own GPU objects, memory or refcounts in their destructors (or assert
there that they were torn down), so a copy would double-free. Nothing copies
them today; this keeps it that way. The manager base classes cover every
backend's subclass.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-29 10:33:32 -06:00
Henrik Rydgård 7c73ed71bf Remove the ability to "set safe size" from SoftwareTransformCommon, now redundant 2026-07-16 18:05:59 +02:00
Henrik Rydgård 90c48671d7 D3D11: Remove support for BGRA textures and preferred framebuffer formats 2026-07-03 16:20:22 +02:00
Henrik Rydgård 1b2f87bf1a Rename GPUgstate to GEState 2026-07-02 20:34:09 +02:00
Henrik Rydgård f60e27a9b7 Just some refactoring of the GPUStatistics struct, and more use of StringWriter 2026-05-29 14:40:31 +02:00
Henrik Rydgård 5a5c7028b9 Assorted warning fixes and data initialization to please valgrind 2026-02-19 11:24:46 +01:00
Henrik Rydgård 8ceffa08cb Ignore extreme Y offsets when matching framebuffers.
Fixes #15828
2026-02-12 11:03:46 +01:00
Henrik Rydgård 5d080d1de8 Add a quick check against bad clut vs depth texture framebuffer matches
See #15828 and #20847
2026-02-10 15:51:49 +01:00
Henrik Rydgård 2ea94534e6 Split up FramebufferManagerCommon::CopyDisplayToOutput 2026-02-08 10:17:42 +01:00
Henrik Rydgård c999367471 Fix crash in DrawPixels in "skip framebuffer effects" mode 2025-12-15 17:18:17 +01:00
Henrik Rydgård 7853881210 GPU header cleanup: Avoid including GPUCommon.h in some places 2025-11-23 20:37:37 +01:00
Henrik Rydgård 67010ff2af Split the display layout config between landscape and portrait orientations 2025-11-05 12:49:51 +01:00
Henrik Rydgård a80756574c Fix really wacky edge case when switching to Auto FrameSkip from "skip buffered" mode.
Fixes issue #20596
2025-07-08 20:08:23 +02:00
Henrik Rydgård 2e7f2ffcd4 Same as previous commit for the framebuffermanager debug UI 2025-05-26 19:39:51 +02:00
Henrik Rydgård aec17d8829 Actually queue up depth draws 2024-12-28 23:21:54 +01:00
Henrik Rydgård 794fa28035 Small simplification 2024-12-15 13:23:34 +01:00
Henrik Rydgård 638607d29a Refactor: Make GPUCommon own the framedump "recorder". 2024-12-15 12:07:44 +01:00
Henrik Rydgård 0df2a40487 Remove the "GPUInterface" base class. Not really useful, GPUCommon is pretty much the same thing. 2024-12-02 11:12:14 +01:00
Henrik Rydgård 194b2ce076 Ge Debugger: Add a framebuffer listing, along with some plumbing 2024-11-23 23:23:48 +01:00
Henrik Rydgård 56a164a14e Handle one more error case in presentation 2024-10-28 17:02:03 +01:00
Henrik Rydgård f7af5a7743 When reinterpreting color between same-sized framebuffers sharing a z-buffer, copy the Z.
Fixes socom character customization screen, #19245
2024-09-26 00:16:55 +02:00
Henrik Rydgård ef95e24169 Implement compat flag proposed in #18423, forcing readbacks in Juiced 2
In-game, there's no slowdown, and this fixes the decal editor. So it's
no use allowing readbacks to be turned off in this game.

See issue #18423
2024-07-20 11:24:24 +02:00
Henrik Rydgård d21fef52ae Allow taking screenshots in the app menu 2024-05-10 21:10:11 +02:00
Herman Semenov b57dab2812 [GPU] Make static and const methods if possible 2024-04-05 17:04:31 +03:00
Henrik Rydgård 8d8ff5886b Fix issue where nothing had started a render pass when we wanted to clear the screen. 2023-12-11 13:06:15 +01:00
Henrik Rydgård 26a51191b3 Cleaner solution to previous commit 2023-12-06 09:54:03 +01:00
Henrik Rydgård 8588b11a6a Rename MayIntersectFramebuffer to MayInteresectFramebufferColor 2023-12-06 09:42:44 +01:00
Henrik Rydgård 6d977b4a12 Remove unnecessary struct FramebufferInfo 2023-12-02 13:56:18 +01:00
Henrik Rydgård d9365a6df1 FramebufferCopy: New framebuffer candidate sorting, similar to block transfer detection.
The previous attempt was simply flawed.
2023-12-01 00:10:16 +01:00
Henrik Rydgård 632fa1c9d6 Cache and hash data for DrawPixels.
We already had a cache to reuse texture objects so just
opportunistically reuse them when easy to do so.
2023-11-11 19:58:12 +01:00
Henrik Rydgård b4419a9146 Remove the old screen resolution popup thing 2023-07-16 17:05:26 +02:00
Henrik Rydgård 7c4b9bac90 Cache textures created by MakePixelsTexture and reuse where appropriate. 2023-05-30 14:07:44 +02:00
Henrik Rydgård 9512bc6174 Don't cache render target copies for shader blending, only cache copies for overlap
Fixes #17451, while also keeping the Dante performance fix from #17032.

Of course, it's possible that something else could slow down now... But
hopefully not. This could also fix other problems.
2023-05-11 12:04:29 +02:00
Unknown W. Brackets 92a18eed01 GPU: Discard framebuffer copy when clearing.
This avoids retaining the framebuffer copy any longer than the current
framebuffer target.
2023-03-01 22:11:20 -08:00
Henrik Rydgård 4d0fbdb96f Add a safety check - don't cache partial copies. 2023-03-01 22:51:23 +01:00
Henrik Rydgård 7a7117f2f7 Cache framebuffer copies (for self-texturing) until the next TexFlush instruction.
Fixes #17030 , or at least improves on it - for optimal performance that
big framebuffer used for bloom should be split like in Killzone, but it's not trivial.

The regression in 1.14 is fixed with this, at least.

I tried it with a few other games with no issues - it seems games are
using TexFlush when needed. But let's see if it really is safe to rely
on that...

There might also be other places we should call DiscardFramebufferCopy
in.
2023-03-01 22:42:22 +01:00
Henrik Rydgård ae9291f3b5 More work on depth copies. Seems to be enough for Iron Man. 2023-02-15 07:35:07 +01:00
Henrik Rydgård 62a6f351d5 Initial work on depth copies 2023-02-15 07:35:07 +01:00
Henrik Rydgård 6b902a7d6b Minor code cleanup, one very minor stride bugfix 2023-02-15 07:35:07 +01:00
Henrik Rydgård 1938fa44d4 Split the depth copy shader into depth copy and depth encode, dynamic depth scale in Draw2D 2023-02-11 18:24:07 +01:00
Henrik Rydgård d426ce5118 Clear depth buffers after changing depth rounding mode.
And thus change of depth buffer scale/offset.

Previously, old depth buffers with values that now are out of range
could stick around, causing #16941. This clears them to the expected 0
value, which helps Outrun. Ideally we should convert depth buffers to
the new format, but if we can get away without that, that's also nice.

This is enough for #16941.
2023-02-10 10:03:14 +01:00
Henrik Rydgård 937975000b Add a ReadbackMode parameter to more functions in the FramebufferManager 2023-02-05 13:57:45 +01:00
Henrik Rydgård 236611ac16 Initial implementation of depth readback for Syphon Filter. Fixes the lens flares. 2023-02-04 13:54:57 +01:00