Control memory, counted as the driver writes it

nvn keeps no control entries of its own, but it counts the bytes the game's driver would write there (nvn_cmd.c's ctl_count), so GetControlMemoryUsed, GetControlMemoryFree and GetControlMemorySize answer as the driver does. Before, Used was 0, and one game gave several command buffers the same control memory while it still called the recordings made there. The counts, from one NVN 55 driver's code:

EntryBytes
a recording's start mark (BeginRecording)0x10
its end mark (EndRecording)8
a range of the commands since the last entry, in an open block / opening one0x18 / 0x20
a compute-stage texture, sampler or image bind; a dispatch0x10 (and the range before it, closing the block)
a compute-stage uniform or storage buffer bind0x18
a calla range entry per callee (0x18, or 0x20 opening a block)
a copythe range of the commands it copies
a recording still open when the game adds control memory0x10, the link to the new memory

The driver keeps the last 0x10 bytes of the memory for that link. When the entries don't fit, it calls the memory callback with event 1 and 0x100 bytes, and stops the game if there is still no room: nvn counts nothing more then. The room it checks is the entry's own bytes (0x20 for a range entry, also one of 0x18). The 0x100 is only what it asks the callback for, so a game that gives 0x100 bytes records there without a callback (the NVN drivers of SDK 6.5 and 19.3 both do this). It merges a range with the one before it when the two touch, which nvn doesn't model, so its count can be higher. A call also copies the callee's other entries (its compute binds), which nvn doesn't count: the handles of recordings in the runtime's memory are used again once their pieces come back, so a count kept by handle went to the wrong recording (a recording that calls the one before it at the same handle counted 0x18 more each frame, and one game's 0x200 bytes of control memory ran out).

The pieces of the runtime's memory that carry a recording's records are anchored in both memories: where the recording starts in command memory and in control memory. A look at either memory over the anchor gives them back. A recording that counted no command bytes (calls, compute binds) is all control entries on the console, so only a look at the control memory gives it back. One game hands the command memory such a recording starts in to another command buffer while it still calls the recording. Before, the pieces of a recording of calls alone came back only when the command memory wrapped round, and one game's records grew to 64 MiB of the runtime's memory in a minute.


Made from docs/layers/gpu/nvn.md at 69237645142c. GPL-3.0-or-later.