Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/pipeline_check.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Build with `make_game.py --stages shaders --compact-spirv` to run SPIRV-Tools lo
| `--large-module-bytes N` | Compile modules larger than N bytes alone (default 4 MiB; 0 disables isolation). |
| `--stats FILE` | Write the driver's per-shader statistics as CSV rows `name,stage,statistic,value`. Needs `VK_KHR_pipeline_executable_properties`; use it without `cache.bin`, because a cached pipeline may come without statistics. |
| `--cache-feedback` | Group successful pipeline creations by `VkPipelineCreationFeedback`: cache hits, no hit reported, and unavailable. |
| `--no-pipeline-cache` | Pass `VK_NULL_HANDLE` to pipeline creation and do not create, read, or save an application `VkPipelineCache`. Cannot be combined with `cache.bin`; the driver's internal or on-disk caches are unaffected. |
| `--isolate` | POSIX only: check in child processes, `--isolate-batch N` modules at a time (default 256), so a crashing module is recorded as `MODULE CRASH` and the pass continues. Not compatible with `--stats`. |
| `--inflight-file F` | Keep the modules currently in the driver in F as `name<TAB>phase` lines. It is rewritten by the watchdog and when a large module enters or leaves, and emptied at the end; `make_game.py`'s pipelines stage reads it. |
| `--skip-file F` | Do not compile modules named one per line in F; each is reported as `MODULE CRASH` and counted as a failed pipeline. `make_game.py` writes F after a crash so the next run checks the rest. |
Expand Down
28 changes: 20 additions & 8 deletions runtime/test/vk_pipeline_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
// --cache-feedback count each stage's successful pipelines by VkPipelineCreationFeedback: hits (VALID and
// APPLICATION_PIPELINE_CACHE_HIT), no hit reported (VALID only) and unavailable (no VALID bit, or a
// pre-1.3 device without VK_EXT_pipeline_creation_feedback). The three add up to the ok count.
// --no-pipeline-cache pass VK_NULL_HANDLE to pipeline creation for an application-cache A/B run; cannot use cache.bin
// --nv-diagnostics create the device with VK_NV_device_diagnostics_config and the flags the runtime's
// LEONIDA_DEVICE_FAULT=1 / LEONIDA_AFTERMATH=1 use (shader debug info, resource tracking, automatic
// checkpoints), to measure what that does to compile times and to cache hits
Expand Down Expand Up @@ -796,7 +797,7 @@ int main(int argc, char** argv) {
std::fprintf(stderr,
"usage: vk_pipeline_check <spirv dir> [cache.bin] [--jobs N] [--start I] [--count N] [--slow SEC] "
"[--max-bytes N] [--large-module-bytes N] [--large-parallel N] [--stage all|cs|graphics | --compute-only | --graphics-only] "
"[--stats FILE] [--cache-feedback] [--isolate [--isolate-batch N]] [--inflight-file F] "
"[--stats FILE] [--cache-feedback] [--no-pipeline-cache] [--isolate [--isolate-batch N]] [--inflight-file F] "
"[--skip-file F]\n");
return 2;
}
Expand All @@ -809,7 +810,7 @@ int main(int argc, char** argv) {
unsigned large_parallel = 0; // 0 = by the memory budget
double slow = 30.0;
std::string stage_filter = "all";
bool cache_feedback = false, isolate = false, iso_child = false, nv_diagnostics = false;
bool cache_feedback = false, no_pipeline_cache = false, isolate = false, iso_child = false, nv_diagnostics = false;
size_t isolate_batch = 256;
for (int i = 2; i < argc; i++) {
std::string a = argv[i];
Expand Down Expand Up @@ -853,6 +854,7 @@ int main(int argc, char** argv) {
else if (a == "--inflight-file") valid = !(inflight_path = value()).empty();
else if (a == "--skip-file") valid = !(skip_path = value()).empty();
else if (a == "--cache-feedback") cache_feedback = true;
else if (a == "--no-pipeline-cache") no_pipeline_cache = true;
else if (a == "--isolate") isolate = true;
else if (a == "--nv-diagnostics") nv_diagnostics = true;
else if (a == "--isolate-child") iso_child = true; // internal: the parent's child runs
Expand Down Expand Up @@ -881,6 +883,11 @@ int main(int argc, char** argv) {
return 2;
}

if (no_pipeline_cache && cache_given) {
std::fprintf(stderr, "--no-pipeline-cache cannot be combined with cache.bin\n");
return 2;
}

if (isolate && !stats_path.empty()) {
std::fprintf(stderr, "--isolate cannot be combined with --stats\n");
return 2;
Expand Down Expand Up @@ -956,6 +963,7 @@ int main(int argc, char** argv) {
"--large-module-bytes", std::to_string(large_module_bytes),
"--large-parallel", std::to_string(large_parallel)};
if (cache_feedback) pass.push_back("--cache-feedback");
if (no_pipeline_cache) pass.push_back("--no-pipeline-cache");
if (!inflight_path.empty()) pass.insert(pass.end(), {"--inflight-file", inflight_path});
if (!skip_path.empty()) pass.insert(pass.end(), {"--skip-file", skip_path});
struct Agg { uint32_t mod_ok = 0, mod_bad = 0, pipe_ok = 0, pipe_bad = 0, pipe_skip = 0, big = 0, crashed = 0, fb[3] = {}; };
Expand Down Expand Up @@ -1434,19 +1442,23 @@ int main(int argc, char** argv) {
}
VkPipelineCacheCreateInfo pci{VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO};
std::vector<char> seed;
if (!cache_path.empty()) { // resume: pipelines already in the cache compile instantly
if (!no_pipeline_cache && !cache_path.empty()) { // resume: pipelines already in the cache compile instantly
std::ifstream cf(cache_path, std::ios::binary);
seed.assign(std::istreambuf_iterator<char>(cf), {});
if (!seed.empty()) std::fprintf(stderr, "seeded the pipeline cache with %zu bytes from %s\n", seed.size(), cache_path.c_str());
}
pci.initialDataSize = seed.size(); pci.pInitialData = seed.empty() ? nullptr : seed.data();
VkPipelineCache cache = VK_NULL_HANDLE;
if (vkCreatePipelineCache(dev, &pci, nullptr, &cache)) { // data from another driver: start empty
pci.initialDataSize = 0; pci.pInitialData = nullptr;
if (VkResult r = vkCreatePipelineCache(dev, &pci, nullptr, &cache)) {
std::fprintf(stderr, "vkCreatePipelineCache failed: %d\n", r);
return 1;
if (!no_pipeline_cache) {
if (vkCreatePipelineCache(dev, &pci, nullptr, &cache)) { // data from another driver: start empty
pci.initialDataSize = 0; pci.pInitialData = nullptr;
if (VkResult r = vkCreatePipelineCache(dev, &pci, nullptr, &cache)) {
std::fprintf(stderr, "vkCreatePipelineCache failed: %d\n", r);
return 1;
}
}
} else {
std::fprintf(stderr, "application pipeline cache: disabled (driver-internal caches may still be active)\n");
}
std::vector<char>().swap(seed); // the driver has copied the seed; it can be several GiB
auto save_cache = [&](bool final_save) {
Expand Down