Engine tour

One frame, step by step

A frame is beginFrame, some passes, and endFrame. By default all passes go into one command buffer, and the frame has one submit. With async compute on, the frame is a few batches on two queues, each with its own command buffer and submit. The CPU records the next frame while the GPU still runs the last one, so there are two frame slots. A timeline fence per queue tells the CPU when a slot is free again.

This is stop 2 of the engine tour, after the big picture. It walks one frame of RASM and shows where each job runs. The ideas under it have their own guides: frames in flight, the swapchain, barriers and layouts, and indirect draws.

CPU work GPU work GPU buffer shader entry point

In short

  • Renderer::render runs a render graph (ViewGraph::render): beginFrame, the scene passes from addScenePasses into a 16-bit float target, the Tone Map pass from addToneMapPass into the swapchain, with EngineConfig::ui the UI pass from addUiPass over it, endFrame. With a list of views, each view has its own target and tone map (Many views of one scene).
  • The scene passes are Cull 1, Scene 1, Hi-Z, Cull 2, Scene 2 (only Cull and Scene without occlusion culling), then Transparent, which draws the see-through materials back to front. The graph puts the barriers between them.
  • frameCount is the slot (0 or 1), not a frame counter. MAX_FRAMES_IN_FLIGHT = 2.
  • Each graphics submit signals the next value of frameFence, and each compute submit the next value of computeFence. Before a slot is reused, beginFrame waits for the values its last submits signaled.
  • With EngineConfig::asyncCompute, Cull 1, Hi-Z and Cull 2 run on the compute queue, and the frame is four batches, submitted together at the end (below). It is off by default.
  • Everything that rewrites a slot's buffers runs right after that wait: frame stats, the overlay text or the UI (buildUi, which also runs the application's UI callback), syncGpuScene.
  • beginFrame returns false to skip a frame (minimized, swapchain out of date). Then record nothing and do not call endFrame.

1Three ways to run a frame

render(scene, camera) RenderGraph::execute Your own frame ViewGraph::render first frame, or new views or sizes: a new graph + addScenePasses + addToneMapPass graph.execute(camera) beginFrame(camera) each pass in sorted order, after the barriers and waits it needs endFrame() if (!beginFrame) skip your passes: beginPass, your own draws, endPass endFrame()
All three use the same frame functions. render keeps one graph and builds it again only when a view (scene, camera, output, settings) or a view's size in pixels changes; before that it polls the events and recreates a resized swapchain, so the views take the new size in the same frame. The stepper below walks that frame. Only graph passes draw the scene: an app with its own graph calls addScenePasses and addToneMapPass itself (render graphs).

2One frame, step by step

This is frame 7 of an app that calls render(scene, camera) with occlusion culling on and async compute off (the defaults). Frame 7 uses slot 0. Click through the steps (or use the arrow keys). The strip at the top of each picture shows where we are.

1. Input and finished loads

input · loads skip checks fence wait stats · sync acquire record submit · present pollEvents (once per frame) deltaTime = fixedDeltaTime, or time since last frame (≤ 0.1 s) InputEvents: addInputEvent's + platform's W A S D, mouse drag and wheel → CameraInput then updateCamera(camera, input), unless NONE finishLoads(false) publishes loads whose copies are done meshes, then textures, in 4 MiB parts copies out at once on the transfer queue stops once LOAD_BUDGET (4 ms) is spent main-thread time load A load B: still finishes load C: next frame 4 ms 0 ms

F1 shows the stats (showStats: the RASM window with the UI, else the overlay), and F2 steps forcedLod through the LODs and back to the automatic choice (-1). Loads that end together spread over several frames. finishLoads runs before anything binds the bindless set or the geometry pool. A load is drawn once its copies are done, a frame or two after its fill, so no frame waits for copies in flight. See Streaming assets in the background and transfer queues.

2. Skip checks and resize

input · loads skip checks fence wait stats · sync acquire record submit · present minimized, or 0 × 0 pixels? resized or swapchainOutOfDate? go on to the fence wait no no yes return false (skip) yes recreateSwapchain() fails return false (skip) ok

