Skip to content

Commit

Permalink
Disable blitting depth or stencil buffers to the screen if multisampl…
Browse files Browse the repository at this point in the history
…ing is enabled in the texture.

(Blitting a multisampled texture into a single-sample screen results in a GL_INVALID_OPERATION.)
Should there be a warning if blitting is not possible?
  • Loading branch information
LukasRuppert committed Nov 4, 2022
1 parent ddfa84a commit 6c85fd3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/renderpass_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,13 @@ void RenderPass::blit_to(const Vector2i &src_offset,
if (screen) {
target_id = 0;
what = GL_COLOR_BUFFER_BIT;
if (screen->has_depth_buffer() && m_targets[0])
// blit the depth buffer (only possible if number of samples is equal)
const Texture* depth_buffer = dynamic_cast<Texture*>(m_targets[0].get());
if (screen->has_depth_buffer() && depth_buffer && depth_buffer->samples() == 1)
what |= GL_DEPTH_BUFFER_BIT;
if (screen->has_stencil_buffer() && m_targets[1])
// blit the stencil buffer (only possible if number of samples is equal)
const Texture* stencil_buffer = dynamic_cast<Texture*>(m_targets[1].get());
if (screen->has_stencil_buffer() && stencil_buffer && stencil_buffer->samples() == 1)
what |= GL_STENCIL_BUFFER_BIT;
} else if (rp) {
target_id = rp->framebuffer_handle();
Expand Down

0 comments on commit 6c85fd3

Please sign in to comment.