From 37b1a3e0aa3249bec4afb7d8745ea8fbab4ed01e Mon Sep 17 00:00:00 2001 From: grorp Date: Fri, 8 Nov 2024 21:55:46 +0100 Subject: [PATCH] Document a workaround in the render pipeline code I originally wanted to get of the legacy IVideoDriver::setRenderTarget and this workaround altogether, but that ended up being too much work. Instead I'm documenting my findings so they're not wasted. --- src/client/render/pipeline.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/client/render/pipeline.cpp b/src/client/render/pipeline.cpp index 5558d05b0dcd7..8cc9672aaf897 100644 --- a/src/client/render/pipeline.cpp +++ b/src/client/render/pipeline.cpp @@ -179,6 +179,23 @@ void TextureBufferOutput::activate(PipelineContext &context) // Use legacy call when there's single texture without depth texture // This binds default depth buffer to the FBO + + // This is currently neccessary for a working depth buffer in the following cases: + // - post-processing disabled, undersampling enabled + // (addUpscaling specifies no depth texture) + // - post-processing disabled, 3d_mode = sidebyside / topbottom / crossview + // (populateSideBySidePipeline specifies no depth texture) + // - post-processing disabled, 3d_mode = interlaced (probably) + // (populateInterlacedPipeline specifies no depth texture) + // With post-processing disabled, the world is rendered to the TextureBufferOutput + // created in the functions listed above, so a depth buffer is needed + // (-> this workaround is needed). + // With post-processing enabled, only a fullscreen rectangle is rendered to + // this TextureBufferOutput, so a depth buffer isn't actually needed. + // But: These pipeline steps shouldn't rely on what ends up being rendered to + // the TextureBufferOutput they provide, since that may change. + // https://irc.minetest.net/minetest-dev/2022-10-04#i_6021940 + if (textures.size() == 1 && depth_stencil == NO_DEPTH_TEXTURE) { driver->setRenderTarget(textures[0], m_clear, m_clear, context.clear_color); return;