Skip to content

Latest commit

 

History

History
1323 lines (1263 loc) · 93.7 KB

rendering.md

File metadata and controls

1323 lines (1263 loc) · 93.7 KB

Rendering

The problem

Bloodborne's renderer was written for the PS4's GPU, an AMD GCN part. The game draws through FromSoftware's graphics layer, GX, which sits on Sony's Gnm library: GX turns the engine's draws into PM4 command buffers - the packet format the GPU's command processor reads - and the game ships its shaders as GCN machine code. A PC has neither a GCN command processor nor a way to run GCN shaders directly.

An emulator would answer this at the lowest level: decode every packet, keep the GPU's registers, and reconstruct each draw from them. bbhost started there and is moving up a level, to where the engine's intent is still visible. Dark Souls III on PC, built on the same engine, puts Direct3D 11 under the same GX layer; bbhost does the equivalent with Vulkan.

How a frame is drawn today

GX hooks. bbhost hooks GX's draw, dispatch, resource-creation and state methods. When the game draws, bbhost records the draw's inputs from the engine's own objects - its shaders, vertex layout, state descriptions, textures and constant buffers - and leaves a small token in the command buffer. When the command processor reaches the token, the draw is built from those inputs. No packet is decoded and no register file is consulted for a draw. At Uncapped, 90 and 120, where the command processor limits the frame rate, the draw's resource records travel packed - each stage's header and only the slots it sets, a few hundred bytes - and the command processor unpacks them into a set of its own; at 30 and 60 the GX threads hand over the whole sparse set, which costs them less CPU, and a paced frame does not wait for the command processor (BBHOST_GX_PACKED_RECORDS=1 or =0 forces either).

Compute dispatches are tokens too. A dispatch through GX's compute commit - the GPU particles, the tone-map and depth-of-field look-up tables - takes its compute stage from the engine's objects at the call, as a draw does: the compute shader, its views, UAVs, samplers and constant buffers, from which the command processor builds the shader's user data, tables included - and, for the particles, each UAV's hidden counter: its word and the initial count the game set, as D3D11's pUAVInitialCounts (BBHOST_GX_TOKEN_COUNTERS). YEBIS's passes are built from YEBIS's own state, as its draws are, and need no constant engine (BBHOST_GX_YEBIS_DISPATCH); GX's own resource passes take the user data their writers set. A dispatch the hooks did not take would still run from its packet and the register file (BBHOST_GX_NATIVE_DISPATCH=0 runs them all that way), and the exit report counts those by reason.

The command processor. bbhost still walks the game's command buffers, and mostly to take the tokens in their order. What else it does is the completions the game waits on - the labels GX's block pools, its command arena, Map and its queries' results, YEBIS's flush counter and Scaleform's fences are written with, which it records on the GPU's timeline - and a few waits and constant-engine writes outside GX (YEBIS's own drains, the flip's, Gnmx's constant update engine). GX's pipeline drains are barrier tokens: the CP's own writes after one go behind the work before it, with no label and no wait. Occlusion queries are tokens from GX's Begin and End, measured by the renderer's own queries. The packets nothing on the host reads - the cache flushes, the context registers, the shader prefetches, the compute stage's registers (a dispatch token carries them, and a fallback writes them before its packet), the counter steps between the constant and draw engines - are not written at all (BBHOST_CP_DEAD_PACKETS). The constant engine's wait is: the game writes a NOP over it when a draw leaves the engine unused, so a writer whose packet its caller rewinds over or edits cannot write nothing. Clears and copies come as tokens from GX's own calls: a clear names its view, and is made as the next pass's load op, or as a transfer clear when something reads the image first.

Host command lists. What the command processor acts on in those buffers - the tokens, labels and waits, which our versions of Gnm's packet writers write - can be recorded as it is written, a list per chunk of command buffer, so that a submitted range reaches the command processor as its list's packets instead of all its bytes (BBHOST_HOST_LISTS=1, the default; a range no list covers is walked, counted by reason; =0 walks every range as before, =2 records the lists and checks them against the walk, range by range).

Labels. A submission carries its labels, and a thread of the host's, bb-labels, writes them into guest memory in the order the command processor made them once the timeline semaphore says the submission has run: the queue's order holds without barriers between fills, and a label's memory needs no import. A submission counts as completed for the rest of bbhost only once its labels are in memory, and the command arena's acquire, waiting for a chunk, looks again as each label lands. The thread waits in the driver, or polls on Windows (BBHOST_LABEL_WAIT), where NVIDIA's driver holds its lock through that wait; there the labels are still GPU fills at the end of their submission's command buffer unless BBHOST_LABEL_LANDING=1 (=0 keeps the fills anywhere). Measured on Windows on the Radeon 8060S (AMD's driver, 2026-10-29, the run commit on, the GPU the limit at 640x360): fills 200.0 and 200.8 fps, landed with the thread polling 199.6 and 200.9, waiting in the driver (BBHOST_LABEL_WAIT=block, no lock trouble on AMD's driver) 201.2 and 201.0; 2.5 million writes from 146,000 submissions in a 100-s run, landed 5.4-5.6 ms after the submit (p99 7.4 ms), none into a reused command buffer, the frame pacing the same. A label meant for a command buffer the game has begun writing again since the label's submission - YEBIS cycles two command buffers and reuses one without waiting for the GPU, so a GPU running behind lands the old round's fences on the new round's packets - is counted and not written: what it was written for is gone (BBHOST_LABEL_REUSED_DROP=0 writes it anyway). As GPU fills, only those found reused when the fill is recorded can be left out. The chunk rounds this needs come from the host command lists, and the exit report counts what was found (and the CP what it lost: a wait no value could pass, a token without its magic).

Recording. The command processor leaves the Vulkan calls to a thread of its own, bb-record. Each draw goes into a packet, and most of its other commands - barriers, fills, copies and the like - into the same ordered stream as typed records (src/host/recorder.cpp, src/host/stream_ops.h). bb-record replays the stream into command buffers, begins and ends each one and hands it to the thread that submits, while the command processor goes on to the next draw. With BBHOST_STREAM_SUBMIT=0 the command processor begins, ends and submits the command buffers itself, to compare. The submitting thread, bb-submit, gives the queue the game's submissions as they come; when it falls behind - where the kernel's half of a submission is costly, as on a Steam Deck, whose driver makes every import of the game's memory resident again at each one - the submissions queued behind each other go to the queue as one (BBHOST_SUBMIT_MERGE=1 keeps them apart, to compare). Between two blocks bb-record spins (BBHOST_RECORDER_SPIN: 20,000 pauses with 16 hardware threads or more, 4,000 under) before it sleeps, which pays where the command processor limits the frame: a wake of a sleeping recorder is a system call on the command processor. Where something else holds the frame with room to spare, the recorder rests instead: a frame cap (two half-second windows with the limiter waiting 15% of the time, as the draw pool's rest at a cap) with the GPU busy under 85%, or the GPU under the cap (busy 90% of two windows) with the command processor's thread busy under 85%. Resting, it sleeps after 100 pauses, and the command processor wakes it at a submission or every 64 blocks, so it replays its blocks in batches; every wait of the command processor's on it wakes it at once (src/host/recorder_rest.h). At a true 60 that took the process 18-27 points of CPU under Windows on an RTX 3070 Ti Laptop GPU (the recorder from 39-48% of a core to 13-16%), 25-34 on its Radeon 680M (GPU-bound) and 21-29 on an RTX 4070 under Linux, the frame rate and the slowest frames the same. Without that room the rest's delays land on the frame: its waits added to a command processor near its limit (Old Yharnam uncapped on that laptop, the thread busy 91-95%: 2-4% slower; a Steam Deck's 60 fps profile at the Nightmare of Mensis, 94-95%: 0.8%), and a submission it delays at a cap with the GPU near full (the same profile at Central Yharnam, the GPU 88-91% busy: the 99th percentile frame from 17 to 20 ms in one run of two). The command processor's share is its thread's own CPU time, read once a window - not its jobs' time, which takes in its waits for the GPU (98-101% of the window on the 680M at 32-37 fps, the thread busy 29-44%). A cap's rest ends with the limiter waiting under 8% of a window or the GPU busy 92%, the GPU's with the GPU under 80% busy (the median of six windows), the command processor busy 92% or a cap holding the frame, both at a loading screen. BBHOST_RECORDER_REST=0: it never rests; =always: it always does.

What is still recorded in place - by the command processor itself, on the command buffer - first waits for bb-record to replay everything published before it (a drain). Two kinds made nearly all of them: a GX image-copy token's barrier, copy and barrier (13 copies a flip at Old Yharnam and Central Yharnam), and draws left without their packet when an op had to follow what the packet held - a batch of home copies too long for one packet - each then recording its ~10 commands in place (2-4 draws a flip). The copy token's commands go into the stream as its ops (BBHOST_STREAM_COPY_TOKEN=0: in place), and a draw whose packet an op must follow goes on in a fresh packet (BBHOST_STREAM_SPLIT=0: in place); the same commands in the same order. Under Windows on an RTX 3070 Ti Laptop GPU uncapped that took the recordings in place from 79-82 a flip to 1 at Old Yharnam (25-28 to 1 at the Nightmare of Mensis, 69-72 to 1 at Central Yharnam) and the command processor's waits for the recorder from 1.4% of its time to 0.2%: Old Yharnam ran 127.7 fps against 126.6, the Nightmare of Mensis 125.0 against 123.0. On a Steam Deck's 60 fps profile Old Yharnam's frames over 16.7 ms went from 45 to 2 in a window, and the Nightmare of Mensis ran 56.0 fps against 55.6.

Shaders. GCN shaders are converted to SPIR-V when the game creates them, and GX creates every shader of the game's bundles at the start (1,663 vertex and 1,346 pixel programs; all but the debug bundle's), so their stages and pipeline libraries are compiled behind the title. What a draw still has to make itself is a variant creation does not know of - most of them the pixel shader of a pair that clips by a varying - and the eboot's own programs (YEBIS's, Scaleform's: the eboot carries some 5,400, a tour draws about 80). Every pipeline a draw creates is recorded in pipeline-manifest.bin with what built it, and the next start builds them all again on the precompile workers, its optimized link included, so what an earlier run has drawn is not compiled again when it comes into view (tools/pipeline_list.py makes a list of them that names the programs instead of holding them). There are two compilers:

  • the translator (src/gcn/translate.cpp) reproduces the GCN program's execution faithfully - one invocation per lane, with the execution mask as data - and handles every shader the game uses;
  • the lifter (src/gcn/lift.cpp) decompiles a shader into typed, structured SPIR-V, the form a person could read and edit. It is used for every pixel and compute shader, and every vertex shader on vertex input, it accepts - with the vertex formats read from the shader's parameters, or as specialisation constants, the way the translator reads them; the rest keep the translation. tools/lift_verify.py compares the two compilers' output byte for byte.

