Skip to content

Commit

Permalink
Document a workaround in the render pipeline code
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
grorp committed Nov 9, 2024
1 parent b406709 commit cebc0ad
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/client/render/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,28 @@ 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 means Irrlicht creates a depth texture for us and binds it 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

// This also means a depth texture is bound in cases where it isn't actually
// needed (post-processing steps). This workaround should be replaced by
// explicitly configuring depth textures where needed.

if (textures.size() == 1 && depth_stencil == NO_DEPTH_TEXTURE) {
driver->setRenderTarget(textures[0], m_clear, m_clear, context.clear_color);
return;
Expand Down

0 comments on commit cebc0ad

Please sign in to comment.