diff --git a/src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp b/src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp index 5548fb396..ed0abca18 100644 --- a/src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp +++ b/src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -313,6 +314,16 @@ ShaderModule& PipelineCache::CompileModule(Program& program, const ProgramKey& k .function_code = {function_code.begin(), function_code.end()}, }); EXIT_IF(module.module == nullptr); + m_compiled[static_cast(key.stage)]++; + // Guest geometry shaders are compiled through the host mesh stage. + std::printf("Shaders: VS %u | PS %u | CS %u | GS %u | LS %u | HS %u | TES %u\n", + m_compiled[static_cast(ShaderType::Vertex)], + m_compiled[static_cast(ShaderType::Pixel)], + m_compiled[static_cast(ShaderType::Compute)], + m_compiled[static_cast(ShaderType::Mesh)], + m_compiled[static_cast(ShaderType::Local)], + m_compiled[static_cast(ShaderType::TessellationControl)], + m_compiled[static_cast(ShaderType::TessellationEvaluation)]); // The inputs of these come from the stage's static key. if (key.stage == ShaderType::Vertex || key.stage == ShaderType::Local) { module.vertex_formats = VertexInputFormats(*options.input_info.vertex, module.info); diff --git a/src/graphics/host_gpu/renderer/pipeline/pipelineCache.h b/src/graphics/host_gpu/renderer/pipeline/pipelineCache.h index 4615390e5..7ac17c48d 100644 --- a/src/graphics/host_gpu/renderer/pipeline/pipelineCache.h +++ b/src/graphics/host_gpu/renderer/pipeline/pipelineCache.h @@ -200,6 +200,8 @@ private: GraphicContext& m_graphics; ShaderRecompiler::IR::ImageHeapSource* m_image_heap; std::unordered_map m_program_cache; + // Modules compiled per stage. + std::array(ShaderType::TessellationEvaluation) + 1> m_compiled {}; ProgramKey m_lookup_key; vk::PipelineCache m_driver_cache = nullptr; std::filesystem::path m_driver_cache_path; diff --git a/tests/ShaderRecompilerComputeTests.cpp b/tests/ShaderRecompilerComputeTests.cpp index 08c14c7fe..659f5cae1 100644 --- a/tests/ShaderRecompilerComputeTests.cpp +++ b/tests/ShaderRecompilerComputeTests.cpp @@ -609,6 +609,8 @@ struct PipelineCacheTestAccess { } return count; } + + static auto Compiled(const PipelineCache &cache) { return cache.m_compiled; } }; namespace { @@ -44648,6 +44650,12 @@ void CheckStableProgramIds(VulkanHarness &vulkan) { { PipelineCache cache(vulkan.RuntimeContext(), nullptr); for (size_t i = 0; i < cases.size(); i++) forward[i] = compile(cache, cases[i]); + // One compute module per case and nothing else. + auto expected = PipelineCacheTestAccess::Compiled(cache); + expected.fill(0); + expected[static_cast(ShaderType::Compute)] = static_cast(cases.size()); + Require(name, "compiled modules", PipelineCacheTestAccess::Compiled(cache) == expected, + "the per-stage compile counts missed or added a module"); } { PipelineCache cache(vulkan.RuntimeContext(), nullptr);