Repository navigation
perf(shader): span single-wave wave64 compute by default after a uniformity check - #7922
Conversation
|
This pull request is labeled |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
7ae9e88 to
2e78528
Compare
2e78528 to
753bb56
Compare
CnRJay
left a comment
There was a problem hiding this comment.
The Stray numbers are strong (GPU busy per present 303.4 to 173.1 ms, frame p50 449.3 to 331.5 ms, three interleaved rounds, spread small next to the gain), and the fallback to two lanes per invocation when the check rejects is the right shape. Turning this on by default for every device with 32-lane compute subgroups is where I don't agree yet.
- Everything measured is one Intel Arc (Meteor Lake) on ANV. "Wherever it was available under the switch" means NVIDIA and RDNA wave32 parts get a different compute layout for 1,130 of Stray's 1,751 programs without a run on either. Barrier-in-divergent-flow on a vendor that implements
OpControlBarrierdifferently is a hang orVK_ERROR_DEVICE_LOST, not a wrong picture. Please postspanned_uniformityplus the Stray (or any wave64-compute title) pair on an NVIDIA card and a Radeon, or keep the default off for vendors that haven't been run. - The description says the check treats a load from workgroup, storage or uniform memory at a uniform address as uniform, "not proven for memory another invocation writes without a barrier in between", and that a one-barrier ballot loss is unexplained. That is a known hole in the analysis that decides whether the program can hang, and it is being made the default path. Either close it (treat such a load as divergent unless a barrier dominates it, and see what fraction of the 1,130 still spans), or state the programs it affects and keep the switch default-off until the ballot loss is explained.
- The replay of 1,751 requests ran with a local switch that isn't in the PR, and found 0 rejections. A check that never rejects on its real corpus only shows the false-positive rate; the rejected cases are the hand-built eleven modules. It would help to have at least one real program from the corpus where the barrier sits under a divergent construct, to show the check reaches it on real SPIR-V.
APS5_SPANNED_WAVEis removed andAPS5_NO_SPANNED_WAVEadded. Is the spanning decision part of the shader disk cache key and the pipeline journal key? A cache written under the old switch must not serve a two-lane module to a spanned layout (or the other way round) after this default flips.- 858 added lines moving
Opcode,ResultandVisitIdOperandsbetween files alongside the new pass. Splitting the move out of the behavior change would make the pass reviewable.
|
This PR looks strictly contained in #8004: its single commit If the intent was one review thread, closing this in favour of #8004 would keep a single place for the maintainers to look — #8004 also has a verified rebase handoff onto current |
|
Tested enabling
Also reviewed
|
753bb56 to
4d84eb2
Compare
|
Rebased onto @CnRJay, on your two points:
The one-barrier ballot loss from #5405 is still unexplained, and the debt entry says so. @hamb3r, thanks for the run and the review:
The rebase also showed that @blawesom, thanks. I'd keep #7922 open because @CnRJay's review and the assignment are here. #8004 lists it under Depends on, and reviewing #8004 covers both. AI-assisted: yes |
|
@ThatsLeo Thanks for closing the analysis gap. I read
The rest looks right to me: the fallback doesn't set |
4d84eb2 to
8d4f486
Compare
|
@oneandonlydean Thanks, all three are addressed. Both PRs are rebased onto
Tests on the new heads:
AI-assisted: yes |
|
A discrete RDNA 2 run with spanning on by default: RX 6700 XT (gfx1031), AMD's Windows driver 32.0.21045.5002, Windows 11 26200, MinGW GCC 15.2.0, Release. It compares
Not run: the Khronos validation layer, other AMD drivers, and titles. |
|
@ThatsLeo a discrete RDNA 2 data point from @thuanquang: with spanning on by default on AMD's Windows driver, the device log confirms spanning is active, and |
8d4f486 to
5cce035
Compare
|
Data from three homebrew titles whose own GPU fence waits give up (RADV's vkQuake (PPSA99010), shareware pak0, ray-traced setup at map load. SPIR-V size and NVIDIA pipeline build time of the first dispatches:
PS5 FSR4 Showcase (PPSA99011), the guided tour, no input. Its FSR4 pass uses about 30 compute programs of 117k–750k words, and the title gives each fence 4.5 s (
PS5LM Plus (PPSA99581), llama-server with SmolLM2-360M-Instruct q8_0 (Apache-2.0).
AI-assisted: yes (Claude Code); results above were run on this machine. |
|
@Michael-KD Works for me. Whichever lands second rebases and keeps both entries. |
|
@wachi35676 Thanks, this is very useful. The 0x20c37f400 programs spanning correctly under AI-assisted: yes |
CnRJay
left a comment
There was a problem hiding this comment.
@oneandonlydean I don't have a setup that runs these titles, so I can't rerun 4844a28 on a GPU and won't post a result I haven't measured. My cross-vendor point was that every number came from one Intel/ANV machine; since then NVIDIA (@hamb3r, RTX 3080, Demon's Souls) and AMD (@thuanquang, RX 6700 XT, spanning confirmed active) runs have come in with no device loss, hang or corruption, which answers it. What the current head still needs from the people who have the hardware is a run of the same scene with and without APS5_NO_SPANNED_WAVE=1 on each vendor, with the GPU and driver, so the default has a paired result on NVIDIA and AMD and not only a clean boot.
|
@oneandonlydean the rerun on
AI-assisted: yes (Claude Code); results above were run on this machine. |
|
@ThatsLeo here are the requests and what refuses each program. Build: vkQuake (PPSA99010) requests: To find the rule, I added local logging to
PS5 FSR4 Showcase (PPSA99011): I'm reporting the cause here instead of attaching the shaders, because the licence of the FSR4 code is unclear. The check doesn't refuse any of them, and my earlier comment was wrong about this.
AI-assisted: yes (Claude Code); results above were run on this machine. |
|
GTA V (PPSA04263, content 01.010.002) on this head, as asked in #7922 (comment). Build: 4844a28 as pushed (not merged with Stability. Neither run lost the device, hung or crashed: no For comparison, The prologue's heaviest program is refused. With It is built at 228,900 SPIR-V words in both runs. On Performance. No claim. The prologue stays at about 3 FPS in both runs. Both still stalled for seconds on pipeline builds, so only a few 10 s intervals are clean: GPU busy per present was 167 and 210 ms with spanning, and 244, 259, 272 and 244 ms with AI-assisted: yes (Claude Code); the runs above were made on this machine. |
# Conflicts: # docs/dev/ENVIRONMENT.md # docs/dev/debt/shader.md
…ater writes Keep faulted wave participants voting instead of returning, while masking their later writes, atomics and exports. This also preserves the healthy partner of a two-lane invocation. Retain existing eligibility exclusions. Latch the first guarded SRT fault so later words cannot replace it. Strengthen host assertions; retain the runtime address and PC oracle. Based on ThatsLeo/AnyPS5@b9362d8 core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp (author: ThatsLeo). Adapt the actual-stopping predicate for masked lanes. No spanned-wave policy from boykopovar#7922 is included. AI-assisted: yes
✅ NVIDIA GPU test: passedPR head
Intermittent validation messages (1, seen once in the parallel run, not reproduced when the test was re-run alone 2 times; not counted against this PR)Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (3, not counted against this PR)Validation IDs already present on main (5 IDs in 484 tests)Skipped (45)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
|
Additional qualification of head Tested as an adaptation onto archived integrated source Nine focused tests passed with Vulkan required, shader cache disabled and validation enabled: spanned uniformity, shader memory, guarded null pointers, LDS mask waterfall, wave32 subgroup, BDA device, BDA span reads (including draw-pipeline mode), and scalar wide loads. No VUID or missing layer was observed. The full replay qualification had exact matches for all three supplied final buffers, 45 submissions, 13,268.2 MiB restored, and zero failed/stale registrations, unfinished submissions, skipped mappings, pacing timeouts or synthesised waits. Existing warnings remained: one packet wait timeout, one prebuild warning and eight pending-image CPU-change warnings. This checks replay outputs, not native-perfect game rendering or every temporal frame. The convergence check rejects the dominant program because an OpControlBarrier is under flow decided by a per-invocation value. Sixteen other distinct programs also fell back. The dominant translation retains the existing two-lanes-per-invocation layout. The raw unsafe spanning override was not enabled. The two warm qualification passes had GPU batch-envelope unions of 513.07/518.47 ms per frame and dominant dispatches of 202.35/199.51 ms. This was a qualification/cache-population run, not a matched performance comparison; these numbers prove neither regression nor gain. The useful result is that the safety fallback is exercised in this workload, and simply enabling the guarded proposal does not remove its dominant bottleneck. AI-assisted investigation, locally checked. No game code, captured/translated shaders, images, memory or private logs are attached. |
|
Follow-up to our earlier fallback qualification: sharing an experimental source-only patch and a null performance result, so others can build on the analysis without spending time repeating the same register-pressure experiment. Scope/provenance. This is a separate laptop continuation of the same five-frame recorded workload: i7-13700HX, RTX 4070 Laptop 8 GiB, NVIDIA 592.82, 32 GiB RAM, Windows, WinLibs GCC 15.2 Release. It targets head What made the rejected programs eligibleTwo obstacles were identified in the convergence analysis:
All 17 previously rejected programs in this capture became eligible. For the dominant dispatch, reported register count changed 255 → 128, binary size 518,656 → 381,056 bytes, and SPIR-V 198,869 → 142,216 words. These are compile statistics, not occupancy or executed-instruction measurements. Result: no demonstrated speedupBoth timing arms used the identical candidate binary, with
Negative reduction means spanned was slower. Query misses were zero for the dominant dispatch. Other detail ranges hit the existing cap. Neither table establishes a gain or a reliable regression; the intervals are wide. Reducing registers did not demonstrate a performance benefit here, but this does not rule out an occupancy limitation: the alternative layout also adds substantial workgroup synchronisation, which could offset a benefit. The underlying instruction/stall bottleneck remains unmeasured. The laptop was under severe memory pressure (other applications held about 3.4 GiB VRAM), with heavy eviction/re-upload activity and competing CPU activity. Whole-frame GPU and replay wall times therefore do not isolate the shader change; even per-dispatch results need replication under cleaner conditions. Two runs across the profile/wall series performed a real, non-synthesised wait release with an extra 204.6 MiB restore. They were retained and marked excluded; inclusive and strictly matched statistics were both reported. This is replay evidence, not a live-game FPS claim, and the 33.3 ms target was not met. Correctness evidence and remaining gaps
Please treat this as an experimental enabling patch for review, not a recommended performance optimisation or a general correctness proof. No captured memory, game code, guest disassembly, translated shader binaries, images or private logs are included. The tests below construct synthetic SPIR-V; the diagnostic addition is code only, with no dump output attached. AI-assisted: yes (Codex/Claude Code across the investigations), with local report/patch review and the test/measurement limits above. Source-only experimental patch (AnyPS5 implementation, synthetic tests and documentation)diff --git a/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp b/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
index c130ffc7..d55f0bb9 100644
--- a/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
+++ b/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
@@ -103,6 +103,7 @@ struct SpirvEmitterState {
bool splitSubgroup = false;
bool spannedWave = false;
std::uint32_t spannedExchangeVariable = 0;
+ std::uint32_t spannedBroadcastVariable = 0;
bool narrowSubgroupClock = false;
bool float64DenormPreserve = false;
bool depthRangeRemap = false;
diff --git a/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvMemory/SpirvSubgroup.hpp b/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvMemory/SpirvSubgroup.hpp
index ad10afcb..5ef9207f 100644
--- a/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvMemory/SpirvSubgroup.hpp
+++ b/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvMemory/SpirvSubgroup.hpp
@@ -12,6 +12,7 @@ void EmitHostSubgroupBallot(SpirvEmitterState& state, std::uint32_t result, std:
void EmitSubgroupBallotFindLsb(SpirvEmitterState& state, std::uint32_t result, std::uint32_t ballot);
void EmitSubgroupShuffle(SpirvEmitterState& state, std::uint32_t type, std::uint32_t result, std::uint32_t value, std::uint32_t lane);
void EmitSubgroupShuffleInHalf(SpirvEmitterState& state, std::uint32_t type, std::uint32_t result, std::uint32_t value, std::uint32_t lane);
+std::uint32_t EmitSpannedUniformLoad(SpirvEmitterState& state, std::uint32_t type, std::uint32_t value);
void EmitSubgroupElect(SpirvEmitterState& state, std::uint32_t result);
std::uint32_t EmitSubgroupLocalInvocationId(SpirvEmitterState& state);
std::uint32_t EmitHostSubgroupLane(SpirvEmitterState& state, std::uint32_t lane);
diff --git a/core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp b/core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp
index c878d293..e7f90d26 100644
--- a/core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp
+++ b/core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp
@@ -331,7 +331,24 @@ std::vector<std::uint32_t> SpirvEmitter::Emit(const IrProgram& program, const Sh
state.module.EmitEntryPoint(ExecutionModelForStage(state.program.Resources().stage), state.mainFunc, "main", state.interfaceVariables);
auto words = state.module.Finalize();
if (state.spannedWave) {
- if (auto reason = SpannedBarrierInDivergentFlow(words)) throw SpannedWaveUnsupported(*reason);
+ if (auto reason = SpannedBarrierInDivergentFlow(words)) {
+ if (const char* dump = std::getenv("APS5_DUMP_REJECTED_SPANNED"); dump != nullptr && *dump != '\0') {
+ std::uint64_t hash = 0xcbf29ce484222325ull;
+ for (const auto word : words) {
+ hash ^= word;
+ hash *= 0x100000001b3ull;
+ }
+ char name[64];
+ std::snprintf(name, sizeof(name), "/rejected-%016llx.spv", static_cast<unsigned long long>(hash));
+ const std::string path = std::string(dump) + name;
+ if (std::FILE* file = std::fopen(path.c_str(), "wb")) {
+ std::fwrite(words.data(), sizeof(std::uint32_t), words.size(), file);
+ std::fclose(file);
+ *reason += " (module written to " + path + ")";
+ }
+ }
+ throw SpannedWaveUnsupported(*reason);
+ }
}
if (info != nullptr) {
info->fullSubgroups = state.spannedWave;
diff --git a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp
index 16e6a6f8..593db382 100644
--- a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp
+++ b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp
@@ -293,21 +293,23 @@ std::uint32_t LoadBda(SpirvValueEmitContext& ctx, const IrValue& inst, const Mem
const auto zero = ConstantU32(state, 0u);
const auto none = state.module.AllocateId();
state.module.AddFunction(spv::OpCompositeConstruct, vector, none, zero, zero, zero, zero);
- const auto all = EmitValueOrDefaultIfCondition(state, ActiveArgument(ctx, inst), vector, none, [&]() {
+ auto all = EmitValueOrDefaultIfCondition(state, ActiveArgument(ctx, inst), vector, none, [&]() {
const auto values = ReadBdaDwords(ctx, inst, mem, 4u, used);
const auto read = state.module.AllocateId();
state.module.AddFunction(spv::OpCompositeConstruct, vector, read, values[0], values[1], values[2], values[3]);
return read;
});
+ if (mem.kind == ResourceKind::ScalarAddress) all = EmitSpannedUniformLoad(state, vector, all);
for (const auto& member : members) state.bdaGroupedLoads[member.first] = {all, member.second};
const auto value = state.module.AllocateId();
state.module.AddFunction(spv::OpCompositeExtract, TypeU32(state), value, all, 0u);
return value;
}
}
- return EmitValueOrZeroIfCondition(ctx.state, ActiveArgument(ctx, inst), [&]() {
+ const auto value = EmitValueOrZeroIfCondition(ctx.state, ActiveArgument(ctx, inst), [&]() {
return ReadBda(ctx, inst, mem, bits);
});
+ return mem.kind == ResourceKind::ScalarAddress && bits == 32u ? EmitSpannedUniformLoad(state, TypeU32(state), value) : value;
}
void StoreWordInBounds(SpirvValueEmitContext& ctx, const MemoryResourceAccess& resource, std::uint32_t index, std::uint32_t data) {
@@ -1592,7 +1594,7 @@ void EmitReadConstBuffer(SpirvValueEmitContext& ctx, const IrValue& inst) {
const auto& mem = ctx.Memory(inst);
if (mem.planningOnly) return;
if (mem.kind != ResourceKind::ScalarBuffer) ctx.Fail(inst, "must read a scalar buffer resource");
- ctx.Define(inst, EmitRuntimeScalarBufferLoad(ctx, inst));
+ ctx.Define(inst, EmitSpannedUniformLoad(ctx.state, TypeId(ctx.state, inst.Type()), EmitRuntimeScalarBufferLoad(ctx, inst)));
}
void EmitGetSrtResource(SpirvValueEmitContext& context) {
diff --git a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvSubgroup.cpp b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvSubgroup.cpp
index 81449d6a..d386e2f5 100644
--- a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvSubgroup.cpp
+++ b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvSubgroup.cpp
@@ -146,6 +146,50 @@ namespace ShaderRecompiler
state.module.AddFunction(spv::OpGroupNonUniformShuffle, type, result, ConstantU32(state, spv::ScopeSubgroup), value, EmitBinaryU32(state, spv::OpBitwiseAnd, lane, ConstantU32(state, 31u)));
}
+ std::uint32_t EmitSpannedUniformLoad(SpirvEmitterState& state, std::uint32_t type, std::uint32_t value) {
+ if (!state.spannedWave) return value;
+ std::uint32_t components = type == TypeU32(state) ? 1u : 0u;
+ for (std::uint32_t count = 2u; components == 0u && count <= 4u; ++count) {
+ if (type == TypeU32Vector(state, count)) components = count;
+ }
+ if (components == 0u) throw SpannedWaveUnsupported("a spanned wave shares only 32-bit scalar loads of up to four dwords");
+ if (state.spannedBroadcastVariable == 0u) {
+ state.spannedBroadcastVariable = state.module.DefineGlobalVariable(TypeU32ArrayPointer(state, spv::StorageClassWorkgroup, 256u), spv::StorageClassWorkgroup);
+ state.module.AddName(state.spannedBroadcastVariable, "wave_broadcast");
+ }
+ const auto slot = [&](std::uint32_t index) {
+ const auto pointer = state.module.AllocateId();
+ state.module.AddFunction(spv::OpAccessChain, TypeU32ElementPointer(state, spv::StorageClassWorkgroup), pointer, state.spannedBroadcastVariable, index);
+ return pointer;
+ };
+ const auto lane = SpannedLane(state);
+ std::array<std::uint32_t, 4> words{};
+ for (std::uint32_t component = 0; component < components; ++component) {
+ if (components == 1u) {
+ words[component] = value;
+ continue;
+ }
+ words[component] = state.module.AllocateId();
+ state.module.AddFunction(spv::OpCompositeExtract, TypeU32(state), words[component], value, component);
+ }
+ SpannedBarrier(state);
+ for (std::uint32_t component = 0; component < components; ++component) {
+ state.module.AddFunction(spv::OpStore, slot(EmitAddU32(state, lane, ConstantU32(state, component * 64u))), words[component]);
+ }
+ SpannedBarrier(state);
+ std::array<std::uint32_t, 4> shared{};
+ for (std::uint32_t component = 0; component < components; ++component) {
+ shared[component] = state.module.AllocateId();
+ state.module.AddFunction(spv::OpLoad, TypeU32(state), shared[component], slot(ConstantU32(state, component * 64u)));
+ }
+ if (components == 1u) return shared[0];
+ const auto result = state.module.AllocateId();
+ if (components == 2u) state.module.AddFunction(spv::OpCompositeConstruct, type, result, shared[0], shared[1]);
+ else if (components == 3u) state.module.AddFunction(spv::OpCompositeConstruct, type, result, shared[0], shared[1], shared[2]);
+ else state.module.AddFunction(spv::OpCompositeConstruct, type, result, shared[0], shared[1], shared[2], shared[3]);
+ return result;
+ }
+
void EmitSubgroupElect(SpirvEmitterState& state, std::uint32_t result) {
if (HostSubgroupSingleLane(state)) {
state.module.AddFunction(spv::OpCopyObject, TypeBool(state), result, ConstantBool(state, true));
diff --git a/core/shader/recompiler/SpirvBackend/src/SpirvSpannedUniformity.cpp b/core/shader/recompiler/SpirvBackend/src/SpirvSpannedUniformity.cpp
index 1b7a231b..f3d1f75b 100644
--- a/core/shader/recompiler/SpirvBackend/src/SpirvSpannedUniformity.cpp
+++ b/core/shader/recompiler/SpirvBackend/src/SpirvSpannedUniformity.cpp
@@ -30,6 +30,9 @@ struct Module {
std::unordered_map<std::uint32_t, std::uint32_t> storageClasses;
std::unordered_map<std::uint32_t, std::uint32_t> pointerClasses;
std::unordered_map<std::uint32_t, std::uint32_t> constants;
+ std::unordered_set<std::uint32_t> nonWritable;
+ std::unordered_set<std::uint32_t> deviceAddressPointers;
+ std::unordered_map<std::uint32_t, std::uint32_t> chains;
std::vector<Function> functions;
};
@@ -46,6 +49,17 @@ Module Parse(std::span<const std::uint32_t> words) {
switch (Opcode(instruction)) {
case spv::OpDecorate:
if (instruction.size() >= 4u && instruction[2] == spv::DecorationBuiltIn) module.builtins[instruction[1]] = instruction[3];
+ if (instruction.size() >= 3u && instruction[2] == spv::DecorationNonWritable) module.nonWritable.insert(instruction[1]);
+ break;
+ case spv::OpConvertUToPtr:
+ if (instruction.size() >= 3u) module.deviceAddressPointers.insert(instruction[2]);
+ if (block != nullptr) block->body.push_back(std::move(instruction));
+ break;
+ case spv::OpAccessChain:
+ case spv::OpInBoundsAccessChain:
+ case spv::OpPtrAccessChain:
+ if (instruction.size() >= 4u) module.chains[instruction[2]] = instruction[3];
+ if (block != nullptr) block->body.push_back(std::move(instruction));
break;
case spv::OpTypePointer:
if (instruction.size() >= 4u) module.pointerClasses[instruction[1]] = instruction[2];
@@ -165,7 +179,12 @@ public:
for (const auto& block : function.blocks) {
for (const auto& instruction : block.body) {
const auto pointer = WrittenPointer(instruction);
- if (pointer != 0u) written.insert(ClassOf(pointer));
+ if (pointer != 0u) {
+ written.insert(ClassOf(pointer));
+ const auto variable = BaseVariable(pointer, module.chains);
+ if (module.storageClasses.contains(variable)) writtenVariables.insert(variable);
+ else if (!module.deviceAddressPointers.contains(variable)) writtenThroughUnknownRoot = true;
+ }
if (Opcode(instruction) == spv::OpImageWrite) written.insert(spv::StorageClassImage);
}
}
@@ -241,7 +260,8 @@ private:
return fenced && storageClass != spv::StorageClassWorkgroup && storageClass != UnknownClass;
}
- bool Racy(std::uint32_t pointer, bool fenced) const {
+ bool Racy(std::uint32_t pointer, std::uint32_t variable, bool fenced) const {
+ if (module.nonWritable.contains(variable) && module.storageClasses.contains(variable) && !writtenVariables.contains(variable) && !writtenThroughUnknownRoot) return false;
const auto storageClass = ClassOf(pointer);
if (storageClass != UnknownClass && (PrivateStorage(storageClass) || storageClass == spv::StorageClassInput)) return false;
if (!Written(storageClass)) return false;
@@ -494,11 +514,11 @@ private:
const auto builtin = module.builtins.find(variable);
const auto storage = module.storageClasses.find(variable);
varying = NonUniform(instruction[3]) || (builtin != module.builtins.end() && VaryingBuiltin(builtin->second)) || storedNonUniform.contains(variable) ||
- (storage != module.storageClasses.end() && storage->second == spv::StorageClassInput && builtin == module.builtins.end()) || Racy(instruction[3], fencedBefore);
+ (storage != module.storageClasses.end() && storage->second == spv::StorageClassInput && builtin == module.builtins.end()) || Racy(instruction[3], variable, fencedBefore);
break;
}
case spv::OpAtomicLoad:
- varying = NonUniform(instruction.at(3)) || Racy(instruction[3], fencedBefore);
+ varying = NonUniform(instruction.at(3)) || Racy(instruction[3], BaseVariable(instruction[3], chains), fencedBefore);
break;
case spv::OpPhi:
varying = inDivergentFlow || divergentMerges.contains(label);
@@ -525,6 +545,8 @@ private:
const Module& module;
std::unordered_map<std::uint32_t, std::uint32_t> types;
std::unordered_set<std::uint32_t> written;
+ std::unordered_set<std::uint32_t> writtenVariables;
+ bool writtenThroughUnknownRoot = false;
std::unordered_set<std::uint32_t> barriers;
std::unordered_set<std::uint32_t> nonUniform;
std::unordered_set<std::uint32_t> storedNonUniform;
diff --git a/core/shader/recompiler/tests/SpannedUniformityTests.cpp b/core/shader/recompiler/tests/SpannedUniformityTests.cpp
index 7e191571..349ebe9f 100644
--- a/core/shader/recompiler/tests/SpannedUniformityTests.cpp
+++ b/core/shader/recompiler/tests/SpannedUniformityTests.cpp
@@ -29,6 +29,8 @@ enum Id : std::uint32_t {
StoragePointer,
Storage,
PhysicalPointer,
+ ReadOnlyStorage,
+ PointerFunctionType,
First = 100u,
};
@@ -41,6 +43,7 @@ public:
emit(spv::OpEntryPoint, {spv::ExecutionModelGLCompute, Main, 0x6e69616du, 0u, Index});
emit(spv::OpExecutionMode, {Main, spv::ExecutionModeLocalSize, 64u, 1u, 1u});
emit(spv::OpDecorate, {Index, spv::DecorationBuiltIn, spv::BuiltInLocalInvocationIndex});
+ emit(spv::OpDecorate, {ReadOnlyStorage, spv::DecorationNonWritable});
emit(spv::OpTypeVoid, {Void});
emit(spv::OpTypeBool, {Bool});
emit(spv::OpTypeInt, {Uint, 32u, 0u});
@@ -58,6 +61,8 @@ public:
emit(spv::OpTypePointer, {FunctionPointer, spv::StorageClassFunction, Uint});
emit(spv::OpTypePointer, {StoragePointer, spv::StorageClassStorageBuffer, Uint});
emit(spv::OpVariable, {StoragePointer, Storage, spv::StorageClassStorageBuffer});
+ emit(spv::OpVariable, {StoragePointer, ReadOnlyStorage, spv::StorageClassStorageBuffer});
+ emit(spv::OpTypeFunction, {PointerFunctionType, Void, StoragePointer});
emit(spv::OpTypePointer, {PhysicalPointer, spv::StorageClassPhysicalStorageBuffer, Uint});
}
@@ -224,6 +229,28 @@ Module joined(const std::function<void(Module&)>& condition) {
return module;
}
+Module storeThroughParameter(std::uint32_t argument) {
+ Module module;
+ module.emit(spv::OpFunction, {Void, Helper, spv::FunctionControlMaskNone, PointerFunctionType});
+ module.emit(spv::OpFunctionParameter, {StoragePointer, First + 30u});
+ module.emit(spv::OpLabel, {First + 31u});
+ module.emit(spv::OpStore, {First + 30u, Three});
+ module.end();
+ module.function(Main);
+ module.emit(spv::OpLabel, {First});
+ module.emit(spv::OpFunctionCall, {Void, First + 32u, Helper, argument});
+ module.emit(spv::OpLoad, {Uint, First + 6u, ReadOnlyStorage});
+ module.emit(spv::OpIEqual, {Bool, First + 8u, First + 6u, Two});
+ module.emit(spv::OpSelectionMerge, {First + 9u, spv::SelectionControlMaskNone});
+ module.emit(spv::OpBranchConditional, {First + 8u, First + 7u, First + 9u});
+ module.emit(spv::OpLabel, {First + 7u});
+ module.barrier();
+ module.emit(spv::OpBranch, {First + 9u});
+ module.emit(spv::OpLabel, {First + 9u});
+ module.end();
+ return module;
+}
+
void laneSplit(Module& module, std::uint32_t merge) {
module.emit(spv::OpULessThan, {Bool, First + 2u, First + 1u, Three});
module.emit(spv::OpSelectionMerge, {merge, spv::SelectionControlMaskNone});
@@ -310,5 +337,39 @@ int main() {
module.emit(spv::OpLoad, {Uint, First + 6u, First + 5u});
module.emit(spv::OpIEqual, {Bool, First + 8u, First + 6u, Two});
}), true);
+ expect("a barrier under a non-writable buffer word read at a uniform index after a store through a device address", joined([](Module& module) {
+ module.emit(spv::OpConvertUToPtr, {PhysicalPointer, First + 10u, Two});
+ module.emit(spv::OpStore, {First + 10u, Three});
+ module.emit(spv::OpLoad, {Uint, First + 6u, ReadOnlyStorage});
+ module.emit(spv::OpIEqual, {Bool, First + 8u, First + 6u, Two});
+ }), false);
+ expect("a barrier under a non-writable buffer word read at a uniform index after a store through another buffer", joined([](Module& module) {
+ module.emit(spv::OpStore, {Storage, Three});
+ module.emit(spv::OpLoad, {Uint, First + 6u, ReadOnlyStorage});
+ module.emit(spv::OpIEqual, {Bool, First + 8u, First + 6u, Two});
+ }), false);
+ expect("a barrier under a non-writable buffer word read at a uniform index after a store through that buffer", joined([](Module& module) {
+ module.emit(spv::OpStore, {ReadOnlyStorage, Three});
+ module.emit(spv::OpLoad, {Uint, First + 6u, ReadOnlyStorage});
+ module.emit(spv::OpIEqual, {Bool, First + 8u, First + 6u, Two});
+ }), true);
+ expect("a barrier under a non-writable buffer word read at a uniform index after an atomic through that buffer", joined([](Module& module) {
+ module.emit(spv::OpAtomicIAdd, {Uint, First + 5u, ReadOnlyStorage, Two, Semantics, Three});
+ module.emit(spv::OpLoad, {Uint, First + 6u, ReadOnlyStorage});
+ module.emit(spv::OpIEqual, {Bool, First + 8u, First + 6u, Two});
+ }), true);
+ expect("a barrier under a non-writable buffer word read at a lane index", joined([](Module& module) {
+ module.emit(spv::OpAccessChain, {StoragePointer, First + 5u, ReadOnlyStorage, First + 1u});
+ module.emit(spv::OpLoad, {Uint, First + 6u, First + 5u});
+ module.emit(spv::OpIEqual, {Bool, First + 8u, First + 6u, Two});
+ }), true);
+ expect("a barrier under a non-writable buffer word read after a store through a pointer parameter bound to that buffer", storeThroughParameter(ReadOnlyStorage), true);
+ expect("a barrier under a non-writable buffer word read after a store through a pointer parameter bound to another buffer", storeThroughParameter(Storage), true);
+ expect("a barrier under a writable buffer word read at a uniform index after a store through a device address stays rejected", joined([](Module& module) {
+ module.emit(spv::OpConvertUToPtr, {PhysicalPointer, First + 10u, Two});
+ module.emit(spv::OpStore, {First + 10u, Three});
+ module.emit(spv::OpLoad, {Uint, First + 6u, Storage});
+ module.emit(spv::OpIEqual, {Bool, First + 8u, First + 6u, Two});
+ }), true);
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
}
diff --git a/docs/dev/ENVIRONMENT.md b/docs/dev/ENVIRONMENT.md
index 1320d3cb..6b7a7b7f 100644
--- a/docs/dev/ENVIRONMENT.md
+++ b/docs/dev/ENVIRONMENT.md
@@ -155,6 +155,7 @@ The code reads environment names through `getenv`, `IsEnvironmentSet`, `kibSetti
| `APS5_DUMP_FRAMES_EVERY` | integer | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | 1 | dumps every n-th presented frame |
| `APS5_DUMP_QUEUE` | integer | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp` | | dumps the first submissions of the queue with this hex id |
| `APS5_DUMP_REJECTED` | presence | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/CommandValidation.cpp` | | writes a rejected submission to rejected_submission_<n>.bin |
+| `APS5_DUMP_REJECTED_SPANNED` | string | `core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp` | | directory in which a spanned single-wave64 compute module that the convergence check sends back to two lanes per invocation is written as `rejected-<hash>.spv`, named in the `[spanned-wave]` fallback line |
| `APS5_DUMP_SCALE` | integer | `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` | 4 | keeps every n-th pixel in each direction of a dumped frame (1 to 16384; any other value fails) |
| `APS5_DUMP_SHADERS` | string | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cpp` | | writes each prepared shader's request to shader_<address>.req; a comma-separated list of hex program addresses (for example `807b90a100,0x807b925400`) writes only those programs' requests, and any other value (such as `1`) writes every request |
| `APS5_DUMP_STORAGE` | string | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | selects storage textures to dump by hex address or WxHxL[:format] extent as storage_<address>_<n>.raw |
diff --git a/docs/dev/debt/shader.md b/docs/dev/debt/shader.md
index 9faf3a95..9f0a2eb0 100644
--- a/docs/dev/debt/shader.md
+++ b/docs/dev/debt/shader.md
@@ -210,7 +210,7 @@
- [Flag structurization](../../../core/shader/recompiler/ControlFlow/src/Structurizer.cpp) (shader recompiler) - a graph that every structurizer attempt refuses, irreducible and non-terminating graphs included, is rebuilt with one reach flag per block and one again flag per loop (`structurizeWithFlags`): each block keeps one copy and runs behind a guard on its flag, and each strongly connected component becomes a loop whose single latch repeats it while a back edge set its flag. The output has about 8 times the input's blocks and one route variable per block, and ends in an empty Return that never runs. Only blocks that start the top-level order unconditionally run unguarded, so resource planning also sees the static paths that skip a guarded block and can plan extra descriptor candidates for them. The attempts still run first. Shared merge splitting refuses an attempt once the graph has grown past 16 times its block count at the start of splitting (at least 64 blocks); succeeding attempts grew at most 10.6 times on random graphs of up to 128 blocks, and an attempt that would succeed only beyond the budget leaves the graph to a later attempt or to this construction. Splitting that adds one block per round stays within that budget until its 4 rounds per block run out, so the attempts can still take more than 10 s (9 of 2,000 random graphs of up to 128 blocks, 63 s at most). `APS5_FORCE_STRUCTURIZER_FALLBACK=1` builds every graph this way, for tests
- [Shared loop latches](../../../core/shader/recompiler/ControlFlow/src/Structurizer.cpp) (shader recompiler) - a loop whose single latch holds instructions and is reached by one edge gets an empty continue block, so its continue construct is that one block. A latch that several `continue` paths share keeps its instructions in the continue construct, since isolating it would clone them into each path. When such a latch emits more than one SPIR-V block, as a memory or image access does, SPIRV-Cross (MoltenVK) folds the construct into a `for` increment and drops the header's `OpPhi` updates, so the loop never advances on Metal. No title is known to reach this case.
- [Scalar buffer descriptors](../../../core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp) - the PS5's gfx1013 is not measured, nor is a V# with a null base. Scalar loads use only the base address, stride and record count: the fourth word is normalized to zero for resources accessed exclusively by scalar loads, and a [V# read at run time](../../../core/shader/recompiler/SpirvBackend/src/SpirvRuntimeBuffer.cpp) does not fault on its type for a scalar load. Measured on RDNA2 (gfx1036, AMD Windows driver 32.0.21030.31) with `s_buffer_load_dword` and `_dwordx4` through the [hardware oracle](../HW_ORACLE.md): every `OOB_SELECT`, `TYPE`, `FORMAT` 0, `ADD_TID_ENABLE`, `INDEX_STRIDE`, a zero and an all-ones fourth word read as 0x31016fac does; the range is `NUM_RECORDS` bytes with stride 0, else `STRIDE` × `NUM_RECORDS`, whatever `SWIZZLE_ENABLE`; a dword not wholly in range reads 0. Vector and mixed accesses retain descriptor validation.
-- [Spanned wave64 compute](../../../core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvSubgroup.cpp) (shader recompiler) - a spanned wave exchanges ballots, shuffles and reductions between its two host subgroups through workgroup barriers, which hang the device when not every invocation reaches them. [SpannedBarrierInDivergentFlow](../../../core/shader/recompiler/SpirvBackend/src/SpirvSpannedUniformity.cpp) sends a program back to two lanes per invocation when a barrier sits in control flow that a per-invocation value decides. It counts a load at a uniform address as uniform only from memory the program never writes, or from workgroup memory a barrier fences on every path since the last write; writes by other dispatches or queues are not considered. An earlier one-barrier ballot also lost the device for a reason that is not understood. `APS5_NO_SPANNED_WAVE` turns spanning off.
+- [Spanned wave64 compute](../../../core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvSubgroup.cpp) (shader recompiler) - a spanned wave exchanges ballots, shuffles and reductions between its two host subgroups through workgroup barriers, which hang the device when not every invocation reaches them. [SpannedBarrierInDivergentFlow](../../../core/shader/recompiler/SpirvBackend/src/SpirvSpannedUniformity.cpp) sends a program back to two lanes per invocation when a barrier sits in control flow that a per-invocation value decides. It counts a load at a uniform address as uniform only from memory the program never writes, or from workgroup memory a barrier fences on every path since the last write; writes by other dispatches or queues are not considered. A load through a `NonWritable` storage buffer variable (BDA page table, flattened SRT, image table map: filled by the driver before the dispatch, never stored to by the module) counts as uniform at a uniform address although the module stores elsewhere or through device addresses, which reach only guest memory; a store through that variable, or through a pointer whose root is neither a variable nor a device address, withdraws this. A spanned wave shares every scalar memory load (`s_load`, `s_buffer_load`) from lane 0 through workgroup memory behind two barriers, so both host subgroups see the one value a wave would; a scalar load inside per-invocation control flow still sends the program back to two lanes. Neither the broadcast nor the `NonWritable` rule is measured on hardware beyond the focused tests and one title's replay. An earlier one-barrier ballot also lost the device for a reason that is not understood. `APS5_NO_SPANNED_WAVE` turns spanning off.
- [Guest memory load guards](../../../core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp) (shader recompiler) - a guest load whose lane is inactive or whose address is out of bounds is still performed and its result replaced by 0 with `OpSelect`, instead of a selection per guard, when the load can be pointed at a location nothing writes: scratch reads its own element 0; storage buffers (direct buffers, GDS) read element 0xfffffffe, which `robustBufferAccess2` turns into a zero load with no memory access, so the extra read cannot race with a write the guarded program would not have raced with ([Vulkan memory model](https://docs.vulkan.org/spec/latest/appendices/memorymodel.html#data-race)). Without `robustBufferAccess2` ([VulkanDevice.cpp](../../../core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp) enables it when the device has it) those loads keep their selections; LDS loads, stores, atomics, formatted and physical-address (BDA) accesses always do. LDS keeps the branch because NVIDIA's compiler predicates a branched LDS load at no cost, while the select form costs about 2.5 instructions per dword and splits a `ds_read_b128` into four loads (RTX 4060 measurements by @karanvora2599 in #4048); Intel's static counts favour the select only for wide reads, and run time was not measured on either. The aligned high word of a misaligned-capable buffer read re-reads the low word's own element. A selection guard costs four blocks per lane half and the host compiler's time grows with the block count: PPSA11142's merged PSP vertex program (3176 ISA words, wave64) emitted 16,983 blocks and 1,710 conditional branches, 5,907 and 868 with the selects. `agc_guarded_memory_loads` traces the emitted loads in both device modes. When the device also reports `robustStorageBufferAccessSizeAlignment` 1, a direct buffer load leaves out the comparison with the descriptor's `OpArrayLength` (which reads the descriptor) and the device returns the zero past the descriptor range: the host rounds a guest buffer's or a draw snapshot's descriptor range of 4 bytes or more down to whole dwords, which no direct access reaches past, and the misaligned-base high word keeps its comparison with the length. The guest bound and the guards of stores, atomics, GDS, LDS and BDA are unchanged. The flag is part of the shader cache key and `APS5_NO_EXACT_ROBUST_LOADS` (any value) keeps the comparison. Hardware treatment of a 32-bit load that straddles the end of a 1 to 3 byte range is not measured.
- [Merged hull programs](../../../core/shader/recompiler/Optimization/src/TessellationLowering.cpp) (registered binary type 3) run whole in the hull stage, one invocation per output control point. On the console hull lane i keeps local lane i's registers, which with fewer input than output control points stop matching the patch's control points from i = inputs on; here invocation i holds control point min(i, inputs - 1) of its own patch. A wave-mask branch (`s_cbranch_exec[n]z`, `s_cbranch_vcc[n]z`) tests the invocation's own lane, so it can skip a block, scalar instructions included, that the console runs for the wave; `v_readfirstlane_b32` returns the invocation's own value, not the first active lane's, and another lane's register throws. The register layout (`s3`, `v0`-`v5`, as for the separate halves) is not measured on hardware. s[0:1] hold the hull user-data address (SH 0x102/0x103) when a draw sets it and zero otherwise, so a program reading it unset faults at the null address.
- [SPIR-V instruction length and deferred phi validation](../../../core/shader/recompiler/SpirvBackend/src/SpirvModule.cpp) (shader recompiler) - SPIR-V instruction word count boundaries and deferred phi patch tokens validate bounds against logical layout rules; console GPU driver responses to oversized instructions or unlinked phi tokens remain unmeasured. Instruction emission enforces the 65,535 word limit (16-bit word count field), and deferred phi patching verifies token registration.
Patch file SHA-256: 31B5364C57CA7C9DA36F9212DECE53E6A5588148FD162D60B867213E9368E7FA |
boykopovar#7922 made single-wave wave64 compute span two subgroups by default; main's push build 41428291528 (18bb046) timed out agc_driver_image_table_vouched_lookups at 60 s on lavapipe. Not reproduced locally (submodule fetch fails here); the test pins the previous lowering. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ater writes Keep faulted wave participants voting instead of returning, while masking their later writes, atomics and exports. This also preserves the healthy partner of a two-lane invocation. Retain existing eligibility exclusions. On the hardware-spanning wave path, keep the lanes active for subgroup operations and guard byte loads when a lane fault is recorded without returning from the invocation. Latch the first guarded SRT fault so later words cannot replace it. Strengthen host assertions; retain the runtime address and PC oracle. Based on ThatsLeo/AnyPS5@b9362d8 core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp (author: ThatsLeo). Adapt the actual-stopping predicate for masked lanes. No spanned-wave policy from boykopovar#7922 is included. AI-assisted: yes
…ater writes Keep faulted wave participants voting instead of returning, while masking their later writes, atomics and exports. This also preserves the healthy partner of a two-lane invocation. Retain existing eligibility exclusions. On the hardware-spanning wave path, keep the lanes active for subgroup operations and guard byte loads when a lane fault is recorded without returning from the invocation. Latch the first guarded SRT fault so later words cannot replace it. Strengthen host assertions; retain the runtime address and PC oracle. Based on ThatsLeo/AnyPS5@b9362d8 core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp (author: ThatsLeo). Adapt the actual-stopping predicate for masked lanes. No spanned-wave policy from boykopovar#7922 is included. AI-assisted: yes
What
#5405 runs a single-wave wave64 compute program at one guest lane per invocation, across two full 32-lane host subgroups. It is off unless
APS5_SPANNED_WAVEis set, because its cross-lane exchanges use workgroup barriers, and the emitter could not tell whether every invocation reaches them: its debt entry lists a manualspirv-disscan as the only check. This PR adds that check and turns the layout on by default.SpannedBarrierInDivergentFlow(SpirvSpannedUniformity.cpp) runs on every spanned module after emission. It marks the values that can differ between the invocations of a wave, iterating until nothing changes:LocalInvocationId/Index,GlobalInvocationId,SubgroupId,SubgroupLocalInvocationId, the subgroup masks);A selection is divergent when its condition is marked. A loop is divergent when its header condition is marked, or when it can be left from per-invocation control flow. The construct's blocks are read off the dominator tree: the header's subtree minus the merge's. A construct is also divergent when a per-invocation branch without a merge instruction leaves it or continues its loop. When a divergent construct returns or kills, everything reachable from its merge is divergent; when it branches past its merge, as a
continuedoes, the merge's subtree is.If an
OpControlBarrier, or a call that reaches one, sits in a divergent construct,EmitthrowsSpannedWaveUnsupported.Recompilealready catches that and emits the program at two lanes per invocation, so a rejected program runs as onmain. The check runs beforeSpirvEmitInfo::fullSubgroupsis set, so the fallback is not created withREQUIRE_FULL_SUBGROUPS.VulkanDeviceturns spanning on wherever it was available under the switch (computeFullSubgroupswith 32-lane compute subgroups).APS5_NO_SPANNED_WAVEturns it off;APS5_SPANNED_WAVEis gone.The analysis runs until nothing changes, so it cannot stop early and throw. It is skipped for a module with no
OpControlBarrier, and each function's flow graph is built once.Opcode,ResultandVisitIdOperandsmove unchanged fromSpirvSpecialization.cpptoSpirvInstructionOperands.hpp, templated on the instruction container, so both passes share the operand table.SpirvSpecialization.cppkeepsmain's arena-backedInstruction.Guarded SRT reads. A spanned wave does not stop an invocation after a fault (
bdaStopsInvocationsis false), so each later guarded read of a poisoned pointer wrote its record over the first.agc_driver_guarded_null_pointerthen reported the second dword of ans_load_dwordx2(address=0x4). Where invocations do not stop, the record is now written with a compare-exchange against 0, asrecord_bda_faultalready does, so the first fault is kept. Programs whose invocations stop keep the atomic store.The debt entry states what the check proves and what it does not: writes by other dispatches or queues, and the unexplained one-barrier ballot loss.
spanned_uniformity_testslinkslibcon MinGW, asspirv_validator_exit_testsdoes.Tested
Intel Arc (Meteor Lake), Mesa 26.2.4 ANV, Fedora 44, Linux 7.2.10, GCC 16.2.1, Release.
spanned_uniformity(new) builds twenty-one modules by hand:With
LocalInvocationIndexremoved from the per-invocation built-ins, the lane-dependent cases fail. Without the fence, early-exit, guest-memory and unmerged-continue rules, the cases they cover fail.Stray's compute requests: all 1,751 (PPSA02101) replayed through
agc_shader_replaywith a 32-lane target and spanning on, using a local switch that is not part of this PR. 1,117 programs span, the same with the guest-memory and unmerged-continue rules. The fence rule sends 13 programs back to two lanes per invocation that spanned without it (1,130). Stray's heaviest programs,0x2011300000and0x200e390000, still span. A Python prototype of the first analysis agreed with it.ctestonmain3bb15be09+ this PR:APS5_NO_SPANNED_WAVE=1:application_heap_scripting,application_heap_lazy,agc_driver_image_table_vouched_lookups,agc_driver_guest_memory_lifetime,agc_driver_multisample_retirement, plusguest_kernel_fcntl, which passes alone.application_heaptests fail.agc_driver_lds_mask_waterfallstill runs both modes and still spans.maineda7477ac, with perf(shader): let spanned waves run at any host subgroup size where it can be narrower than 32 #8004 on top: see perf(shader): let spanned waves run at any host subgroup size where it can be narrower than 32 #8004. The Arc and lavapipe failures also fail onmain, and the focused tests under the validation layer show noVUID-error.agc_driver_guarded_null_pointer, new onmain, failed with spanning on before the guarded-read fix and passes after it, 5 of 5 runs.Stray, frames 20 to 50 of the boot (
APS5_TRACE_FRAMES=20:30, 3840x2160).main+ fix(shader): keep host interpolation across entry EXEC copies #7811, againstmain+ this PR + fix(shader): keep host interpolation across entry EXEC copies #7811. Stray stops onmainwithout fix(shader): keep host interpolation across entry EXEC copies #7811 (AGC: since #6291, Stray (PPSA02101) stops on Intel Arc with "a pixel shader that reads barycentrics … needs a vertex shader before it" on a Geometry-path draw #7693).128b8c1f8is this PR's first push. The final head differs from it only in the helper header's template parameters.main+ #7811trace_digest.py, first capture of each:aps5-summary.jsonllines,main+ #7811:{"commit":"4b4d52f7d953","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":13716.468},"presents":30,"frame_ms":{"p50":451.183,"p90":472.083,"p99":586.282,"max":586.282},"gpu_busy_ms_per_present":308.934,"worker_busy_pct":{"queue worker 0x0":96.582,"queue worker 0x20":97.047},"top_phases_ms_per_frame":{"Driver.Packet":882.201,"Driver.Packet.memory_wait":418.127,"Driver.Packet.device_lock":208.359,"Driver.Packet.prepare_memory":138.870,"Graphics.Draw":127.060,"Graphics.Draw.draw_and_resource_release":126.577,"Recorder.Submit":114.858,"Driver.Packet.dispatch":68.164},"trace_dropped":false,"trace":"aps5-trace-4b4d52f7d953-938192.json.gz"} {"commit":"4b4d52f7d953","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":13995.080},"presents":30,"frame_ms":{"p50":464.151,"p90":479.730,"p99":509.222,"max":509.222},"gpu_busy_ms_per_present":312.990,"worker_busy_pct":{"queue worker 0x0":96.781,"queue worker 0x20":96.913},"top_phases_ms_per_frame":{"Driver.Packet":900.975,"Driver.Packet.memory_wait":428.313,"Driver.Packet.device_lock":205.633,"Driver.Packet.prepare_memory":148.125,"Graphics.Draw":128.606,"Graphics.Draw.draw_and_resource_release":128.151,"Recorder.Submit":107.255,"Driver.Packet.dispatch":72.186},"trace_dropped":false,"trace":"aps5-trace-4b4d52f7d953-940261.json.gz"} {"commit":"4b4d52f7d953","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":13088.121},"presents":30,"frame_ms":{"p50":432.628,"p90":450.240,"p99":530.799,"max":530.799},"gpu_busy_ms_per_present":288.316,"worker_busy_pct":{"queue worker 0x0":96.056,"queue worker 0x20":96.773},"top_phases_ms_per_frame":{"Driver.Packet":837.222,"Driver.Packet.memory_wait":395.185,"Driver.Packet.device_lock":213.902,"Graphics.Draw":129.895,"Graphics.Draw.draw_and_resource_release":129.422,"Recorder.Submit":114.352,"Driver.Packet.prepare_memory":110.092,"Driver.Packet.dispatch":71.040},"trace_dropped":false,"trace":"aps5-trace-4b4d52f7d953-942091.json.gz"}This PR + #7811:
{"commit":"128b8c1f83c0","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":10177.000},"presents":30,"frame_ms":{"p50":334.856,"p90":347.438,"p99":418.694,"max":418.694},"gpu_busy_ms_per_present":180.675,"worker_busy_pct":{"queue worker 0x0":95.362,"queue worker 0x20":96.360},"top_phases_ms_per_frame":{"Driver.Packet":646.122,"Driver.Packet.memory_wait":298.561,"Driver.Packet.device_lock":193.196,"Graphics.Draw":116.729,"Graphics.Draw.draw_and_resource_release":116.290,"Recorder.Submit":108.061,"Driver.Packet.dispatch":69.570,"Driver.Dispatch":64.534},"trace_dropped":false,"trace":"aps5-trace-128b8c1f83c0-939198.json.gz"} {"commit":"128b8c1f83c0","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":9748.101},"presents":30,"frame_ms":{"p50":324.600,"p90":332.281,"p99":340.520,"max":340.520},"gpu_busy_ms_per_present":165.056,"worker_busy_pct":{"queue worker 0x0":95.368,"queue worker 0x20":97.098},"top_phases_ms_per_frame":{"Driver.Packet":622.706,"Driver.Packet.memory_wait":285.025,"Driver.Packet.device_lock":182.915,"Graphics.Draw":113.762,"Graphics.Draw.draw_and_resource_release":113.340,"Recorder.Submit":97.834,"Driver.Packet.dispatch":72.730,"Driver.Dispatch":68.024},"trace_dropped":false,"trace":"aps5-trace-128b8c1f83c0-941263.json.gz"} {"commit":"128b8c1f83c0","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":10014.061},"presents":30,"frame_ms":{"p50":334.968,"p90":340.775,"p99":354.031,"max":354.031},"gpu_busy_ms_per_present":173.489,"worker_busy_pct":{"queue worker 0x0":95.324,"queue worker 0x20":96.938},"top_phases_ms_per_frame":{"Driver.Packet":639.070,"Driver.Packet.memory_wait":298.617,"Driver.Packet.device_lock":189.827,"Graphics.Draw":115.684,"Graphics.Draw.draw_and_resource_release":115.257,"Recorder.Submit":104.396,"Driver.Packet.dispatch":72.309,"Driver.Dispatch":68.740},"trace_dropped":false,"trace":"aps5-trace-128b8c1f83c0-943100.json.gz"}Traces, digests and summaries:
ThatsLeo:evidence/spanned-default.The fence and early-exit rules on Stray. Same scene and machine,
main559f35d68+ this PR (without, then with, the second commit) + #8004 + #7811. One warm run each, then four interleaved rounds. After a battery drain this laptop idled at 56 °C, so every capture started below 58 °C, not 55.The difference is inside the spread.
aps5-summary.jsonllines{"commit":"9667780a1567","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8273.368},"presents":30,"frame_ms":{"p50":276.642,"p90":287.880,"p99":294.712,"max":294.712},"gpu_busy_ms_per_present":111.544,"worker_busy_pct":{"queue worker 0x0":97.191,"queue worker 0x20":97.311},"top_phases_ms_per_frame":{"Driver.Packet":532.809,"Driver.Packet.memory_wait":229.082,"Driver.Packet.device_lock":165.884,"Graphics.Draw":114.639,"Graphics.Draw.draw_and_resource_release":114.308,"Driver.Packet.dispatch":85.599,"Driver.Dispatch":59.489,"Recorder.Submit":48.015},"trace_dropped":false,"trace":"aps5-trace-9667780a1567-108138.json.gz"} {"commit":"9667780a1567","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8223.104},"presents":30,"frame_ms":{"p50":271.596,"p90":287.082,"p99":292.329,"max":292.329},"gpu_busy_ms_per_present":113.868,"worker_busy_pct":{"queue worker 0x0":97.306,"queue worker 0x20":96.759},"top_phases_ms_per_frame":{"Driver.Packet":529.169,"Driver.Packet.memory_wait":216.791,"Driver.Packet.device_lock":164.966,"Graphics.Draw":115.568,"Graphics.Draw.draw_and_resource_release":115.240,"Driver.Packet.dispatch":94.578,"Driver.Dispatch":63.130,"Vulkan.Dispatch":47.380},"trace_dropped":false,"trace":"aps5-trace-9667780a1567-113059.json.gz"} {"commit":"9667780a1567","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8561.265},"presents":30,"frame_ms":{"p50":285.252,"p90":299.190,"p99":305.800,"max":305.800},"gpu_busy_ms_per_present":117.525,"worker_busy_pct":{"queue worker 0x0":97.291,"queue worker 0x20":97.585},"top_phases_ms_per_frame":{"Driver.Packet":552.832,"Driver.Packet.memory_wait":224.121,"Driver.Packet.device_lock":164.165,"Graphics.Draw":115.802,"Graphics.Draw.draw_and_resource_release":115.458,"Driver.Packet.dispatch":109.259,"Driver.Dispatch":72.453,"Vulkan.Dispatch":47.232},"trace_dropped":false,"trace":"aps5-trace-9667780a1567-116244.json.gz"} {"commit":"9667780a1567","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8493.756},"presents":30,"frame_ms":{"p50":280.819,"p90":298.458,"p99":301.837,"max":301.837},"gpu_busy_ms_per_present":116.292,"worker_busy_pct":{"queue worker 0x0":97.613,"queue worker 0x20":97.336},"top_phases_ms_per_frame":{"Driver.Packet":549.554,"Driver.Packet.memory_wait":230.652,"Driver.Packet.device_lock":163.134,"Graphics.Draw":115.009,"Graphics.Draw.draw_and_resource_release":114.660,"Driver.Packet.dispatch":100.944,"Driver.Dispatch":72.601,"Recorder.Submit":49.593},"trace_dropped":false,"trace":"aps5-trace-9667780a1567-119633.json.gz"} {"commit":"219315aabfb1","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8094.501},"presents":30,"frame_ms":{"p50":268.921,"p90":282.204,"p99":285.051,"max":285.051},"gpu_busy_ms_per_present":115.018,"worker_busy_pct":{"queue worker 0x0":97.361,"queue worker 0x20":96.984},"top_phases_ms_per_frame":{"Driver.Packet":522.612,"Driver.Packet.memory_wait":216.751,"Driver.Packet.device_lock":163.550,"Graphics.Draw":115.508,"Graphics.Draw.draw_and_resource_release":115.189,"Driver.Packet.dispatch":89.641,"Driver.Dispatch":54.537,"Recorder.Submit":47.263},"trace_dropped":false,"trace":"aps5-trace-219315aabfb1-110545.json.gz"} {"commit":"219315aabfb1","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8388.481},"presents":30,"frame_ms":{"p50":279.752,"p90":289.914,"p99":307.567,"max":307.567},"gpu_busy_ms_per_present":114.558,"worker_busy_pct":{"queue worker 0x0":97.228,"queue worker 0x20":97.175},"top_phases_ms_per_frame":{"Driver.Packet":541.081,"Driver.Packet.memory_wait":229.579,"Driver.Packet.device_lock":164.570,"Graphics.Draw":115.558,"Graphics.Draw.draw_and_resource_release":115.217,"Driver.Packet.dispatch":97.113,"Driver.Dispatch":67.063,"Recorder.Submit":47.239},"trace_dropped":false,"trace":"aps5-trace-219315aabfb1-114700.json.gz"} {"commit":"219315aabfb1","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8163.070},"presents":30,"frame_ms":{"p50":272.213,"p90":284.784,"p99":291.836,"max":291.836},"gpu_busy_ms_per_present":114.038,"worker_busy_pct":{"queue worker 0x0":97.290,"queue worker 0x20":96.736},"top_phases_ms_per_frame":{"Driver.Packet":524.954,"Driver.Packet.memory_wait":218.094,"Driver.Packet.device_lock":160.249,"Graphics.Draw":114.762,"Graphics.Draw.draw_and_resource_release":114.432,"Driver.Packet.dispatch":88.844,"Driver.Dispatch":56.043,"Recorder.Submit":46.681},"trace_dropped":false,"trace":"aps5-trace-219315aabfb1-117978.json.gz"} {"commit":"219315aabfb1","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8315.173},"presents":30,"frame_ms":{"p50":278.251,"p90":288.303,"p99":290.344,"max":290.344},"gpu_busy_ms_per_present":112.656,"worker_busy_pct":{"queue worker 0x0":97.424,"queue worker 0x20":97.292},"top_phases_ms_per_frame":{"Driver.Packet":532.199,"Driver.Packet.memory_wait":217.928,"Driver.Packet.device_lock":162.971,"Graphics.Draw":116.778,"Graphics.Draw.draw_and_resource_release":116.362,"Driver.Packet.dispatch":101.673,"Driver.Dispatch":67.305,"Recorder.Submit":48.184},"trace_dropped":false,"trace":"aps5-trace-219315aabfb1-120956.json.gz"}Traces, digests and summaries:
ThatsLeo:evidence/spanned-fence.Runs by others, on earlier heads:
Not tested:
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)