Skip to content
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

Graphical Glitches in Colin McRae Dirt 2 (missing water) #13012

Closed
Panderner opened this issue Jun 8, 2020 · 30 comments · Fixed by #15960
Closed

Graphical Glitches in Colin McRae Dirt 2 (missing water) #13012

Panderner opened this issue Jun 8, 2020 · 30 comments · Fixed by #15960
Labels
GE emulation Backend-independent GPU issues
Milestone

Comments

@Panderner
Copy link
Contributor

There are some graphical gliches in Dirt 2:

Car Models renders incorrectly:

Real Hardware:
IMG_20200608_161249
IMG_20200608_161300

PPSSPP:
Screenshot_2020-06-08-16-09-12-08_2f85358b2198d26f8aca533d68bee793
Screenshot_2020-06-08-16-06-38-08_2f85358b2198d26f8aca533d68bee793

Water are missing in some tracks.
Real Hardware:
IMG_20200608_162404

PPSSPP:
Screenshot_2020-06-08-16-22-40-67_2f85358b2198d26f8aca533d68bee793

And of course here's a GE Dump:
Car Select.ppdmp.zip
In-game.ppdmp.zip
Water.ppdmp.zip

@ghost
Copy link

ghost commented Jun 9, 2020

OpenGL
Screenshot_20200609-202454

@hrydgard hrydgard added the GE emulation Backend-independent GPU issues label Jun 14, 2020
@hrydgard hrydgard added this to the v1.11.0 milestone Jun 14, 2020
@Maarcis12
Copy link

Looks like you fixed the issue, thank you.
ULES01301_00004
ULES01301_00002

@Maarcis12
Copy link

so now only water isn't rendered in the game.

@Panderner
Copy link
Contributor Author

But the car models still not fixed in OpenGL on latest build
Screenshot_2020-09-22-22-11-30-09_2f85358b2198d26f8aca533d68bee793
Screenshot_2020-09-22-22-10-51-08_2f85358b2198d26f8aca533d68bee793

@Maarcis12 have you tested all backends?

@Panderner
Copy link
Contributor Author

Looks like you fixed the issue, thank you.
ULES01301_00004
ULES01301_00002

it's seem the GO texture is wrong. here's a screenshot for correct result:
Screenshot_2020-09-22-22-17-00-36_2f85358b2198d26f8aca533d68bee793

@Maarcis12
Copy link

@Panderner yeah, i tested all backends, it could also be that i have "disable slower effects" enabled, so my bad on that one.

@Panderner
Copy link
Contributor Author

Screenshot_2020-09-30-20-11-14-21_2f85358b2198d26f8aca533d68bee793
It's seems the Off-Road Vehicles are glitched too in white texture.

But when i tried to make the GE Dump the car disappears:
Off-Road Vehicle.ppdmp.zip

@Maarcis12
Copy link

also, sorry for silence, i was bit busy with my job, but i will apologize for the initial confusion because the reason it doesn't act up on my end is that i have "Disable slower effects" enabled.

@Panderner
Copy link
Contributor Author

Panderner commented Oct 15, 2020

Umm yes @Maarcis12. Disable slower effects can fix texture glitches for cars but the water still not fixed. the water issue still remain.

@Maarcis12
Copy link

and that's what i mentioned earlier.

@Panderner
Copy link
Contributor Author

It seems v1.10.3-1267-gf1ab6c62c breaks Dirt 2
Screenshot_2020-12-11-22-27-00-41_2f85358b2198d26f8aca533d68bee793

@Maarcis12
Copy link

ULES01301_00000
Yeah, it definitely broke the game

@hrydgard
Copy link
Owner

hrydgard commented Dec 11, 2020

thanks for reporting!

The issue is this line that I added in ReinterpretFramebufferFrom in f1ab6c6 :

currentRenderVfb_ = vfb;

Doesn't quite make sense though .. I can revert that but it messes up ghosts&goblins on old hardware. This will need some digging...

@hrydgard
Copy link
Owner

OK, cars should be back now, and with better lighting.

@Panderner
Copy link
Contributor Author

The graphics are fixed but water is still glitching
Screenshot_2020-12-13-17-38-28-568_org ppsspp ppsspp

@hrydgard hrydgard modified the milestones: v1.11.0, v1.12.0 Dec 13, 2020
@Maarcis12
Copy link

ULES01301_00002
yeah, the reflections are fixed, tho water is flickering, it spawns then it doesn't spawn

@ghost
Copy link

ghost commented Aug 9, 2021

The graphics are fixed but water is still glitching
Screenshot_2020-12-13-17-38-28-568_org ppsspp ppsspp

This gfx issue can only reproduce on opengl
Screenshot_2021-08-09-16-04-30-715_org ppsspp ppsspp
vulkan is ok?
Screenshot_2021-08-09-16-06-13-374_org ppsspp ppsspp

@Panderner
Copy link
Contributor Author

Same here for my PC and my phone using vulkan:
Ppsspp Screenshot 2021 08 09 - 19 44 31 14

in DIrect3D 11 the water flickers:
ezgif com-gif-maker

@ghost
Copy link

ghost commented Aug 9, 2021