The events come from the SDL platform and from the application's Renderer::addInputEvent, all through one path (The platform layer): quit, Esc (SDL only), F1–F3, resize, minimize, and the camera's input. While every SDL window is minimized, pollEvents waits up to 100 ms for an event (SDL_WaitEventTimeout), so skipped frames do not spin the CPU; a NATIVE application skips frames with a size of 0 (setWindowSize) and waits in its own loop. Each window is checked on its own (Renderer::updateSwapchain): a minimized one sits the frame out, and the frame is skipped only when no window can show. A failed recreation keeps the window's WindowFrame::outOfDate set, so the next frame tries again.

3. Wait until the slot is free

input · loads skip checks fence wait stats · sync acquire record submit · present frameResources[0] fenceValue = 5 (frame 5) · frameCount = 0 frameResources[1] fenceValue = 6 (frame 6) ctx.waitForFence(frameFence, 5) 0 1 2 3 4 5 6 7 8 frameFence values the GPU has reached 4: frame 5 still runs slot 0 waits for 5, then it is free frameFenceValue = 6: the last value a submit signals

beginFrame waits for frameResources[frameCount].fenceValue, and with async compute also for computeFenceValue on computeFence. Then the GPU is done with everything slot 0 used: its command buffers, its per-slot buffers, its timestamp queries. At start both slots hold 0 and the fence starts at 0, so the first waits return at once. How a timeline fence works is in Frames in flight.

4. Rewrite the slot: stats, overlay, scene

input · loads skip checks fence wait stats · sync acquire record submit · present slot 0 is free: the GPU finished frame 5, the last frame that used it updateFrameStats() reads frame 5's timestamps and the slot's cull stats buffer resets the queries, zeros counts (only while stats are measured) updateStatsOverlay() overlay text into the slot's buffer or, with the UI, buildUi(): ImGui's frame, your callback, vertices into the slot's buffers syncGpuScene() rows for entities with a ready mesh checks entities waiting for textures rebuilds dirty draw lists uploads the slot's dirty rows All three write only this slot's buffers. Doing it here is safe: the GPU no longer reads them.

A change made after beginFrame (for example updateTransform during the passes) reaches the GPU in the next frame. See the GPU scene tables (stop 3), GPU timing for the stats and bitmap text for the overlay, immediate-mode UI for the UI. The UI is built before syncGpuScene, so what its callback changes reaches the GPU in this frame.

5. Acquire a swapchain image

input · loads skip checks fence wait stats · sync acquire record submit · present acquireNextImage( imageIdx) OK go on SUBOPTIMAL go on; set swapchainOutOfDate, recreate next frame OUT_OF_DATE set swapchainOutOfDate, return false FAILURE return false SUBOPTIMAL still renders: the image is acquired and its semaphore will be signaled.

Acquire comes after the scene sync, so a skip here wastes nothing: the uploads it queued go out with the next submit. The swapchain picks its own acquire semaphore; see The swapchain and presenting.

6. Start recording, then Cull 1

input · loads skip checks fence wait stats · sync acquire record submit · present Frame Command Buffer 0 begin ts Frame history · bake barrier G|C→C ts Cull 1 countMain barrier C→C writeMain clusters ts end beginFrame "Cull 1" pass (compute) prepareSceneView(view), on the CPU first writes the view's SceneData: camera, frustum planes, light counts, addresses grows the slot's visible-draw and Hi-Z buffers; makes the pipelines once

history · bake: clearNewHistory clears new copies of history render targets (none in this app). Then recordEnvironmentBakes records the compute work that prepares image-based lighting, before any pass: the BRDF LUT in the engine's first frame, and an environment whose image has just loaded (Image-based lighting). Most frames have none.
barrier G|C→C: from the graph (G = graphics, C = compute). Last frame's Scene 2 read what Cull 1 writes.
ts: a GPU timestamp, only while frame stats are measured. Every pass gets a pair, named after the pass.

beginFrame acquires an image from every window that can show (WindowFrame::acquired, rendered false) and opens the graphics batch (Renderer::useQueue), which begins the slot's command buffer. Each command buffer has its own pool, and begin resets it. That is safe because of the wait in step 3. Then RenderGraph::execute runs the passes in its order. Before each pass it records the barriers that the pass's declared reads and writes need, outside any render pass. With async compute, Cull 1 records into a compute batch instead, and the graph adds waits between the queues (below).

