Skip to content

nv2a: Download overlapping VGA framebuffer surfaces #2190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

abaire
Copy link
Contributor

@abaire abaire commented May 20, 2025

Fixes #1120

@abaire
Copy link
Contributor Author

abaire commented May 20, 2025

Draft as it still needs testing on Vulkan. Edit: Also seems like it deadlocks during the regression suite.

Hey @Triticum0 can you check the other black menu games to see if any are fixed? I believe you thought #584 might be a similar issue, not sure if there were any others.

@abaire abaire force-pushed the fix_tombraider_black_menu_stale_vga_mem branch 3 times, most recently from 55df9bc to 4eb68c2 Compare May 20, 2025 23:40
@Triticum0

This comment was marked as off-topic.

@abaire
Copy link
Contributor Author

abaire commented May 21, 2025

Thanks for testing!

I have some performance improvements for the typical path that I'll push after I figure out the freezing issue I'm seeing with the pgraph regression tests. I suspect there's something wrong with my dev machine, since it's also freezing without this change.

Edit: Looks like the freezing may be related to an nxdk update in the pgraph tester and not my machine or this PR. I'll roll it back and merge in my performance updates soon-ish.

@abaire abaire force-pushed the fix_tombraider_black_menu_stale_vga_mem branch from 4eb68c2 to 7612514 Compare May 21, 2025 04:02
@abaire
Copy link
Contributor Author

abaire commented May 21, 2025

Performance improvements are applied. It's slightly better on my machine, but still pretty bad. I see about 5 host frame updates per CRTC register modification. Also the offset surface draws continue into gameplay; I had hoped that they would just be during the menu sequence. This means that this particular title has many times as many GL surface downloads as typical titles. We may need to consider some alternative approach (e.g., creating a border surface in GPU memory and merging the GL surface created for the guest draws into it to avoid the round trip to RAM and back).

I'm also seeing very rare texture corruption and crashes when testing this game; unclear if they're related to this change or just a separate issue with this title.

@Triticum0

This comment was marked as off-topic.

@abaire
Copy link
Contributor Author

abaire commented May 21, 2025

Generally a momentary glitch across the entire screen, often with a fairly strong green component to it.

It's not aligned to the rendered geometry, which makes me suspect it's related to grabbing the framebuffer rather than any issue with the guest-side rendering or the game itself. My guess is that the locking I'm doing when downloading the texture is somehow incorrect and the host-side framebuffer texture ends up containing some uninitialized data due to a race condition.

@Triticum0

This comment was marked as off-topic.

@abaire
Copy link
Contributor Author

abaire commented May 22, 2025

are you taking about this i think.

2025-05-22.11-39-06.mp4

Interesting, it is something like that, but on macOS/M3 it manifests as more distinct uninitialized-looking corruption, often over just part of the window.

It grass meshes and lighting disapearing and reappering here the frame where it missing

I did not notice that in my testing, but I do have other weird behavior (will note below)

There an issue with water rendering simiar to Prince of Persia series

I see this on macOS as well.

With my continued changes trying to find a solution I was able to get some new weird behavior when spinning the camera around where there is sometimes a tiling effect with quadrants of the frame retaining old data while others are updated. It seems to happen most frequently when the water starts to come into frame; as you pointed out previously the framerate dips noticeably when the water is rendered. Seen on both macOS/M3 and Linux/GTX1070

Watch the lower left corner:

test.mp4

I also get very weird occasional updates to the ~64 lines at the top of the screen that necessitated this fix in the first place. I would've expected that data to always remain black, but perhaps we're ending up with multiple GL surfaces within the guest framebuffer. I'll look into it.

I also see a bunch (~27 per frame) of nv2a: EMPTY NV097_SET_BEGIN_END instances right at the opening checkpoint. As this is marked as NV2A_UNCONFIRMED it's possible that it should actually be drawing something but isn't.

@Triticum0
Copy link
Collaborator

Also fixes #1121

@antoniodesousa
Copy link

antoniodesousa commented May 28, 2025

