An execution of render commands recorded in its GPU form wrote its whole
scratch into the command buffer's upload arena, which on a discrete GPU
is system memory. The preprocess wrote its slot tables, arguments and
index entries there, the two merge passes' serial loops read and wrote
the prefix and block sums there many times a command, and every draw
read its slot tables and arguments there, all across the bus.
The scratch is now a buffer of the runtime's own in Private memory
(Device::scratch_buffer), held by the segment's encoder until the
command buffer completes. The host still writes the head alone (the
parameters, the resident root table and its set, the extents, the
encoder's buffers and a merged replay's header) into an upload region,
and a copy carries it into the scratch between barriers before the
range's copy and the preprocess. The command buffer's first submission
still points the table in that region at the resident set as it lies
then, before the copy runs. The table lies at a multiple of an entry in
the scratch (the buffer takes 32 more bytes and the scratch starts
where that holds), as RootTable::resident_fields needs of a table and
its set.
The translator is unchanged: the kernels still address every section
from the resident table's address, so the scratch stays one buffer.
The preprocess writes every byte the merge passes, the draws and the
trail read (every command's arguments, zero where it draws nothing; a
merged replay's index entries, prefix, block sums and draws), so the
unzeroed buffer needs no clear.
With the encoder trail on, the GPU copies the words the trail's line
reads (GpuForm::sections: the range copied, the merged draws, the first
2^20 commands' arguments and their index entries) into an upload region
at the scratch's offsets once the passes that write them ended, and
the line reads that copy. Off, nothing is copied.
WorkCounts::gpu_form_device_local_bytes counts the scratch bytes the
device placed in device-local memory (checked on the buffer's pages),
and the trail GPU-form tests assert it is non-zero where a GPU form was
recorded, with their texts unchanged.