diff options
author | Kunal Mohan <kunalmohan99@gmail.com> | 2020-06-04 01:19:13 +0530 |
---|---|---|
committer | Kunal Mohan <kunalmohan99@gmail.com> | 2020-06-04 01:19:13 +0530 |
commit | 3b5ede153d61c2c033326b5df2417e3757dba17b (patch) | |
tree | 96bee91b9cef09d97e5a27445b745c71a5d5361a /components/script/dom/gpudevice.rs | |
parent | 1d4efb48ba904aab93ebad3a2892aed46444088f (diff) | |
download | servo-3b5ede153d61c2c033326b5df2417e3757dba17b.tar.gz servo-3b5ede153d61c2c033326b5df2417e3757dba17b.zip |
Update wgpu-core and wgpu-types
Diffstat (limited to 'components/script/dom/gpudevice.rs')
-rw-r--r-- | components/script/dom/gpudevice.rs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/components/script/dom/gpudevice.rs b/components/script/dom/gpudevice.rs index 6a4301124b9..e8720bf2189 100644 --- a/components/script/dom/gpudevice.rs +++ b/components/script/dom/gpudevice.rs @@ -85,7 +85,7 @@ impl GPUDevice { limits: Heap<*mut JSObject>, device: webgpu::WebGPUDevice, queue: &GPUQueue, - ) -> GPUDevice { + ) -> Self { Self { eventtarget: EventTarget::new_inherited(), channel, @@ -106,7 +106,7 @@ impl GPUDevice { limits: Heap<*mut JSObject>, device: webgpu::WebGPUDevice, queue: webgpu::WebGPUQueue, - ) -> DomRoot<GPUDevice> { + ) -> DomRoot<Self> { let queue = GPUQueue::new(global, channel.clone(), queue); reflect_dom_object( Box::new(GPUDevice::new_inherited( @@ -121,6 +121,7 @@ impl GPUDevice { fn validate_buffer_descriptor( &self, descriptor: &GPUBufferDescriptor, + mapped_at_creation: bool, ) -> (bool, wgt::BufferDescriptor<std::string::String>) { // TODO: Record a validation error in the current scope if the descriptor is invalid. let wgpu_usage = wgt::BufferUsage::from_bits(descriptor.usage); @@ -132,6 +133,7 @@ impl GPUDevice { wgt::BufferDescriptor { size: descriptor.size, usage: wgpu_usage.unwrap(), + mapped_at_creation, label: Default::default(), }, ) @@ -141,6 +143,7 @@ impl GPUDevice { wgt::BufferDescriptor { size: 0, usage: wgt::BufferUsage::empty(), + mapped_at_creation, label: Default::default(), }, ) @@ -181,7 +184,7 @@ impl GPUDeviceMethods for GPUDevice { /// https://gpuweb.github.io/gpuweb/#dom-gpudevice-createbuffer fn CreateBuffer(&self, descriptor: &GPUBufferDescriptor) -> DomRoot<GPUBuffer> { - let (valid, wgpu_descriptor) = self.validate_buffer_descriptor(descriptor); + let (valid, wgpu_descriptor) = self.validate_buffer_descriptor(descriptor, false); let id = self .global() .wgpu_id_hub() @@ -217,7 +220,7 @@ impl GPUDeviceMethods for GPUDevice { cx: SafeJSContext, descriptor: &GPUBufferDescriptor, ) -> Vec<JSVal> { - let (valid, wgpu_descriptor) = self.validate_buffer_descriptor(descriptor); + let (valid, wgpu_descriptor) = self.validate_buffer_descriptor(descriptor, true); let buffer_id = self .global() .wgpu_id_hub() @@ -225,7 +228,7 @@ impl GPUDeviceMethods for GPUDevice { .create_buffer_id(self.device.0.backend()); self.channel .0 - .send(WebGPURequest::CreateBufferMapped { + .send(WebGPURequest::CreateBuffer { device_id: self.device.0, buffer_id, descriptor: wgpu_descriptor.clone(), @@ -546,7 +549,9 @@ impl GPUDeviceMethods for GPUDevice { resource: BindingResource::Buffer(BufferBinding { buffer: bind.resource.buffer.id().0, offset: bind.resource.offset, - size: bind.resource.size.unwrap_or(bind.resource.buffer.size()), + size: wgt::BufferSize( + bind.resource.size.unwrap_or(bind.resource.buffer.size()), + ), }), }) .collect::<Vec<_>>(); @@ -729,11 +734,8 @@ impl GPUDeviceMethods for GPUDevice { mipmap_filter: convert_filter_mode(descriptor.mipmapFilter), lod_min_clamp: *descriptor.lodMinClamp, lod_max_clamp: *descriptor.lodMaxClamp, - compare: if let Some(c) = descriptor.compare { - convert_compare_function(c) - } else { - wgt::CompareFunction::Undefined - }, + compare: descriptor.compare.map(|c| convert_compare_function(c)), + anisotropy_clamp: None, }; self.channel .0 |