I just tested this PR and I'm very impressed with it. Only issues I have with it, it's the water has this yellow color in some areas and a small area on the right side of the screen is mirroring a portion of the left side.

xemu-2025-05-28-17-41-27

@abaire
Copy link
Contributor Author

abaire commented May 28, 2025

I just tested this PR and I'm very impressed with it. Only issues I have with it, it's the water has this yellow color in some areas and a small area on the right side of the screen is mirroring a portion of the left side.

Thanks. The yellow water is probably not related to the issue this PR addresses and will need to be investigated/fixed separately.

The screen mirroring is more concerning. What are your machine specs (GPU, OS, upscale factor in particular)? I'm surprised to see such a problem manifest horizontally.

I've heard that it's possible to get into the game without this PR; if that's the case I'd be very interested in whether these issues show up without this change or if they're somehow artifacts of the surface downloading I'm introducing.

@antoniodesousa
Copy link

Ok, I tested it with the latest master release and it does have the mirroring issue as well. I tried 1x upscaled and it doesn't fix it. One thing interesting is that the yellow color doesn't appear on master, but it has other issues like the UI elements don't render at all.

CPU: AMD Ryzen 9 6900HX with Radeon Graphics
OS Platform: Windows
OS Version: 24H2
Manufacturer: ATI Technologies Inc.
GPU Model: AMD Radeon RX 6600M
Driver: 4.0.0 Core Profile Context 25.5.1.250417
Shader: 4.60

xemu-2025-05-28-20-03-28
xemu-2025-05-28-20-01-32

@abaire
Copy link
Contributor Author

abaire commented May 28, 2025

Ok, I tested it with the latest master release and it does have the mirroring issue as well. I tried 1x upscaled and it doesn't fix it. One thing interesting is that the yellow color doesn't appear on master, but it has other issues like the UI elements don't render at all.

Thanks for checking!

That top image looks similar to the way signed textures are misrendered, but I'm surprised that master behaves differently. I've never actually played the game before, is the second image supposed to be looking at water? Does water look generally correct on master or is it just broken in another way?

CPU: AMD Ryzen 9 6900HX with Radeon Graphics OS Platform: Windows OS Version: 24H2 Manufacturer: ATI Technologies Inc. GPU Model: AMD Radeon RX 6600M Driver: 4.0.0 Core Profile Context 25.5.1.250417 Shader: 4.60

Excellent; I'm wondering if the mirroring is an AMD-specific issue or if it's just something that only happens on certain levels. It also looks like you do not have the corruption I see at the top of the screen on M3, which is interesting.

If you spin the camera around quickly, do portions of the screen lag? If you look at the video I posted above it captures what I see on M3 and Nvidia GPUs.

I never bothered to go beyond the waterfall on the first level, so I'm not sure if some of these problems just go away, or if they don't appear w/ an AMD card.

@antoniodesousa
Copy link

Does water look generally correct on master or is it just broken in another way?

Now that I double check, the water in master is less waving than this PR. Like more calm if it makes sense. Maybe is not rendering some extra layer of waves?

Excellent; I'm wondering if the mirroring is an AMD-specific issue or if it's just something that only happens on certain levels. It also looks like you do not have the corruption I see at the top of the screen on M3, which is interesting.

It's all the time present. It looks kind of similar to your issue on the top of the screen except mine is on the right side and larger.

If you spin the camera around quickly, do portions of the screen lag? If you look at the video I posted above it captures what I see on M3 and Nvidia GPUs.

Nope, it doesn't.

2025-05-28.21-15-09.mp4

@abaire abaire force-pushed the fix_tombraider_black_menu_stale_vga_mem branch 2 times, most recently from 4bdec58 to 482a062 Compare June 3, 2025 19:35
@abaire abaire force-pushed the fix_tombraider_black_menu_stale_vga_mem branch 2 times, most recently from 75e3876 to baab9e4 Compare June 28, 2025 14:07
@abaire abaire force-pushed the fix_tombraider_black_menu_stale_vga_mem branch from baab9e4 to 887da83 Compare July 2, 2025 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lara Croft Tomb Raider: Legend Menu Issue
3 participants