hrydgard/ppsspp

Pro Yakyu Spirits 2010 (NPJH50234): character shadows are not cleared properly per frame

nassau-tk opened this issue · 25 comments

What happens?

Strange characters shadow appear.
But, May be it won't getting the dump corectly I think.
(It isn't understood by my knowledge.)
So,Please see attached screenshot & dump.

What should happen?

Graphic drawing corectly.

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

PPSSPP Ver.:1.10.3-581
OS:Android 9.0
DeviceName:SONY SO-02K / Xperia XZ1 Compact(Japan)
CPU:Snapdragon835(Octa-core)
GPU:Adreno 540
Resolution:720×1280
RAM:4GB
ROM:32GB
ExternalStrage:microSDXC 512GB

PPSSPP Ver.:1.10.3-581
OS:Windows10(64-bit)Japanese
CPU:Ryzen7 3800X(8-core)
GPU:RADEON RADEON RX5700XT
Resolution:2560×1440
RAM:32GB

[Before the issue happen.]
ProYakyuSpirits2010_000

[After the issue happen.]
ProYakyuSpirits2010_001
and
ProYakyuSpirits2010_002

Dump files here.
NPJH50234_ProYakyuSpirits2010_Dump.zip

@nassau-tk how is this look for software renderer and real hardware?

@Panderner
Software rendering is not happen the strange shadow.

Is it meaning "Real Hardware" equal "Real PSP"?
If it's right.
Please,See below.[Real PSP ScreenShot animationGIF]
ProYakyuSpirits2010_RealPSP

The dumpfiles isn't draw strange shadow isn't it?

This strange shadow is cleared when switch the window to back ground on Android.
Cleared by switch to full screen on Windows(Not every time).
I can't get these strange shadow in GE Dump.
So,I attached MP4 file.
Please,See it.
NPJH50234_2020-09-19_05-20-45.zip

EDIT: D3D11 is not work.

@hrydgard

This game is not working on "D3D11" at v1.10.3-711.
But, Working from v1.10.3-712.

v1.10.3-712-g7ed1ade56 | Henrik Rydgård | 2020-09-19 14:14:06
A couple of D3D11 fixes.

Just Report!!

But,This issue is still happen.

And,This Baseball game has more seriese.

Pro Yakyu Spirits 2011 (NPJH50336).
Pro Yakyu Spirits 2012 (NPJH50520).
Pro Yakyu Spirits 2013 (NPJH50730).
Pro Yakyu Spirits 2014 (NPJH50838).

These games happen the same issue.

Thanks for detailed reporting!

ok so broken by 7ed1ade according to comment above - seems kinda weird...

The issue still happen v1.10.3-1375.

Screenshot_20210112-140526_PPSSPP

Re-tested on v1.10.3-1552 (Windows10/64-bit & Android)

I found a point.
If change to "Skip buffer effects(non-buffered, faster)" then shadow will draw correctly at [Vulkan/D3D9/D3D11].

[OpenGL] is still happen the issue on any settings.

EDIT: Pitcher's shadow will not correct drawing on all backends.

I'd guess something (possibly a reinterpret or memory transfer) should be clearing the buffer used for shadows.

-[Unknown]

I got a log.
There is a few red code when timinmg of start up .

https://gist.github.com/nassau-tk/45c8f1aa599e3c48dcf536acb2cf7668

The original dump should look like this:

playback expected

In playback, it does. This seems to be an issue with clearing previous shadows.

The lower shadow is drawn at step 41/275 from 0x0418e000. That buffer is rendered to at 67/275. To draw, it:

  • Clears 128x128x16-bit at 0x0418e000 to 0x00000000 using a 5551 clear (color/alpha/stencil, not depth.)
  • The clear has the 0x7F bits of stencil masked, but it's 5551 anyway so that should change nothing.
  • Renders to 0x0418e000 as 5551 using 5551, flat, lighting color, and weights.
  • During that render, it uses and ALWAYS stencil test to increment stencil.
  • The render has color masked off and stencil 0x7F masked, so it writes stencil only.
  • Once done, it does a stencil != 0 test to blend using fog I think. This causes the shadow.

When using that as a texture (back at 41), it sets it as a 5551 texture with blending based on src.a.

So that shadow (on the mound) should rely on simple stencil clearing.

The shadow for the pitcher is similar, but without a temporary (maybe because no mound deformation.) It:

  • Draws shapes with everything but 0x80 masked off for stencil, but again it's 5551 so that just means write stencil.
  • At draw 66, it unmasks color and does a full screen draw with a stencil != 0 test.

Interestingly, we begin the frame with a color-only clear, 5551. Then we do a alpha/stencil clear (separately...) with 0x7F masked for stencil. Then we do ANOTHER clear, this time stencil + depth but with stencil masked.

We seem to be handling the masking during stencil clears on 5551 incorrectly.

-[Unknown]

Interesting! Do we manage to actually convert it to a real clear in DrawEngine or is it drawn as triangles?

Our state mapping for stencil is rather complex so would not surprise me if we had a bug in either place...

Not a real clear - primitives. It looks like the stencil mask fails to take into account the framebuffer format.

-[Unknown]

This is probably working now after #13972 - please test.

@hrydgard

OK! I tested it.
OpenGL with Buffered Rendering.
Vulkan with Buffered Rendering.
D3D9 with Buffered Rendering.
D3D11 with Buffered Rendering.

All backends solved the issue!

EDIT : On Windows10 (Sorry I forgot to Android.)

Oops!!
Sorry!!

Windows10(64-bit) is no problem.
But, My Android Galaxy S20 is not appear the pitcher's shadow at Vulkan.

Screenshot_20210125-215113_PPSSPP

OpenGL is Good.
Screenshot_20210125-220114_PPSSPP

@nassau-tk what chipset for your s20?

PPSSPP Ver.:1.10.3-1636
OS:Android 11.0
DeviceName:Samusung Galaxy S20 / SC-51A
CPU:Snapdragon865(Octa-core)
GPU:Adreno 650
Resolution:3200 x 1440 (Max)
RAM:12GB
ROM:128GB
ExternalStrage:microSDXC 512GB

GEdump here.
proyakyu2010.zip
This dump was got from my phone.
But, If open on the Windows then it will appear correctly.

Weird! But that is not as distracting as the old problem, I'll look at this after 1.11.

YEs! I think so too!

It might be related to dual source blending.

-[Unknown]

It might be related to dual source blending.

-[Unknown]

@nassau-tk have you tried direct3d 9?

It might be related to dual source blending.
-[Unknown]

@nassau-tk have you tried direct3d 9?

@Panderner

I did it on Windows.
It's no problem.

Android?
I have only OGL or Vulkan.

Okay, it's not dual src blending then (since d3d9 doesn't support it). thanks for testing though!

When playing back the latest frame dump on a PSP, there's actually no shadow:
#13391_NPJH50234_pro_yakyu_shadow2

Maybe it's a bug in the frame dump handling, though. Software rendering matches the PSP in any case.

The previous one does have one (as noted above):
#13391_NPJH50234_pro_yakyu_shadow

Seems like Android Vulkan is not showing either shadow. After digging a bit, it's caused by the workaround for #10421. Not hard to fix.

-[Unknown]