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.19k stars 2.17k forks source link

dust effect displays green triangular shapes issue #10969

Closed joelolopez closed 6 years ago

joelolopez commented 6 years ago

im playing this Brave story new traveler game using vulkan backend when i notice that the dust effects displays wrong images (green triangular shapes)

1

OS android 7.0 , Octa-core, 2360 MHz, ARM Cortex-A53, 64-bit, 16 nm , Mali-T830 MP2 , 4 GB RAM

Leopard20 commented 6 years ago

Did you try changing the options? Like disabling the stencil test?

joelolopez commented 6 years ago

yup i tested it and still displaying the same image

unknownbrackets commented 6 years ago

If I remember correctly, this is rendered using flat shading. It might be impacted in some way by render-to-CLUT, though.

Stencil test won't help. Does this happen with both OpenGL and Vulkan?

If it happens with OpenGL, did it work in v1.5.4? Is it broken in the latest git build?

-[Unknown]

joelolopez commented 6 years ago

this only happen with vulkan, im using v. 1.5.4 from the ppsspp. Org

unknownbrackets commented 6 years ago

The problem here is that flat shading on Vulkan picks a different vertex for the triangle strips:

GLES: i + 2 (default GL_LAST_VERTEX_CONVENTION) Everyone else: i

Brave Story uses the wrong colors if you follow the wrong convention. So my guess (without testing) is that the PSP used the OpenGL default convention.

In theory, we could pass the offset vertex into the vertex shader and pull the correct color, I guess. Not sure what the most efficient solution is here.

-[Unknown]

hrydgard commented 6 years ago

Oh, that makes sense. Ouch.

Well, depending on the primitive type there can be somewhat easier solutions, like for example if it's TRIANGLE_LIST then we can "just" copy the color from the third to the first vertex in each triangle... Unfortunately that does mean reading back from decoded vertices, which can be expensive on some platforms as we write verts directly to uncached VRAM (remember that slowness bug..). Or we need to make the vertex decoder a lot smarter. Or simply always software-transform FLAT triangles, then we can easily poke around in the vertex data to fix it up and will handle all the types easily, at the cost of losing hardware transform for these triangles. This will also let us simulate FLAT on platforms that don't support it...

unknownbrackets commented 6 years ago

In this specific case it's a triangle strip. Really, the first two colors are garbage, it's correct after that.

Always software transforming flat really doesn't sound too terrible to me. They're pretty infrequent, although I could imagine finding some crazy game that uses flat for complicated many-vertex shape rendering or something...

-[Unknown]

hrydgard commented 6 years ago

Yeah, I think I like that idea best too. Bit of a minor perf regression risk as you say, but probably not common.