mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[ir] add SAMPLED image flag
This commit is contained in:
@@ -56,6 +56,7 @@ pub enum Error {
|
||||
MixedExecutionModels(crate::Token<crate::Function>),
|
||||
MissingBinding(crate::Token<crate::GlobalVariable>),
|
||||
MissingBindTarget(BindSource),
|
||||
InvalidImageFlags(crate::ImageFlags),
|
||||
BadName(String),
|
||||
}
|
||||
|
||||
@@ -510,14 +511,19 @@ impl<W: Write> Writer<W> {
|
||||
spirv::Dim::DimCube => "Cube",
|
||||
_ => panic!("Unsupported dim {:?}", dim),
|
||||
};
|
||||
let access = if flags.contains(crate::ImageFlags::READABLE | crate::ImageFlags::WRITABLE) {
|
||||
"read_write"
|
||||
} else if flags.contains(crate::ImageFlags::WRITABLE) {
|
||||
"write"
|
||||
} else {
|
||||
assert!(flags.contains(crate::ImageFlags::READABLE));
|
||||
//TODO: figure out when to use `read`
|
||||
let access = if flags.contains(crate::ImageFlags::SAMPLED) {
|
||||
if flags.intersects(crate::ImageFlags::CAN_STORE) {
|
||||
return Err(Error::InvalidImageFlags(flags));
|
||||
}
|
||||
"sample"
|
||||
} else if flags.contains(crate::ImageFlags::CAN_LOAD | crate::ImageFlags::CAN_STORE) {
|
||||
"read_write"
|
||||
} else if flags.contains(crate::ImageFlags::CAN_STORE) {
|
||||
"write"
|
||||
} else if flags.contains(crate::ImageFlags::CAN_LOAD) {
|
||||
"read"
|
||||
} else {
|
||||
return Err(Error::InvalidImageFlags(flags));
|
||||
};
|
||||
write!(self.out, "typedef texture{}<{}, access::{}> {}", dim, base_name, access, name)?;
|
||||
}
|
||||
|
||||
@@ -1066,21 +1066,21 @@ impl<I: Iterator<Item = u32>> Parser<I> {
|
||||
flags |= crate::ImageFlags::MULTISAMPLED;
|
||||
}
|
||||
let is_sampled = self.next()?;
|
||||
if is_sampled != 0 {
|
||||
flags |= crate::ImageFlags::SAMPLED;
|
||||
}
|
||||
let _format = self.next()?;
|
||||
let access = if inst.wc > 9 {
|
||||
if inst.wc > 9 {
|
||||
inst.expect(10)?;
|
||||
self.next()?
|
||||
} else if is_sampled == 1 {
|
||||
0 // read-only
|
||||
} else {
|
||||
2 // read-write
|
||||
let access = self.next()?;
|
||||
if access == 0 || access == 2 {
|
||||
flags |= crate::ImageFlags::CAN_LOAD;
|
||||
}
|
||||
if access == 1 || access == 2 {
|
||||
flags |= crate::ImageFlags::CAN_STORE;
|
||||
}
|
||||
};
|
||||
if access == 0 || access == 2 {
|
||||
flags |= crate::ImageFlags::READABLE;
|
||||
}
|
||||
if access == 1 || access == 2 {
|
||||
flags |= crate::ImageFlags::WRITABLE;
|
||||
}
|
||||
|
||||
let decor = self.future_decor
|
||||
.remove(&id)
|
||||
.unwrap_or_default();
|
||||
|
||||
@@ -60,8 +60,9 @@ bitflags::bitflags! {
|
||||
pub struct ImageFlags: u32 {
|
||||
const ARRAYED = 0x1;
|
||||
const MULTISAMPLED = 0x2;
|
||||
const READABLE = 0x4;
|
||||
const WRITABLE = 0x8;
|
||||
const SAMPLED = 0x4;
|
||||
const CAN_LOAD = 0x10;
|
||||
const CAN_STORE = 0x20;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user