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

Fix OpenGL framebuffer depth reads #426

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

Archez
Copy link
Contributor

@Archez Archez commented Feb 8, 2024

We have an optimization for reading depth values in OpenGL when there is only one coordinate, and that is to skip the blit and just read directly.

The problem with this, is glReadPixels does not work on multi-sampled framebuffers. In the case of msaa, you have to blit first to a single-sampled buffer, then the pixels can be read.

This PR adds a check for MSAA <= 1 when choosing if we can use the optimized read.

Additionally, the default framebuffer setup by SDL was missing a stencil size, where as all the other buffers we create in Fast3D do have a stencil set. I've added the attribute as it is required in our depth test due to the format being GL_DEPTH24_STENCIL8.


Without these fixes, the depth read silently fails and leads to things like the sun lens flare/torch glows sometimes not rendering in OOT.

@Kenix3 Kenix3 merged commit 21a5df5 into Kenix3:main Feb 8, 2024
4 checks passed
@Archez Archez deleted the fix-opengl-depth-read branch February 8, 2024 16:14
Archez added a commit to Archez/libultraship that referenced this pull request Feb 20, 2024
louist103 pushed a commit to louist103/libultraship that referenced this pull request Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants