Pcsx2: Smuggler's Run: Missing HW Shadows/Incorrect GS Dump Playback

Created on 30 May 2017  路  16Comments  路  Source: PCSX2/pcsx2

PCSX2 version:
v1.5.0-dev-2104-g49840bb

PCSX2 options:
Defaults, Safest

Plugins used:
Defaults. Both GSdx plugins used in the emulator and GSDumpGUI are matching versions

Description of the issue:
In Smuggler's Run, shadows near the player have never been rendered in any HW renderer. In addition to this however, the GS Dump shows an outline of the shadow in HW mode, where they were missing in-game. In all instances, distant shadows are still rendered normally.

How to reproduce the issue:
In-game: Boot game, drive to an area with shadows.

GSDump: Select any HW renderer, find first frame and observe shadows. As a side note, you can see the alpha texture of the trees shadows flicker at the top when stepping to another frame in the GSDump.

GSDump
SmugglersRun_ShadowsHW.zip

Last known version to work:
Never

PC specifications:
Intel Core i5-6600k, GTX 1070, Windows 10 Home 64-bit

In-Game (HW):
gsdx_20170530132642

GSDump (HW):
gsdump

Bug Hardware Texture Cache

Most helpful comment

Analysis main issue is about a texture channel implementation.
Input: 0x0/0x1180
Output: 0x80/0x1200
Effect: permutation of RG and BA channels

Tricks are

  • Input and output overlap
  • The 0x80 offset will change page/pixel order

Permutation is easy to implement. But overlap/pixel positions will be tricky.

I'm not sure the game rely on overlapping. So I propose that we implement an hle dedicated shader to implement color channel shuffles. I'm afraid that shadow position will require the pixels position update too. But we will see if at least some shadows appear.

All 16 comments

Forgot to add in the report that both dumps I captured in SW and HW have the playback issue. The dump that was uploaded was captured in the HW renderer.

I also got some more info from GSdx here that could be of use in the future. :)

Complex Alpha Test
Alternate ATE handling: ate_RGB_then_ZA

Additional tests on real hardware shows that the game uses pre-baked shadows at a distance and transitions to stencil shadows (I hope I got this right) when the player gets closer. I believe this is why the shadows are disappearing when the player gets too close in HW renderers.

Here's an in-game example

50/50 (Top half is pre-baked, bottom half is stencil shadow)
gsdx_20171001013312
Full image
gsdx_20171001013312

Transition layer (stencil shadow is missing):
gsdx_20171001013310

Pre-baked shadow (photo was cropped, but taken further away)

gsdx_20171001013225

Technically there is no stencil on GS.

Is SW renderer impacted (in game) ?
Did you try zerogs ?

SW renderer is not impacted.

I haven't tried zerogs yet, but some tests a while back with older versions of GSdx around 0.9.6; and they didn't have working shadows in HW either.

If sw renderer is fine, it is likely a readback of GS memory by EE which is later transferred again to GS. I added some logs on readback and texture is dumped

@gregory38 So is there anything else I should get? I had no luck with captured frames from my graphics debugger, it doesn't get trace logs or anything unfortunately.

Enable gsdx hidden dump option. Do you see gl error in your debugger (which is btw)?

I use RenderDoc, it's cross-platform as well: https://renderdoc.org

"Enable API validation" is the option used in the program to get the GL debug logs, that's how I got the logs from Guitar Hero earlier. Unfortunately, this game doesn't print any GL debug, I don't get the individual drawcall frames either. It's a hit or miss depending on the game itself. In addition, I use GSdx-dbg when capturing.

I'll post example later frames later.

For some reason I can't edit my original comment, guess Github is glitching out.

Anyways, I got a successful frame capture after some tinkering. For some reason, the missing alpha textures are positioned in an odd orientation. As for debug messages, here are the Medium severity ones:
sr_debug

sr_alpha

sr_terrain

All gl messages are stored in a debug file (should be current dir). It will greatly help you to understand what happen. Debug build is quite verbose because you have all TC information.

The above message is about a texture depth effect. Typically the green channel of depth buffer (bit 8-16) are copyied into the alpha channel of a color buffer. Hint if the detection of the effect doesn't work, it is wrongly replaced by a FBMSK emulation. If you spot those message, there are likely a bug.

You need to check the code of InvalidateLocalMem. This function will transfer code from the GPU to the GS mem which could be send to EE. Check the code there are some GL related messages.

Log analysis. There is a color effect based on channels shuffle (from ba to rg). Around draw call 13. The source is located at 0x1180 and the destination is located at 0x1200. My feeling is that we have some kind of overlapping of color buffers/textures.

Edit: next step, to confirm the behavior, is to get the resolution of the color buffer. The width can be extrapolated from FBW register value (...._context.txt file) i.e. width = 64 * FBW. Above address 0x1180/0x1200 are in block unit.

@gregory38

Here's the context for drawcall 13. If you need 14, ect. let me know ;)

FRAME
    FBP (*32):0x1200
    FBW:16
    PSM:0x2
    FBMSK:0x0

New GS Dump: smugglersrun_badtex.zip

This is the raw dump with all the drawcalls, contexts, ect.
smugglersrun_debug_contexts.zip

Analysis main issue is about a texture channel implementation.
Input: 0x0/0x1180
Output: 0x80/0x1200
Effect: permutation of RG and BA channels

Tricks are

  • Input and output overlap
  • The 0x80 offset will change page/pixel order

Permutation is easy to implement. But overlap/pixel positions will be tricky.

I'm not sure the game rely on overlapping. So I propose that we implement an hle dedicated shader to implement color channel shuffles. I'm afraid that shadow position will require the pixels position update too. But we will see if at least some shadows appear.

HW Shadows are also missing in TLoS 2, just thought I'd mention that here, seeing that both games seem to suffer from the same issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Javed-Iqbal-1 picture Javed-Iqbal-1  路  5Comments

mcabel picture mcabel  路  4Comments

Clarke2131 picture Clarke2131  路  3Comments

AraHaan picture AraHaan  路  5Comments

Nezarn picture Nezarn  路  6Comments