Cull 1 is a compute pass, so its dispatches sit between render passes, in the same command buffer. countMain tests each draw against the frustum and last frame's visibility flags, and writeMain packs the visible ones into the view's visible-draw list. The COMPUTE → COMPUTE barrier between them is inside the pass. What they do is in Frustum culling, LOD selection and Stream compaction. Then, since this scene has a point light with a range, recordLightClusters sorts it into the view's clusters: three dispatches under a GPU timer of their own, Light Clusters (Clustered lighting).

7. Scene 1: the early draws

input · loads skip checks fence wait stats · sync acquire record submit · present graph barrier, then beginPass("Scene 1", ops) barrier C→G ts Scene 1 image → COLOR depth → DEPTH beginRendering (clear) viewport scissor cull NONE drawSceneView(view), then endPass() bind pipeline bind set bind index cull BACK push draw indirect count … cull NONE endRendering ts end once per run of equal cull mode sceneData[frameCount] the view's SceneData (prepareSceneView) its address goes in the push constant

barrier C→G: from the graph. Cull 1 wrote the visible draws and counts these draws read.
image and depth of scene_hdr, the 16-bit float target ViewGraph makes, start from UNKNOWN (discard): Scene 1 is the target's first pass, so it clears both.

A barrier call names only the new usage: RenderContext remembers the layout each texture is in (TextureStates). With discard set, as here, the old contents are dropped and the barrier starts from UNKNOWN. acquireNextImage marks the acquired swapchain image UNKNOWN too, and its barrier, in the Tone Map pass, waits at color output, after the acquire. Barriers must be recorded outside a render pass. See GPU synchronization.

The draw lists and runs drawSceneView uses are in stop 3. The ideas: indirect draws, device addresses for the push constant, vertex pulling and the uber shader for what each draw runs.

8. Hi-Z, Cull 2, Scene 2: occlusion culling

input · loads skip checks fence wait stats · sync acquire record submit · present "Hi-Z" pass (compute) barrier C→C depth → SAMPLED ts Hi-Z hizMain + barrier C→C, per level ts end "Cull 2" pass (compute) barrier G|C→C ts Cull 2 late countMain barrier C→C late writeMain ts end "Scene 2" pass (graphics) barrier C→G ts Scene 2 image → COLOR depth → DEPTH beginRendering (load) late draws endRendering ts end

depth → SAMPLED: Hi-Z declares readDepth of the target, so the graph makes Scene 1 store its depth.
hizMain builds one level per dispatch: level 0 from the depth of the early draws, each next one from the one before.
late countMain: seen = in the frustum and not occluded. It writes the visibility flags and keeps what Scene 1 missed.
Scene 2 loads color and depth (no discard), and draws the sky last. Hi-Z, Cull 2 and Scene 2 dispatch and draw nothing when the view has no Hi-Z.
When the scene has see-through (BLEND) materials, Cull 2 also sorts them back to front after writeMain (sorting on the GPU), and a Transparent pass after Scene 2 draws them with blending on and depth writes off (transparency). This app has none, so Transparent only begins and ends its rendering.

Each step is a pass of its own, so no dispatch ever sits inside a render pass. The late culling rewrites the same visible-draw list and counts that Scene 1 read, so the graph's barrier before Cull 2 waits for the early draws. Cull 1 reads the visibility flags that this pass wrote last frame (readPrevious). Without occlusionCulling, addScenePasses adds only Cull and Scene, and this step is not there. Why two passes, and how a Hi-Z works, is in Occlusion culling with Hi-Z.

9. Tone Map, then endFrame closes the command buffer

input · loads skip checks fence wait stats · sync acquire record submit · present "Tone Map" endFrame() … Transp. exposure, AgX UI / overlay readbacks barrier: → PRESENT_SRC barrier C→H ts Frame end close

