hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
11.11k stars 2.16k forks source link

Elements missing when scoping in Valkyria Chronicles II (ULUS-10515) #13462

Open justafella opened 4 years ago

justafella commented 4 years ago

What happens?

Things such as objects from scenery disappear while scoping. Sometimes soldiers get cropped as well if they're in front of those objects. Happens on Vulkan and Direct3D 11.

What should happen?

Everything should be fine as is with Direct3D 9 and OpenGL.

What hardware, operating system, and PPSSPP version? On desktop, GPU matters for graphical issues.

ULUS10515_00000 ULUS10515_00001 ULUS10515_00002

Here is a Save State for testing: ULUS10515_1.00_2.zip

justafella commented 4 years ago

As for cropped units: ULUS10515_00000 ULUS10515_00001 ULUS10515_00002

Panderner commented 4 years ago

@justafella could you send me the GE Dump for scoping?

justafella commented 4 years ago

How do I do it?

Panderner commented 4 years ago

How do I do it?

Just go to http://ppsspp-debugger.unknownbrackets.org/

justafella commented 4 years ago

Well, if I got that right, these are the files:

Scoping: recording (2).zip

Scoping+zoom: recording (3).zip

If you need it, whenever I come across the cropped unit problem again I'll bring its GE dump as well

hrydgard commented 4 years ago

Thanks, those will be useful!

justafella commented 4 years ago

If you need it, whenever I come across the cropped unit problem again I'll bring its GE dump as well

Here it is:

Cropped unit on scope: recording.zip

Cropped unit on scope+zoom: recording (1).zip

Hope it helps you guys

unknownbrackets commented 3 years ago

Well, here's something interesting.

In Valkyria Chronicles 3, I reproduced easily. In the GE debugger, I then disabled the depth clamp flag for a frame, which fixed it, because background stuff was clamping over the character.

But then I realized that it stayed fixed - nothing was turning clamp back on. I played through a bunch of the game without it getting set back enabled. Instead, returning to the chapter map finally re-enabled it. It also re-enabled when going to the deploy screen, each time when "Now loading" was being shown. Interestingly, for the loading into the mission - it did not set the depth clamp flag.

So it could be this is depth clamp behaving wrong - but it could also be that, somewhere, something is supposed to clear this and isn't? Well, just a guess. I can't find anything obvious that should be resetting it (like contexts on lists or signals or CALLs etc.)

-[Unknown]

unknownbrackets commented 3 years ago

The behavior described in #12058 should fix this.

-[Unknown]

justafella commented 3 years ago

I have tested the game with the same save state I provided back then, using the latest buildbot. My system remains the same apart from the graphics driver's version (that I keep updated). I tested it on all backends (with hardware transform on and then off) but only D3D9 worked properly. I couldn´t understand everything here, so if there is something more I could do for testing as an end-user, I´ll gladly help.

unknownbrackets commented 3 years ago

If you try the artifacts in #14833, it should fix it on modern systems.

-[Unknown]

justafella commented 3 years ago

I haven't been able to test this yet because I can't seem to build it right. I'm all new to this and even with the instructions provided I'm still messing up somewhere. I'd be grateful if you could build it and send me a .zip or something.

unknownbrackets commented 3 years ago

There's a build attached to the under artifacts.

  1. Go to https://github.com/hrydgard/ppsspp/pull/14833/checks.
  2. Select Artifacts near the top right.
  3. Select Windows x64 build (or similar.)

macOS, Windows ARM64, and Linux builds are available too. These are not permanent however, and only last for 90 days after the code in the pull request is most recently updated.

-[Unknown]

justafella commented 3 years ago

IT IS FIXED!!!! Thank you!!!!! You may close the issue 🥇

hrydgard commented 3 years ago

Thanks for reporting!

Let's close it when that branch is merged - I'm not gonna merge it for 1.12, due to the risk of breakage. It will however be merged soon after that release, and then we can close this.

vit9696 commented 3 years ago

Does not seem to fix the issue for me on macOS 11.6 with https://github.com/hrydgard/ppsspp/pull/14833 on Vulkan. OpenGL implementation is unsupported as explained in https://github.com/hrydgard/ppsspp/pull/14833#issuecomment-922460423.

Screenshot 2021-09-19 at 15 32 38

Confirmed that the latest master of https://github.com/KhronosGroup/MoltenVK (https://github.com/KhronosGroup/MoltenVK/commit/f78ab20b79f186eae57606442293163c748de5d3) does not solve the issue at the very least.

hrydgard commented 3 years ago

Vulkan on MacOS uses MoltenVK, it could be that it lacks support for the clip/cull distances.

vit9696 commented 3 years ago

That somewhat surprised be, but you are right:

(lldb) p caps_.clipCullDistanceSupported
(bool) $0 = false
(lldb) p vulkan->GetDeviceFeatures().enabled.shaderClipDistance
(const VkBool32) $1 = 1
(lldb) p vulkan->GetDeviceFeatures().enabled.shaderCullDistance
(const VkBool32) $2 = 0

