Fix OpenGL framebuffer depth reads #426
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.