native: basic compute resource binding

This commit is contained in:
Dzmitry Malyshau 2018-10-02 21:37:27 -04:00
parent c7bb1b453e
commit 45def95763
5 changed files with 44 additions and 9 deletions

View File

@ -76,6 +76,6 @@ pub struct BindGroupDescriptor {
pub bindings_length: usize,
}
pub struct BindGroup {
// TODO
pub(crate) struct BindGroup<B: hal::Backend> {
pub raw: B::DescriptorSet,
}

View File

@ -1,12 +1,14 @@
use registry::{HUB, Items, Registry};
use {
Stored,
CommandBufferId, ComputePassId
BindGroupId, CommandBufferId, ComputePassId, ComputePipelineId,
};
use hal;
use hal::command::RawCommandBuffer;
use std::iter;
pub struct ComputePass<B: hal::Backend> {
raw: B::CommandBuffer,
@ -37,6 +39,34 @@ pub extern "C" fn wgpu_compute_pass_end_pass(
pass.cmb_id.0
}
pub extern "C" fn wgpu_compute_pass_set_bind_group(
pass_id: ComputePassId, index: u32, bind_group_id: BindGroupId,
) {
let bind_group_guard = HUB.bind_groups.lock();
let set = &bind_group_guard.get(bind_group_id).raw;
let layout = unimplemented!();
// see https://github.com/gpuweb/gpuweb/pull/93
HUB.compute_passes
.lock()
.get_mut(pass_id)
.raw
.bind_compute_descriptor_sets(layout, index as usize, iter::once(set), &[]);
}
pub extern "C" fn wgpu_compute_pass_set_pipeline(
pass_id: ComputePassId, pipeline_id: ComputePipelineId,
) {
let pipeline_guard = HUB.compute_pipelines.lock();
let pipeline = &pipeline_guard.get(pipeline_id).raw;
HUB.compute_passes
.lock()
.get_mut(pass_id)
.raw
.bind_compute_pipeline(pipeline);
}
pub extern "C" fn wgpu_compute_pass_dispatch(
pass_id: ComputePassId, x: u32, y: u32, z: u32,
) {

View File

@ -106,6 +106,8 @@ pub type BindGroupLayoutId = Id;
type BindGroupLayoutHandle = BindGroupLayout<B>;
pub type PipelineLayoutId = Id;
type PipelineLayoutHandle = PipelineLayout<B>;
pub type BindGroupId = Id;
type BindGroupHandle = BindGroup<B>;
// Pipeline
pub type BlendStateId = Id;
@ -117,9 +119,10 @@ pub type ShaderModuleId = Id;
type ShaderModuleHandle = ShaderModule<B>;
pub type AttachmentStateId = Id;
type AttachmentStateHandle = AttachmentState<B>;
pub type ComputePipelineId = Id;
pub type RenderPipelineId = Id;
type RenderPipelineHandle = RenderPipeline<B>;
pub type ComputePipelineId = Id;
type ComputePipelineHandle = ComputePipeline<B>;
pub type CommandBufferId = Id;
type CommandBufferHandle = CommandBuffer<B>;

View File

@ -227,8 +227,8 @@ pub struct ComputePipelineDescriptor {
pub stages: *const PipelineStageDescriptor,
}
pub struct ComputePipeline {
// TODO
pub(crate) struct ComputePipeline<B: hal::Backend> {
pub raw: B::ComputePipeline,
}
#[repr(C)]

View File

@ -9,10 +9,10 @@ pub use self::local::{Id, ItemsGuard, Registry as ConcreteRegistry};
pub use self::remote::{Id, ItemsGuard, Registry as ConcreteRegistry};
use {
AdapterHandle, AttachmentStateHandle, BindGroupLayoutHandle, BlendStateHandle,
CommandBufferHandle, DepthStencilStateHandle, DeviceHandle, InstanceHandle,
AdapterHandle, AttachmentStateHandle, BindGroupLayoutHandle, BindGroupHandle,
BlendStateHandle, CommandBufferHandle, DepthStencilStateHandle, DeviceHandle, InstanceHandle,
RenderPassHandle, ComputePassHandle,
PipelineLayoutHandle, RenderPipelineHandle, ShaderModuleHandle,
PipelineLayoutHandle, RenderPipelineHandle, ComputePipelineHandle, ShaderModuleHandle,
};
@ -37,12 +37,14 @@ pub struct Hub {
pub(crate) devices: ConcreteRegistry<DeviceHandle>,
pub(crate) pipeline_layouts: ConcreteRegistry<PipelineLayoutHandle>,
pub(crate) bind_group_layouts: ConcreteRegistry<BindGroupLayoutHandle>,
pub(crate) bind_groups: ConcreteRegistry<BindGroupHandle>,
pub(crate) attachment_states: ConcreteRegistry<AttachmentStateHandle>,
pub(crate) blend_states: ConcreteRegistry<BlendStateHandle>,
pub(crate) depth_stencil_states: ConcreteRegistry<DepthStencilStateHandle>,
pub(crate) shader_modules: ConcreteRegistry<ShaderModuleHandle>,
pub(crate) command_buffers: ConcreteRegistry<CommandBufferHandle>,
pub(crate) render_pipelines: ConcreteRegistry<RenderPipelineHandle>,
pub(crate) compute_pipelines: ConcreteRegistry<ComputePipelineHandle>,
pub(crate) render_passes: ConcreteRegistry<RenderPassHandle>,
pub(crate) compute_passes: ConcreteRegistry<ComputePassHandle>,
}