fix(agc): GPL fragment libraries keyed by the sample count

The fragment shader and fragment output libraries are built with the
pipeline's rasterizationSamples, so a 1x and a 4x pipeline with the same
shaders and formats must not share them. Reported by adriadam10 (found by
Raghav314 in #2242).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Michon 2026-10-11 16:32:47 +02:00 committed by Adrià Franch
parent ae6dfd9073
commit b64da7caf7
2 changed files with 9 additions and 0 deletions

View File

@ -186,6 +186,8 @@ bool libraryKeys(PipelineLibraryKeys& keys, const Context& context, const State&
appendKey(keys.preRasterization, state.depth.has_value() && state.depthBias);
appendKey(keys.preRasterization, state.stages.tessellation.has_value());
if (state.stages.tessellation) appendKey(keys.preRasterization, state.stages.tessellation->inputControlPoints);
appendKey(keys.fragmentShader, state.samples);
appendKey(keys.fragmentOutput, state.samples);
for (const auto& blend : state.blends) appendKey(keys.fragmentOutput, blend);
for (const auto value : state.blendConstants) appendKey(keys.fragmentOutput, value);
appendKey(keys.renderPass, state.blends.size());

View File

@ -5040,6 +5040,13 @@ void pipelineLibraryTests(const Device& device) {
state.colors.front().format = VK_FORMAT_R16G16B16A16_SFLOAT;
static_cast<void>(lookup());
Require(counters().built == std::array<std::uint64_t, 4>{2, 2, 3, 3}, "another target format rebuilt more than the fragment output library");
state.samples = 4;
state.colors.front().samples = 4;
const auto multisampled = lookup();
Require(counters().built == std::array<std::uint64_t, 4>{2, 2, 4, 4}, "a 4x pipeline shared the 1x fragment shader or fragment output library");
state.samples = 1;
state.colors.front().samples = 1;
Require(lookup() != multisampled && counters().built == std::array<std::uint64_t, 4>{2, 2, 4, 4}, "the 1x pipeline after a 4x one built its libraries again");
WaitForOptimizedPipelines(context.device);
const auto lto = std::getenv("APS5_NO_PIPELINE_LTO") == nullptr && context.pipelineLinkTimeOptimization;
Require(counters().optimized == (lto ? counters().linked : 0u), "a linked pipeline was not optimized in the background");