nCine::RHI::GS::GsRenderTarget class

Off-screen render target of the GS backend (aliased as RHI::RenderTarget).

Holds the color textures the rasterizer writes into (addressed by attachment index) and an optional depth/stencil (ignored for 2D). BindDraw() records the target on the device, which points FRAME.FBP at the attachment's pages for the following clears and draws - on the GS switching render target really is nothing more than that.

The pages themselves are allocated by the attached texture (see GsTexture::SetRenderTarget()) out of the layout's render-target reserve rather than the streaming cache, because a render target has no host copy to be rebuilt from and so must never be evicted.

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

GsRenderTarget()
~GsRenderTarget()
GsRenderTarget(const GsRenderTarget&) deleted

Public functions

auto operator=(const GsRenderTarget&) -> GsRenderTarget& deleted
void AttachColorTexture(GsTexture& 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 - the GS backend is 2D).
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 true if 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 -> GsTexture*
Returns the texture attached at the given color attachment index, or nullptr.