Tone Map: the graph's last pass. The graph moves scene_hdr's color to SAMPLED; the pass draws one triangle over the swapchain image (UNKNOWN → COLOR_ATTACHMENT) that multiplies by the camera's exposure and applies AgX. See Tone mapping.
UI / overlay: with EngineConfig::ui, the graph's UI pass draws ImGui's windows over the image, through the swapchain's UNORM view where the device has one (Immediate-mode UI); a graph without it gets the pass from endFrame. Without the UI, the stats overlay, only when it is shown (F1). Both draw after the tone map, so their colors are not mapped, and both load the image's color.
readbacks: the copies asked for with readFrame or readTexture since the last frame (recordReadbacks), after everything that draws, into host-readable buffers (Headless rendering and readback).
barrier → PRESENT_SRC: once per frame, the swapchain image goes COLOR_ATTACHMENT → PRESENT_SRC. A headless engine's offscreen image skips it: nothing presents it.
barrier C→H: COMPUTE → HOST. The CPU reads the cull stats after this slot's next fence wait. With a compute queue the culling runs there, and the barrier goes in its last batch instead.
No pass drew to the swapchain? endFrame first records an empty pass named "Clear", so present still works.

Present needs the image in PRESENT_SRC. A frame that only draws into render targets gets the empty "Clear" pass, so it presents the clear color. A headless engine (PlatformType::HEADLESS) does the same into its offscreen image, whose "present" does nothing. A render target pass instead leaves its color textures SAMPLED in endPass, for later passes.

10. Submit and present

input · loads skip checks fence wait stats · sync acquire record submit · present uploads.flush() submitBatches(): signal 7 queue upload copies Frame Command Buffer 0: every pass of the frame fence → 7 one submission; waits for the acquired image at color output submit succeeded frameFenceValue = 7 frameResources[0].fenceValue = 7 present(): SUBOPTIMAL or OUT_OF_DATE → swapchainOutOfDate, recreate next frame submit failed no present; fence values stay as they were the image stays acquired: the next acquire hands out the same image again a value nothing signals is never waited for

submitBatches ends the command buffer, then submits it. The upload copies go out first on the same queue, so the frame sees their data (GPU memory and uploads). A slot takes the new fence value only after a successful submit: waiting for a value that nothing signals would block forever.

11. Move to the other slot

input · loads skip checks fence wait stats · sync acquire record submit · present frameResources[0] fenceValue = 7 (frame 7) frameResources[1] fenceValue = 6 → frame 8 waits for 6 frameCount: 0 → 1 frameCount = (frameCount + 1) % MAX_FRAMES_IN_FLIGHT Then the Tracy frame mark. The slot moves even after a failed submit; a skipped frame (beginFrame false) does not move it.

Frame 8 can start at once if the GPU already reached 6. Otherwise the CPU waits in step 3 of frame 8.

With async compute: a frame of batches

With EngineConfig::asyncCompute, on a GPU with a compute queue, the steps are the same, but recording moves between two queues. A batch is one command buffer and one submit on one queue.

compute graphics Cull 1 · Scene 1 · … · Scene 2 · Tone Map 1 command buffer, 1 submit

Async compute off (the default)

One batch. Every pass is recorded into it.

compute graphics Cull 1 Scene 1 Hi-Z, Cull 2 Scene 2Tone Map 4 command buffers, 4 submits

Async compute on

Recording moves between the queues. Each move closes a batch.

A batch that cannot start drops the frame

If a batch's command buffer can't be made or begun, useQueue returns false and the frame is dropped: the graph stops, and submitBatches ends every batch and submits none.

compute graphics 1 · Cull 1 closed for Scene 1 2 · Scene 1 closed for Hi-Z 3 · Hi-Z, Cull 2 closed for Scene 2 4 · Scene 2 + Transparent, Tone Map beginFrame opens batch 2 (timer, history clear); it closes second. submitBatches(), in the order closed submit 1 · compute waits: frame N-2 only signals c+1 submit 2 · graphics waits: c+1, the image signals g+1 submit 3 · compute waits: g+1 signals c+2 submit 4 · graphics waits: c+2, all compute signals g+2, presents g, c = frameFenceValue and computeFenceValue when the frame starts. Hot arrows: the waits between the queues.
Cull 1 uses this slot's visible draws, which frame N-2 used last, so it waits only for that frame, which the fence wait in step 3 already covers. It can run next to the previous frame's Scene 2. The last graphics submit waits for all of the frame's compute work, so fenceValue covers the whole frame. Only the first graphics submit waits for the image (the swapchain). The idea: Async compute and multiple queues; how the graph picks the waits: render graphs.

