BlitFramebuffer clarification

Hi,
the following use case:

FBO0 (2 attachments)

  • color0 multisampled RGBA
  • depth stencil

FBO1 (1 color attachment)

  • color0 RGBA

When using glBlitFramebuffer to resolve the multisample texture to a non-multisample texture i am doing the following:

FBO0 read framebuffer
FBO1 draw framebuffer


    math::vec2ui min_drawable_region = math::min(in_draw_buffer->drawable_region(),
                                                 in_read_buffer->drawable_region());

    glBlitFramebuffer(0, 0, min_drawable_region.x, min_drawable_region.y,
                      0, 0, min_drawable_region.x, min_drawable_region.y,
                      GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
                      GL_NEAREST);

According to the spec chapter 4.3.2:

If a buffer is specified in mask and does not exist in both the read and draw framebuffers, the corresponding bit is silently ignored.

Calling BlitFramebuffer will result in an INVALID_OPERATION error if mask includes DEPTH_BUFFER_BIT or STENCIL_BUFFER_BIT, and the source and destination depth and stencil buffer formats do not match.

Now i expect the blit operation to work and silently ignore the depth-stencil buffer in FBO0. The spec says it is ignored when both buffers do not contain a depth or stencil attachment, but does not clarify what happens if only one is missing the attachment.

I am asking this because on Nvidia drivers this works and on ATi drivers i get a invalid operation error.

Another thing i noticed in the spec in the same chapter:

If the read framebuffer is layered (see section 4.4.7), pixel values are read from layer zero. If the draw framebuffer is layered, pixel values are written to layer zero. If both read and draw framebuffers are layered, the blit operation is still performed only on layer zero.

Now when trying to implement single pass render to cube map using a multisampled layered target, how to i resolve the layers without rendering a full screen quad and doing the resolve in a shader by hand for each layer into the layerd non-multisample buffer. I think this is a limitation which could be loosened by allowing to select the layer for the source and destination of the blit.

-chris

Now when trying to implement single pass render to cube map using a multisampled layered target, how to i resolve the layers without rendering a full screen quad and doing the resolve in a shader by hand for each layer into the layerd non-multisample buffer.

Just because it’s a cubemap doesn’t mean you have to bind it as a layered texture. You can bind each face of a cubemap as though it were a 2D texture. Then do your blit from those.

it seems unnecessary overhead to have one fbo with the cubemap bound layered for one-pass-rendering and one fbo with the cubemap bound to separate color attachments for the blit, why not make the targeted resource selectable (i.e. attachment X, layer Y, miplevel Z or something similar).