Skip to content

ludus::graphics::renderer::RasterViewport

Ludus Wiki · API overview · Browse API

Class

Interactive raster output for the current extracted World snapshot and camera. Uses ordinary PrepareView/DrawView and authored material lighting, with no compute/ray capability, reference capture, CPU pixel readback or accumulation. Raster lighting does not infer indirect illumination from emissive geometry. All methods run on the RHI owner thread, between frames. The Renderer and device must outlive this object, and Renderer::Reset must follow Reset here. Qt import requires the exact logical device and a separate RHI interop lease; complete foreign sampling and release that lease before Release(frame).

Declared in modules/graphics/renderer/include/ludus/graphics/renderer/viewport.hpp

#include <ludus/graphics/renderer/viewport.hpp>
class ludus::graphics::renderer::RasterViewport final

Methods

RasterViewport

ludus::graphics::renderer::RasterViewport::RasterViewport() noexcept
Construct an empty viewport; performs no GPU work.

Declared in modules/graphics/renderer/include/ludus/graphics/renderer/viewport.hpp

~RasterViewport

ludus::graphics::renderer::RasterViewport::~RasterViewport() noexcept
Reset owned resources; see Reset's consumer lifetime precondition.

Declared in modules/graphics/renderer/include/ludus/graphics/renderer/viewport.hpp

Initialize

rhi::RasterStatus ludus::graphics::renderer::RasterViewport::Initialize(Renderer &renderer, rhi::DeviceHandle device, ludus::foundation::uint32 width, ludus::foundation::uint32 height, ludus::foundation::float32 exposure=1, ViewportColorMode colorMode=ViewportColorMode::PreferHdr, bool shouldPresentToSurface=false, ToneCurve toneCurve=ToneCurve::Reinhard, bool hasBackdrop=false, SpatialAntialiasing antialiasing=SpatialAntialiasing::Off) noexcept
Prepare a linear scene target, two display targets and their presentation. Renderer lighting/views must be Ready. Positive dimensions are physical pixels; exposure follows LightingOutput. Output is tone-mapped/sRGB-encoded RGB; the consumer preserves the display values without a second encoding. Ready/Pending owns setup. Color mode chooses the linear scene target; PreferHdr cannot draw unlit textured material programs into an HDR attachment. Use Linear8 for those snapshots.
ParameterDescription
renderer
Borrowed initialized renderer, which must outlive this viewport.
device
Borrowed device used by renderer, on its owner thread.
width
Positive output width in physical pixels.
height
Positive output height in physical pixels.
exposure
Finite exposure multiplier admitted by LightingOutput.
colorMode
Linear attachment policy for the selected material programs.
shouldPresentToSurface
Also composite the encoded display image to the acquired surface in the same submission, without CPU transfer or a second color encoding. The surface extent must equal width/height; default false leaves surface presentation to the consumer.
toneCurve
Display curve of the presentation. The Editor uses PbrNeutral; its debug shading views are pre-compensated for that curve (MaterialDebugView), so use another curve only without debug views.
hasBackdrop
Show the editor backdrop gradient behind uncovered scene pixels (LightingOutput::HasBackdrop); the scene pass then clears alpha to zero. Default false keeps the flat black background.
antialiasing
Spatial antialiasing of the display image (LightingOutput::Antialiasing). Default Off. Failure leaves this empty. Resize by preparing a separate candidate, then retiring this instance after its producers/consumers finish.

Related types: Renderer · ludus::foundation::float32 · ludus::foundation::uint32 · SpatialAntialiasing · ToneCurve · ViewportColorMode · rhi::RasterStatus · rhi::DeviceHandle

Declared in modules/graphics/renderer/include/ludus/graphics/renderer/viewport.hpp

Poll

rhi::RasterStatus ludus::graphics::renderer::RasterViewport::Poll() noexcept
Poll setup/producer completion and publish a pending view only when Ready. A failed candidate is discarded, preserving the prior drawable view. Returns that failure once; a later poll may use the preserved view. No waiting or GPU-memory readback.

Related types: rhi::RasterStatus