Pending uploads still go out first, on the graphics queue. Their copies wait for the last compute submit, the copies flushed while recording too, and a compute submit waits for them, so a frame with uploads loses the overlap. With async compute off, or on a GPU without a compute family that has no graphics, there is one batch, as in the steps above. Async compute costs a little more than it saves on the scene passes today, so it is off by default (P11).

3Two slots over time

With two slots, the CPU can record frame N+1 while the GPU runs frame N. It cannot get further ahead: frame N+2 uses the same slot as frame N, so step 3 waits for frame N's fence value. Frames in flight draws this on a timeline and explains why one timeline fence per queue is enough. The picture is for one graphics submit per frame; with async compute, a frame signals two graphics values and two compute values.

slot 0 slot 1 the value the frame's submit signals
frameCount (slot) waits for signals F1F2F3F4F5 0 1 0 1 0 0passes at once 0passes at once 1 2 3 1 2 3 4 5 A frame waits for the value its own slot signaled, two frames before.
Each frame's values, for one graphics submit per frame.

Nothing is reset: the fence values only grow. A skipped frame needs no cleanup, because it signaled nothing and changed no slot value.

Play both sides to see the rule work. You are the CPU and the GPU. It starts where step 3 above did: frame 7 wants slot 0, which last signaled 5, and the GPU has reached 4.

the CPU writes the slot the GPU still uses the slot this frame's slot the CPU is blocked
Press only "CPU: next step" and see how far the CPU gets before beginFrame blocks. Then let the GPU finish a frame. Try to make the CPU write a slot that the GPU still uses: the fence wait never lets it.

What has one copy per slot

slot 0 · frameCount = 0 depth texture fence values command buffers, per batch SceneData, cull stats visible draws + counts Hi-Z buffer instance, material tables draw list buffers timestamp query pool overlay text buffer history target textures slot 1 · frameCount = 1 depth texture fence values command buffers, per batch SceneData, cull stats visible draws + counts Hi-Z buffer instance, material tables draw list buffers timestamp query pool overlay text buffer history target textures shared by both slots textures of a render target without history visibility flags, one buffer per scene view
The frame uses the set of its slot. The table says where each one is stored.
Per slotWhere
depth texture, fence values, the command buffer being recordedFrameResources in Renderer::frameResources
command buffers per queue, one per batchRenderer::batchCommandBuffers
SceneData (a slot per scene view), cull statsGpuScene
visible draws with their draw counts, Hi-Z bufferSceneView, one per scene view in GpuScene::views
instance and material table buffers, draw list buffersGpuTable, SceneDrawList::buffers
GPU timestamp query poolFrameStatsSlot
stats overlay text bufferStatsOverlaySlot
color and depth textures of a render target with historyRenderTarget::attachments

All of them are indexed by frameCount. A history render target's texture changes every frame, so fetch it with getRenderTargetTexture each frame. A render target without history has one pair of textures that both slots share: the GPU runs the frames in order, and each frame's first use waits for the frame before. The visibility flags of occlusion culling (SceneView::visibility) have one buffer per scene view, shared by both slots: only the compute passes use them, those run on one queue in frame order, and each frame reads what the one before wrote.

4Swapchain results and skipped frames

CallOKSUBOPTIMALOUT_OF_DATEFAILURE
acquireNextImagego ongo on, recreate next frameskip, recreate next frameskip
present—recreate next framerecreate next framelogged
recreateSwapchaingo on—0 × 0 surface: keep the old swapchain, skipskip, try again next frame

"Recreate next frame" means the window's WindowFrame::outOfDate is set, and step 2 of the next frame recreates that window's swapchain. What these results mean in Vulkan is in The swapchain and presenting.