Same here for my PC and my phone using vulkan:
Ppsspp Screenshot 2021 08 09 - 19 44 31 14

in DIrect3D 11 the water flickers:
ezgif com-gif-maker

No glitch on my phone using vulkan issue only happen on opengl.

@Panderner
Copy link
Contributor Author

@Gamemulatorer I'm using POCO M3 still have graphical glitch on vulkan.

@ghost
Copy link

ghost commented Aug 9, 2021

@Gamemulatorer I'm using POCO M3 still have graphical glitch on vulkan.

So the vulkan gpu of SD662 POCO M3 is so glitchy on PPSSPP 🤔

@Panderner
Copy link
Contributor Author

And yes my PC too on vulkan. I'm using a GTX 1050 Ti GPU

@unknownbrackets
Copy link
Collaborator

In the water frame dump, it seems like the water starting being drawn near 1999/6546. The water is drawn using a stencil test, only drawing water where stencil is set. At that point, there's just a bunch of dots where there should be water, so that's why it draws as a bunch of dots. The problem must be earlier, where the stencil bits are established.

The frame starts with all stencil cleared. It draws the water stencil around 1839/6546, which goes wrong mostly due to alpha testing on the texture:
Game image with water visible

The texture is at 0x040cc000. It's drawn at 1364/6546 as 565, but then used as 4444. So definitely going through reinterpret.

The game is doing an alpha test on alpha for 0xE0 (effectively 0xE since it's 4444) == 0x20 (effectively a & 0xE == 0x2.)

This problem seems to be an RGB mask issue. When the game draws the texture that is reinterpreted, its final draw is masked with 0x7FFFFF. Because we don't actually support masking, we end up clearing the entire blue color, instead of just the top bit.

-[Unknown]

@hrydgard
Copy link
Owner

We do have support for write masks through shader framebuffer blend now if you turn them on in compat.ini, actually (ShaderColorBitmask). maybe that'll be enough together with reinterpret?

@hrydgard hrydgard removed this from the v1.12.0 milestone Aug 29, 2021
@hrydgard hrydgard added this to the Future-Prio milestone Aug 29, 2021
@hrydgard hrydgard changed the title Graphical Glitches in Colin McRae Dirt 2 Graphical Glitches in Colin McRae Dirt 2 (missing water) Aug 24, 2022
@hrydgard hrydgard modified the milestones: Future-Prio, v1.14.0 Aug 24, 2022
@hrydgard
Copy link
Owner

Even turning off BlueToAlpha and on ShaderColorBitmask doesn't help here, the reinterprets seem to be going okay though, don't quite see where it goes wrong or how exactly it's supposed to work. It does involve stencil too, and actually does two passes of first drawing water masks with alpha test and then stencil-tested water texture, just with two different diffuse colors, but I don't see any annoying stencil/alpha interaction like using DST_ALPHA or similar.

@unknownbrackets
Copy link
Collaborator

Turning off the alpha test for 1920/6546 gives pretty solid looking water (obviously that goes outside bounds.) There's indeed an earlier pass at 1450/6546, which also sets stencil.

It's a bit odd that it wants alpha to be >= 0x20 && <= 0x3F. When it renders at 565, we end up with this:
Almost looks like an eyeball

The sphere is created around 2633/6546 (so, later in the frame), but all the draws starting at 1364 use a mask to write only 4 or less bits of blue.

Software rendering has a more dithered but similar result:
Smaller eyeball

But the reinterpreted result looks correct (still software):
Nice cloudy water texture

And a lot of the alpha values are 34 (0x22.) So this must be what it's going for.

Back to Vulkan, the preview in the GE debugger, at least, shows this:

Weird blue patches

The places we wanted to have alpha seem to have blue, and full alpha. I wonder if 4444 and 5551 are swapped or something.

-[Unknown]

@unknownbrackets
Copy link
Collaborator

Okay, turns out the dump I'm using didn't activate the ShaderColorBitmask flag somehow, but forcing it on still gives this as the texture:

Patchy alpha

Which is converted from this:

Better eyeball

There's almost no blue with the right colors. In software, I see dither is actually not enabled during these draws. But ultimately the alpha ends in the right ranges.

-[Unknown]

@hrydgard
Copy link
Owner

hrydgard commented Sep 2, 2022

Maybe it was an old dump before we had game IDs embedded in them?

Anyway, I think there might be a problem with the combination of shader blending (which is required for the masking) and logic ops (all of these steps manipulating the water texture uses them). The logic operation will happen after the masking, and not itself be masked, which is gonna result in some wrong bits.

We are going to have to move logic ops into shader blending (assuming this is the issue, but we should anyway). This also allows for emulating logic ops on platforms where they are not available.

At least there's no stencil involved in making the water texture...

Oh yeah, #15944 helps a lot when looking at stuff in renderdoc, so much easier to see what's going on without all these copies.

@unknownbrackets
Copy link
Collaborator

Aha, darn. I missed that it was doing logic ops. That explains it indeed.

-[Unknown]

@hrydgard
Copy link
Owner

hrydgard commented Sep 4, 2022

Note: Not yet fully fixed on all platforms. D3D11 and OpenGL ES coming up. Keeping closed, since the mystery is solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GE emulation Backend-independent GPU issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants