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:
ST_VS, and a VertexA merged with its VertexB in ship_dual) becomes a PR part with only the
vertex stage. A fragment program becomes an FS part.What the pass must guess for each part, from no draw:
| What | The guess | A wrong guess costs |
|---|---|---|
the module's key (mask) | the pass's key now: all words 0, the clip word from ship_clip | a new translation and a part compile at the draw, as now |
| the last stage before rasterization | the vertex program is the last (ship_clip) | the same |
arrays | the program's own indexed bit, known after the translation | nothing (the bit comes from the program) |
| polygon, depth clamp, provoking vertex, conservative, patch | none, they are dynamic | a PR compile, only on a device without that dynamic state |
feedback | none with has_feedback_dynamic | an FS compile, only without it |
| sample shading | off (FS part with no multisample state) | an FS compile for a draw with sample shading |
| transform feedback | none | the 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.