input checks wait sync acquire record submit returns false frameCount stays · no Tracy frame mark the sync's uploads go out with the next submit

A skipped frame (beginFrame returns false)

Nothing is recorded or submitted. frameCount does not move, and there is no Tracy frame mark. What ran before the skip still counts: input, finished loads, and (when acquire skips) the scene sync, whose uploads go out with the next submit.

input checks wait sync acquire record submit fails: no present frameCount moves · the slot keeps its old fence value the image stays acquired

A frame that fails to submit

It was recorded, but the slot keeps its old fence value, so the next wait on it passes at once. frameCount still moves. The image stays acquired, and the next acquire returns it again. Its timestamps are not read, because the slot's value did not change.

submitBatches calls discardRecording, so the textures it moved go back to the layouts they still have on the GPU. With several batches, a failed submit ends the frame there, since later ones may wait for it; the textures go back only to the layouts the batches that went out left them in. An environment bake in a dropped frame is recorded again in the next one: finishEnvironmentBakes sees that its textures went back.

5Resize

old, dropped or destroyed new, at the new size
before window swapchain images swapchain-sized targets recreateSwapchain waits until the device is idle after window, new pixel size new handles rebuilt camera aspect ratio updated
The five steps below, as one picture.
  1. The window reports a new pixel size. With SDL, SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED sets resized and the new pixelWidth and pixelHeight in pollEvents; a NATIVE or headless application calls Renderer::setWindowSize, which does the same.
  2. The next beginFrame recreates. It calls Renderer::recreateSwapchain, which calls RenderContext::recreateSwapchain.
  3. The swapchain is rebuilt. A 0 × 0 surface returns OUT_OF_DATE and keeps the old swapchain. Otherwise it releases pending semaphores, waits until the device is idle, and builds the new swapchain.
  4. Image handles change. The old swapchain image handles are dropped and new ones are registered. Handles from an earlier getSwapchainImages are no longer valid.
  5. Sizes follow. createSwapchainResources calls RenderContext::resizeRenderTargets, which rebuilds every target with a swapchainScale at the new size, and updateCameraAspectRatio. The device is idle, so the old textures can be destroyed at once. A rebuilt target keeps its bindless slots, so the Hi-Z pass still finds its depth. The swapchain itself has no depth.

Everything swapchain-sized uses the swapchain extent in pixels. Window::width and height are the logical size, used only for the mouse. They differ on HiDPI screens.

6Where each job runs in the frame

beginFrame finishLoads fence wait, free released updateFrameStats stats overlay, or buildUi syncGpuScene acquire the image RenderGraph::execute for each pass, in sorted order: barriers, queue waits prepareSceneViewrecordSceneCulling drawSceneView recordHiz Tone Map draw purple: compute · green: graphics endFrame cull stats barrier submitBatches upload flush, in submit the frame's submits tagReleases present
The order of the jobs. The table gives the reason for each place.
JobWhenWhy there
finishLoadsstart of beginFramebefore anything binds the bindless set or the geometry pool
updateFrameStatsafter the fence waitreads what the slot's last frame measured, then resets the slot
updateStatsOverlayafter updateFrameStats, without the UIwrites the slot's text buffer, which the GPU no longer reads
buildUiafter updateFrameStats, with EngineConfig::uibuilds the RASM window and runs the UI callback before syncGpuScene, so what the UI changes reaches this frame; the UI pass draws it
syncGpuSceneafter the fence wait, before acquirewrites the slot's tables and draw lists
graph barriers and queue waitsRenderGraph::execute, before each pass beginsbarriers are not allowed inside a render pass, and a wait closes the other queue's batch
prepareSceneViewstart of the Cull pass, on the CPUwrites the view's SceneData slot, which the GPU reads after the whole frame is recorded
recordSceneCulling, recordHizthe Cull and Hi-Z compute passesdispatches are not allowed inside a render pass
drawSceneViewthe Scene graphics passesrecords draws; needs a rendering scope
tone mapthe Tone Map pass, the graph's lastreads the finished HDR image; the overlay draws after it, in endFrame, so the overlay is not tone mapped
cull stats barrierendFrame, after the last pass; with a compute queue, submitBatches, at the end of the last compute batchCOMPUTE → HOST, so the CPU can read the counters after the fences
submitssubmitBatches, at the end of endFramethe GPU starts the frame once it is recorded, and every wait is on a submit already made
upload flushinside RenderContext::submitthe copies must run before the frame that reads them
tagReleasesendFrame, after submitBatches, also for a dropped framewhat was destroyed since the last frame waits for the values the queues and the uploads signaled last (deferred destruction)
collectReleasesbeginFrame: at its start (after a tagReleases, so skipped frames still free), and after the fence waitfrees the destroyed objects and bindless slots whose values the fences reached, by reading the fences, never waiting; nothing to do when nothing was destroyed
Known issues

