Render to a texture¶
Offscreen rendering uses an ordinary graph and view. Create a target through
runtime.Presentation().CreateRenderTarget, then prepare the profile for an
output compatible with that target. A profile can also produce intermediates
owned by the graph. Only expose the image that the graph has declared as the
selected terminal.
Submit a prepared target¶
This function excerpt assumes the caller owns a compatible target and a prepared graph. The returned completion point is the caller’s authority for safe readback or reuse.
#include <Renderer/Runtime/RendererRuntime.h>
namespace SnAPI::Renderer::Docs
{
// Target and terminal belong to an existing prepared runtime configuration.
TResult<GpuCompletionPoint> SubmitPreparedTarget(
RendererRuntime& runtime, RenderTargetHandle target, RenderView view,
RenderProfileHandle profile, ResourceName terminal)
{
if (auto began = runtime.BeginFrame({}); began.Failed())
{
return began.Error();
}
auto submitted = runtime.SubmitViewToTarget({
.Target = target,
.View = view,
.Profile = profile,
.FrameGraphOutputResourceName = terminal,
});
// Close the host frame on both submission paths. The completion point
// still governs when the caller may read or retire submitted resources.
auto ended = runtime.EndFrame();
if (submitted.Failed())
{
return submitted.Error();
}
if (ended.Failed())
{
return ended.Error();
}
return submitted.Value();
}
}
SubmitViewToTarget reports accepted work. EndFrame closes the host
scope. To use the image on the CPU, join GPU completion with the runtime
before using a compatible readback path. External images and targets remain
owned by their creator. Retire the target through the presentation system
after its last GPU use.
Use Views, coordinate spaces, and temporal state to keep independent histories when rendering several cameras, editor thumbnails, or probe faces.