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

Implement vertex range culling #11393

Merged
merged 5 commits into from
Sep 18, 2018
Merged

Conversation

unknownbrackets
Copy link
Collaborator

@unknownbrackets unknownbrackets commented Sep 17, 2018

Based on tests, skips triangles with any point outside the 4096x4096 box, except when depth clamping would engage. Does not actually implement depth clamp, just implements the culling rules related to it.

Alternative to (and heavily inspired by) #9527 and currently GLES only seeking feedback and tests in more games. This at least fixes the Brave Story triangle (#8251) so far, but I don't have all the affected racing games to confirm.

If this seems right, can port it to the other backends for merge.

Fixes #9527, fixes #8251, fixes #5001, fixes #10928, fixes #11260, may help #2159, #5507, #7026, and #7294.

-[Unknown]

@unknownbrackets unknownbrackets added the Guardband / Range Culling Involves vertices outside fustrum. label Sep 17, 2018
@unknownbrackets
Copy link
Collaborator Author

I guess we could maybe use this on some devices?
https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_clip_cull_distance.txt

Also wonder if I should add a hidden ini-only setting in case this causes issues or performance problems...

-[Unknown]

@hrydgard
Copy link
Owner

So the cull distance extension specifies how far behind a clipping plane a single vertex is? That means that to kill a whole triangle from the context of a single vertex, you'll have to set it to a very large number (and you still might get stray pixels from the other two verts? Though probably not much of an issue in this case).

@hrydgard hrydgard added this to the v1.8.0 milestone Sep 17, 2018
@hrydgard
Copy link
Owner

hrydgard commented Sep 17, 2018

Tagged this for 1.8.0, depending on how it goes might un-bump to 1.7.0.

@marosis
Copy link

marosis commented Sep 17, 2018

@hrydgard😥

@hrydgard
Copy link
Owner

What? It's not finished. No need for the sadface.

Based on tests, skips triangles with any point outside the 4096x4096 box,
except when depth clamping would engage.
Also D3D11, since they are very similar.
@unknownbrackets
Copy link
Collaborator Author

I tried setting gl_ClipDistance[0] to a very negative number, and glEnable(GL_CLIP_DISTANCE0);, but doesn't clip anything. Not sure what I'm missing... no errors.

Well, maybe we stick with the w approach. Anyway, I went ahead and ported this to the other backends.

-[Unknown]

@hrydgard
Copy link
Owner

Looking very good so far, though I don't have all the affected games either. Unlike my old change it doesn't break Wipeout subtly in the corners.

It doesn't seem to have any bad effect that I can see, but I haven't tested on many devices yet. If there are issues, as mentioned we can just whitelist it per game...

@hrydgard hrydgard modified the milestones: v1.8.0, v1.7.0 Sep 17, 2018
@unknownbrackets unknownbrackets changed the title WIP - GLES: Implement vertex range culling Implement vertex range culling Sep 18, 2018
@unknownbrackets
Copy link
Collaborator Author

Vulkan depth clamp is interacting poorly with this on #11260 - of the two examples, one isn't fixed still, and it's only not fixed when Vulkan's depthClampEnable is true. On all other backends, it's fixed by this pull.

I'm not sure why - presumably depth clamping happens right before depth testing, after the vertex shader? I didn't find any obvious definition of this for Vulkan. In that case, it would imply depth clamping is sometimes breaking the w = NAN thing.

-[Unknown]

Vulkan clamps to the clip range, not the full range.  So when clipping, we
don't really want to clamp at all.  Unfortunately, when one side is
clipping, we can't do it exactly right.

But many games clip depth, like Dissidia.  Fixes hrydgard#11260.
@unknownbrackets
Copy link
Collaborator Author

Added a depth clamping improvement, see #11399 for more details (there's still a less common scenario that is wrong.) Now #11260 is fixed.

-[Unknown]

@hrydgard
Copy link
Owner

Thanks. I'll run through a whole bunch of games soon and then probably merge. Seems safe enough nw (and easy enough to disable in case of problems).

The Vulkan clamping behavior is a bit unfortunate, yeah..

@hrydgard
Copy link
Owner

Let's try it.

@hrydgard hrydgard merged commit acfd688 into hrydgard:master Sep 18, 2018
@unknownbrackets unknownbrackets deleted the cullrange branch September 18, 2018 22:20
@marosis
Copy link

marosis commented Sep 19, 2018

I will test some games and write if they are fixed

@marosis
Copy link

marosis commented Sep 19, 2018

Btw please can you answer me why are android builds minimaly? I see only for Windows platform on PPSSPP builds website

@unknownbrackets
Copy link
Collaborator Author

There was an issue with cmake - fixed in 1f881d7.

-[Unknown]

@ghost
Copy link

ghost commented Sep 19, 2018

screenshot_2018-09-19-12-57-04
Hellboy The Science Of Evil
screenshot_2018-09-19-12-56-32
YuGiOh Arc V tag force special

@ghost
Copy link

ghost commented Sep 19, 2018

screenshot_2018-09-19-12-55-54

screenshot_2018-09-19-12-56-21
Tekken 6

@ghost
Copy link

ghost commented Sep 19, 2018

Phone Specs:
OpenGL 2.0
Mali-450 MP
Octacore
2GB ram
PPSSPP use Build 1.6 3-483g1f881d790

@unknownbrackets
Copy link
Collaborator Author

Maybe we ran out of vertex shader registers... ugh. Might have to blacklist cullrange on Mali-4xx.

-[Unknown]

@marosis
Copy link

marosis commented Sep 19, 2018

Ohhhh. Aaaaaand problems are starting😂😂😂

@unknownbrackets
Copy link
Collaborator Author

Maybe we could use gl_extensions.gpuVendor == GPU_VENDOR_ARM && strstr(gl_extensions.model, "Mali-4") && !gl_extensions.VersionGEThan(3, 0) to set a bug flag, and blacklist on Mali 4xx, but I don't have enough devices to validate that it fixes it...

-[Unknown]

@unknownbrackets
Copy link
Collaborator Author

Or maybe those games are using large viewports, should try after #11407.

-[Unknown]

@ghost
Copy link

ghost commented Sep 21, 2018

I have found a weird solution for this issue in my Mali-450 GPU using GLtools (not advisable) since my phone is rooted I just enable Optimize GLSL shader in the menu and then boom its fixed the issue.
screenshot_2018-09-21-10-52-15

@ghost
Copy link

ghost commented Sep 21, 2018

screenshot_2018-09-21-13-20-22
Tekken 6 now are OK and other my ppsspp game also its improved the performance just a little bit.

*sorry for my bad english 😅

@unknownbrackets
Copy link
Collaborator Author

Hmm, I wonder if we should try running a glsl->spirv->opt->glsl pass on the shaders...

-[Unknown]

@hrydgard
Copy link
Owner

Hm. They have so little confidence in the driver optimizer that they hide it behind an option?

But yeah, that would be interesting to try.

@ghost
Copy link

ghost commented Sep 21, 2018

PPSSPP Build v1.6.3-492-g9fddfff66 didn't helped the issue :(

@marosis
Copy link

marosis commented Sep 21, 2018

DTM race driver-still same issue
screenshot_20180921-191444

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Guardband / Range Culling Involves vertices outside fustrum.
Projects
None yet
3 participants