diff --git a/src/binding_model.rs b/src/binding_model.rs index 5fa664e98..577dcf43a 100644 --- a/src/binding_model.rs +++ b/src/binding_model.rs @@ -1,6 +1,76 @@ use hal; +use {BindGroupLayoutHandle, BufferHandle, SamplerHandle, TextureViewHandle}; + +bitflags! { + #[repr(transparent)] + pub struct ShaderStageFlags: u32 { + const NONE = 0; + const VERTEX = 1; + const FRAGMENT = 2; + const COMPUTE = 4; + } +} + +#[repr(C)] +pub enum BindingType { + UniformBuffer = 0, + Sampler = 1, + SampledTexture = 2, + StorageBuffer = 3, +} + +#[repr(C)] +pub struct BindGroupLayoutBinding { + pub binding: u32, + pub visibility: ShaderStageFlags, + pub ty: BindingType, +} + +#[repr(C)] +pub struct BindGroupLayoutDescriptor<'a> { + pub bindings: &'a [BindGroupLayoutBinding], +} + +pub struct BindGroupLayout { + // TODO +} + +#[repr(C)] +pub struct PipelineLayoutDescriptor<'a> { + pub bind_group_layouts: &'a [BindGroupLayoutHandle], +} pub struct PipelineLayout { raw: B::PipelineLayout, } + +#[repr(C)] +pub struct BufferBinding { + pub buffer: BufferHandle, + pub offset: u32, + pub size: u32, +} + +#[repr(C)] +pub enum BindingResource { + Buffer(BufferBinding), + Sampler(SamplerHandle), + TextureView(TextureViewHandle), +} + +#[repr(C)] +pub struct Binding { + pub binding: u32, + pub resource: BindingResource, +} + +#[repr(C)] +pub struct BindGroupDescriptor<'a> { + pub layout: BindGroupLayout, + pub bindings: &'a [Binding], +} + +pub struct BindGroup { + // TODO +} diff --git a/src/conv.rs b/src/conv.rs index f19f0b24c..39d55b2ca 100644 --- a/src/conv.rs +++ b/src/conv.rs @@ -37,4 +37,4 @@ pub(crate) fn map_buffer_usage(usage: resource::BufferUsageFlags) -> (hal::buffe } (hal_usage, hal_memory) -} \ No newline at end of file +} diff --git a/src/lib.rs b/src/lib.rs index 3772d2fd8..55a7b6353 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -58,7 +58,13 @@ pub type AdapterHandle = Handle>; pub type DeviceHandle = Handle>; pub type BufferHandle = Handle>; +// Resource +pub type TextureViewHandle = Handle; +pub type TextureHandle = Handle; +pub type SamplerHandle = Handle; + // Binding model +pub type BindGroupLayoutHandle = Handle; pub type PipelineLayoutHandle = Handle>; // Pipeline