multisampled FBO depth/stencil and OpenGL specs

1.8k views Asked by At

the OpenGL 4.2 specs (section 3.3.1) clearly states that:

Because each sample includes color, depth, and stencil information, the color (including texture operation), depth, and stencil functions perform equivalently to the single-sample mode. An additional buffer, called the multisample buffer, is added to the framebuffer. Pixel sample values, including color, depth, and stencil values, are stored in this buffer. Samples contain separate color values for each fragment color. When the framebuffer includes a multisample buffer, it does not include depth or stencil buffers , even if the multisample buffer does not store depth or stencil values. Color buffers do coexist with the multisample buffer, however.

However, if I need depth/stencil test I have to setup a depth_stencil multisampled renderbuffer.

Does this go against the specs or am I missing something?

1

There are 1 answers

4
Nicol Bolas On BEST ANSWER

Well, let's see. Section 4.4.4 states:

A framebuffer object is said to be framebuffer complete if all of its attached images, and all framebuffer parameters required to utilize the framebuffer for rendering and reading, are consistently defined and meet the requirements defined below. The rules of framebuffer completeness are dependent on the properties of the attached images, and on certain implementation-dependent restrictions.

Among the many rules mentioned "below":

The value of RENDERBUFFER_SAMPLES is the same for all attached render-buffers; the value of TEXTURE_SAMPLES is the same for all attached tex-tures; and, if the attached images are a mix of renderbuffers and textures, the value of RENDERBUFFER_SAMPLES matches the value of TEXTURE_-SAMPLES.

So if your depth/stencil buffer is not multisampled while your color buffer is multisampled, then your FBO will not be complete. And you cannot render to an incomplete framebuffer object.

So yes, you need to not only make sure that they are multisampled, they must use the same number of samples.