All 13,394 vertex, pixel and compute shaders in the game's bundles translate to valid SPIR-V (gcn2spv --check). Domain, hull and local shaders run on the host GPU's own tessellation stages, and the GPU particles' export and geometry shaders on its vertex and geometry stages. The lifter takes those too: the particles' local, hull and domain shaders, whose one control point travels as stage attributes, and the game's own hull draws (the Forbidden Woods' meshes, every hull in the bundles), whose local, hull and domain shaders become one native pipeline - the LDS they pass patches through turned into stage inputs and outputs, the game's patch list drawn as it is, with no compute pass in front. BBHOST_LIFT_TESS=0 keeps every tessellation stage translated.

The GPU particles - the effects' standard particles, their sparks and the wandering visions - draw a point a particle through an export shader, a geometry shader and the copy shader the geometry shader's container carries. On the PS4 the export shader writes each point's attributes to a ring in memory, the geometry shader reads them there and writes its vertices to a second ring, and the copy shader exports those to the rasterizer. Neither ring exists on the host, and no geometry stage is used: the particles are drawn the way a PC engine draws them, as one vertex stage, on every device. The lifter lifts the export shader as a vertex stage, its ring stores its outputs, and the geometry shader as a geometry stage on a point: its ring loads are the point's inputs, its stores and emits the vertices, and a vertex's outputs what the copy shader exports of its dwords. A geometry shader that stores at an offset its compiler counts per lane (the standard particles') keeps that ring as an array in the invocation. The two lifts are then spliced into one vertex stage (gcn/gs_vertex.h). Each output vertex runs its particle's export shader, keeps the ring dwords in the invocation for the geometry shader's loads, and keeps the one emitted vertex it stands for - a particle's vertices are the most the geometry shader can emit on one path, eight for a standard particle, forty for a spark's trail of ten quads. The draw is indexed over a static list of each particle's triangles in the order its strips make them, so the provoking vertex of every triangle is the strip's: one strip a particle where the geometry shader cuts only after its last emit (the standard particles), else strips of four (the sparks); a vertex past its particle's emits is its last emit, which leaves every triangle it is in without area. A standard particle's first four emits are its trail's, made only when a dword of its geometry shader's constant buffer is above 0 (host/gs_emit_gate.h finds that gate in the program): a draw with the dword at 0 or less, as the draw records it, draws each particle's first four vertices alone - all a particle can emit then - and runs the vertex stage half as often (BBHOST_GX_PARTICLE_GATE=0: all eight).

The stage reads the simulation's indirect arguments itself and leaves out every particle at or past their count. The draw takes the live count: after the dispatches - the simulation's run outside any render pass - the next draw runs one more pass, once for the run of them, that writes every emitter's indexed-draw arguments from the game's, its live count times a particle's indices, and the draw reads those (BBHOST_GX_PARTICLE_ARGS=each: a pass after each dispatch). An emitter's first draws, before such a pass has written its arguments, run its room, the most records a buffer its export shader reads by index holds; BBHOST_GX_PARTICLE_ARGS=0 always runs the room. The pipeline is built on the pipeline workers, so a system draws from the frame its pipeline is ready, and is recorded with its two extra programs in the stage manifest (format 5) for the next start. A draw the path refuses - its pipeline still being built, or a geometry shader the lift or the splice does not take - is not drawn: as its export and pixel shaders it would draw nothing and only store the export shader's ring through a buffer its draw's tables name. The exit report counts the refusals by reason. With BBHOST_GPU_PROFILE=1 these draws' pipelines carry ~particles in their names, and a gpu profile particles line lists each of them with the arguments' pass (particle-args).

BBHOST_GX_PARTICLES=gs is a debug switch for comparisons: the particles are drawn with the geometry shader's lift as a geometry stage and the export shader's as the vertex stage, as earlier versions drew them. On GCN under AMD's own driver (the proprietary one or AMDVLK: a GPU whose only subgroup size is 64, such as an RX 580) that path drew the Hunter's Dream's particles as long streaks across the screen, so those versions left the particles out there; the vertex stage draws them on every device.

