Present in a window¶
Use SnAPI.Core to create and pump the window. The renderer consumes the
presentation target exported by the host. Start with
RendererConfig::DefaultPresentation(), then use
runtime.Presentation() to manage the surface and inspect its active
presentation profile. Match that profile when preparing the terminal so the
color format and transfer intent agree with the actual output.
Prepare OpenPBR for the current scene¶
This function excerpt accepts a live scene, its first view, a presentation profile, and the host’s preparation routes. It also shows the live API for disabling one already admitted reflection provider.
#include <utility>
#include <Renderer/OpenPBRProfile/OpenPBRProfile.h>
#include <Renderer/Runtime/RendererRuntime.h>
namespace SnAPI::Renderer::Docs
{
// The caller owns and drives the Core preparation routes through completion.
Core::TTask<TResult<OpenPBRProfileBundle>> PrepareRaster(
RendererRuntime& runtime, RenderScene& scene, RenderView view,
SurfacePresentationProfile presentation, PassResourcePreparationContext context)
{
OpenPBRProfileOptions options{};
options.PresentationProfile = presentation;
options.EnableAtmosphere = false;
options.EnableScreenSpaceReflections = true;
options.EnableReflectionDenoising = true;
co_return co_await OpenPBRProfile::CreateAsync(
runtime, scene, view, std::move(options), std::move(context));
}
TResult<void> DisableScreenReflections(const OpenPBRProfileBundle& bundle)
{
// Changes the permitted providers in already prepared passes.
OpenPBRReflectionProviderSettings settings{};
settings.ScreenSpace = false;
return OpenPBRProfile::SetReflectionProviders(bundle, settings);
}
}
Start preparation with no open host frame. Wait for the result before
submitting its terminal, or continue submitting an older ready terminal while
a separate replacement builds. Supply the returned profile handle and output
resource from the bundle when submitting through RenderSceneToSurface.
The example opts out of the atmosphere background for an indoor view. Actual
environment probe contribution is controlled separately.
Run the host loop¶
Pump Core and obtain the current drawable extent. A minimized or resized window can temporarily prevent normal surface admission.
Open a frame with
BeginFrame, the nonblockingTryBeginFrame, or an applicable async admission route. Handle admission before recording.Submit the view/scene with the live surface and ready terminal. A deferred submission is expected during conditions such as unavailable presentation.
Close an admitted frame. Use the actual settings, capabilities, and presentation state when deciding whether the surface or graph needs refresh. Prepare a replacement outside frame recording if its graph creation-time contract has changed.
On shutdown, stop admitting submissions, join preparation, observe completion, and retire resources in dependency order. Keep the Core presentation target alive while the renderer surface borrows it.
For a compiled complete host example, build SnAPI.Renderer.New.Example
or the SnAPI.Renderer.OpenPBRReference sample from
Build and integration. See Frame lifecycle and GPU completion for completion and
Resolution domains and upscaling for the three resolution domains.