Each part has a key struct with no padding, zeroed before it is filled, and compared with memcmp. This is the
method of PipeKey now and of vkd3d-proton's vkd3d_vertex_input_pipeline_desc and
vkd3d_fragment_output_pipeline_desc. One function splits a PipeKey into the four keys:
typedef struct { u32 topo_class; VertexLayout vi; } PipeViKey;
typedef struct {
VkShaderModule vs, tcs, tes, gs;
u32 arrays; /* bits 0, 2, 3, 4 */
u32 patch, polygon, depth_clamp; /* 0 where g_vk.dyn_pr makes them dynamic */
u32 provoking_last, conservative;
} PipePrKey;
typedef struct {
VkShaderModule fs; /* or null_fs() */
u32 arrays; /* bit 1 */
u32 feedback; /* 0 with has_feedback_dynamic */
u32 sample_shading;
u32 samples, sample_off, alpha_to_coverage, alpha_to_one; /* 0 without sample_shading */
VkCoverage coverage;
u32 spec; /* the module's specialization constants */
} PipeFsKey;
typedef struct {
u32 ncolor, color[8], depth, stencil;
struct { u32 en, sc, dc, cop, sa, da, aop, mask; } blend[8];
u32 logic_op, samples, sample_off, alpha_to_coverage, alpha_to_one, sample_shading, feedback;
VkCoverage coverage;
u32 has_fs; /* the write masks are 0 without a fragment program, as in pipe_create */
} PipeFoKey;
void vk_pipe_split(const PipeKey* k, PipeViKey* vi, PipePrKey* pr, PipeFsKey* fs, PipeFoKey* fo);
vk_pipe_split is a pure function of PipeKey and of the device bits (g_vk.dyn_pr, has_feedback_dynamic). A
test in tests/ checks it, with no device: two keys that differ only in a field of one part give the same keys of
the other parts.
The caches:
PipeLib entries for the four parts, in g_pipeline.plib in pipeline.c. The parts share the workers, their
queues and their lock with the whole pipelines, so they stay in the same file. The pure functions (the choice, the
split, the dynamic state lists) are in pipeline_parts.c, which the test compiles alone. An entry holds the part's
key, its hash, the VkPipeline of the library and its state (to make, being made, made, under g_pipeline.pj_lock).vk_pipe_part_src), not from the key of the
first pipeline that needed it. So one part has one create info, and a part made without a draw is the one that a
draw makes.g_pipeline.plib.lock. A
worker or the GPU thread that needs a part makes it, or waits on g_pipeline.pj_done while another thread makes it.Pipe gets pointers to its four parts, the fast pipeline (the link) and an opt flag. Pipe.p stays as "the
best one now", for the code that reads it, with atomic loads and stores.PR and FS parts use g_pipeline.pcache, so the driver keeps their compiled code across runs in vk_pipelines.bin. VI and FO
parts and the links use no cache: they are cheap, and a link with LTO off gives no data worth a cache entry.
Made from docs/layers/gpu/pipeline-libraries.md at 69237645142c. GPL-3.0-or-later.