nCine::RHI::GXM::GxmRenderTarget class

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

Records the colour texture the following scene renders into and owns the SceGxmRenderTarget that describes how that surface is tiled. BindDraw() records the target on the device, which closes the scene in progress and opens a new one over this surface (sceGxm has no "switch the framebuffer" operation - a scene is a pass over one surface).

One colour attachment.** sceGxm binds a single colour surface per scene, so unlike the desktop backends there is no multi-attachment case to bound: the published MAX_COLOR_ATTACHMENTS is 1, which is also all the render pipeline uses (every off-screen pass here is a single-target one).

No depth storage.** The engine is a 2D renderer that never needs a depth buffer's contents to survive a pass, and a tile-based architecture gives depth testing within a scene from the on-chip tile buffer for free. Every scene therefore shares the one panel-sized depth/stencil surface the device allocates, rather than each target carrying its own - the surface is only ever a scratch area, and its stride covers any target the pipeline creates.

Public static variables

static std::uint32_t MaxColorAttachments constexpr
Number of colour attachments a target can carry (see the class documentation).

Public static functions

static void UnbindDraw()
Unbinds any render target from the device.

Constructors, destructors, conversion operators

GxmRenderTarget()
~GxmRenderTarget()
GxmRenderTarget(const GxmRenderTarget&) deleted

Public functions

auto operator=(const GxmRenderTarget&) -> GxmRenderTarget& deleted
void AttachColorTexture(GxmTexture& texture, std::uint32_t index)
Attaches a texture as the colour attachment with the given index.
void DetachColorTexture(std::uint32_t index)
Detaches any texture from the colour 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, see the class documentation).
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 colour attachments enabled for drawing.
auto IsStatusComplete() -> bool
Returns true if the target has a usable colour attachment 0.
void InvalidateDepthStencil(DepthStencilFormat format)
Hints that the depth/stencil contents are no longer needed (no-op: they are never stored).
void SetObjectLabel(StringView label)
Sets a debug label for the render target (ignored).
auto GetColorTexture(std::uint32_t index) const -> GxmTexture*
Returns the texture attached at the given colour attachment index, or nullptr.
auto GetNumDrawBuffers() const -> std::uint32_t
Returns the number of colour attachments enabled for drawing (see SetDrawBuffers()).
auto GetSceneTarget(SceGxmRenderTarget*& renderTarget, SceGxmColorSurface*& colorSurface, SceGxmSyncObject*& syncObject, std::int32_t& width, std::int32_t& height) -> bool
Returns the sceGxm render target, colour surface and sync object a scene over this target begins with.

Function documentation

bool nCine::RHI::GXM::GxmRenderTarget::GetSceneTarget(SceGxmRenderTarget*& renderTarget, SceGxmColorSurface*& colorSurface, SceGxmSyncObject*& syncObject, std::int32_t& width, std::int32_t& height)

Returns the sceGxm render target, colour surface and sync object a scene over this target begins with.

Returns false if the target has no usable attachment.

All three are built on demand from the attached texture's GPU-visible surface, and rebuilt when the attachment or its size changes. The sync object is what serializes operations on these texels against each other. sceGxm pipelines scenes, so a scene that renders into a surface and a later one that samples it are not otherwise ordered - which is the whole reason sceGxmBeginScene() takes one, and passing nullptr (as this backend did) leaves a render-to-texture hand-off with nothing guaranteeing the write finished before the read. The display buffers have always had theirs for the same reason, against the scan-out.