Framebuffers are device resources which control the set of textures that render commands draw into. Framebuffers have zero-or-more color attachments, and zero-or-one depth attachment. They are created with a FramebufferDescription.
To be used as the depth target of a Framebuffer, it must have been created with the DepthStencil flag. Additionally, only Textures created using the R16_UNorm, R32_Float, D24_UNorm_S8_UInt, and D32_Float_S8_UInt PixelFormats are able to be used as depth targets. The latter two formats also include 8 bits of stencil buffer space.
All target textures used to create a Framebuffer must have identical dimensions and multisample counts.
Before any Draw command can be issued, there must be an active Framebuffer set using the CommandList.SetFramebuffer method. Additionally, the current Pipeline and Framebuffer must be "compatible". A Pipeline is compatible with a Framebuffer if:
- It has the same number of outputs (color and depth)
- The format of those outputs all match.
- The sample count of all outputs match.
It is possible to create a multisampled Framebuffer by using multisampled target textures. All target textures must have the same multisample count. In order to resolve the multisampled target textures into a single-sampled texture (in order to sample or present the image, for example), the CommandList.ResolveTexture method should be used.