Shaders: reads of uninitialized SGPRs read as zero, as VGPRs do

Compute programs read SGPRs the hardware does not initialize when two
branches make the paths look like they allow a read before a write, even
though the branch that skips the write does not reach the read. That stops
translation with 'a hardware SGPR input is not supported' and drops the
program's dispatches.

ComputeIo::initialized_sgprs() counts the user SGPRs, the enabled system
ones and the scratch wave offset. A read of a general SGPR (0..=105) at or
above that count holds whatever the previous wave left, so no program can
depend on its value: read it as zero, as unset VGPRs already are. Reserved
registers (VCC, trap temporaries, M0, EXEC) keep their current handling.
This commit is contained in:
local committed 2026-11-23 22:16:27 -05:00
1 parent d2a4bae1f4
commit f4438b38f4
3 files changed
+47 -1

No files matched your search

+7
View File
@@ -182,6 +182,9 @@ pub struct Io {
pub inputs: Vec<(Value, Input)>,
pub interps: Vec<(Site, Interp)>,
pub exports: Vec<Export>,
/// Compute: how many SGPRs the hardware initializes
/// ([`ComputeIo::initialized_sgprs`](crate::native::ComputeIo::initialized_sgprs)).
pub initialized_sgprs: Option<u8>,
}
/// Raises the I/O of `p`, built from `native`'s patched code. Fails for
@@ -287,6 +290,10 @@ pub fn raise(p: &Program, native: &NativeProgram) -> Result<Io, ShaderError> {
let mut io = Io {
inputs: inputs.clone(),
initialized_sgprs: match &native.io {
StageIo::Cs(cs) => Some(cs.initialized_sgprs()),
_ => None,
},
..Io::default()
};
let defs: std::collections::HashMap<Value, Site> = p