mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 00:03:29 +00:00
Add binding model types
This commit is contained in:
parent
7a46f83a02
commit
20b87711c1
@ -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<B: hal::Backend> {
|
||||
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
|
||||
}
|
||||
|
@ -58,7 +58,13 @@ pub type AdapterHandle = Handle<hal::Adapter<B>>;
|
||||
pub type DeviceHandle = Handle<Device<B>>;
|
||||
pub type BufferHandle = Handle<Buffer<B>>;
|
||||
|
||||
// Resource
|
||||
pub type TextureViewHandle = Handle<TextureView>;
|
||||
pub type TextureHandle = Handle<Texture>;
|
||||
pub type SamplerHandle = Handle<Sampler>;
|
||||
|
||||
// Binding model
|
||||
pub type BindGroupLayoutHandle = Handle<BindGroupLayout>;
|
||||
pub type PipelineLayoutHandle = Handle<PipelineLayout<B>>;
|
||||
|
||||
// Pipeline
|
||||
|
Loading…
Reference in New Issue
Block a user