The programs a game ships

The startup pass (pf_ship_pass, ship_program, ship_make) translates about 7,400 programs into <game>.vkshipped, with no draw state. It makes no modules and no pipelines now. A draw takes a module from the file when its key matches (pf_ship_take).

After the pass, a worker can compile the parts of these programs:

What the pass must guess for each part, from no draw:

WhatThe guessA wrong guess costs
the module's key (mask)the pass's key now: all words 0, the clip word from ship_clipa new translation and a part compile at the draw, as now
the last stage before rasterizationthe vertex program is the last (ship_clip)the same
arraysthe program's own indexed bit, known after the translationnothing (the bit comes from the program)
polygon, depth clamp, provoking vertex, conservative, patchnone, they are dynamica PR compile, only on a device without that dynamic state
feedbacknone with has_feedback_dynamican FS compile, only without it
sample shadingoff (FS part with no multisample state)an FS compile for a draw with sample shading
transform feedbacknonethe module differs, so a new translation

A part compile for 7,400 programs is a lot of driver time and driver memory. A 1.7 MB vertex program takes seconds. So the pass does not keep these parts. A worker makes each part into g_pipeline.pcache and destroys it at once. This is the method that Fossilize uses to warm a driver cache. When a draw asks for the part later, its make is a hit in the cache. Its cost is the hash and the lookup, not the compile. The parts go on the lowest queue, behind the draws' work. They stop when the game exits, and g_pipeline.pcache is saved by vk_pipeline_save as now.

The module that a part needs must exist for the make. A worker makes a module from the SPIR-V of the ship record, makes the part, then destroys both. The draw's module later is a new VkShaderModule with the same SPIR-V. The driver's cache key is the SPIR-V and the create info, not the module handle, so the hit holds. This must be measured (see the open questions).

The pass can mark which programs it warmed, by a flag in the PF_SHIPPED record set, so that the next run warms only the programs that are new. The ship_ready flag already tells the draws when the pass is done. The warm work starts after it.


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