Initial implementation of GPUCommandEncoder

Added WebIDL bindings for `GPUCommandEncoder`, `GPUCommandBuffer`, `GPUComputePassEncoder`, `GPUProgrammablePassEncoder`.
Implemented the `beginComputePass`, `copyBufferToBuffer` and `finish` functions of `GPUCommandEncoder`.
Implemented the `createCommandEncoder` function of `GPUDevice`.
This commit is contained in:
Zakor Gyula 2020-01-14 08:54:08 +01:00 committed by Istvan Miklos
parent 9031369c19
commit 4facd3d4d2
14 changed files with 443 additions and 13 deletions

View file

@ -12,7 +12,9 @@ use crate::dom::bindings::codegen::Bindings::GPUBindGroupLayoutBinding::{
};
use crate::dom::bindings::codegen::Bindings::GPUBufferBinding::GPUBufferDescriptor;
use crate::dom::bindings::codegen::Bindings::GPUComputePipelineBinding::GPUComputePipelineDescriptor;
use crate::dom::bindings::codegen::Bindings::GPUDeviceBinding::{self, GPUDeviceMethods};
use crate::dom::bindings::codegen::Bindings::GPUDeviceBinding::{
self, GPUCommandEncoderDescriptor, GPUDeviceMethods,
};
use crate::dom::bindings::codegen::Bindings::GPUPipelineLayoutBinding::GPUPipelineLayoutDescriptor;
use crate::dom::bindings::codegen::Bindings::GPUShaderModuleBinding::GPUShaderModuleDescriptor;
use crate::dom::bindings::codegen::UnionTypes::Uint32ArrayOrString::{String, Uint32Array};
@ -26,6 +28,7 @@ use crate::dom::gpuadapter::GPUAdapter;
use crate::dom::gpubindgroup::GPUBindGroup;
use crate::dom::gpubindgrouplayout::GPUBindGroupLayout;
use crate::dom::gpubuffer::{GPUBuffer, GPUBufferState};
use crate::dom::gpucommandencoder::GPUCommandEncoder;
use crate::dom::gpucomputepipeline::GPUComputePipeline;
use crate::dom::gpupipelinelayout::GPUPipelineLayout;
use crate::dom::gpushadermodule::GPUShaderModule;
@ -589,4 +592,21 @@ impl GPUDeviceMethods for GPUDevice {
let compute_pipeline = receiver.recv().unwrap();
GPUComputePipeline::new(&self.global(), compute_pipeline)
}
/// https://gpuweb.github.io/gpuweb/#dom-gpudevice-createcommandencoder
fn CreateCommandEncoder(
&self,
_descriptor: &GPUCommandEncoderDescriptor,
) -> DomRoot<GPUCommandEncoder> {
let (sender, receiver) = ipc::channel().unwrap();
let id = self
.global()
.wgpu_create_command_encoder_id(self.device.0.backend());
self.channel
.0
.send(WebGPURequest::CreateCommandEncoder(sender, self.device, id))
.expect("Failed to create WebGPU command encoder");
let encoder = receiver.recv().unwrap();
GPUCommandEncoder::new(&self.global(), self.channel.clone(), encoder)
}
}