Merge pull request #432 from Proudnoob4/fix/uninitialized-sgprs

Shaders: reads of uninitialized SGPRs read as zero, as VGPRs do
This commit is contained in:
Marvis authored and GitHub committed 2026-11-24 09:14:53 +01:00
commit ce42e77634
3 files changed
+47 -1

No files matched your search

+9 -1
View File
@@ -921,8 +921,16 @@ impl<'a> Lower<'a> {
for &(reg, v) in &self.x.p.inputs {
let val = match reg {
Reg::S(_) if self.params.contains_key(&v) => continue, // loaded on first use
Reg::S(_) => match io_inputs.get(&v) {
Reg::S(n) => match io_inputs.get(&v) {
Some(&input) => self.input(input),
// Above the SGPRs the hardware initializes, a register
// holds what the last wave left, so no program depends
// on it: a read the paths only seem to allow (a branch
// past the write, taken only with one past the read)
// reads zero, as VGPRs do.
None if n <= 105 && self.x.io.initialized_sgprs.is_some_and(|k| n >= k) => {
Val::I32(self.s.m.i32(0))
}
None => Val::Missing("a hardware SGPR input"),
},
Reg::Scc => Val::Missing("SCC on entry"),