Initial implementation of GPUComputePipeline

Added WebIDL bindings for `GPUComputePipeline`.
Implemented the `createComputePipeline` function of `GPUDevice`.
This commit is contained in:
Istvan Miklos 2020-02-03 15:42:13 +01:00
parent a8621c4ed9
commit 9031369c19
11 changed files with 180 additions and 8 deletions

View file

@ -59,6 +59,14 @@ pub enum WebGPURequest {
wgpu::id::BindGroupLayoutId,
Vec<wgpu::binding_model::BindGroupLayoutBinding>,
),
CreateComputePipeline(
IpcSender<WebGPUComputePipeline>,
WebGPUDevice,
wgpu::id::ComputePipelineId,
wgpu::id::PipelineLayoutId,
wgpu::id::ShaderModuleId,
String,
),
CreatePipelineLayout(
IpcSender<WebGPUPipelineLayout>,
WebGPUDevice,
@ -310,6 +318,33 @@ impl WGPU {
)
}
},
WebGPURequest::CreateComputePipeline(
sender,
device,
id,
layout,
program,
entry,
) => {
let global = &self.global;
let entry_point = std::ffi::CString::new(entry).unwrap();
let descriptor = wgpu_core::pipeline::ComputePipelineDescriptor {
layout,
compute_stage: wgpu_core::pipeline::ProgrammableStageDescriptor {
module: program,
entry_point: entry_point.as_ptr(),
},
};
let cp_id = gfx_select!(id => global.device_create_compute_pipeline(device.0, &descriptor, id));
let compute_pipeline = WebGPUComputePipeline(cp_id);
if let Err(e) = sender.send(compute_pipeline) {
warn!(
"Failed to send response to WebGPURequest::CreateComputePipeline ({})",
e
)
}
},
WebGPURequest::Exit(sender) => {
self.deinit();
if let Err(e) = sender.send(()) {
@ -342,5 +377,6 @@ webgpu_resource!(WebGPUDevice, wgpu::id::DeviceId);
webgpu_resource!(WebGPUBuffer, wgpu::id::BufferId);
webgpu_resource!(WebGPUBindGroup, wgpu::id::BindGroupId);
webgpu_resource!(WebGPUBindGroupLayout, wgpu::id::BindGroupLayoutId);
webgpu_resource!(WebGPUComputePipeline, wgpu::id::ComputePipelineId);
webgpu_resource!(WebGPUPipelineLayout, wgpu::id::PipelineLayoutId);
webgpu_resource!(WebGPUShaderModule, wgpu::id::ShaderModuleId);