Shaders: image_sample_o with constant offsets

image_sample_o was refused by name. Its offset dword (x in bits 0-5, y
in 8-13, z in 16-21, signed) becomes sample's immediate offsets when it
is a constant within DXIL's -8..7; a computed or wider offset is still
refused, now saying so. Module::int_value reads an integer constant.

translate --validate on shaders.rpf: vertex/pixel 12172 -> 12176
validated (all four).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Saitken91andClaude Opus 5.5 committed 2026-11-23 23:58:14 -06:00
1 parent d2a4bae1f4
commit 260611acaa
2 files changed
+31 -1

No files matched your search

+11
View File
@@ -291,6 +291,17 @@ impl Module {
self.constant(ty, Const::Aggregate(ids))
}
/// The value of an integer constant; `None` for anything else.
pub fn int_value(&self, v: V) -> Option<i64> {
match v {
V::Const(i) => match self.consts[i as usize].1 {
Const::Int(x) => Some(x),
_ => None,
},
_ => None,
}
}
/// Gives constant `old` the content of `new` (both stay valid).
pub fn replace_const(&mut self, old: V, new: V) {
if let (V::Const(o), V::Const(n)) = (old, new) {