Skip to content

Commit 3e7b788

Browse files
committed
Disable blitting depth or stencil buffers to the screen if multisampling 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?
1 parent b17b828 commit 3e7b788

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/renderpass_gl.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,13 @@ void RenderPass::blit_to(const Vector2i &src_offset,
358358
if (screen) {
359359
target_id = 0;
360360
what = GL_COLOR_BUFFER_BIT;
361-
if (screen->has_depth_buffer() && m_targets[0])
361+
// blit the depth buffer (only possible if number of samples is equal)
362+
const Texture* depth_buffer = dynamic_cast<Texture*>(m_targets[0].get());
363+
if (screen->has_depth_buffer() && depth_buffer && depth_buffer->samples() == 1)
362364
what |= GL_DEPTH_BUFFER_BIT;
363-
if (screen->has_stencil_buffer() && m_targets[1])
365+
// blit the stencil buffer (only possible if number of samples is equal)
366+
const Texture* stencil_buffer = dynamic_cast<Texture*>(m_targets[1].get());
367+
if (screen->has_stencil_buffer() && stencil_buffer && stencil_buffer->samples() == 1)
364368
what |= GL_STENCIL_BUFFER_BIT;
365369
} else if (rp) {
366370
target_id = rp->framebuffer_handle();

0 commit comments

Comments
 (0)