Clear auto-generated temporary depth/stencil buffers in setCanvas.

Previously it would discard them, which needed the user to call love.graphics.clear afterward to get them into a valid state.

The current code has suboptimal performance if the user still calls clear after setCanvas (a common situation), so more optimizations will probably be needed.

Fixes #1843.
This commit is contained in:
Sasha Szpakowski
2023-01-11 18:17:22 -04:00
parent 249d90067e
commit 94d05e319b
+9 -3
View File
@@ -963,10 +963,16 @@ void Graphics::setRenderTargets(const RenderTargets &rts)
resetProjection();
// Invalidate temporary depth/stencil. This could be a clear, but if the
// user also clears a double-clear may be slow...
// Clear/reset the temporary depth/stencil buffers.
// TODO: make this deferred somehow to avoid double clearing if the user
// also calls love.graphics.clear after setCanvas.
if (rts.depthStencil.texture == nullptr && rts.temporaryRTFlags != 0)
discard({}, true);
{
OptionalColorD clearcolor;
OptionalInt clearstencil(0);
OptionalDouble cleardepth(1.0);
clear(clearcolor, clearstencil, cleardepth);
}
}
void Graphics::setRenderTarget()