A compute shader is lifted against its dispatch's translation and binds exactly what that binds - the parameter block with the page table, the images and samplers, the particles' counter words - so a dispatch is set up the same way whichever runs. Its memory reads and writes go through the same page-table walk. GCN's loops that run until every lane's execution bit clears become structured per-invocation loops, a block GCN branches over where no lane needs it becomes a selection an invocation skips where its own bit is clear, and the GPU particles' wave-wide counter idiom (ds_append/ds_consume in GDS, each lane's rank from v_mbcnt) becomes one atomic add per subgroup, as GCN steps the counter once a wave and as the translation does: an elected invocation adds the count of the invocations stepping together and each takes the base plus (append) or minus (consume) its rank among them, on the counter word the dispatch hands over by its device address, with no page-table walk (BBHOST_GDS_SUBGROUP=0 keeps an atomic an invocation). A barrier is accepted only where every invocation of the workgroup provably reaches it, and LDS, which no game compute shader uses, is refused. BBHOST_LIFT_COMPUTE=0 keeps every compute shader translated. A compute shader reads its constant buffers, tables and typed loads, and reads and writes the elements of its particle buffers (typed loads and stores at an index or offset, format loads, atomic adds; GCN's bounds checks kept), through storage buffers its dispatch pushes, where every one of them binds, rather than through the page-table walk (BBHOST_CS_BUFFERS=0: the walk; BBHOST_CS_BOUND_ELEMENTS=0: the elements walk): a translated one as that variant of its translation, a lifted one as the lift of that translation, which reads what the translation binds from the same buffers and walks what it walks (BBHOST_LIFT_CS_BUFFERS=0: a lifted shader walks). tools/lift_verify.py --stage cs --lean replays dispatch captures in that form, both the translation and its lift against the walking translation, with their buffers bound from the captured pages.

Textures and memory. The game's memory is shared with the GPU, as on the PS4: its GPU-visible parts (about 5 GB) are imported into Vulkan, because shaders that cannot be fully resolved read memory through a page table. Over the 12-place tour the GPU touches about half of that, and only a few hundred MB in place; the rest it reads only as the source of a copy (texture detiling, the buffer shadow's mirrors). BBHOST_IMPORT_WINDOWS=1 imports only what is used, a 16 MB window at a time when something first needs it or when the engine makes a resource there (on a thread of its own); an import over several windows replaces the ones it covers, so no page stays imported twice, and a dispatch imports what its shader reads and stores (an import a draw waits for is counted in the log's frames: and stall: lines, imports waited for N in M ms, and the exit report gives the driver's time by the thread that waited). The page table's entries of a window that named the import a newer one replaces keep naming it until every submission made before the newer one has run: a shader walking the table reads whatever address an entry holds as it runs, and AMD's Linux driver maps a new buffer's addresses for the submissions made after it, not for the ones already queued (host/import_table.h; BBHOST_IMPORT_TABLE_DEFER=0 switches them at once, as before). An import none of whose windows anything has used for a minute - an area's meshes and copy-backs once the game has gone elsewhere, a buffer the import thread imported that the draws never read in place - is let go: its windows' entries point at the sink at once (no work in flight reads them, and the sink is memory every submission sees), it is freed once the work recorded with it has run, and a later use imports it again (host/import_retire.h, BBHOST_IMPORT_RETIRE; on by default wherever windows are imported, but on NVIDIA's driver under Windows, whose import of a window wanted again took 23-57 ms on the command processor, at the draw that wanted it). A retired import - let go, or replaced by a merge - is freed on a thread of its own, in the background and 50 ms apart (BBHOST_IMPORT_FREE_THREAD=0 frees it on the command processor, BBHOST_IMPORT_FREE_GAP_MS sets the gap): the driver's free took up to 14 ms there. Window imports are on by default on an integrated GPU under Windows, where whole spans kept about 1.5 GB more of the game's memory resident for the GPU, and on a graphics card with small video memory (under 7.5 GiB free at the start), whose whole spans pin 4-5 GiB of system memory beside a 4-6 GB card. It is off on a graphics card with room, and on an integrated GPU under Linux, where window imports have not been measured yet (AMD's imports go through udmabuf there). gpu.import_windows, true or false, decides it either way. The log's gpu: memory: line gives the decision with the others made for the device (host/memory_policy.h). The work under way moves each of those uses off guest memory, and windows are then only the fallback for what is not moved yet. The Steam Deck kit turns it on: there the memory shared with the GPU stays under the driver's budget and the start is about 3 s sooner, at the same frame rate (its device-local twins, below, stay off: on an APU they are the same memory plus copies). One such move, off while it is measured: BBHOST_GX_TWINS=1 keeps the GX buffers the GPU writes - particle state, append buffers and their counters, arguments a dispatch fills - in device memory, as a copy made at the buffer's first GPU use that every GPU use reads and writes from then on; nothing copies their guest bytes on the CPU after that, and anything that would read them from guest memory (a page-table walk, a texture over one) has the copy written back first. BBHOST_GX_TWINS=2 adds the buffers GX writes with GPU copies: a dynamic buffer's renamed bytes written back to its own address, a constant buffer's update (a world has about 3,800 of them, 4 MB, kept in shared device-memory blocks). The GPU particles' buffers alone are kept that way by default on a discrete GPU (BBHOST_PARTICLE_TWINS: 0 keeps them in guest memory, 1 makes them twins on any GPU): a buffer becomes one once a dispatch that counts in GDS binds it - its records, and whatever else that dispatch reads and stores - from the next command buffer on; the counter words, past the records, stay in guest memory. In guest memory the particle update read and wrote its 176-byte records across the bus at about 0.2 µs a particle: 7.4 ms of an RTX 4070 a frame in Vicar Amelia's room (73 fps uncapped at 1080p), against 0.14 ms as twins (161 fps). An integrated GPU's device memory is the host's own, so there they stay in guest memory, as they do under a capture. Every buffer binding asks the twins first; one that meets no twin and no armed buffer - nearly all of a frame's - is answered from a sorted list of their ranges' union instead of two map walks (BBHOST_TWIN_FAST_MISS: 0 walks the maps for every lookup, check does both and counts any answer that differs in the exit report). With window imports a copy's source the CPU wrote is copied through upload staging, as copy versions' bytes are, rather than read through an import. The exit report lists what still reads or writes guest memory in place, by the path that asked. Textures are detiled on the GPU. A texture's image, a render target's and a copy's belong to the GX resource they were made for, by that resource's generation: GX's own calls change them - the resource's creation, upload and copy tokens, the shaders that write it - and they are retired when the resource is destroyed, so memory the game gives to a new resource with texels of its own never hands it the old image. A target, or an image only shaders wrote, goes instead to a texture the game makes over the same memory without data, as the console's memory carries it over: the game re-creates its targets at an area load and may only clear and copy from them. YEBIS's and Scaleform's own textures are known the same way, from those libraries' own creation and release calls, and their writes from their own Map, update and unmap calls. The device-local copies of vertex and index data are told what changed by GX's calls as well: the renamed copy a Map hands out is copied again until GX writes it back or frees it, and a creation with data marks the memory it fills. Only memory no call tells of - the engine's own rings outside GX, YEBIS's buffers - is still noticed by write-protecting its pages. A draw names its targets' resource generations, so the image at a target's base is the drawing resource's from its first draw; copies and texture binds take a target there only if it is their resource's - drawn since the resource was made, or the resource made over it without data. A whole texture copied from one a shader or a copy wrote is copied image to image, so the copy carries what the GPU wrote (BBHOST_COPY_BY_RESOURCE=1 copies the memory under it instead, which the GPU's writes never reach; =0 goes by addresses). Render targets are Vulkan images sized from the engine's own views, and can be re-created at any resolution while the game runs, the way the PC engine's GX device resizes. At such a change - a Resolution or an Upscaling quality chosen while the game runs - the old size's targets go with the change, before the next frame makes the new size's in their room, unless the resource the game makes next at the same address takes them; kept for the ten seconds an area load's are, both sizes' targets were in video memory at once after every change, and the new size's took a new block of the image heap. Images are kept in VK_IMAGE_LAYOUT_GENERAL, which a driver with VK_KHR_unified_image_layouts handles as well as any other layout. AMD's own drivers without it keep no compression for a depth target in GENERAL: a clear writes every texel, and depth tests read and write it uncompressed. There depth targets have layouts of their own, as a PC engine keeps them: drawn in the attachment layout, sampled in the read-only one, cleared in the transfer layout, and in GENERAL around copies and readbacks. A use that wants another layout records the transition just before it, outside any pass, and a clear of all of a target discards what it held. Colour targets and textures stay in GENERAL. On a Radeon 680M at a lamp in Central Yharnam the game ran 14% faster at 960x540 (60 to 69 fps) and 15% faster at 1920x1080 (27 to 31 fps): the shadow map's pass took 0.3 ms instead of 1.6 (its clear had written all 4096x4096 texels), and the G-buffer's 5.8 ms instead of 6.5 at 960x540, 10.1 instead of 12.4 at 1920x1080. Other drivers keep every image in GENERAL until they are measured; BBHOST_DEPTH_LAYOUTS=1 uses the layouts on any device, =0 on none. A depth target a draw samples while drawing into it would go back to GENERAL for good; no place has had one. A colour target a draw writes no channel of - its write mask, the game's cut to what the pixel shader exports, is empty - gets no blend state either. The game leaves blending on for targets a shader does not export: the G-buffer's puddle decals export six of the seven targets bound and blend into the seventh too, and the effects' soft sprites export one of two. The shader's output for such a target is undefined and Vulkan writes nothing through an empty mask, so the state is dead where a driver honours the mask; a driver may blend the undefined output in anyway, and with the state zeroed there is nothing to blend (BBHOST_MASKED_BLEND=0 keeps the game's blend state). Lavapipe, once a pipeline without colour attachments has been bound in a command buffer, draws every colour attachment of the later draws in it with attachment 0's blend state: a target the shader does not export is written wherever attachment 0 blends, and the puddle decals left NaN in the G-buffer's seventh target - black holes in the floor. On lavapipe alone, a draw that follows a depth-only pipeline in the command buffer being recorded, and whose attachments' blend states differ where that would change what it draws, starts a command buffer of its own, what was recorded before it submitted without waiting (BBHOST_LVP_BLEND_SPLIT=0 records it like any other); other drivers draw it correctly. A draw of a run committed in parts (BBHOST_RUN_COMMIT) that would split, or mark the command buffer, stops, and the command processor commits it and the rest of the run in order. A draw whose rasterizer state comes from the registers rather than a GX description takes its depth clamp from PA_CL_CLIP_CNTL: with CLIP_DISABLE, ZCLIP_NEAR_DISABLE or ZCLIP_FAR_DISABLE set z is not clipped, and the depth block clamps depth to the viewport's range, which is Vulkan's depth clamp. GX's rasterizer builder sets both z bits from D3D11's DepthClipEnable, so this is exact for its states; Vulkan has no switch per plane, and a register with one alone clamps the other plane's geometry onto it instead of clipping it. DX_RASTERIZATION_KILL is rasterizer discard, a dynamic state only the pipelines of such draws take (BBHOST_CLIP_CONTROL=0 keeps depth clamp from CLIP_DISABLE alone and rasterizes every draw).

Native passes. Several parts of the frame no longer run the game's GPU path at all:

  • YEBIS, the post-processing library (bloom, glare, depth of field, tone mapping): every stage's resources and constants are built by bbhost. Its depth of field blends each blurred level in by the circle of confusion in pixels, which grows with the picture, against an offset that does not. A blur drawn with several levels keeps its look by itself, as a growing circle moves on to the next, larger level (the cutscenes, a plugin's lens), but the areas' own faint far blur has one level, so it faded out below 1080 lines and grew above them. On a side drawn with one level the offset now scales with the picture's height over 1080, which keeps the 1080-line look at every Resolution; with an upscaler the height is the picture's, the one YEBIS works at.
  • Scaleform, the menu renderer: its draws are taken from its hardware abstraction layer.
  • Depth snapshots, the on-screen overlay and FSR 1 upscaling are bbhost's own. The depth snapshot's compute pass goes into the recorder's stream (BBHOST_STREAM_DEPTH_COPY=0 records it in place, draining the recorder). The scene's own depth copy is one: after the G-buffer the game copies its depth into DepthRenderTarget (and its first G-buffer target, the normals, into GBuffer0), which SSAO, the sun's screen-space shadows, motion blur's and screen space reflections' smaller depths, the decals, the forward passes and depth of field read. The world's view makes them with CopyResource; the renderer's two other modes make them with three calls of their own (0x26a10c0, 0x26a2829, 0x26a283f), which the built-in Performance patch turned into NOPs until v0.2.35 - calls the world's view never makes, so leaving them out changed nothing there; only a view drawn in those modes read targets nothing had written that frame.

Native or emulated