D7: one window: the engine draws one main window, and its own camera input covers all of it.

B21: the swapchain always uses VK_PRESENT_MODE_FIFO_KHR, so the frame rate is capped at the display refresh rate.

P11: async compute does not pay off for the scene passes yet, so it is off by default.

7Where it lives in code

WhatWhere
Frame functionsRenderer::render, Renderer::beginFrame, Renderer::endFrame, Renderer::beginPass, Renderer::endPass in src/renderer/renderer.cpp
The graph behind renderViewGraph::render in src/renderer/viewGraph.cpp
Tone mapRenderer::addToneMapPass in src/renderer/toneMap.cpp; the shader in shaders/passes/toneMap.slang
Load budgetAssetLoader::Impl::finishLoads, LOAD_BUDGET in src/renderer/renderer.cpp
Frame slot stateFrameResources in include/rasm/types.h; frameFence, frameFenceValue, computeFence, computeFenceValue, frameCount in include/rasm/renderer.h
BatchesRenderer::useQueue, Renderer::waitForQueue, Renderer::waitForQueueWork, Renderer::closeBatch, Renderer::submitBatches in src/renderer/renderer.cpp
ResizeRenderer::recreateSwapchain, Renderer::createSwapchainResources in src/renderer/renderer.cpp; RenderContext::recreateSwapchain in src/rhi/renderContext.cpp
Events and minimizeRenderer::pollEvents, addInputEvent, setWindowSize in src/renderer/renderer.cpp, the input state in src/platform/input.cpp and src/platform/cameraInput.cpp, the SDL events in src/platform/sdlPlatform.cpp
Scene sync, scene passesRenderer::syncGpuScene, Renderer::addScenePasses, Renderer::prepareSceneView, Renderer::recordSceneCulling, Renderer::recordHiz, Renderer::drawSceneView in src/renderer/gpuScene.cpp
StatsRenderer::updateFrameStats in src/renderer/frameStats.cpp
Acquire, submit, presentVulkanSwapchain in src/rhi/vulkan/vulkanSwapchain.cpp, VulkanQueue::submit in src/rhi/vulkan/vulkanQueue.cpp
Graph frameRenderGraph::execute, RenderGraph::bufferBarrier in src/renderer/renderGraph.cpp
Texture layoutsRenderContext::transitionImageLayout, RenderContext::discardRecording in src/rhi/renderContext.cpp; TextureStates in src/rhi/textureStates.cpp

8Rules when you change it

Keep these true
  • frameCount is the frame-in-flight slot (0 or 1). Per-frame mutable buffers are indexed by it.
  • A slot's buffers are written only after that slot's fence wait. GPU scene tables are written only in syncGpuScene.
  • A slot takes a new fence value only when a submit that signals it succeeded.
  • Without async compute the frame has one command buffer and one submit; with it, a few batches. GPU work goes in as a graph pass that declares every buffer and target it uses: the graph records barriers and queue waits only for what is declared.
  • Record through FrameResources::commandBuffer, read inside the pass: it names the batch being recorded, which changes between queues.
  • When beginFrame returns false, record nothing and do not call endFrame.
  • Every swapchain call handles SUBOPTIMAL and OUT_OF_DATE explicitly.
  • Swapchain-sized resources use the swapchain extent in pixels, not the window's logical size.
  • Run the examples with enableValidation on after a frame-loop change. A change that adds validation messages is not done.