MetalRenderTarget class
Off-screen render target of the Metal backend (aliased as RHI::RenderTarget).
Records the color textures addressed by attachment index and an optional depth/stencil (ignored for 2D). BindDraw() records the target on the device so the following clears and draws are associated with its color attachments. Metal has no framebuffer object: the device builds an MTL::RenderPassDescriptor over every contiguously attached color texture whenever it opens a render command encoder for the draws routed here (so multiple render targets work).
Public static variables
-
static std::
uint32_t MaxColorAttachments constexpr
Public static functions
- static void UnbindDraw()
- Unbinds any render target from the device.
Constructors, destructors, conversion operators
- MetalRenderTarget()
- ~MetalRenderTarget()
- MetalRenderTarget(const MetalRenderTarget&) deleted
Public functions
- auto operator=(const MetalRenderTarget&) -> MetalRenderTarget& deleted
-
void AttachColorTexture(MetalTexture& texture,
std::
uint32_t index) - Attaches a texture as the color attachment with the given index.
-
void DetachColorTexture(std::
uint32_t index) - Detaches any texture from the color attachment with the given index.
-
void AttachDepthStencil(DepthStencilFormat format,
std::
int32_t width, std:: int32_t height) - Records a depth/stencil buffer (no storage is created).
- void DetachDepthStencil(DepthStencilFormat format)
- Clears the recorded depth/stencil buffer.
- void BindDraw()
- Binds the render target as the current draw target on the device.
-
auto SetDrawBuffers(std::
uint32_t numColorAttachments) -> bool - Sets the number of color attachments enabled for drawing.
- auto IsStatusComplete() -> bool
- Returns
trueif the target has a usable color attachment 0. - void InvalidateDepthStencil(DepthStencilFormat format)
- Hints that the depth/stencil contents are no longer needed (no-op).
- void SetObjectLabel(StringView label)
- Sets a debug label for the render target (ignored).
-
auto GetColorTexture(std::
uint32_t index) const -> MetalTexture* - Returns the texture attached at the given color attachment index, or
nullptr. -
auto GetAttachedCount() const -> std::
uint32_t - Returns the number of contiguously attached color textures starting from attachment 0 (the render pass attachment count).
-
auto GetNumDrawBuffers() const -> std::
uint32_t - Returns the number of color attachments enabled for drawing (see SetDrawBuffers()).
-
auto GetAttachmentGeneration() const -> std::
uint32_t - Monotonic counter bumped on every attachment change (the device's open render pass is invalidated when it changes).