There is a note on that in https://github.com/KhronosGroup/MoltenVK/issues/203#issuecomment-419676902. Interestingly, culling appears to be rather rarely used by the games (https://github.com/KhronosGroup/MoltenVK/issues/203#issuecomment-494815290), so one can expect it not to land any soon. I wonder if the alternative can be found here.

vit9696 commented 3 years ago

To be fair, software one (i.e. HardwareTransform = False) does work fairly well for me with both OpenGL and Vulkan though after fixing up the hardware usage requirements in https://github.com/hrydgard/ppsspp/pull/14833#discussion_r711746731 without performance issues. However, this is a desktop (11700k clocked at 5.0 GHz to be precise), laptops may have bigger issues.

justafella commented 3 years ago

Is there any way I can get an android build with these fixes? I have a Moto G9 Play with Qualcomm SM6115 Snapdragon 662 (11 nm) Octa-core (4x2.0 GHz Kryo 260 Gold + 4x1.8 GHz Kryo 260 Silver) Adreno 610

ghost commented 3 years ago

Is there any way I can get an android build with these fixes? I have a Moto G9 Play with Qualcomm SM6115 Snapdragon 662 (11 nm) Octa-core (4x2.0 GHz Kryo 260 Gold + 4x1.8 GHz Kryo 260 Silver) Adreno 610

You need to compile this https://github.com/hrydgard/ppsspp/pull/14833 all by your self.

unknownbrackets commented 3 years ago

It'll get merged in not very long and included in git builds. It should work on Adreno, but it won't yet work on Mali, so it's not a complete fix. Be warned there are likely to be issues on some devices once it's merged, so I can't say for sure it'll work on your device.

-[Unknown]

IrfanH495 commented 2 years ago

thanks(^o^). working on v1.12.3-39-g16bf5197e vulkan adreno 530 Valkyria Chronicles 3 Screenshot_20211019-213637

ghost commented 2 years ago

I try the dump and here's the results. Screenshot_2021-10-19-23-19-41-123_org ppsspp ppsspp Screenshot_2021-10-19-23-19-27-727_org ppsspp ppsspp

hrydgard commented 2 years ago

@Gamemulatorer not sure I understand, is that a failure or success? Which GPU on your device?

ghost commented 2 years ago

@Gamemulatorer not sure I understand, is that a failure or success? Which GPU on your device?

I think is a success because as far as I can see all elements is present 🤔🙂

hrydgard commented 2 years ago

Ok, so several successful reports. I'm gonna close this, even though the new code doesn't have full effect on Mali and D3D9 yet.

vit9696 commented 2 years ago

@hrydgard while D3D9 is rather old, macOS VK/GL is considerably new. Shall we have a separate issue for the added code being incompatible with macOS? I believe a shader implementation will still be faster than a software one.

hrydgard commented 2 years ago

@vit9696 who says the added code is incompatible with macOS?

unknownbrackets commented 2 years ago

Apple GL doesn't expose cull distance, possibly also with Vulkan. But I thought this one was probably fixed by clipping, so it might be fixed anyway? If it requires cull, then I think it's still related to all the other open guardband issues.

-[Unknown]

vit9696 commented 2 years ago

I did earlier: https://github.com/hrydgard/ppsspp/issues/13462#issuecomment-922474313, can retest the master version, but I am pretty sure it is still broken.

vit9696 commented 2 years ago

@unknownbrackets, sure, I will retest as I am not positive I did local tests after culling/clipping separation.

vit9696 commented 2 years ago

Yes, the issue is still there. In master both hardware and software transforms are broken. The former is broken because culling is unsupported and the latter is broken, because nobody merged the second branch by @unknownbrackets. Funny enough, this branch is now entirely gone from GitHub, so I needed to restore the patch from my local copy (attached below). 0001-GPU-Implement-cull-behavior-in-sw-transform.patch.zip

vit9696 commented 2 years ago

Applying the attached patch (requires fixing GPU_SUPPORTS_CULL_DISTANCE name) resolves the problem for software transform.

hrydgard commented 2 years ago

Gonna reopen as a reminder.

vit9696 commented 2 years ago

@hrydgard @unknownbrackets can we merge software culling in 1.13 to at least have a partial workaround? I believe Mali would also benefit.

hrydgard commented 2 years ago

Yeah, I think we should. It can be optimized, but that can be done after.

For Mali I'm planning to try a different approach using a geometry shader, too.

vit9696 commented 2 years ago

Just to make it clear, with https://github.com/hrydgard/ppsspp/pull/15072 merged, disabling hardware transform fixes this issue on macOS. Thanks. I guess it might be useful to autoenable software culling based on the platform for affected games, but something like that is clearly out of the scope of this issue.

ghost commented 2 years ago

This might improve now with https://github.com/hrydgard/ppsspp/pull/16142?