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 early depth test #551

Open
1 task done
skyfloogle opened this issue Dec 7, 2024 · 2 comments
Open
1 task done

Implement early depth test #551

skyfloogle opened this issue Dec 7, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@skyfloogle
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

What feature are you suggesting?

The PICA200 offers an "early depth test" feature, which performs a depth test before fragment processing happens. This appears to at least be widespread enough to have a page on the OpenGL wiki. I've looked through the code of Azahar's predecessors, and this doesn't appear to be implemented.

Why would this feature be useful?

I'm interested in using this for Red Viper. Some quick tests on my 3DS suggest that the early depth test could help rendering performance significantly, but it doesn't seem to behave in quite the way I expect it to. I usually throw Citra into RenderDoc to investigate graphical oddities, but that's not currently possible for this.

@skyfloogle skyfloogle added the enhancement New feature or request label Dec 7, 2024
@skyfloogle
Copy link
Author

To my understanding, there's an automatic aspect in modern GPUs, but it can also be manually configured. In OpenGL, fragment shaders can be manually configured to force early depth testing. The 3DS is even more configurable in this regard: it can be toggled with 2 different registers, the compare function can be chosen, and a 24-bit clear value can be specified (problemkaputt, 3dbrew).

@rtiangha
Copy link
Collaborator

rtiangha commented Dec 9, 2024

OK, dumb question since I'm not an OpenGL guy: Is it enough to set depth.test_enabled to GL_TRUE in src/video_core/renderer_opengl/gl_state.cpp or would a depth buffer also have to be created for it to work? Or am I totally missing the mark?

    depth.test_enabled = false;
    depth.test_func = GL_LESS;
    depth.write_mask = GL_TRUE;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants