Merge pull request #634 from SAitken91/shader/image-sample-o
Shaders: image_sample_o with constant offsets
This commit is contained in:
commit
cf63d91ac3
2 files changed
+31
-1
No files matched your search
@@ -291,6 +291,17 @@ impl Module {
|
|||||||
self.constant(ty, Const::Aggregate(ids))
|
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).
|
/// Gives constant `old` the content of `new` (both stay valid).
|
||||||
pub fn replace_const(&mut self, old: V, new: V) {
|
pub fn replace_const(&mut self, old: V, new: V) {
|
||||||
if let (V::Const(o), V::Const(n)) = (old, new) {
|
if let (V::Const(o), V::Const(n)) = (old, new) {
|
||||||
|
|||||||
@@ -5602,7 +5602,7 @@ impl<'a> Lower<'a> {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let (op, sample) = match name {
|
let (op, sample) = match name {
|
||||||
"image_sample" => (60, true),
|
"image_sample" | "image_sample_o" => (60, true),
|
||||||
"image_sample_lz" | "image_sample_l" => (62, true),
|
"image_sample_lz" | "image_sample_l" => (62, true),
|
||||||
"image_sample_b" => (61, true),
|
"image_sample_b" => (61, true),
|
||||||
"image_sample_c_lz" => (65, true),
|
"image_sample_c_lz" => (65, true),
|
||||||
@@ -5747,6 +5747,25 @@ impl<'a> Lower<'a> {
|
|||||||
args.extend(&cs);
|
args.extend(&cs);
|
||||||
match op {
|
match op {
|
||||||
60 => {
|
60 => {
|
||||||
|
if offset_word {
|
||||||
|
// DXIL takes immediate offsets in -8..=7; the
|
||||||
|
// console's are 6-bit and may be computed.
|
||||||
|
let w = addr_val(self, 0)?;
|
||||||
|
let w = self
|
||||||
|
.s
|
||||||
|
.m
|
||||||
|
.int_value(w)
|
||||||
|
.ok_or("a sample offset that is not constant")?
|
||||||
|
as u32;
|
||||||
|
for (k, o) in os.iter_mut().enumerate().take(offsets) {
|
||||||
|
let x = (w >> (8 * k) & 0x3F) as i32;
|
||||||
|
let x = if x >= 32 { x - 64 } else { x };
|
||||||
|
if !(-8..=7).contains(&x) {
|
||||||
|
return Err("a sample offset past -8..7");
|
||||||
|
}
|
||||||
|
*o = self.s.m.i32(x as u32);
|
||||||
|
}
|
||||||
|
}
|
||||||
args.extend(&os);
|
args.extend(&os);
|
||||||
args.push(fu);
|
args.push(fu);
|
||||||
self.s
|
self.s
|
||||||
|
|||||||
Reference in new issue
Block a user