<p>When the framebuffer attachment sizes differ, rendering will only happen to the smallest size supported by all attachments (i.e. a rectangle of minimal width &amp; height among all the attachments). See the <a href="https://www.khronos.org/opengl/wiki/Framebuffer_Object#Completeness_Rules" rel="nofollow noreferrer">OpenGL wiki</a></p>
<blockquote>
<p>Notice that there is no restriction based on size. The effective size of the FBO is the intersection of all of the sizes of the bound images (ie: the smallest in each dimension).</p>
</blockquote>
<p>or the <a href="https://registry.khronos.org/OpenGL/specs/gl/glspec46.core.pdf" rel="nofollow noreferrer">OpenGL specification</a>, section 9.2 <em>Binding and Managing Framebuffer Objects</em>:</p>
<blockquote>
<p>If the attachment sizes are not all identical, the results of rendering are defined only within the largest area that can fit in all of the attachments. This
area is defined as the intersection of rectangles having a lower left of (0, 0)
and an upper right of (width, height) for each attachment. Contents of attachments outside this area are undefined after execution of a rendering command (as defined in section 2.4).</p>
</blockquote>
<p>So, if the stencil buffer is smaller than the color attachments, it will simply limit the rendering area to its size.</p>

CC BY-SA 4.0
2023-10-08T05:23:46.840Z
Can you point out or provide a citation on exact rule from which this implied? I've read your link, but it's not obvious to me why it would be a violation.
simd
CC BY-SA 4.0
2023-10-08T08:42:32.040Z
@simd I'm terribly sorry, apparently this answer is completely wrong :) I'll update it shortly.
lisyarus
CC BY-SA 4.0
2023-10-08T09:10:13.347Z
Thank you! It's strange that it's not simply an error. I can't image this intersection behaviour ever be useful.
simd
CC BY-SA 4.0
2023-10-07T11:22:02.103Z
2023-10-08T08:48:30.433Z
2023-10-08T08:48:30.433Z
lisyarus
<p>I may not need as precise pixel-perfect stenciling as my render target during stencil tested render pass. I could be okay with stencil test happening at half or quarter of resolution to save bandwidth, but is it even an option, or the way stencil test designed is to always work on matching dimensions?</p>

<opengl><fragment-shader><metal><stencil-buffer><stencil-test>
Are stencil buffer dimensions required to match render target dimensions?
simd
# Are stencil buffer dimensions required to match render target dimensions?

(Asked by: username_0 on 2023-10-07)

I may not need as precise pixel-perfect stenciling as my render target during stencil tested render pass. I could be okay with stencil test happening at half or quarter of resolution to save bandwidth, but is it even an option, or the way stencil test designed is to always work on matching dimensions?

**Tags:** opengl, fragment-shader, metal, stencil-buffer, stencil-test


---

## 1 answers

### Answer by username_1 on 2023-10-07. Score: 2 | Accepted answer

When the framebuffer attachment sizes differ, rendering will only happen to the smallest size supported by all attachments (i.e. a rectangle of minimal width & height among all the attachments). See the [OpenGL wiki](https://www.khronos.org/opengl/wiki/Framebuffer_Object#Completeness_Rules)

> Notice that there is no restriction based on size. The effective size of the FBO is the intersection of all of the sizes of the bound images (ie: the smallest in each dimension).

or the [OpenGL specification](https://registry.khronos.org/OpenGL/specs/gl/glspec46.core.pdf), section 9.2 *Binding and Managing Framebuffer Objects*:

> If the attachment sizes are not all identical, the results of rendering are defined only within the largest area that can fit in all of the attachments. This
> area is defined as the intersection of rectangles having a lower left of (0, 0)
> and an upper right of (width, height) for each attachment. Contents of attachments outside this area are undefined after execution of a rendering command (as defined in section 2.4).

So, if the stencil buffer is smaller than the color attachments, it will simply limit the rendering area to its size.

> **Comments:**
> **username_0**: Can you point out or provide a citation on exact rule from which this implied? I've read your link, but it's not obvious to me why it would be a violation.  
> **username_1**: @username_0 I'm terribly sorry, apparently this answer is completely wrong :) I'll update it shortly.  
> **username_0**: Thank you! It's strange that it's not simply an error. I can't image this intersection behaviour ever be useful.  

---