Operation Today
Draws native: built from the engine's objects at a token
Tessellated draws native: host tessellation stages; the game's hull draws one lifted pipeline each
Geometry-shader draws (the GPU particles) native: the host's geometry stage, the PS4's two rings as stage inputs and outputs
Post-processing (YEBIS) native resource building; the game's shaders
Menus (Scaleform) native draw building from the HAL
Fills and copies without a shader recognised and performed directly
Other compute dispatches native: built at a token from the engine's objects (GX's compute stage, the particles' counters with it; YEBIS's state) or the user data its writers set (GX's own passes); the game's shaders
Clears and target copies native: tokens from GX's calls, in the view's terms
Occlusion queries native: tokens from GX's calls, measured by the renderer's own queries
Pipeline drains native: barrier tokens from GX's calls
Labels and fences the game waits on emulated: recorded by the command processor, written by the host once their submission has run (GPU fills on Windows for now)
Shaders decompiled (lifted) to SPIR-V; a few refused programs translated (see below)
Resource identity GX's, YEBIS's and Scaleform's textures by their objects and generations; vertex and index copies told by GX's Map calls; memory no call tells of (YEBIS's buffers, the engine's own rings) by address, with write tracking

Shader lifting

Every shader the game creates goes through the lifter. One it refuses is translated instead, so nothing is lost. The program counts below cover every shader the game ships. The draw shares were measured at the twelve places tools/area_check.py visits; elsewhere they are expected, not measured.

Shader stage Programs lifted Draws lifted (12 places) Left
Pixel 3,206 of 3,209 100% FXAA3HQ, which needs a whole-wave proof; two debug shaders whose result depends on how the PS4 packs pixels into waves (no exact PC form). None is drawn at the 12 places.
Vertex all 10,116 100% -
Tessellation: local, hull, domain all; the 141 mesh hull sets as native pipelines 100% -
Geometry, with its export shader the effects' 4 particle geometry shaders of their 7; none of the models' 1,694 100% once its pipeline is built (its draws until then are not drawn) The models' geometry shaders (cube-map depth, a face a layer) and the effects' two array shaders write a layer, which the lift does not take; the effects' point sprite reads its vertices through a fetch shader. None is drawn at the 12 places.
Compute all 38 in the bundles, and the 6 of the executable's own (GX's and YEBIS's) that the 12 places dispatch 100% of dispatches The executable carries 24 more, lifted when first dispatched; none is dispatched at the 12 places.

A draw whose setup the lifter hasn't seen still falls back to the translator. The exit report counts those by reason, and BBHOST_LIFT_TESS and the other switches turn the lifted paths off for comparison.

Step State
Pixel and vertex shaders lifted done
Tessellation lifted, mesh hulls native done
Compute shaders lifted done
HLSL: the lifted SPIR-V printed as HLSL and compiled with DXC to SPIR-V for Vulkan on the player's machine on by default, compiled behind the game (below)
Shaders as editable source, generated on the player's machine from their own game files (never shipped) a first slice: edited HLSL replaces a stage's module (below)
D3D12 (Shader Model 6) from the same HLSL, if ever wanted; D3D11 is not planned, since it lacks the quad operations 703 programs use later, optional

HLSL

Every lift is printed as HLSL (src/gcn/hlsl.cpp) and compiled by DXC to SPIR-V for Vulkan on the player's machine, and the stage takes DXC's module where it declares the lift's interface and keeps its operations; anything else keeps the lift's SPIR-V, counted by reason in the exit report. This is the default, and nothing waits on DXC:

  • A start uses what is ready. A stage takes DXC's module when the translation cache has it, and the lift's otherwise. The first start after an install or an update is the lift's throughout.

  • DXC compiles behind the game. The modules a start did not have are compiled by bb-hlsl threads (two; one on a machine with fewer than eight hardware threads; BBHOST_HLSL_THREADS) at the lowest priority, after the start's own shader compiles, and kept in the translation cache. On an integrated GPU, which shares the CPU's chip and power budget (the Steam Deck), they compile only before the first in-game frame and on loading screens: beside the world they cost the Deck ~2 fps and a long frame almost every second (BBHOST_HLSL_IN_WORLD=1 lets them run in the world on any GPU, =0 holds them there on any). Their order follows the pipeline manifest: what this start's draws took, then what the manifests replay (what earlier starts drew, the most recent first), then what GX created but nothing drew yet, then predictions and the opt-in sweep. A stage a draw takes moves to the front.

  • The switch is at the next start. A pipeline is never rebuilt live to swap a module: the frames are the same either way, and a rebuild would be a driver compile in the middle of play. The next start takes DXC's modules, and its precompile builds their pipelines from the manifests before the world is drawn.

  • The off switch. The Shaders setting (F10, under Graphics; HLSL or Lifted; the game's System > PC Graphics > HLSL Shaders, On or Off; video.shaders in bbhost.toml) applies at the next start. BBHOST_HLSL=0 is the lift alone, =1 compiles each module at its first use (the start waits for DXC: for checks), =2 is the default; the variable wins over the setting.

  • Compiling up front. The setup window's Shaders tab shows whether the caches were made by this bbhost's translator and for this GPU and driver, what the last compile did, and has Compile shaders now: bbhost starts itself again with --compile-shaders, a run with no game and no window that starts the GPU and compiles every shader in the game's bundles (the debug menu's aside) and every stage and pipeline the manifests name - the player's earlier sessions' and the list a release ships beside bbhost (pipeline-list.bin, running.md) - translations, lifts, DXC's modules and the driver's pipelines - into the same caches, on the game's own precompile workers. Progress (N of M, the time left; the manifests' and the list's pipelines counted in it and on a line of their own), failures by reason and the HLSL counts show as it runs, and it ends when every job has; Cancel keeps what is done; the window stays live and Play waits for it. When the caches are missing, or were made by another bbhost's translator or for another GPU or driver, the window recommends it - on the Shaders tab and in a line on the main tab, each with its button and the time it is likely to take (the last compile's, else a guess: about 2-3 minutes on a Steam Deck); it never starts by itself. The run logs to <data>/bbhost/shader-compile.log and records its result in <data>/bbhost/shader-compile.txt before its last lines, with the id of the run the window started; a window that did not get those lines takes the result from that record, never from an earlier run's. On the RTX 4070 it takes ~60 s (3,281 shaders, 3,682 DXC modules, 16 workers), on a laptop's RTX 3070 Ti (Ryzen 7 6800H, Windows) ~90 s and on the Steam Deck ~150 s. What it does not do is a first session's first sight: the variants a draw makes (clip-discard pixel shaders, vertex layouts, the eboot's own programs, the tessellation LS pipelines) come from the pipeline manifest, which only earlier sessions fill; a first tour after it built as many pipelines on arrival as a cold start (25 vs 27-31). Its gain on a new install is a first session already on DXC's modules with no compiling behind it (CPU ~385% against ~470%). Skipping it costs nothing: the background path does the same over the first sessions.

  • Edited shaders. BBHOST_HLSL_DUMP=1 writes each module's HLSL to <data>/bbhost/hlsl-dump/ (or BBHOST_HLSL_DUMP=<dir>), and an edited copy in <data>/bbhost/shaders/ - or a plugin's source (plugin API 27, plugins.md) - replaces that stage's module when it compiles, declares the lift's interface and validates (modding.md). The source is generated from the player's own game files and stays on their machine; none is committed or shipped. Edited shaders apply while the game runs: a program's sources are named by one salt, the hash of their identities, which goes into the keys of its draws, dispatches and lifted stages, so a change builds that program's pipelines again and a return to an earlier source finds them; a new source is compiled for the variants met before it takes effect, and none of it is kept in the manifests or the caches' files. A plugin's shaders read numbers of its own from a small buffer by device address, uploaded in command order at a frame's start.

  • What the HLSL is. The lifter's SPIR-V stays the shader's IR of record: typed values in structured control flow. The printer reads it back and writes one statement an operation, values named by their SPIR-V ids, resources and stage variables by the engine's names, and constant-buffer loads annotated with the member they read (// cbSceneParam.VC_MatrixViewProj[0].x). Constant buffers are ByteAddressBuffers read a dword at a time, as the lift reads them.

  • Exact by construction. Every operation is spelled the way DXC lowers back to the lift's instruction: floats are precise (NoContraction); where HLSL's spelling is another instruction - sign, ldexp, mad (which DXC makes a fused multiply-add a driver must not split), fmin/fmax, the half packing, bitfield extracts, carries, borrows and wide multiplies - the operation is inline SPIR-V (spelled out instead, the wide multiplies made modules the NVIDIA driver's compiler refused); the helper-lane query is the built-in, which keeps discard an OpKill; quad operations are QuadReadLaneAt/QuadReadAcross*; an invariant position (BBHOST_VS_INVARIANT=1) keeps its decoration. Each compiled module is checked against its lift: the same descriptor bindings, stage interface and specialization constants, and no float, image, quad or discard operation the lift does not have.

  • Tessellation and compute. The LS is a vertex shader with an array output, the domain shader takes its control points as an OutputPatch, and the game's hull - one body each control point runs, a barrier, then the patch's factors - becomes HLSL's control-point and patch-constant functions from that one body. Compute lifts print too (raw addresses as vk::RawBufferLoad/Store, their counters as InterlockedAdd on a vk::BufferPointer).

  • Offline checks. gcn2hlsl lifts every program in the bundles as the renderer does, prints, compiles and validates it: 13,318 of 13,318 vertex and pixel lifts, 450 of 450 tessellation stages, and the compute lifts; with --runtime-offsets, as on a device with maintenance8, 89 pixel shaders sample with a run-time offset, and those compile too. hlsl_equiv runs each lift and its DXC module on the same random inputs on lavapipe and compares the outputs bit for bit: 13,308 of the 13,318 vertex and pixel lifts identical, 10 differing only in the bits of NaNs (which Vulkan leaves to the implementation), none otherwise; the 89 with run-time offsets identical; all 450 tessellation stages identical (a domain shader behind a generated hull, a hull with its outputs stored from inside it, since random constants give factors that cull every patch). tools/hlsl_verify.py replays captured draws and dispatches with DXC's stage against the lift's: identical on lavapipe and on an RTX 4070, and hlsl_equiv --compile asks a device's compiler to build every compute module.

  • In game. At the title screen, every lift through DXC, the frames equal the direct path's except the animated menu highlight, which differs between any two runs. The default, on twelve places of a save that reaches the Old Hunters areas (an RTX 4070 at 60 fps; two rounds against the lift alone):

    • A first start (no caches) draws with the lift's modules throughout, and its first-sight hitches are the lift's. Meanwhile two bb-hlsl threads compile ~3,360 modules: ~435 s of their time, all done ~250 s after the first was queued (~60 s of that waiting for the start's own compiles). The process's CPU is ~470% against ~385% while they run, and its memory up to ~0.6 GiB higher; when the queue empties ~0.4 GiB of DXC's heap goes back to the system (glibc's malloc_trim).
    • The next start takes DXC's module for every stage met before (~3,380; a few new ones keep the lift and compile behind). The pipeline manifest builds their pipelines at the start, though the driver has never seen those modules, and no pipeline is built during play.
    • From then on every stage is DXC's: every frame within the runs' own noise at all twelve places (24 of 24), the frame rate the same, nothing compiled. Against the same build with BBHOST_HLSL=0 the GPU is busy 2-5% less at five places (DXC's optimized code) and more at none. Compute dispatches take DXC's modules too.
    • A Windows laptop (RTX 3070 Ti Laptop GPU): after Compile shaders now, every start at 60 fps with no stall after the first in-game frame, the GPU busy ~4.5% less than with the lift (409-415 against 429-430 ms/s), the frames within the runs' own noise; its driver builds every lift and every DXC module of the game (gcn2hlsl --sweep: none refused).
    • The Steam Deck: after Compile shaders now, 60 fps as with the lift, and GPU-bound (uncapped) 66.6-67.1 fps against the lift's 66.5-66.9. A first session's compiles beside the world cost it ~2 fps and a long frame almost every second, hence the hold on an integrated GPU (above): with it a first session's world holds 60.0 fps (p95 16.8 ms, as the lift's own first start does), and an install that skips Compile shaders now takes DXC's modules a few hundred at a time, compiled over the title, the menus and the loading screens of its next starts.
  • Halves on a device that rounds them itself. GCN's v_cvt_pkrtz_f16_f32 rounds toward zero. On a device that converts that way inside a module and keeps f16 denormals (RADV, so the Steam Deck) the lift uses the device's conversion, two operations a pair instead of ~6 integer operations a component. BBHOST_HALF_NATIVE=0 keeps the integer form, which a driver cannot fold (RADV's compiler drops some f32-to-f16-to-f32 round trips the native form leaves to it); on the Deck it cost ~1.8% of the frame rate GPU-bound (65.3-66.0 against 66.6-67.1 fps uncapped), so the device's own rounding stays the default.

  • A driver that refuses DXC's module. A pipeline the driver will not build from DXC's modules is built again from the lifts' own: a graphics pipeline whole or from its libraries, the native hulls' included, and a compute pipeline from the lift's module and then from the translation. No draw or dispatch is lost to the switch. A stage refused once takes its lift's module at once in the pipelines after. The exit report's HLSL line counts the refusals by what was being built; BBHOST_TEST_HLSL_REFUSE=1 makes every such pipeline a refusal, to run the path on a driver that refuses none (the RTX 4070 here builds every module since the carries and wide multiplies were spelled out).

  • DXC. bbhost loads libdxcompiler (dxcompiler.dll on Windows) at run time - the one BBHOST_HLSL_DXC names, else the one beside the executable, which every package carries (DXC's v1.9.2602 release, pinned and checked by tools/fetch_dxc.sh), else the system's - and needs nothing else of it (not dxil.dll). A library that does not compile to SPIR-V is passed over; without one the switch keeps every lift, counted as "DXC not found". A module costs DXC ~65 ms median (-O3, eight at a time on this machine), once: the result is kept in the translation cache. A sample's run-time offset, which Vulkan allows with maintenance8, is one thing DXC's own validator refuses with no option to allow it: such a module is compiled without that validator and validated by bbhost with SPIRV-Tools, with the offset allowed (the Windows build has SPIRV-Tools for it too; a build without keeps the lift).

  • Drivers. gcn2hlsl --sweep --app0 <game folder> lifts every program as bbhost does on the machine's GPU, compiles it through HLSL, and has that GPU's driver build both the lift's module and DXC's into the pipelines the renderer makes of the stage (its graphics pipeline libraries, then a fast and an optimized link; a game hull's three stages as one native hull pipeline), printing what it built and refused by stage and every DXC module refused where the lift was built - the stages the in-game fallback would give back the lift. The pipeline state the modules do not say (target and vertex formats, the neighbouring stages) is made from their interfaces. On lavapipe with the validation layer and on an RTX 4070 every one of the 13,858 lifts and its DXC module was built (171 hull sets among them). tools/package_hlsl_sweep.sh makes a kit that runs it on another machine.

What comes next

  • The completions the game waits on (GX's block pools and command arena, Map, query results) from the host's own submission timeline rather than labels, after which the PM4 command processor only orders work.
  • Guest memory off the GPU, the way the PC engine's resources are API objects filled by copies: copy sources through staging, constants and rewritten vertex data copied as recorded, compute shaders' buffers bound, the buffers the GPU writes held by the host; the whole import then goes.
  • Edited shaders with textures or samplers of their own (a descriptor set kept for them in every pipeline layout), and an edited shader for some draws of a program and not others.

Window imports and the textures' sources (a design note)

The game's GPU-visible memory can be imported a 16 MB window at a time (BBHOST_IMPORT_WINDOWS=1, or import_windows = true under [gpu]) instead of whole. About 1.0-1.3 GB stays imported instead of 5 GB, the driver spends 0.27 s importing instead of 1.27 s (RTX 4070), and the command processor's time in play is the same. The Steam Deck kit uses it. On the desktop it waits on the area arrivals, measured at Central Yharnam, Cathedral Ward, the Hunter's Nightmare, Laurence's staircase, Lumenwood and Astral:

  • With windows, three copies the GPU made from the whole import became CPU copies into upload staging: the buffer shadow's mirror pages (8,552 pages, 534 MB at Nightmare of Mensis' arrival), copy tokens' sources (about 2 GB a run), and texture uploads' tiled bytes (copied by the prep pool besides being hashed).
  • The first hitch after a load (130-160 ms) was the mirror pages, copied on the command processor. On threads of their own (bb-pagecopy, BBHOST_SHADOW_COPY_THREADS) that first frame came back to whole imports' 42-62 ms.
  • What is left are copies a submission needs at once. The command processor waits for the texture preps whose staged sources the next submission reads: 350-450 waits and 150-180 ms a run, against about 45 and 4 ms with whole imports; more prep threads do not shorten it. It also waits for copy tokens' sources copied just before a submission. Window mode then counts one to three more arrival stalls a place than whole imports, and 32-36 a 12-place tour against 25.
  • Most of those waits were for textures made ahead of their first bind, and most of those are never bound. Such a texture's upload is now recorded at the first submission after the prep pool has copied its tiled bytes into staging, with no wait (BBHOST_GXVK_AHEAD_DEFER=0 records it at the creation, as before). Whatever uses the image before then records it first, and waits for the copy only if it is still running: a binding, an upload token, a fill, a move in the image heap. A carry of a mip chain no longer waits for the upload it has just queued, whose hashes it takes again at once. On lavapipe at Laurence's staircase the waits fall from 227-236 to 11 a run.
  • The rest of the remedy is to let the GPU read those sources again: windows imported ahead of the upload, off the command processor, at the GX resource's creation (as the import prefetch does for buffers), and retired once idle so that the imports stay near a gigabyte, with staging only where no window is there yet. It belongs to the step that makes GX textures Vulkan images at their creation, which removes most of these imports anyway.

Resolving draws where their command lists are finished (a design note)

The command processor limits the uncapped frame rate at the heaviest scenes - at Nightmare of Mensis about 11 ms of its CPU a flip for 1,270 draws, against 8.4-8.75 ms for 913 at Central Yharnam - and the next large step for it would be to stop visiting draws: each GX command list's draws resolved, and recorded into Vulkan secondary command buffers, on the thread or pool that finished it (GX's FinishCommandList and ExecuteCommandList(s) are source, src/decomp/gx/command_list.cpp), the command processor checking each list against what ran before it and stitching the lists in order. It is not being built yet; the reasoning, as measured on the development machine:

  • Recording is already off the command processor. bb-record replays its packets, ~2.3 ms of work a flip at Mensis. Secondary command buffers as such would spread work that is not on the critical path; what costs the command processor is resolving each draw.
  • Moving pieces of it to the GX call does not help. Two experiments did: a draw's CPU-written constant buffers copied at the call, and each stage's key bindings (its T#s' words, image types and views, its samplers' modes) resolved there. Both were correct and neither shortened the command processor, while the GX threads paid 0.5-1.5 ms a flip for them. Its cost is reading each draw's data - 116-135 last-level cache misses a draw, a quarter of them its lookahead's prefetches of what the GX threads wrote - and a piece moved to the call is replaced by reading what the call wrote. Only a command processor that no longer visits each draw gains.
  • What could leave it. Of its time at Mensis ~19% does not depend on the order of execution (pipeline keys, vertex formats, user data, the token lookahead, building packets), ~16% needs only a check per list (the buffer shadow's placements, texture views), ~22% must stay in order (copy tokens and copy-backs, the packet walk with its labels and waits, render targets and passes, the GPU-write tracking and copy versions, tessellation, submission), and the draw path's own code, ~42%, goes with whichever of these it serves. Keeping the serial work (~1.4 ms) and adding a check, the barriers and an execute per list, 7-9 ms a flip could leave it, realistically 4-6.
  • What has to stay serial. Labels and waits (a list splits at each wait, and the draws after it are resolved only once the command processor has passed it), the submission and flip order, copies and dispatches between lists, the buffer shadow's imports, GPU-write tables and copy versions (each list's read ranges checked against the GPU writes and imports since it was resolved), and render targets - their surfaces, layouts, clears and barriers, which go only between secondary command buffers, so a list splits at every target change, barrier, clear, copy or wait.
  • Why it waits. The main loop's own frame is ~10.1 ms at both places, so at Mensis the command processor needs only ~1 ms less to stop limiting it (+10-12% there), and every millisecond after that shows nothing until the main loop is faster; Central Yharnam is limited by the main loop already. A paced frame rate gains nothing, the CPU time moves to other threads rather than shrinking, and a four-core machine has no spare thread for it. It is the step after the main loop is under ~8-9 ms.
  • Its risks. State that changes between a list's finish and its execution - the command processor runs about a frame behind: streaming, area entry, render-to-texture within a frame, resolution changes - which needs a mode that resolves both ways and counts disagreements; dynamic-rendering inheritance per secondary; descriptor and command pools per thread, alive until their submission retires; the pipeline cache and its compiles from many threads; resolving on the GX workers would lengthen the barrier the main loop waits in for their jobs; the drivers' cost for hundreds of secondaries a frame; and the tools that assume the command processor resolves each draw (F12 captures, tools/glitch_hunt.sh, BBHOST_GX_COST, drawreplay). Its first step would be a compact command per draw, built at the GX call in place of the token's sparse records.
  • Measured where the command processor limits. At Kyo's save in Central Yharnam on a Radeon 8060S (165 fps, the command processor 96% busy, the main loop's own work 4.4 ms) 42% of bb-cp0 is per-list work, 31% per-list work with a check, 20% in order; ~1,390 draws a flip fall into ~67 runs of one GX context each, and the command processor reaches most draws two flips after their GX call. The split, the runs (BBHOST_LIST_RESOLVE=runs) and the order to build it in are list-resolve.md.

Draws committed ahead and spliced (BBHOST_GXVK_LISTS=splice, off by default while it is measured). A first form of it is built: a pool of host threads (bb-list0, bb-list1) takes each GX-native draw a GX thread has stored and commits it ahead of the command processor through the draw path itself, in a list mode - a run part's draw (as the run commit's parts make them) with its own packet, its params blocks kept as contents, its constant buffers' copies in an arena of its own, the targets the command processor last looked up for the same target names, and the caches read through their readers' paths under a lock their writers take exclusive (src/host/cache_rw.h). Whatever only the command processor's place in the walk answers - the pass, the barriers owed for what the draw samples, owed clears, a texture's refresh in the recording it lands in, occlusion queries and predicates, a cached set still being the cache's, a home with a copy pending - is noted, not read. At the draw's token the command processor checks those notes against the run it has open (the run's first draw drawn as before: its targets looked up, its pass begun), makes the refreshes as it would, copies the params into the recording's slots and appends the packet; any draw not committed, or whose checks fail, is drawn as before, counted by why. A draw that reads an answer of the walk's order (copy versions, GPU writes, the buffer shadow's mirrors, twins) is not committed, so the constant buffers' homes (BBHOST_GXVK_HOMES=1) are what give it most of its draws. BBHOST_GXVK_LISTS=splice-compare draws every draw as before and compares each draw the splice would have taken with the commit, field by field; the pool's threads keep cores of their own (BBHOST_GXVK_LIST_CPUS=off: anywhere). On lavapipe at Central Yharnam with the homes on, the pool committed 64% of the draws and the command processor spliced 55%; the compare found 0 of 52,269 draws different, and the frames were within the noise of the homes alone.

Segments (BBHOST_GXVK_LISTS=segments). A list a GX context finishes comes to the pool as the draws its context recorded, in order, and a pool thread cuts it into segments: draws one after another in the list's command buffer - nothing between their tokens the command processor does in order - into the same targets and pass, each committed. A segment's first draw is left as the splice has it (it opens the command processor's run and pass); for the draws after it the pool writes their params blocks into its own region of the params buffer and merges what each noted for its splice. At the first of those draws the command processor checks that the stream holds the segment's tokens as recorded, checks the segment once as the splice checks a draw, and appends one op; the tokens of its other draws are given back as the walk meets them, without being read. By default the recorder replays the segment's packets into the command buffer from that op, chained. With BBHOST_GXVK_SEGMENTS_REPLAY=secondary the pool records them into a secondary command buffer instead - each draw under the caches' readers' lock, once the descriptor sets it binds are written - which the recorder executes: passes then begin able to hold secondaries where the device has VK_KHR_maintenance7 (asked of the device only then), and are ended and begun again around them where it has not, at ~10 us of GPU time each. On an RTX 4070 the two replays did as well as each other within noise, the inline one with a little less GPU time and a quarter of the pool's work a draw. A segment whose checks fail goes back to its draws' own splices, counted by why. The pool's constant-buffer copies take the last 16 MiB of the command processor's ring, which keeps the rest while the pool runs, so on a card with a small window of video memory the CPU writes both stay in video memory (in host memory the GPU read them across the bus: +11% GPU time on an RTX 4070). Their tables - the vertex and resource tables a draw's user data points at - take the last 16 MiB of GX's tables ring in the same way, in 1 MiB segments a pool thread owns while it places there, each taken again only once no commit placed in it can still be spliced and the recordings its commits went into have run; the command processor's part of that ring waits, at a lap, for the recording that last placed in a segment to have run. (Until 2026-11-13 a pool thread kept a chunk of the shared ring until it was full - across a rest at a frame cap too - and could write over tables the ring had handed out since.) Unset, the switch follows the constant buffers' homes: segments where the homes bind by handle, off elsewhere (small video memory, an integrated GPU) with the reason in the log; the pool needs 8 hardware threads or more. BBHOST_GXVK_LISTS=segments-compare draws everything in order and compares each draw of a segment that would have been spliced with its commit. On an RTX 4070 with the homes on, uncapped, the command processor's time a flip fell 27-31% at Old Yharnam, the Nightmare of Mensis and Cainhurst's courtyard, at 0.35-0.5 us a spliced draw, and the frame rate rose 5-11% at Old Yharnam, where the command processor had been the limit.

On by default above 60 fps, and on Windows at any rate (BBHOST_GXVK_HOMES unset). The constant buffers' homes - and with them the segments and the copy-back captures they take - are on by default only where the frame rate can gain from them: a graphics card with room, or one with small video memory that has 5,000 MiB or more free at the start (the homes' own rule below: not an integrated GPU, no tight memory), and a frame rate above 60 (a fixed rate above 60, or Display-Limited on a display above 60 Hz). The pool takes its threads from the CPUs the process may run on (its CPU affinity, so a taskset counts): two from 16 hardware threads, one from 8, none under 8, where the homes go on alone. With fewer threads the old path's command processor competes with the game's own, and the homes win more: with the game confined to 8, 6 and 4 hardware threads of an RTX 4070's Xeon (uncapped, alternating runs) they ran Old Yharnam 51%, 9.0% and 1.4% faster than the old path, Central Yharnam 5.1%, 5.5% and 2.8%, the sewer pit 6.7%, 4.2% and 5.1%, the slowest frames no slower. Under Windows on an RTX 3070 Ti Laptop GPU with the game on 8 hardware threads (start /affinity FF) the default ran Old Yharnam 42% faster than the run commit and the other four places 3.2-6.3%, the process 19-51 points of CPU lower but at Old Yharnam. On Linux at 60 and below the frame waits for its limit anyway, and the command processor draws in order as it did before them. On Windows, where the run commit is on by default, the homes take its place at any frame rate: the run commit gives way to them and the pool rests while a cap holds the frame (its duty rule, below). At a true 60 on an RTX 3070 Ti Laptop GPU (1080p, alternating runs) they took 15-33 points of CPU less than the run commit at Old Yharnam, the Nightmare of Mensis, Cainhurst's courtyard, Central Yharnam and the sewers under it, the frame rate (59.7-59.8) and the slowest frames the same. On a card with small video memory the homes take the pool's budget (128 MiB, as on a card with room) and the game's memory is still imported a window at a time; under 5,000 MiB free they stay off (on a 4 GB card the pool pushed images into host memory), unless BBHOST_GXVK_HOMES_BUDGET_MB gives a budget. A 6 GB card has more: acted out at 5,000 MiB free (BBHOST_TEST_VRAM_MB=5000, the device-local types held to it too) the homes ran Old Yharnam 36.5% faster than the run commit under Windows on an RTX 3070 Ti Laptop GPU (the other four places 2.6-4.7%, the GPU's time no longer) and 24% faster than the old path on an RTX 4070 under Linux (the Nightmare of Mensis 6.3%, Central Yharnam level, the GPU's time 2.6% longer), no image pushed to host memory.

The pool's splices give way to the run commit (BBHOST_RUN_COMMIT). Turned on by its setting, it keeps the homes off by default. On by Windows' default alone, it gives way instead where the rest of the rule holds: there the draws are committed in order but for the pool's splices, as on Linux. Under Windows on an RTX 3070 Ti Laptop GPU with 16 hardware threads (1080p, uncapped, alternating runs, frames within noise, no draw failures), the homes and the segments without the run commit against the run commit:

the card Old Yharnam Nightmare of Mensis Cainhurst's courtyard Central Yharnam
as shipped (8 GB, 7,249 MiB free: small video memory, the 128 MiB budget, window imports) +27% +3.0% +3.6% +4.0%
taken as a card with room (BBHOST_SMALL_VRAM=0: whole imports) +29% +2.5% +2.2% +3.4%

As shipped, the shared GPU memory stayed at 2.1 GB (whole imports, on the second row, pinned 4.95 GB). Where the rule does not hold - an integrated GPU, a card under 5,000 MiB free - the run commit stays on by Windows' default, and works by the pool's duty rule (below). The homes are made as their buffers are, so the choice is made once, with the device at start: a frame rate changed in play (it changes at once, 30 included) leaves the choice as it was until the next start. Off, one line says why (gxvk homes: off by default here (...)); on, the homes' line says what decided it, and on Windows the run commit's line (list-resolve: run commit ...) says whether it gave way. BBHOST_GXVK_HOMES=1 turns the homes on anywhere they can be made, and Windows' run commit gives way to them there as it does to the default - kept beside them at 60 fps, the pool committed 86% of the draws for nothing on the RTX 3070 Ti Laptop GPU, 106-152 points of CPU over the run commit alone, where the homes without it took 9-34 points less than the run commit at a true 60; =0 keeps the path before them with the run commit as it was; BBHOST_RUN_COMMIT set decides the run commit either way, and BBHOST_GXVK_LISTS the segments alone.

The pool's duty (BBHOST_GXVK_LISTS_REST). The pool works only where it shortens the frame; resting, it is given no draw and the command processor draws them all in order with the homes, as with BBHOST_GXVK_LISTS=0. A draw stored while the pool rests is the command processor's alone: it asks the pool nothing about it (BBHOST_GXVK_LISTS_SKIP_UNFED=0: it looks each one up as it does while the pool works) - at a 90 cap on the RTX 4070 below that takes the 99th percentile frame 0.7-0.85 ms shorter where the pool rests. It rests while a frame cap holds the frame (two half-second windows in a row with the limiter waiting 15% of the time; it works again once the command processor, drawing everything, is busy 85% with the frame meeting its cap narrowly - the limiter waiting under 15%, the medians of three windows at the cap - or 92% however long the limiter waits, or the frame misses the cap with the game held back by the command processor's backlog 20% of the time; until 2026-11-10 any one window 85% busy woke it, and at Central Yharnam at a 90 cap on the RTX 4070 below, with Windows' default acted out and the command processor 71-75% busy at rest, one such window kept the pool working, 1.2 cores, for a frame the cap held either way - it rests there now; a saturated command processor drops frames resting, so the pool works on there: at Old Yharnam at the same cap, 92-97% busy at rest, resting left 4-15 frames of a 30 s window over 16.7 ms against 2 working and the 99th percentile frame 1.7 ms longer (15.4 against 13.7 ms), for 0.8 of a core and 4 W; near a cap (the limiter waiting 8-15%), where it used to work on for good, it tries a rest - the switch's 1.5 s, then 1-1.5 s counted - and keeps it where the cap holds the frame without it, else it works again and the next trial waits the cap's backoff), while the frame is the GPU's (busy 90% of two windows, until it is under 80% over six), and wherever resting costs the frame nothing. With no cap holding the frame, a rest the GPU began is judged by the frame when it ends: resting 8% slower than the GPU-bound windows that began it, the pool's work was what kept the frame the GPU's, and that is an experiment's clear answer - the pool works, and no GPU-bound rest and no probe come for 40 s, then 160, then 240 (a loading screen starts the place over; at a cap nothing changes). On the RTX 4070 below, uncapped, the Hunter's Dream ran 204-208 fps working with the GPU 91-95% busy and ~170 resting (the command processor the wall, the game held back 70%), and Cainhurst's courtyard 166-170 and 106-113: the GPU's rest began after two windows, ended after six and began again two later, ten times in every 20 s, and the places ran 180-184 and 121-124 fps against 216 and 167 with the pool never resting. A rest that runs as fast - an APU's frame, the GPU's either way - is the GPU's as before. That last is measured at each place, both ways: 10 s after the pool began to work there, an experiment rests it for 5.5 s and lets it work for 5.5 s more, and compares the frame rate resting with the windows on either side of it; under 0.5% slower resting, the pool rests, and an ask now and then (work, then rest again, compared the same way) looks again, twice as far apart each time (to 4 minutes). An 8% difference decides in 3 s and puts the next experiment four times as far away. Where resting holds the game back by the command processor's backlog under 10% of the time, the pool has nothing to shorten: it rests unless resting is 8% slower, and no ask is made while that lasts (the frame rate alone, a few seconds each way, can be 2-3% off at such a place). Each switch takes 1-2 s to settle either way, and the first 1.5 s of each phase are not counted. On an RTX 4070 with two Xeon Gold 6230 (1080p, uncapped) the pool is worth 9-13% at Old Yharnam and 7-11% at Cainhurst's courtyard, and costs 1-3.5% in the sewers under Central Yharnam, where its two threads beside the game's slow the game's own code; under Windows on an RTX 3070 Ti Laptop GPU (16 hardware threads) it is worth 24-32% at Old Yharnam, 2-4% at the Nightmare of Mensis and Cainhurst's courtyard, about 4% in the sewer pit, and 0-4% at Central Yharnam from one sitting to the next. Each place after a loading screen starts working, and a rest at a cap ends once the frame is under 85% of the cap for 3 s (the title's menus meet an uncapped game's 960 cap). BBHOST_GXVK_LISTS_REST=0: the pool never rests; =always: it always does (what resting costs against the pool off); =cycle:N rests and works N frames each in turn (a check); BBHOST_GXVK_LISTS_REST_LOG=1: every window of the rule in the log.

The run commit's duty (BBHOST_RUN_COMMIT_REST). Where Windows' default keeps the run commit - an integrated GPU, tight memory, a card under 5,000 MiB free - the same rule decides when it forks a run's parts, without the frame-rate experiments: it rests while a cap holds the frame and while the frame is the GPU's, and works anywhere else, as it did. Resting, no run is forked: the command processor draws every draw in order and the run commit's workers sleep (a run forked before the rest began is taken as it was). At a true 60 under Windows on an RTX 3070 Ti Laptop GPU held to a 4 GB card's 2,950 MiB that took Central Yharnam from 235% of CPU to 207% and ran the GPU-bound Nightmare of Mensis at 38.8 fps against 35.5; on the laptop's Radeon 680M, GPU-bound at 30-34 fps, it took 21-31 points; with Windows' small-card default acted out on an RTX 4070 under Linux, 80-105 points at five places, the frame the same. An experiment (the other state for a few seconds) cannot see what its rests cost later: on that 4 GB card a working run commit came back slower after them. Its lines say list-resolve: where the pool's say gxvk-lists:. BBHOST_RUN_COMMIT_REST=0: it never rests (as before); =always: it always does; BBHOST_RUN_COMMIT set keeps its own answer.

GX's objects as Vulkan objects (a design note)

GX - the engine's Direct3D 11-shaped layer - keeps its buffers and textures in guest memory, and the command processor finds each draw's bytes there by address: copy versions, the buffer shadow's mirrors and snapshots, the import, the texture cache. The direction is to make GX's objects Vulkan objects when GX creates them, so that a draw carries their handles and the command processor resolves nothing, in stages: buffers, then textures and views, then GX's state as pipeline pieces, then command lists recorded into Vulkan command buffers in parallel and completions on timeline semaphores, after which guest memory is no longer what the GPU reads for GX's objects.

Buffers (the first stage). A census (BBHOST_GXVK_CENSUS=1) measured what it rests on at Central Yharnam, Old Yharnam, Nightmare of Mensis and Cainhurst: GX makes 53-60 thousand buffers in such a session, 92% of them constant buffers without data; its immutable vertex and index buffers - about 1,040-1,340 of them, 1.2-1.6 GB - are never written again through GX (no Map of them, no UpdateSubresource of a buffer other than a constant buffer), and hold 75-85% of the vertex records the draws bind at the three places where the command processor limits the frame rate (85-94% of those in GX's own buffers) and 74-79% of their index ranges (99%). A GX holder has spare bytes that no GX code writes: the dword at +0x14, the upper half of the reference count (every locked operation on the count is 32-bit), in buffers and textures alike, which canaries confirmed at every binding and death (1 of 2.2 million checks failed). The dword at +0x44 is not spare in a constant buffer's holder: GX counts in its upper half.

Such a buffer - immutable, or default with initial data; no CPU access; a vertex or index bind and nothing the GPU writes - gets an entry in a host table when GX's CreateBuffer (on the decomp list) makes it, and the entry's handle in the holder's +0x14. The GX call copies the handle into the draw's record beside the holder; the command processor binds the entry's device-local copy - placed in a pool and filled from the buffer's memory in the uploads of the first recording that binds it

  • instead of resolving the record's address, and plans the vertex input at the guest addresses, so its bindings and pipeline are today's. A Map, an UpdateSubresource or a GPU copy into the buffer retires the entry and its bindings take today's path again. Every GPU copy GX records asks a watch of the kept default buffers' ranges first, by the 64 KiB granules they cover (one-byte counters in a 16 KiB table), so a copy far from all of them reads a counter or two, and one next to them searches the ranges, sorted, in halves; a buffer that ended (its holder released, its memory unmapped or given to a new resource) is still bound from its copy by the draws recorded before its end. Video memory is used down to the reserve kept for render targets and device buffers; short of room a buffer keeps today's path - never a copy in host memory on a discrete GPU, where one placed during a dip stayed for the session and every draw of it read across the bus (on an integrated GPU, whose host memory is the same RAM, host-visible memory is taken) - until a draw half a second or more after the refusal finds room for its copy (BBHOST_GXVK_ROOM_RETRY=0: for the rest of the session, as before, when a 4 GB card read 109 such buffers' 9.9 M vertex records from guest memory over a 3.5-minute tour). BBHOST_GXVK_BUFFERS=2 keeps today's path and checks the handles beside it - the vertex input, the bytes as today's path finds them, the buffer's bytes against their hash when copied, the device copy read back - and the exit report counts the bindings by handle, the fallbacks by reason and any disagreement.

GX's buffers are bound by handle by default on a discrete GPU and on an integrated GPU with 8 GiB of video memory or more (BBHOST_GXVK_BUFFERS=0 keeps today's path). With small video memory (under 7.5 GiB free at the start) their copies have a budget - an eighth of what is free, 256-512 MiB (BBHOST_GXVK_BUFFERS_BUDGET_MB) - where the least recently bound goes first and the pool gives room back before the buffer shadow's mirrors are refused: without the copies the mirrors carried the meshes, and at a 4 GB card's budget they were refused room and the draws read their vertices across the bus. A smaller integrated GPU and tight memory keep today's path, where the draws read GX's buffers where they are - the buffer shadow in place, or no shadow - so a copy would hold memory the system needs, unless BBHOST_GXVK_BUFFERS=1. The log's gpu: memory: line says which (host/memory_policy.h). On an RTX 4070, uncapped, the frame rate goes from 83.6 to 94.6 at Old Yharnam and from 82.2 to 95.0 at the Nightmare of Mensis by handle, the command processor taking 1.4-1.6 ms a flip less; at 60 it takes up to 1 ms a flip less, with the GPU's time and the frame pacing unchanged.

GX's texture views bind from their entries by default (BBHOST_GXVK_IMAGES=0 keeps today's lookup and refresh). The entry a view gets at its first binding is one line: its image view, the pipeline key's dimensions for its bindings (decoded once from its T#, which never changes), the T#'s base and, bindless, its slot. A GX texture's image that nothing has written since its upload binds without its surface's refresh while nothing could have changed it: every place that changes such a surface moves one epoch, and each entry then refreshes once (and every 200 ms regardless, for the content hashes' schedule and the eviction's clock). No image, view or layout changes. BBHOST_GXVK_IMAGES=2 binds today's way and counts where an entry would have differed - a refresh it would have skipped that found work, an image of another generation, dimensions, bases, slots. On an RTX 4070, uncapped, the command processor takes 0.42-0.56 ms a flip less at Old Yharnam, the Nightmare of Mensis and the Cainhurst courtyard (Old Yharnam 92.8 to 98.3 fps), with the GPU's time, the frames and the frame pacing unchanged.

The upload heap (the stage's second part, off by default while it is measured). GX's device gives its block pool one region - GX's upload heap, 160 MiB, made by the pool's init, which is on the decomp list - and every renamed constant buffer, Map rename and ring allocation comes from it. The pool hands out from both ends of it: the deferred contexts from the heap's start, the immediate context from its top (its Map discards, among them a 256 KiB copy a frame for the ring its user-primitive draws fill), with one free list between them, so after a large load the two ends meet. GX hands a range out again only after an end-of-pipe label behind the work that used it has landed, and a label lands only once the host's submission has completed, so a renamed copy holds what its draws read until the GPU has done with them: in the census, 70% of constant-buffer bindings and 10% of vertex records lie in the heap. BBHOST_GXVK_ARENA=1 binds those where they are, in the heap's import - a vertex record as far as its draw reads - without the snapshot copy or the lookups. Every run it is used proves the rule again: each hand-out is a record, each binding stamps the record it lies in with its submission, and a hand-out over a record's memory needs that submission completed; and one binding in 64 has its bytes hashed when it is bound and again when its submission has completed. A violation sends every binding of the heap back to today's path for the rest of the run, and the exit report says so. Both ends' hand-outs are records: while only the start's were, memory the top end took back after the load into Old Yharnam read as a stale record's, and the proof stopped in two of four runs. A submission counts as completed for the proof from just before its labels land, not after: GX hands a range out again the moment it reads the label, which can come before bbhost has counted the labels in memory, and counted after, such a reuse read as early in one of four runs at Old Yharnam. BBHOST_GXVK_ARENA=compare keeps today's path and checks every binding of the heap as in place would bind it. Moving the heap into video memory the CPU writes was tried and dropped (BBHOST_GXVK_ARENA=2, removed): GX's device is made before bbhost's, so its pool was given a host mapping of bbhost's, whose bytes were copied into video memory at the GPU's start and the video memory mapped over it (VK_EXT_map_memory_placed, on Linux), in pieces of 32 MiB - NVIDIA's driver places that memory at most 124 MiB at a time. Every move worked, and on an RTX 4070 the frame rate fell by about two thirds - uncapped, Old Yharnam from 90.8 to 31.7 fps, the Nightmare of Mensis from 90.9 to 34.4 and Central Yharnam from 105.2 to 31.6, and 31-34 fps at 60 - because the CPU reads the heap too - bbhost's copies of GX's renamed buffers and the game's main thread - and the CPU reads video memory at about 30 MB/s. The heap stays in host memory, where =1 binds it.

The heap's constant buffers, snapshotted with no lookups (on by default; BBHOST_GXVK_HEAP_SNAP=0 keeps today's path). On a discrete GPU, binding the heap in place has the shaders read those constant buffers from host memory across the bus, where today's copies sit in video memory, so the GPU took 0.2-0.3 ms a flip more uncapped at Old Yharnam and the Nightmare of Mensis; and on the Steam Deck, where nothing crosses a bus, binding in place measured no faster than the snapshots once a snapshotted constant buffer took no import lookup. What is left to take away is the lookups a snapshot still asks before its copy: whether a copy-back is still in a copy version over the range, whether a device-local twin holds it, whether a GPU write is still to land on it, and whether it is mapped. For the heap the answers are known - it is a copy-back's source and never its destination, no GX buffer's own memory lies in it, the GPU writes nothing there, and it is mapped for the session - so a binding there takes the snapshot with those answers: the same copy of the same bytes into the same ring, shared within a recording as before. It is the shape Dark Souls III's PC renderer has on the same engine: its material constant buffers are updated with UpdateSubresource just before they are bound, so Direct3D 11 copies the bytes at the call into the driver's own copy in video memory. The answers are watched where they could change, not at each binding: a GPU write noted over the heap, a copy version made into it, a twin made over it, its memory unmapped. The first such event is said in the log, and from it on every binding of the heap asks the lookups again; in the command processor's order it comes before any binding that could see it. BBHOST_GXVK_HEAP_SNAP=compare keeps today's path and checks each binding's lookups against the answers. The exit report counts the bindings that took the answers, the ones that did not by reason (stored to, empty or over 1 MiB, past the heap's end, a draw with CPU-written windows, snapshots off, a check that needs the lookups, no ring yet, after a trip), each guard, and with compare each disagreement. On an RTX 4070, uncapped, the command processor takes 0.46-0.49 ms a flip less at Old Yharnam, the Nightmare of Mensis and Central Yharnam, and Old Yharnam goes from 90.6 to 95.1 fps; at 60 it takes up to 0.55 ms a flip less, with the GPU's time, the frames and the frame pacing unchanged.

Copy-backs from the heap with no CPU copy (BBHOST_GXVK_HEAP_COPY, off by default while it is measured). GX's map resolves copy each renamed buffer back to its own memory, its home - on the console a GPU copy in command order. bbhost makes each such copy-back a copy version: the source's bytes copied into staging as the command processor reaches it, bound for the home's draws until the batch's GPU copy puts them in place, so a draw of the home sees what the copy-back will write. Every such source is a renamed copy in GX's upload heap, which the game hands out again only after the work that read it has completed. With BBHOST_GXVK_HEAP_COPY=1 the version is the source range itself: no staging and no CPU copy. The batch's GPU copy reads the heap; a draw that binds the home as a constant buffer takes the source through the heap's snapshot above, so no shader reads a renamed constant buffer in place (one over the snapshots' 1 MiB puts the copy-backs in place first); a vertex or index binding reads the heap. The release order is checked every run for these sources as for the arena: each source stamps the hand-out it lies in with its submission, and one source in 64 has its bytes hashed when it is taken and again when its submission has completed. GX can hand a source out again before its copy has run: it retires a context's blocks when UpdateSubresource kicks the context's command buffer, before the copy-backs that read renames in them are resolved, which on the console run right after the retire. So such a hand-out waits for the GPU first, as GX's own block reclaim does: what is recorded is submitted and run, and the copy has read the source before its new owner writes it. Changed bytes, or sixteen such waits within a minute, send every copy-back back to a CPU copy for the rest of the run. A source no hand-out holds, one an earlier version covers, one while the heap's snapshots are off or after their guards tripped, and any with window imports take today's copy, counted by reason. BBHOST_GXVK_HEAP_COPY=compare copies as today, runs the proof over the sources as 1 would, and compares each version with its source at its batch.

Constant buffers in device-local homes made at their creation, bound by handle (BBHOST_GXVK_HOMES, on by default above 60 fps - on Windows at any rate - with a card with room or 5,000 MiB free, the run commit giving way on Windows: "On by default above 60 fps, and on Windows at any rate" above). A constant buffer's own memory is written only by GX's GPU copies: every UpdateSubresource of one, and every Map of a dynamic one, writes a renamed copy, and the map resolves copy the renames back. With BBHOST_GXVK_HOMES=1 each constant buffer of default or dynamic usage gets a home when GX creates it - a range of a device-local pool, fixed for the buffer's life - and the home's handle in its holder. GX's draw records carry the handle beside the constant buffer's record when the record names the buffer's own memory, and the command processor binds the home by it: no copy version, no twin, no pending GPU write and no snapshot asked about. The copy-backs' bytes are copied when GX resolves them, on the GX thread that resolves, into a ring the GPU reads (a segment per GX thread, a resolve's copy-backs in one piece, a piece written again only once its tokens are walked and the submissions that read it have run), and land in the home as GPU copies in stream order, put in place together before the next pass starts (or before a dispatch, a transfer that touches them, or the submission's end); a draw in the same pass after the copy-back binds its capture. A home is filled from its buffer's memory at its first use, unless that use is a copy-back over all of it. What reads a home without a handle - a dispatch, a copy, a device address - finds it by address; a CPU copy of its stale guest bytes is refused; a page-table walk that reads it gets it copied back to its memory first, and it stays the home. The command processor's index of the homes by address changes in place, so the draw pool's threads read a copy published for them instead - the homes touching each 4 KiB page as an immutable list swapped by pointer, freed once no reader can hold it, a run of changes seen whole or not at all - and change nothing. A home ends with its buffer, and a buffer made past the pool's budget (128 MiB, BBHOST_GXVK_HOMES_BUDGET_MB) takes today's path for its life. Off on an integrated GPU, and with small video memory under 5,000 MiB free at the start unless a budget is given (on a 4 GB card the pool's ~80 MiB pushed images into host memory); from 5,000 MiB free (a 6 GB card) the pool's budget is the same 128 MiB. BBHOST_GXVK_HOMES=compare keeps today's path bound, keeps the homes beside it with a CPU mirror of each, and checks each binding of a home against its mirror (and each capture against the bytes today's copy takes at the token); =twins keeps the homes as device-local twins (BBHOST_GX_TWINS=2), as measured before. With BBHOST_GXVK_COPYBACK_CHECK=1 each dynamic constant buffer's UpdateSubresource notes a hash of the bytes the rename gets, and each capture is compared with it and its source's block classed: the update's own block, a block handed out since on the same thread, or one handed out again to another thread before the capture read it.

Tools

Tool What it does
gcn2spv translates and validates every shader in the game's bundles
gcn2hlsl lifts every shader in the bundles, prints it as HLSL, compiles it with DXC and checks the module against the lift (--tess for the tessellation stages; --spv for one module); --sweep has a GPU's driver build every lift and DXC module as the renderer would
hlsl_equiv each lift and its DXC module on the same random inputs (on lavapipe), outputs compared bit for bit: pixel, vertex, LS, hull and domain shaders; --compile has a device's compiler build each compute module
tools/hlsl_verify.py captured draws and dispatches replayed with DXC's stage against the lift's
gcndis disassembles GCN programs
F12 in game dumps the frame, every render target and the draw list into a folder of its own (tools/f12_check.py reads it; BBHOST_F12_PNG=1 for PNG)
BBHOST_CAPTURE_DRAW + drawreplay captures one draw with its inputs and replays it outside the game; BBHOST_CAPTURE_DISPATCH does the same for a compute dispatch
tools/area_check.py twelve places in the game measured the same way every time - frame times, GPU time, draws by how their pixel shader ran, compiles, frames and lift checks - and two builds compared against their own noise (area-check.md)
BBHOST_VK_VALIDATE=1 runs with the Vulkan validation layer
BBHOST_VA_TRACE=1 logs every guest-memory import made, put in place, retired and freed, every window whose page-table entries move, every device buffer made through create_dev_buffer with its owner and every staging or scratch chunk freed (va: lines, the wall clock in seconds and microseconds, to match journalctl -k -o short-unix); a device fault report then looks its addresses up in them. =2 adds the driver's own binds and unbinds where it reports them (VK_EXT_device_address_binding_report)
BBHOST_GPU_PROFILE=1 per-pass GPU timings
BBHOST_GPU_CHECKPOINTS=amd the GPU's progress markers (VK_AMD_buffer_marker, which NVIDIA's drivers have too) everywhere, not only while a loading screen is up, as they are by default: two words before each draw and dispatch, and the front end's word before the ops between them where it stops or the pass changes - barriers, pass ends and begins - with every op noted. A lost device then names the draw or dispatch the GPU had started, the op its front end had reached, the ops between the two, and whether a barrier among them says the draw had finished (barriers hold the front end on NVIDIA's and AMD's GPUs; the specification does not promise it); a loss after a loading screen's markers ended says so, and that they were off there. The default's window opens at the first submission recorded once a loading screen is up and closes at the first one 200 ms after it has gone, and nothing of them is written or done in between - in the world they cost frames. =0 keeps them off in loading screens too; =after-loss also marks everything for the three starts after a loss; =amd-dry and =loading-dry record them, everywhere or in loading screens, on a device without the extension (lavapipe)
BBHOST_GPU_MARKER_OPS=all with the markers on, the front end's word before every op between draws: where the front end was held between two barriers shows too, at a cost on NVIDIA's GPUs, where a word between two copies holds them apart
BBHOST_MARKER_TRACE=<prefix or *>[:n] with the markers on, the ops noted after the first n (4) draws of the pipelines whose name starts with the prefix, and every 300 flips what a lost device would say from the words as they stand
BBHOST_UPSCALE_CHECK=4 + tools/upscale_check.py the upscalers' reprojection check, with an upscaler on and BBHOST_UPSCALE_JITTER=0: in place of the upscaler's picture, green where the motion explains how the scene changed since the last frame, red where it does not, blue where a surface came from off the screen; every 30 frames the log has red's share of what changed, over the picture and in sixteen bands of its width, and the tool sums it over the windows where the picture moved
bbhost --stream-selftest[=N] checks the command stream headless against a CPU model, N rounds (16 by default), and exits with 0 when it matched; run it with BBHOST_VK_VALIDATE=1 too