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

Investigate alternative ways to do depal, to fix performance in Sonic Rivals and MGS: Acid 2 #10908

Closed
hrydgard opened this issue Apr 12, 2018 · 7 comments
Labels
D3D9 Direct3D 9 OpenGL

Comments

@hrydgard
Copy link
Owner

hrydgard commented Apr 12, 2018

When games use palettized (CLUT, color look up table) texturing when texturing from a framebuffer, we currently "depalettize" (index) it into a full color texture, and then texture using that. This has the great advantage that texture filtering works as normal, but is quite expensive since we do this in a pixel shader and thus need to start up a render pass, which is not cheap on mobile.

An alternative would be to "depalettize" directly in the shader when reading these textures, but to do that we need to handle filtering ourselves since that needs to happen after the depalettization. So the pixel shader gets heavier but we lose the extra render pass. An additional alternative may be to use a compute shader to do the work, in order to avoid starting up a render pass, but I don't think it's that much cheaper and has obvious compatibility issues with older devices.

Now, the issue is that a few games, like Sonic Rivals, Metal Gear Solid Acid 2 and, IIRC, Test Drive Unlimited, use the depal functionality with color ramps as palettes to perform various forms of color correction. They do this in little tiles across the screen, resulting in many tens or hundreds of render passes per frame. The cost of the above-mentioned alternative with in-shader manual filtering would be much smaller, so might be worth implementing to get acceptable performance out of these games on mobile.

@hrydgard
Copy link
Owner Author

Implemented shader depal for Vulkan in #10911 , Unknown later implemented it for OpenGL.

Leaving open since it's not implemented for all backends, but bumping to 1.8 (at least).

@Panderner
Copy link
Contributor

But how about OpenGL label?

@hrydgard
Copy link
Owner Author

hrydgard commented May 1, 2020

The faster depal implementation is done for OpenGL. It's however not fully utilized yet to fix the perf in these games (by reordering render passes) so yeah, I suppose it should be added.

@hrydgard hrydgard added the OpenGL label May 1, 2020
@Panderner
Copy link
Contributor

Did Rock Band Unplugged use Depal?

@ghost
Copy link

ghost commented May 2, 2021

Sonic Rivals running smooth on my Redmi Note 9 both VK and OpenGL.
Screenshot_2021-05-03-02-26-12-173_org ppsspp ppsspp
Screenshot_2021-05-03-02-26-07-803_org ppsspp ppsspp
Screenshot_2021-05-03-02-25-39-953_org ppsspp ppsspp

@ghost
Copy link

ghost commented Mar 14, 2023

Kurohyo 2 expensive effects belongs here? since is related to depal #8390 (comment).

@hrydgard
Copy link
Owner Author

This is implemented in all backends that can reasonably implement it. Closing.

@hrydgard hrydgard removed this from the Future milestone Apr 29, 2023
@hrydgard hrydgard removed the D3D11 Direct3D 11 label Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D3D9 Direct3D 9 OpenGL
Projects
None yet
Development

No branches or pull requests

2 participants