Shaders: lower waterfall loops over per-lane descriptors in one pass

A descriptor held in VGPRs is used through a waterfall loop: each pass
reads the first active lane's dwords with v_readfirstlane_b32, compares
them with every lane's own (v_cmp_eq), runs the access with the lanes
that match and repeats for the rest. Tracing stopped at the readfirstlane
results ("a descriptor neither loaded nor built").

The tracer now follows the read lanes' dwords to where each lane gets its
own: global_load_dword* from a table or heap at a per-lane address (an
image descriptor's two x4 loads lined up), or a v_cndmask_b32 choice per
lane between such sources (e.g. two s_load descriptors). Other sources
fail naming them (LDS read, buffer load, phi, input, computed VGPRs).
The loop's compares of those reads with their own dwords are recorded.

Lowering gives the access each lane's heap index (its load address over
the descriptor size, or a per-lane select of indices) with
createHandleFromHeap's nonUniformIndex set, lowers the recorded
readfirstlanes as the lane's own dword and their compares as true, so
the loop runs once with all lanes. Wave32 and wave64 are tested.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
This commit is contained in:
Claude committed 2026-11-24 02:07:43 +00:00
1 parent a3d3bc91e7
commit ffa663571f
4 files changed
+755 -11

No files matched your search

+15 -3
View File
@@ -65,6 +65,8 @@ pub(crate) struct Shader {
/// Root SRVs (raw buffers) read, likewise.
pub root_srvs: Vec<(u8, V)>,
pub flags: u64,
/// Heap handles made with a non-uniform index.
pub nonuniform_handles: u32,
/// A compute shader with this thread-group size.
pub threads: Option<[u32; 3]>,
/// The wave size a compute shader requires (`WaveSize`).
@@ -118,6 +120,7 @@ impl Shader {
root_cbvs: Vec::new(),
root_srvs: Vec::new(),
flags: 0,
nonuniform_handles: 0,
threads: None,
wave_size: None,
lds_dwords: 0,
@@ -272,14 +275,23 @@ impl Shader {
)
}
/// A descriptor heap handle, annotated with `props`.
pub fn heap_handle(&mut self, block: usize, index: V, sampler: bool, props: (u32, u32)) -> V {
/// A descriptor heap handle, annotated with `props`; `nonuniform` when
/// the index may differ between lanes (`NonUniformResourceIndex`).
pub fn heap_handle(
&mut self,
block: usize,
index: V,
sampler: bool,
nonuniform: bool,
props: (u32, u32),
) -> V {
self.flags |= if sampler {
flags::SAMPLER_HEAP
} else {
flags::RESOURCE_HEAP
};
let (s, n) = (self.m.bool(sampler), self.m.bool(false));
self.nonuniform_handles += u32::from(nonuniform);
let (s, n) = (self.m.bool(sampler), self.m.bool(nonuniform));
let h = self.op(
block,
"createHandleFromHeap",