use crate::device::Device;
bitflags::bitflags! {
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct ShaderStages: u32 {
const VERTEX = 1;
const FRAGMENT = 1 << 1;
const COMPUTE = 1 << 2;
}
}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum BindingType {
Uniform,
Storage {
read_only: bool,
},
Texture {
filterable: bool,
},
Texture3dFloat {
filterable: bool,
},
Texture3dUint,
StorageTexture3dWrite {
format: crate::TextureFormat,
},
DepthTexture,
Sampler {
comparison: bool,
},
}
#[derive(Clone, Copy, Debug)]
pub struct BindGroupLayoutEntry {
pub binding: u32,
pub visibility: ShaderStages,
pub ty: BindingType,
}
#[derive(Clone, Copy, Debug)]
pub struct BindGroupLayoutDesc<'a> {
pub label: &'static str,
pub entries: &'a [BindGroupLayoutEntry],
}
#[derive(Debug)]
pub enum BindGroupEntry<'a, D: Device> {
Buffer {
binding: u32,
buffer: &'a D::Buffer,
},
BufferRange {
binding: u32,
buffer: &'a D::Buffer,
offset: u64,
size: u64,
},
Texture {
binding: u32,
view: &'a D::TextureView,
},
Sampler {
binding: u32,
sampler: &'a D::Sampler,
},
}
#[derive(Debug)]
pub struct BindGroupDesc<'a, D: Device> {
pub label: &'static str,
pub layout: &'a D::BindGroupLayout,
pub entries: &'a [BindGroupEntry<'a, D>],
}
#[derive(Clone, Copy, Debug)]
pub struct AccelerationStructureBinding<'a, D: Device> {
pub binding: u32,
pub tlas: &'a D::Tlas,
}
#[derive(Clone, Copy, Debug)]
pub struct AccelerationStructureLayoutEntry {
pub binding: u32,
pub visibility: ShaderStages,
}
#[derive(Debug)]
pub struct RayQueryBindGroupLayoutDesc<'a> {
pub label: &'static str,
pub entries: &'a [BindGroupLayoutEntry],
pub acceleration_structures: &'a [AccelerationStructureLayoutEntry],
}
#[derive(Debug)]
pub struct RayQueryBindGroupDesc<'a, D: Device> {
pub label: &'static str,
pub layout: &'a D::BindGroupLayout,
pub entries: &'a [BindGroupEntry<'a, D>],
pub acceleration_structures: &'a [AccelerationStructureBinding<'a, D>],
}