Keys and caches

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:

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.