Declared in modules/graphics/renderer/include/ludus/graphics/renderer/viewport.hpp

Update

rhi::RasterStatus ludus::graphics::renderer::RasterViewport::Update(Snapshot snapshot, const ViewDescription &view, ViewReport &report) noexcept
Replace the current extracted snapshot/camera atomically. Snapshot contents are retained by a prepared view; the caller may release the snapshot after Ready/Pending. Pending retains the prior drawable view until Poll observes successful preparation; another accepted Update supersedes the pending candidate. Report describes the accepted candidate (including Pending), not the last presented image. Rejection preserves the prior view, pending candidate and report. No PT/BVH setup.

Related types: rhi::RasterStatus · Snapshot · ViewDescription · ViewReport

Declared in modules/graphics/renderer/include/ludus/graphics/renderer/viewport.hpp

SetOverlay

rhi::RasterStatus ludus::graphics::renderer::RasterViewport::SetOverlay(OverlayRenderer *overlaysOrNull, PreparedOverlay overlay) noexcept
Compose prepared debug geometry into every later Render, before display conversion. The overlay draws into the linear scene target after the scene and depth-tests each command (OverlayDepth) against that frame's own scene depth, which the scene pass then keeps; OverlayDepth::Always draws through geometry. Overlay colors therefore pass through the same exposure and display encoding as the scene. Between frames only.
ParameterDescription
overlaysOrNull
Overlay renderer on this viewport's device, borrowed until replaced, cleared or Reset. Null clears the overlay, and overlay is then ignored.
overlay
A version of overlaysOrNull whose GetStatus is Ready. The caller keeps it unreleased while set; it may Release a replaced version once this call returns, because accepted frames retain their resources.

Returns

Ready once set or cleared. InvalidState before Initialize or while this viewport's frame is open; the overlay's GetStatus failure (such as Pending) when not Ready; Unsupported when the scene target is not linear RGBA8 (an HDR attachment; initialize with ViewportColorMode::Linear8). Failure preserves the previous overlay.

Related types: OverlayRenderer · rhi::RasterStatus · PreparedOverlay

Declared in modules/graphics/renderer/include/ludus/graphics/renderer/viewport.hpp

Render

rhi::RasterStatus ludus::graphics::renderer::RasterViewport::Render(rhi::SurfaceHandle surface, rhi::SubmissionToken &completion) noexcept
Render the latest Ready view into an unleased display image. Closed frame required; completion starts null. NotReady applies producer/consumer backpressure. A failure may still publish a token for accepted partial work. If EndFrame reservation fails with a frame still open, this object retains recording ownership; retry Render before any other frame/setup/reset call.

Related types: rhi::RasterStatus · rhi::SubmissionToken · rhi::SurfaceHandle

Declared in modules/graphics/renderer/include/ludus/graphics/renderer/viewport.hpp

Acquire

rhi::RasterStatus ludus::graphics::renderer::RasterViewport::Acquire(ViewportFrame &inoutFrame, ViewportImage &outImage) noexcept
Acquire the latest completed image. Null frame required. Ready publishes both outputs; rejection preserves them. Acquired images are never overwritten.

Related types: rhi::RasterStatus · ViewportFrame · ViewportImage

Declared in modules/graphics/renderer/include/ludus/graphics/renderer/viewport.hpp

Release

rhi::RasterStatus ludus::graphics::renderer::RasterViewport::Release(ViewportFrame &inoutFrame) noexcept
Return a lease after all foreign GPU consumers and RHI interop leases finish. Ready clears identity; stale/foreign rejection preserves it.

Related types: rhi::RasterStatus · ViewportFrame

Declared in modules/graphics/renderer/include/ludus/graphics/renderer/viewport.hpp

Reset

void ludus::graphics::renderer::RasterViewport::Reset() noexcept
Invalidate all identities and detach resources; accepted RHI work retires independently. External consumers must hold RHI interop backing leases. No open frame; Renderer/device must still be alive. No waiting/readback.

Declared in modules/graphics/renderer/include/ludus/graphics/renderer/viewport.hpp