Change ErrorScopeId type to NonZeroU64

And extract it from WebGPURequest
This commit is contained in:
Kunal Mohan 2020-08-03 01:45:29 +05:30
parent 8eff1d74de
commit ce6e09a3aa
17 changed files with 277 additions and 250 deletions

View file

@ -2169,7 +2169,7 @@ where
options, options,
ids, ids,
}; };
if webgpu_chan.0.send(adapter_request).is_err() { if webgpu_chan.0.send((None, adapter_request)).is_err() {
return warn!("Failed to send request adapter message on WebGPU channel"); return warn!("Failed to send request adapter message on WebGPU channel");
} }
}, },

View file

@ -831,6 +831,7 @@ malloc_size_of_is_0!(bool, char, str);
malloc_size_of_is_0!(u8, u16, u32, u64, u128, usize); malloc_size_of_is_0!(u8, u16, u32, u64, u128, usize);
malloc_size_of_is_0!(i8, i16, i32, i64, i128, isize); malloc_size_of_is_0!(i8, i16, i32, i64, i128, isize);
malloc_size_of_is_0!(f32, f64); malloc_size_of_is_0!(f32, f64);
malloc_size_of_is_0!(std::num::NonZeroU64);
malloc_size_of_is_0!(std::sync::atomic::AtomicBool); malloc_size_of_is_0!(std::sync::atomic::AtomicBool);
malloc_size_of_is_0!(std::sync::atomic::AtomicIsize); malloc_size_of_is_0!(std::sync::atomic::AtomicIsize);

View file

@ -138,6 +138,7 @@ use std::cell::{Cell, RefCell, UnsafeCell};
use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; use std::collections::{BTreeMap, HashMap, HashSet, VecDeque};
use std::hash::{BuildHasher, Hash}; use std::hash::{BuildHasher, Hash};
use std::mem; use std::mem;
use std::num::NonZeroU64;
use std::ops::{Deref, DerefMut, Range}; use std::ops::{Deref, DerefMut, Range};
use std::path::PathBuf; use std::path::PathBuf;
use std::rc::Rc; use std::rc::Rc;
@ -524,6 +525,7 @@ unsafe_no_jsmanaged_fields!(ActiveUniformBlockInfo);
unsafe_no_jsmanaged_fields!(bool, f32, f64, String, AtomicBool, AtomicUsize, Uuid, char); unsafe_no_jsmanaged_fields!(bool, f32, f64, String, AtomicBool, AtomicUsize, Uuid, char);
unsafe_no_jsmanaged_fields!(usize, u8, u16, u32, u64); unsafe_no_jsmanaged_fields!(usize, u8, u16, u32, u64);
unsafe_no_jsmanaged_fields!(isize, i8, i16, i32, i64); unsafe_no_jsmanaged_fields!(isize, i8, i16, i32, i64);
unsafe_no_jsmanaged_fields!(NonZeroU64);
unsafe_no_jsmanaged_fields!(Error); unsafe_no_jsmanaged_fields!(Error);
unsafe_no_jsmanaged_fields!(ServoUrl, ImmutableOrigin, MutableOrigin); unsafe_no_jsmanaged_fields!(ServoUrl, ImmutableOrigin, MutableOrigin);
unsafe_no_jsmanaged_fields!(Image, ImageMetadata, dyn ImageCache, PendingImageId); unsafe_no_jsmanaged_fields!(Image, ImageMetadata, dyn ImageCache, PendingImageId);

View file

@ -127,7 +127,7 @@ use std::sync::Arc;
use std::thread::JoinHandle; use std::thread::JoinHandle;
use time::{get_time, Timespec}; use time::{get_time, Timespec};
use uuid::Uuid; use uuid::Uuid;
use webgpu::{identity::WebGPUOpResult, WebGPUDevice}; use webgpu::{identity::WebGPUOpResult, ErrorScopeId, WebGPUDevice};
#[derive(JSTraceable)] #[derive(JSTraceable)]
pub struct AutoCloseWorker { pub struct AutoCloseWorker {
@ -3023,7 +3023,7 @@ impl GlobalScope {
pub fn handle_wgpu_msg( pub fn handle_wgpu_msg(
&self, &self,
device: WebGPUDevice, device: WebGPUDevice,
scope: Option<u64>, scope: Option<ErrorScopeId>,
result: WebGPUOpResult, result: WebGPUOpResult,
) { ) {
self.gpu_devices self.gpu_devices

View file

@ -97,14 +97,17 @@ impl GPUAdapterMethods for GPUAdapter {
if self if self
.channel .channel
.0 .0
.send(WebGPURequest::RequestDevice { .send((
sender, None,
adapter_id: self.adapter, WebGPURequest::RequestDevice {
descriptor: desc, sender,
device_id: id, adapter_id: self.adapter,
pipeline_id, descriptor: desc,
label: descriptor.parent.label.as_ref().map(|s| s.to_string()), device_id: id,
}) pipeline_id,
label: descriptor.parent.label.as_ref().map(|s| s.to_string()),
},
))
.is_err() .is_err()
{ {
promise.reject_error(Error::Operation); promise.reject_error(Error::Operation);

View file

@ -146,15 +146,19 @@ impl GPUBufferMethods for GPUBuffer {
let mut info = self.map_info.borrow_mut(); let mut info = self.map_info.borrow_mut();
let m_info = info.as_mut().unwrap(); let m_info = info.as_mut().unwrap();
let m_range = m_info.mapping_range.clone(); let m_range = m_info.mapping_range.clone();
if let Err(e) = self.channel.0.send(WebGPURequest::UnmapBuffer { if let Err(e) = self.channel.0.send((
buffer_id: self.id().0, self.device.use_current_scope(),
device_id: self.device.id().0, WebGPURequest::UnmapBuffer {
scope_id: self.device.use_current_scope(), buffer_id: self.id().0,
array_buffer: IpcSharedMemory::from_bytes(m_info.mapping.borrow().as_slice()), device_id: self.device.id().0,
is_map_read: m_info.map_mode == Some(GPUMapModeConstants::READ), array_buffer: IpcSharedMemory::from_bytes(
offset: m_range.start, m_info.mapping.borrow().as_slice(),
size: m_range.end - m_range.start, ),
}) { is_map_read: m_info.map_mode == Some(GPUMapModeConstants::READ),
offset: m_range.start,
size: m_range.end - m_range.start,
},
)) {
warn!("Failed to send Buffer unmap ({:?}) ({})", self.buffer.0, e); warn!("Failed to send Buffer unmap ({:?}) ({})", self.buffer.0, e);
} }
// Step 3.3 // Step 3.3
@ -185,7 +189,7 @@ impl GPUBufferMethods for GPUBuffer {
if let Err(e) = self if let Err(e) = self
.channel .channel
.0 .0
.send(WebGPURequest::DestroyBuffer(self.buffer.0)) .send((None, WebGPURequest::DestroyBuffer(self.buffer.0)))
{ {
warn!( warn!(
"Failed to send WebGPURequest::DestroyBuffer({:?}) ({})", "Failed to send WebGPURequest::DestroyBuffer({:?}) ({})",
@ -238,14 +242,16 @@ impl GPUBufferMethods for GPUBuffer {
let map_range = offset..offset + range_size; let map_range = offset..offset + range_size;
let sender = response_async(&promise, self); let sender = response_async(&promise, self);
if let Err(e) = self.channel.0.send(WebGPURequest::BufferMapAsync { if let Err(e) = self.channel.0.send((
sender,
buffer_id: self.buffer.0,
device_id: self.device.id().0,
scope_id, scope_id,
host_map, WebGPURequest::BufferMapAsync {
map_range: map_range.clone(), sender,
}) { buffer_id: self.buffer.0,
device_id: self.device.id().0,
host_map,
map_range: map_range.clone(),
},
)) {
warn!( warn!(
"Failed to send BufferMapAsync ({:?}) ({})", "Failed to send BufferMapAsync ({:?}) ({})",
self.buffer.0, e self.buffer.0, e
@ -360,7 +366,7 @@ impl AsyncWGPUListener for GPUBuffer {
if let Err(e) = self if let Err(e) = self
.channel .channel
.0 .0
.send(WebGPURequest::BufferMapComplete(self.buffer.0)) .send((None, WebGPURequest::BufferMapComplete(self.buffer.0)))
{ {
warn!( warn!(
"Failed to send BufferMapComplete({:?}) ({})", "Failed to send BufferMapComplete({:?}) ({})",

View file

@ -45,7 +45,9 @@ pub struct GPUCanvasContext {
impl GPUCanvasContext { impl GPUCanvasContext {
fn new_inherited(canvas: &HTMLCanvasElement, size: Size2D<u32>, channel: WebGPU) -> Self { fn new_inherited(canvas: &HTMLCanvasElement, size: Size2D<u32>, channel: WebGPU) -> Self {
let (sender, receiver) = ipc::channel().unwrap(); let (sender, receiver) = ipc::channel().unwrap();
let _ = channel.0.send(WebGPURequest::CreateContext(sender)); if let Err(e) = channel.0.send((None, WebGPURequest::CreateContext(sender))) {
warn!("Failed to send CreateContext ({:?})", e);
}
let external_id = receiver.recv().unwrap(); let external_id = receiver.recv().unwrap();
Self { Self {
reflector_: Reflector::new(), reflector_: Reflector::new(),
@ -88,11 +90,14 @@ impl GPUCanvasContext {
.wgpu_id_hub() .wgpu_id_hub()
.lock() .lock()
.create_command_encoder_id(texture_id.backend()); .create_command_encoder_id(texture_id.backend());
if let Err(e) = self.channel.0.send(WebGPURequest::SwapChainPresent { if let Err(e) = self.channel.0.send((
external_id: self.context_id.0, None,
texture_id, WebGPURequest::SwapChainPresent {
encoder_id, external_id: self.context_id.0,
}) { texture_id,
encoder_id,
},
)) {
warn!( warn!(
"Failed to send UpdateWebrenderData({:?}) ({})", "Failed to send UpdateWebrenderData({:?}) ({})",
self.context_id, e self.context_id, e
@ -168,14 +173,17 @@ impl GPUCanvasContextMethods for GPUCanvasContext {
self.channel self.channel
.0 .0
.send(WebGPURequest::CreateSwapChain { .send((
device_id: descriptor.device.id().0, None,
buffer_ids, WebGPURequest::CreateSwapChain {
external_id: self.context_id.0, device_id: descriptor.device.id().0,
sender, buffer_ids,
image_desc, external_id: self.context_id.0,
image_data, sender,
}) image_desc,
image_data,
},
))
.expect("Failed to create WebGPU SwapChain"); .expect("Failed to create WebGPU SwapChain");
let usage = if descriptor.usage % 2 == 0 { let usage = if descriptor.usage % 2 == 0 {

View file

@ -277,16 +277,18 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
.insert(DomRoot::from_ref(destination)); .insert(DomRoot::from_ref(destination));
self.channel self.channel
.0 .0
.send(WebGPURequest::CopyBufferToBuffer { .send((
command_encoder_id: self.encoder.0,
device_id: self.device.id().0,
scope_id, scope_id,
source_id: source.id().0, WebGPURequest::CopyBufferToBuffer {
source_offset, command_encoder_id: self.encoder.0,
destination_id: destination.id().0, device_id: self.device.id().0,
destination_offset, source_id: source.id().0,
size, source_offset,
}) destination_id: destination.id().0,
destination_offset,
size,
},
))
.expect("Failed to send CopyBufferToBuffer"); .expect("Failed to send CopyBufferToBuffer");
} }
@ -317,14 +319,18 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
self.channel self.channel
.0 .0
.send(WebGPURequest::CopyBufferToTexture { .send((
command_encoder_id: self.encoder.0,
device_id: self.device.id().0,
scope_id, scope_id,
source: convert_buffer_cv(source), WebGPURequest::CopyBufferToTexture {
destination: convert_texture_cv(destination), command_encoder_id: self.encoder.0,
copy_size: convert_texture_size_to_wgt(&convert_texture_size_to_dict(&copy_size)), device_id: self.device.id().0,
}) source: convert_buffer_cv(source),
destination: convert_texture_cv(destination),
copy_size: convert_texture_size_to_wgt(&convert_texture_size_to_dict(
&copy_size,
)),
},
))
.expect("Failed to send CopyBufferToTexture"); .expect("Failed to send CopyBufferToTexture");
} }
@ -355,14 +361,18 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
self.channel self.channel
.0 .0
.send(WebGPURequest::CopyTextureToBuffer { .send((
command_encoder_id: self.encoder.0,
device_id: self.device.id().0,
scope_id, scope_id,
source: convert_texture_cv(source), WebGPURequest::CopyTextureToBuffer {
destination: convert_buffer_cv(destination), command_encoder_id: self.encoder.0,
copy_size: convert_texture_size_to_wgt(&convert_texture_size_to_dict(&copy_size)), device_id: self.device.id().0,
}) source: convert_texture_cv(source),
destination: convert_buffer_cv(destination),
copy_size: convert_texture_size_to_wgt(&convert_texture_size_to_dict(
&copy_size,
)),
},
))
.expect("Failed to send CopyTextureToBuffer"); .expect("Failed to send CopyTextureToBuffer");
} }
@ -389,14 +399,18 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
self.channel self.channel
.0 .0
.send(WebGPURequest::CopyTextureToTexture { .send((
command_encoder_id: self.encoder.0,
device_id: self.device.id().0,
scope_id, scope_id,
source: convert_texture_cv(source), WebGPURequest::CopyTextureToTexture {
destination: convert_texture_cv(destination), command_encoder_id: self.encoder.0,
copy_size: convert_texture_size_to_wgt(&convert_texture_size_to_dict(&copy_size)), device_id: self.device.id().0,
}) source: convert_texture_cv(source),
destination: convert_texture_cv(destination),
copy_size: convert_texture_size_to_wgt(&convert_texture_size_to_dict(
&copy_size,
)),
},
))
.expect("Failed to send CopyTextureToTexture"); .expect("Failed to send CopyTextureToTexture");
} }
@ -404,13 +418,15 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
fn Finish(&self, descriptor: &GPUCommandBufferDescriptor) -> DomRoot<GPUCommandBuffer> { fn Finish(&self, descriptor: &GPUCommandBufferDescriptor) -> DomRoot<GPUCommandBuffer> {
self.channel self.channel
.0 .0
.send(WebGPURequest::CommandEncoderFinish { .send((
command_encoder_id: self.encoder.0, self.device.use_current_scope(),
device_id: self.device.id().0, WebGPURequest::CommandEncoderFinish {
scope_id: self.device.use_current_scope(), command_encoder_id: self.encoder.0,
// TODO(zakorgy): We should use `_descriptor` here after it's not empty device_id: self.device.id().0,
// and the underlying wgpu-core struct is serializable // TODO(zakorgy): We should use `_descriptor` here after it's not empty
}) // and the underlying wgpu-core struct is serializable
},
))
.expect("Failed to send Finish"); .expect("Failed to send Finish");
*self.state.borrow_mut() = GPUCommandEncoderState::Closed; *self.state.borrow_mut() = GPUCommandEncoderState::Closed;

View file

@ -91,12 +91,14 @@ impl GPUComputePassEncoderMethods for GPUComputePassEncoder {
if let Some(compute_pass) = self.compute_pass.borrow_mut().take() { if let Some(compute_pass) = self.compute_pass.borrow_mut().take() {
self.channel self.channel
.0 .0
.send(WebGPURequest::RunComputePass { .send((
command_encoder_id: self.command_encoder.id().0, self.command_encoder.device().use_current_scope(),
device_id: self.command_encoder.device().id().0, WebGPURequest::RunComputePass {
scope_id: self.command_encoder.device().use_current_scope(), command_encoder_id: self.command_encoder.id().0,
compute_pass, device_id: self.command_encoder.device().id().0,
}) compute_pass,
},
))
.expect("Failed to send RunComputePass"); .expect("Failed to send RunComputePass");
self.command_encoder.set_state( self.command_encoder.set_state(

View file

@ -71,9 +71,7 @@ use std::rc::Rc;
use webgpu::wgpu::{ use webgpu::wgpu::{
binding_model as wgpu_bind, command::RenderBundleEncoder, pipeline as wgpu_pipe, binding_model as wgpu_bind, command::RenderBundleEncoder, pipeline as wgpu_pipe,
}; };
use webgpu::{self, identity::WebGPUOpResult, wgt, WebGPU, WebGPURequest}; use webgpu::{self, identity::WebGPUOpResult, wgt, ErrorScopeId, WebGPU, WebGPURequest};
type ErrorScopeId = u64;
#[derive(JSTraceable, MallocSizeOf)] #[derive(JSTraceable, MallocSizeOf)]
struct ErrorScopeInfo { struct ErrorScopeInfo {
@ -131,7 +129,7 @@ impl GPUDevice {
scope_context: DomRefCell::new(ScopeContext { scope_context: DomRefCell::new(ScopeContext {
error_scopes: HashMap::new(), error_scopes: HashMap::new(),
scope_stack: Vec::new(), scope_stack: Vec::new(),
next_scope_id: 0, next_scope_id: ErrorScopeId::new(1).unwrap(),
}), }),
lost_promise: DomRefCell::new(None), lost_promise: DomRefCell::new(None),
} }
@ -313,12 +311,14 @@ impl GPUDeviceMethods for GPUDevice {
let scope_id = self.use_current_scope(); let scope_id = self.use_current_scope();
self.channel self.channel
.0 .0
.send(WebGPURequest::CreateBuffer { .send((
device_id: self.device.0,
scope_id, scope_id,
buffer_id: id, WebGPURequest::CreateBuffer {
descriptor: wgpu_descriptor, device_id: self.device.0,
}) buffer_id: id,
descriptor: wgpu_descriptor,
},
))
.expect("Failed to create WebGPU buffer"); .expect("Failed to create WebGPU buffer");
let buffer = webgpu::WebGPUBuffer(id); let buffer = webgpu::WebGPUBuffer(id);
@ -451,12 +451,14 @@ impl GPUDeviceMethods for GPUDevice {
.create_bind_group_layout_id(self.device.0.backend()); .create_bind_group_layout_id(self.device.0.backend());
self.channel self.channel
.0 .0
.send(WebGPURequest::CreateBindGroupLayout { .send((
device_id: self.device.0,
bind_group_layout_id,
scope_id, scope_id,
descriptor: desc, WebGPURequest::CreateBindGroupLayout {
}) device_id: self.device.0,
bind_group_layout_id,
descriptor: desc,
},
))
.expect("Failed to create WebGPU BindGroupLayout"); .expect("Failed to create WebGPU BindGroupLayout");
let bgl = webgpu::WebGPUBindGroupLayout(bind_group_layout_id); let bgl = webgpu::WebGPUBindGroupLayout(bind_group_layout_id);
@ -493,12 +495,14 @@ impl GPUDeviceMethods for GPUDevice {
.create_pipeline_layout_id(self.device.0.backend()); .create_pipeline_layout_id(self.device.0.backend());
self.channel self.channel
.0 .0
.send(WebGPURequest::CreatePipelineLayout { .send((
device_id: self.device.0,
pipeline_layout_id,
descriptor: desc,
scope_id, scope_id,
}) WebGPURequest::CreatePipelineLayout {
device_id: self.device.0,
pipeline_layout_id,
descriptor: desc,
},
))
.expect("Failed to create WebGPU PipelineLayout"); .expect("Failed to create WebGPU PipelineLayout");
let pipeline_layout = webgpu::WebGPUPipelineLayout(pipeline_layout_id); let pipeline_layout = webgpu::WebGPUPipelineLayout(pipeline_layout_id);
@ -553,12 +557,14 @@ impl GPUDeviceMethods for GPUDevice {
.create_bind_group_id(self.device.0.backend()); .create_bind_group_id(self.device.0.backend());
self.channel self.channel
.0 .0
.send(WebGPURequest::CreateBindGroup { .send((
device_id: self.device.0,
bind_group_id,
descriptor: desc,
scope_id, scope_id,
}) WebGPURequest::CreateBindGroup {
device_id: self.device.0,
bind_group_id,
descriptor: desc,
},
))
.expect("Failed to create WebGPU BindGroup"); .expect("Failed to create WebGPU BindGroup");
let bind_group = webgpu::WebGPUBindGroup(bind_group_id); let bind_group = webgpu::WebGPUBindGroup(bind_group_id);
@ -592,12 +598,14 @@ impl GPUDeviceMethods for GPUDevice {
let scope_id = self.use_current_scope(); let scope_id = self.use_current_scope();
self.channel self.channel
.0 .0
.send(WebGPURequest::CreateShaderModule { .send((
device_id: self.device.0,
scope_id, scope_id,
program_id, WebGPURequest::CreateShaderModule {
program, device_id: self.device.0,
}) program_id,
program,
},
))
.expect("Failed to create WebGPU ShaderModule"); .expect("Failed to create WebGPU ShaderModule");
let shader_module = webgpu::WebGPUShaderModule(program_id); let shader_module = webgpu::WebGPUShaderModule(program_id);
@ -631,12 +639,14 @@ impl GPUDeviceMethods for GPUDevice {
self.channel self.channel
.0 .0
.send(WebGPURequest::CreateComputePipeline { .send((
device_id: self.device.0,
scope_id, scope_id,
compute_pipeline_id, WebGPURequest::CreateComputePipeline {
descriptor: desc, device_id: self.device.0,
}) compute_pipeline_id,
descriptor: desc,
},
))
.expect("Failed to create WebGPU ComputePipeline"); .expect("Failed to create WebGPU ComputePipeline");
let compute_pipeline = webgpu::WebGPUComputePipeline(compute_pipeline_id); let compute_pipeline = webgpu::WebGPUComputePipeline(compute_pipeline_id);
@ -660,12 +670,14 @@ impl GPUDeviceMethods for GPUDevice {
let scope_id = self.use_current_scope(); let scope_id = self.use_current_scope();
self.channel self.channel
.0 .0
.send(WebGPURequest::CreateCommandEncoder { .send((
device_id: self.device.0,
scope_id, scope_id,
command_encoder_id, WebGPURequest::CreateCommandEncoder {
label: descriptor.parent.label.as_ref().map(|s| s.to_string()), device_id: self.device.0,
}) command_encoder_id,
label: descriptor.parent.label.as_ref().map(|s| s.to_string()),
},
))
.expect("Failed to create WebGPU command encoder"); .expect("Failed to create WebGPU command encoder");
let encoder = webgpu::WebGPUCommandEncoder(command_encoder_id); let encoder = webgpu::WebGPUCommandEncoder(command_encoder_id);
@ -710,12 +722,14 @@ impl GPUDeviceMethods for GPUDevice {
self.channel self.channel
.0 .0
.send(WebGPURequest::CreateTexture { .send((
device_id: self.device.0,
texture_id,
descriptor: desc,
scope_id, scope_id,
}) WebGPURequest::CreateTexture {
device_id: self.device.0,
texture_id,
descriptor: desc,
},
))
.expect("Failed to create WebGPU Texture"); .expect("Failed to create WebGPU Texture");
let texture = webgpu::WebGPUTexture(texture_id); let texture = webgpu::WebGPUTexture(texture_id);
@ -761,12 +775,14 @@ impl GPUDeviceMethods for GPUDevice {
let scope_id = self.use_current_scope(); let scope_id = self.use_current_scope();
self.channel self.channel
.0 .0
.send(WebGPURequest::CreateSampler { .send((
device_id: self.device.0,
scope_id, scope_id,
sampler_id, WebGPURequest::CreateSampler {
descriptor: desc, device_id: self.device.0,
}) sampler_id,
descriptor: desc,
},
))
.expect("Failed to create WebGPU sampler"); .expect("Failed to create WebGPU sampler");
let sampler = webgpu::WebGPUSampler(sampler_id); let sampler = webgpu::WebGPUSampler(sampler_id);
@ -903,12 +919,14 @@ impl GPUDeviceMethods for GPUDevice {
self.channel self.channel
.0 .0
.send(WebGPURequest::CreateRenderPipeline { .send((
device_id: self.device.0,
render_pipeline_id,
scope_id, scope_id,
descriptor: desc, WebGPURequest::CreateRenderPipeline {
}) device_id: self.device.0,
render_pipeline_id,
descriptor: desc,
},
))
.expect("Failed to create WebGPU render pipeline"); .expect("Failed to create WebGPU render pipeline");
let render_pipeline = webgpu::WebGPURenderPipeline(render_pipeline_id); let render_pipeline = webgpu::WebGPURenderPipeline(render_pipeline_id);
@ -961,7 +979,7 @@ impl GPUDeviceMethods for GPUDevice {
fn PushErrorScope(&self, filter: GPUErrorFilter) { fn PushErrorScope(&self, filter: GPUErrorFilter) {
let mut context = self.scope_context.borrow_mut(); let mut context = self.scope_context.borrow_mut();
let scope_id = context.next_scope_id; let scope_id = context.next_scope_id;
context.next_scope_id += 1; context.next_scope_id = ErrorScopeId::new(scope_id.get() + 1).unwrap();
let err_scope = ErrorScopeInfo { let err_scope = ErrorScopeInfo {
op_count: 0, op_count: 0,
error: None, error: None,

View file

@ -88,11 +88,13 @@ impl GPUQueueMethods for GPUQueue {
let command_buffers = command_buffers.iter().map(|cb| cb.id().0).collect(); let command_buffers = command_buffers.iter().map(|cb| cb.id().0).collect();
self.channel self.channel
.0 .0
.send(WebGPURequest::Submit { .send((
queue_id: self.queue.0,
scope_id, scope_id,
command_buffers, WebGPURequest::Submit {
}) queue_id: self.queue.0,
command_buffers,
},
))
.unwrap(); .unwrap();
} }
@ -124,13 +126,15 @@ impl GPUQueueMethods for GPUQueue {
let final_data = IpcSharedMemory::from_bytes( let final_data = IpcSharedMemory::from_bytes(
&bytes[data_offset as usize..(data_offset + content_size) as usize], &bytes[data_offset as usize..(data_offset + content_size) as usize],
); );
if let Err(e) = self.channel.0.send(WebGPURequest::WriteBuffer { if let Err(e) = self.channel.0.send((
queue_id: self.queue.0, self.device.borrow().as_ref().unwrap().use_current_scope(),
scope_id: self.device.borrow().as_ref().unwrap().use_current_scope(), WebGPURequest::WriteBuffer {
buffer_id: buffer.id().0, queue_id: self.queue.0,
buffer_offset, buffer_id: buffer.id().0,
data: final_data, buffer_offset,
}) { data: final_data,
},
)) {
warn!("Failed to send WriteBuffer({:?}) ({})", buffer.id(), e); warn!("Failed to send WriteBuffer({:?}) ({})", buffer.id(), e);
return Err(Error::Operation); return Err(Error::Operation);
} }
@ -158,14 +162,16 @@ impl GPUQueueMethods for GPUQueue {
let write_size = convert_texture_size_to_wgt(&convert_texture_size_to_dict(&size)); let write_size = convert_texture_size_to_wgt(&convert_texture_size_to_dict(&size));
let final_data = IpcSharedMemory::from_bytes(&bytes); let final_data = IpcSharedMemory::from_bytes(&bytes);
if let Err(e) = self.channel.0.send(WebGPURequest::WriteTexture { if let Err(e) = self.channel.0.send((
queue_id: self.queue.0, self.device.borrow().as_ref().unwrap().use_current_scope(),
scope_id: self.device.borrow().as_ref().unwrap().use_current_scope(), WebGPURequest::WriteTexture {
texture_cv, queue_id: self.queue.0,
data_layout: texture_layout, texture_cv,
size: write_size, data_layout: texture_layout,
data: final_data, size: write_size,
}) { data: final_data,
},
)) {
warn!( warn!(
"Failed to send WriteTexture({:?}) ({})", "Failed to send WriteTexture({:?}) ({})",
destination.texture.id().0, destination.texture.id().0,

View file

@ -195,13 +195,15 @@ impl GPURenderBundleEncoderMethods for GPURenderBundleEncoder {
self.channel self.channel
.0 .0
.send(WebGPURequest::RenderBundleEncoderFinish { .send((
render_bundle_encoder: encoder, self.device.use_current_scope(),
descriptor: desc, WebGPURequest::RenderBundleEncoderFinish {
render_bundle_id, render_bundle_encoder: encoder,
device_id: self.device.id().0, descriptor: desc,
scope_id: self.device.use_current_scope(), render_bundle_id,
}) device_id: self.device.id().0,
},
))
.expect("Failed to send RenderBundleEncoderFinish"); .expect("Failed to send RenderBundleEncoderFinish");
let render_bundle = WebGPURenderBundle(render_bundle_id); let render_bundle = WebGPURenderBundle(render_bundle_id);

View file

@ -163,12 +163,14 @@ impl GPURenderPassEncoderMethods for GPURenderPassEncoder {
if let Some(render_pass) = self.render_pass.borrow_mut().take() { if let Some(render_pass) = self.render_pass.borrow_mut().take() {
self.channel self.channel
.0 .0
.send(WebGPURequest::RunRenderPass { .send((
command_encoder_id: self.command_encoder.id().0, self.command_encoder.device().use_current_scope(),
device_id: self.command_encoder.device().id().0, WebGPURequest::RunRenderPass {
scope_id: self.command_encoder.device().use_current_scope(), command_encoder_id: self.command_encoder.id().0,
render_pass, device_id: self.command_encoder.device().id().0,
}) render_pass,
},
))
.expect("Failed to send RunRenderPass"); .expect("Failed to send RunRenderPass");
self.command_encoder.set_state( self.command_encoder.set_state(

View file

@ -57,10 +57,13 @@ impl GPUSwapChain {
impl GPUSwapChain { impl GPUSwapChain {
pub fn destroy(&self, external_id: u64, image_key: webrender_api::ImageKey) { pub fn destroy(&self, external_id: u64, image_key: webrender_api::ImageKey) {
if let Err(e) = self.channel.0.send(WebGPURequest::DestroySwapChain { if let Err(e) = self.channel.0.send((
external_id, None,
image_key, WebGPURequest::DestroySwapChain {
}) { external_id,
image_key,
},
)) {
warn!( warn!(
"Failed to send DestroySwapChain-ImageKey({:?}) ({})", "Failed to send DestroySwapChain-ImageKey({:?}) ({})",
image_key, e image_key, e

View file

@ -167,13 +167,15 @@ impl GPUTextureMethods for GPUTexture {
self.channel self.channel
.0 .0
.send(WebGPURequest::CreateTextureView { .send((
texture_id: self.texture.0,
texture_view_id,
device_id: self.device.id().0,
descriptor: desc,
scope_id, scope_id,
}) WebGPURequest::CreateTextureView {
texture_id: self.texture.0,
texture_view_id,
device_id: self.device.id().0,
descriptor: desc,
},
))
.expect("Failed to create WebGPU texture view"); .expect("Failed to create WebGPU texture view");
let texture_view = WebGPUTextureView(texture_view_id); let texture_view = WebGPUTextureView(texture_view_id);
@ -191,7 +193,7 @@ impl GPUTextureMethods for GPUTexture {
if let Err(e) = self if let Err(e) = self
.channel .channel
.0 .0
.send(WebGPURequest::DestroyTexture(self.texture.0)) .send((None, WebGPURequest::DestroyTexture(self.texture.0)))
{ {
warn!( warn!(
"Failed to send WebGPURequest::DestroyTexture({:?}) ({})", "Failed to send WebGPURequest::DestroyTexture({:?}) ({})",

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::{WebGPUDevice, WebGPURequest}; use crate::{ErrorScopeId, WebGPUDevice, WebGPURequest};
use ipc_channel::ipc::IpcSender; use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::PipelineId; use msg::constellation_msg::PipelineId;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -43,7 +43,7 @@ pub enum WebGPUMsg {
FreeRenderBundle(RenderBundleId), FreeRenderBundle(RenderBundleId),
WebGPUOpResult { WebGPUOpResult {
device: WebGPUDevice, device: WebGPUDevice,
scope_id: Option<u64>, scope_id: Option<ErrorScopeId>,
pipeline_id: PipelineId, pipeline_id: PipelineId,
result: WebGPUOpResult, result: WebGPUOpResult,
}, },
@ -57,12 +57,12 @@ pub enum WebGPUMsg {
#[derive(Debug)] #[derive(Debug)]
pub struct IdentityRecycler { pub struct IdentityRecycler {
sender: IpcSender<WebGPUMsg>, sender: IpcSender<WebGPUMsg>,
self_sender: IpcSender<WebGPURequest>, self_sender: IpcSender<(Option<ErrorScopeId>, WebGPURequest)>,
} }
pub struct IdentityRecyclerFactory { pub struct IdentityRecyclerFactory {
pub sender: IpcSender<WebGPUMsg>, pub sender: IpcSender<WebGPUMsg>,
pub self_sender: IpcSender<WebGPURequest>, pub self_sender: IpcSender<(Option<ErrorScopeId>, WebGPURequest)>,
} }
macro_rules! impl_identity_handler { macro_rules! impl_identity_handler {
@ -130,12 +130,14 @@ impl IdentityHandler<DeviceId> for IdentityRecycler {
} }
fn free(&self, id: DeviceId) { fn free(&self, id: DeviceId) {
log::debug!("free device {:?}", id); log::debug!("free device {:?}", id);
let msg = WebGPUMsg::FreeDevice(id); if self.sender.send(WebGPUMsg::FreeDevice(id)).is_err() {
if self.sender.send(msg).is_err() {
log::error!("Failed to send FreeDevice({:?}) to script", id); log::error!("Failed to send FreeDevice({:?}) to script", id);
} }
let msg_to_self = WebGPURequest::FreeDevice(id); if self
if self.self_sender.send(msg_to_self).is_err() { .self_sender
.send((None, WebGPURequest::FreeDevice(id)))
.is_err()
{
log::error!("Failed to send FreeDevice({:?}) to server", id); log::error!("Failed to send FreeDevice({:?}) to server", id);
} }
} }

View file

@ -22,6 +22,7 @@ use smallvec::SmallVec;
use std::borrow::Cow; use std::borrow::Cow;
use std::collections::HashMap; use std::collections::HashMap;
use std::ffi::CString; use std::ffi::CString;
use std::num::NonZeroU64;
use std::ptr; use std::ptr;
use std::rc::Rc; use std::rc::Rc;
use std::slice; use std::slice;
@ -41,6 +42,7 @@ use wgpu::{
resource::{BufferMapAsyncStatus, BufferMapOperation}, resource::{BufferMapAsyncStatus, BufferMapOperation},
}; };
pub type ErrorScopeId = NonZeroU64;
const DEVICE_POLL_INTERVAL: u64 = 100; const DEVICE_POLL_INTERVAL: u64 = 100;
pub const PRESENTATION_BUFFER_COUNT: usize = 10; pub const PRESENTATION_BUFFER_COUNT: usize = 10;
@ -68,7 +70,6 @@ pub enum WebGPURequest {
sender: IpcSender<WebGPUResponseResult>, sender: IpcSender<WebGPUResponseResult>,
buffer_id: id::BufferId, buffer_id: id::BufferId,
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
host_map: HostMap, host_map: HostMap,
map_range: std::ops::Range<u64>, map_range: std::ops::Range<u64>,
}, },
@ -76,14 +77,12 @@ pub enum WebGPURequest {
CommandEncoderFinish { CommandEncoderFinish {
command_encoder_id: id::CommandEncoderId, command_encoder_id: id::CommandEncoderId,
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
// TODO(zakorgy): Serialize CommandBufferDescriptor in wgpu-core // TODO(zakorgy): Serialize CommandBufferDescriptor in wgpu-core
// wgpu::command::CommandBufferDescriptor, // wgpu::command::CommandBufferDescriptor,
}, },
CopyBufferToBuffer { CopyBufferToBuffer {
command_encoder_id: id::CommandEncoderId, command_encoder_id: id::CommandEncoderId,
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
source_id: id::BufferId, source_id: id::BufferId,
source_offset: wgt::BufferAddress, source_offset: wgt::BufferAddress,
destination_id: id::BufferId, destination_id: id::BufferId,
@ -93,7 +92,6 @@ pub enum WebGPURequest {
CopyBufferToTexture { CopyBufferToTexture {
command_encoder_id: id::CommandEncoderId, command_encoder_id: id::CommandEncoderId,
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
source: BufferCopyView, source: BufferCopyView,
destination: TextureCopyView, destination: TextureCopyView,
copy_size: wgt::Extent3d, copy_size: wgt::Extent3d,
@ -101,7 +99,6 @@ pub enum WebGPURequest {
CopyTextureToBuffer { CopyTextureToBuffer {
command_encoder_id: id::CommandEncoderId, command_encoder_id: id::CommandEncoderId,
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
source: TextureCopyView, source: TextureCopyView,
destination: BufferCopyView, destination: BufferCopyView,
copy_size: wgt::Extent3d, copy_size: wgt::Extent3d,
@ -109,33 +106,27 @@ pub enum WebGPURequest {
CopyTextureToTexture { CopyTextureToTexture {
command_encoder_id: id::CommandEncoderId, command_encoder_id: id::CommandEncoderId,
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
source: TextureCopyView, source: TextureCopyView,
destination: TextureCopyView, destination: TextureCopyView,
copy_size: wgt::Extent3d, copy_size: wgt::Extent3d,
}, },
CreateBindGroup { CreateBindGroup {
device_id: id::DeviceId, device_id: id::DeviceId,
// TODO: Consider using NonZeroU64 to reduce enum size
scope_id: Option<u64>,
bind_group_id: id::BindGroupId, bind_group_id: id::BindGroupId,
descriptor: BindGroupDescriptor<'static>, descriptor: BindGroupDescriptor<'static>,
}, },
CreateBindGroupLayout { CreateBindGroupLayout {
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
bind_group_layout_id: id::BindGroupLayoutId, bind_group_layout_id: id::BindGroupLayoutId,
descriptor: wgt::BindGroupLayoutDescriptor<'static>, descriptor: wgt::BindGroupLayoutDescriptor<'static>,
}, },
CreateBuffer { CreateBuffer {
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
buffer_id: id::BufferId, buffer_id: id::BufferId,
descriptor: wgt::BufferDescriptor<Option<String>>, descriptor: wgt::BufferDescriptor<Option<String>>,
}, },
CreateCommandEncoder { CreateCommandEncoder {
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
// TODO(zakorgy): Serialize CommandEncoderDescriptor in wgpu-core // TODO(zakorgy): Serialize CommandEncoderDescriptor in wgpu-core
// wgpu::command::CommandEncoderDescriptor, // wgpu::command::CommandEncoderDescriptor,
command_encoder_id: id::CommandEncoderId, command_encoder_id: id::CommandEncoderId,
@ -143,32 +134,27 @@ pub enum WebGPURequest {
}, },
CreateComputePipeline { CreateComputePipeline {
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
compute_pipeline_id: id::ComputePipelineId, compute_pipeline_id: id::ComputePipelineId,
descriptor: ComputePipelineDescriptor<'static>, descriptor: ComputePipelineDescriptor<'static>,
}, },
CreateContext(IpcSender<webrender_api::ExternalImageId>), CreateContext(IpcSender<webrender_api::ExternalImageId>),
CreatePipelineLayout { CreatePipelineLayout {
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
pipeline_layout_id: id::PipelineLayoutId, pipeline_layout_id: id::PipelineLayoutId,
descriptor: wgt::PipelineLayoutDescriptor<'static, id::BindGroupLayoutId>, descriptor: wgt::PipelineLayoutDescriptor<'static, id::BindGroupLayoutId>,
}, },
CreateRenderPipeline { CreateRenderPipeline {
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
render_pipeline_id: id::RenderPipelineId, render_pipeline_id: id::RenderPipelineId,
descriptor: RenderPipelineDescriptor<'static>, descriptor: RenderPipelineDescriptor<'static>,
}, },
CreateSampler { CreateSampler {
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
sampler_id: id::SamplerId, sampler_id: id::SamplerId,
descriptor: wgt::SamplerDescriptor<Option<String>>, descriptor: wgt::SamplerDescriptor<Option<String>>,
}, },
CreateShaderModule { CreateShaderModule {
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
program_id: id::ShaderModuleId, program_id: id::ShaderModuleId,
program: Vec<u32>, program: Vec<u32>,
}, },
@ -182,7 +168,6 @@ pub enum WebGPURequest {
}, },
CreateTexture { CreateTexture {
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
texture_id: id::TextureId, texture_id: id::TextureId,
descriptor: wgt::TextureDescriptor<Option<String>>, descriptor: wgt::TextureDescriptor<Option<String>>,
}, },
@ -190,7 +175,6 @@ pub enum WebGPURequest {
texture_id: id::TextureId, texture_id: id::TextureId,
texture_view_id: id::TextureViewId, texture_view_id: id::TextureViewId,
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
descriptor: wgt::TextureViewDescriptor<Option<String>>, descriptor: wgt::TextureViewDescriptor<Option<String>>,
}, },
DestroyBuffer(id::BufferId), DestroyBuffer(id::BufferId),
@ -206,7 +190,6 @@ pub enum WebGPURequest {
descriptor: wgt::RenderBundleDescriptor<Option<String>>, descriptor: wgt::RenderBundleDescriptor<Option<String>>,
render_bundle_id: id::RenderBundleId, render_bundle_id: id::RenderBundleId,
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
}, },
RequestAdapter { RequestAdapter {
sender: IpcSender<WebGPUResponseResult>, sender: IpcSender<WebGPUResponseResult>,
@ -224,18 +207,15 @@ pub enum WebGPURequest {
RunComputePass { RunComputePass {
command_encoder_id: id::CommandEncoderId, command_encoder_id: id::CommandEncoderId,
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
compute_pass: ComputePass, compute_pass: ComputePass,
}, },
RunRenderPass { RunRenderPass {
command_encoder_id: id::CommandEncoderId, command_encoder_id: id::CommandEncoderId,
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
render_pass: RenderPass, render_pass: RenderPass,
}, },
Submit { Submit {
queue_id: id::QueueId, queue_id: id::QueueId,
scope_id: Option<u64>,
command_buffers: Vec<id::CommandBufferId>, command_buffers: Vec<id::CommandBufferId>,
}, },
SwapChainPresent { SwapChainPresent {
@ -246,7 +226,6 @@ pub enum WebGPURequest {
UnmapBuffer { UnmapBuffer {
buffer_id: id::BufferId, buffer_id: id::BufferId,
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>,
array_buffer: IpcSharedMemory, array_buffer: IpcSharedMemory,
is_map_read: bool, is_map_read: bool,
offset: u64, offset: u64,
@ -259,14 +238,12 @@ pub enum WebGPURequest {
}, },
WriteBuffer { WriteBuffer {
queue_id: id::QueueId, queue_id: id::QueueId,
scope_id: Option<u64>,
buffer_id: id::BufferId, buffer_id: id::BufferId,
buffer_offset: u64, buffer_offset: u64,
data: IpcSharedMemory, data: IpcSharedMemory,
}, },
WriteTexture { WriteTexture {
queue_id: id::QueueId, queue_id: id::QueueId,
scope_id: Option<u64>,
texture_cv: TextureCopyView, texture_cv: TextureCopyView,
data_layout: wgt::TextureDataLayout, data_layout: wgt::TextureDataLayout,
size: wgt::Extent3d, size: wgt::Extent3d,
@ -283,7 +260,7 @@ struct BufferMapInfo<'a, T> {
} }
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct WebGPU(pub IpcSender<WebGPURequest>); pub struct WebGPU(pub IpcSender<(Option<ErrorScopeId>, WebGPURequest)>);
impl WebGPU { impl WebGPU {
pub fn new( pub fn new(
@ -341,14 +318,14 @@ impl WebGPU {
pub fn exit(&self, sender: IpcSender<()>) -> Result<(), &'static str> { pub fn exit(&self, sender: IpcSender<()>) -> Result<(), &'static str> {
self.0 self.0
.send(WebGPURequest::Exit(sender)) .send((None, WebGPURequest::Exit(sender)))
.map_err(|_| "Failed to send Exit message") .map_err(|_| "Failed to send Exit message")
} }
} }
struct WGPU<'a> { struct WGPU<'a> {
receiver: IpcReceiver<WebGPURequest>, receiver: IpcReceiver<(Option<ErrorScopeId>, WebGPURequest)>,
sender: IpcSender<WebGPURequest>, sender: IpcSender<(Option<ErrorScopeId>, WebGPURequest)>,
script_sender: IpcSender<WebGPUMsg>, script_sender: IpcSender<WebGPUMsg>,
global: wgpu::hub::Global<IdentityRecyclerFactory>, global: wgpu::hub::Global<IdentityRecyclerFactory>,
adapters: Vec<WebGPUAdapter>, adapters: Vec<WebGPUAdapter>,
@ -358,7 +335,8 @@ struct WGPU<'a> {
// Buffers with pending mapping // Buffers with pending mapping
buffer_maps: HashMap<id::BufferId, Rc<BufferMapInfo<'a, WebGPUResponseResult>>>, buffer_maps: HashMap<id::BufferId, Rc<BufferMapInfo<'a, WebGPUResponseResult>>>,
// Presentation Buffers with pending mapping // Presentation Buffers with pending mapping
present_buffer_maps: HashMap<id::BufferId, Rc<BufferMapInfo<'a, WebGPURequest>>>, present_buffer_maps:
HashMap<id::BufferId, Rc<BufferMapInfo<'a, (Option<ErrorScopeId>, WebGPURequest)>>>,
webrender_api: webrender_api::RenderApi, webrender_api: webrender_api::RenderApi,
webrender_document: webrender_api::DocumentId, webrender_document: webrender_api::DocumentId,
external_images: Arc<Mutex<WebrenderExternalImageRegistry>>, external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
@ -368,8 +346,8 @@ struct WGPU<'a> {
impl<'a> WGPU<'a> { impl<'a> WGPU<'a> {
fn new( fn new(
receiver: IpcReceiver<WebGPURequest>, receiver: IpcReceiver<(Option<ErrorScopeId>, WebGPURequest)>,
sender: IpcSender<WebGPURequest>, sender: IpcSender<(Option<ErrorScopeId>, WebGPURequest)>,
script_sender: IpcSender<WebGPUMsg>, script_sender: IpcSender<WebGPUMsg>,
webrender_api_sender: webrender_api::RenderApiSender, webrender_api_sender: webrender_api::RenderApiSender,
webrender_document: webrender_api::DocumentId, webrender_document: webrender_api::DocumentId,
@ -404,13 +382,12 @@ impl<'a> WGPU<'a> {
let _ = self.global.poll_all_devices(false); let _ = self.global.poll_all_devices(false);
self.last_poll = Instant::now(); self.last_poll = Instant::now();
} }
if let Ok(msg) = self.receiver.try_recv() { if let Ok((scope_id, msg)) = self.receiver.try_recv() {
match msg { match msg {
WebGPURequest::BufferMapAsync { WebGPURequest::BufferMapAsync {
sender, sender,
buffer_id, buffer_id,
device_id, device_id,
scope_id,
host_map, host_map,
map_range, map_range,
} => { } => {
@ -473,7 +450,6 @@ impl<'a> WGPU<'a> {
WebGPURequest::CommandEncoderFinish { WebGPURequest::CommandEncoderFinish {
command_encoder_id, command_encoder_id,
device_id, device_id,
scope_id,
} => { } => {
let global = &self.global; let global = &self.global;
let result = gfx_select!(command_encoder_id => global.command_encoder_finish( let result = gfx_select!(command_encoder_id => global.command_encoder_finish(
@ -485,7 +461,6 @@ impl<'a> WGPU<'a> {
WebGPURequest::CopyBufferToBuffer { WebGPURequest::CopyBufferToBuffer {
command_encoder_id, command_encoder_id,
device_id, device_id,
scope_id,
source_id, source_id,
source_offset, source_offset,
destination_id, destination_id,
@ -506,7 +481,6 @@ impl<'a> WGPU<'a> {
WebGPURequest::CopyBufferToTexture { WebGPURequest::CopyBufferToTexture {
command_encoder_id, command_encoder_id,
device_id, device_id,
scope_id,
source, source,
destination, destination,
copy_size, copy_size,
@ -523,7 +497,6 @@ impl<'a> WGPU<'a> {
WebGPURequest::CopyTextureToBuffer { WebGPURequest::CopyTextureToBuffer {
command_encoder_id, command_encoder_id,
device_id, device_id,
scope_id,
source, source,
destination, destination,
copy_size, copy_size,
@ -540,7 +513,6 @@ impl<'a> WGPU<'a> {
WebGPURequest::CopyTextureToTexture { WebGPURequest::CopyTextureToTexture {
command_encoder_id, command_encoder_id,
device_id, device_id,
scope_id,
source, source,
destination, destination,
copy_size, copy_size,
@ -556,7 +528,6 @@ impl<'a> WGPU<'a> {
}, },
WebGPURequest::CreateBindGroup { WebGPURequest::CreateBindGroup {
device_id, device_id,
scope_id,
bind_group_id, bind_group_id,
descriptor, descriptor,
} => { } => {
@ -567,7 +538,6 @@ impl<'a> WGPU<'a> {
}, },
WebGPURequest::CreateBindGroupLayout { WebGPURequest::CreateBindGroupLayout {
device_id, device_id,
scope_id,
bind_group_layout_id, bind_group_layout_id,
descriptor, descriptor,
} => { } => {
@ -578,7 +548,6 @@ impl<'a> WGPU<'a> {
}, },
WebGPURequest::CreateBuffer { WebGPURequest::CreateBuffer {
device_id, device_id,
scope_id,
buffer_id, buffer_id,
descriptor, descriptor,
} => { } => {
@ -597,7 +566,6 @@ impl<'a> WGPU<'a> {
}, },
WebGPURequest::CreateCommandEncoder { WebGPURequest::CreateCommandEncoder {
device_id, device_id,
scope_id,
command_encoder_id, command_encoder_id,
label, label,
} => { } => {
@ -617,7 +585,6 @@ impl<'a> WGPU<'a> {
}, },
WebGPURequest::CreateComputePipeline { WebGPURequest::CreateComputePipeline {
device_id, device_id,
scope_id,
compute_pipeline_id, compute_pipeline_id,
descriptor, descriptor,
} => { } => {
@ -638,7 +605,6 @@ impl<'a> WGPU<'a> {
}, },
WebGPURequest::CreatePipelineLayout { WebGPURequest::CreatePipelineLayout {
device_id, device_id,
scope_id,
pipeline_layout_id, pipeline_layout_id,
descriptor, descriptor,
} => { } => {
@ -650,7 +616,6 @@ impl<'a> WGPU<'a> {
//TODO: consider https://github.com/gfx-rs/wgpu/issues/684 //TODO: consider https://github.com/gfx-rs/wgpu/issues/684
WebGPURequest::CreateRenderPipeline { WebGPURequest::CreateRenderPipeline {
device_id, device_id,
scope_id,
render_pipeline_id, render_pipeline_id,
descriptor, descriptor,
} => { } => {
@ -661,7 +626,6 @@ impl<'a> WGPU<'a> {
}, },
WebGPURequest::CreateSampler { WebGPURequest::CreateSampler {
device_id, device_id,
scope_id,
sampler_id, sampler_id,
descriptor, descriptor,
} => { } => {
@ -683,7 +647,6 @@ impl<'a> WGPU<'a> {
}, },
WebGPURequest::CreateShaderModule { WebGPURequest::CreateShaderModule {
device_id, device_id,
scope_id,
program_id, program_id,
program, program,
} => { } => {
@ -738,7 +701,6 @@ impl<'a> WGPU<'a> {
}, },
WebGPURequest::CreateTexture { WebGPURequest::CreateTexture {
device_id, device_id,
scope_id,
texture_id, texture_id,
descriptor, descriptor,
} => { } => {
@ -762,7 +724,6 @@ impl<'a> WGPU<'a> {
texture_id, texture_id,
texture_view_id, texture_view_id,
device_id, device_id,
scope_id,
descriptor, descriptor,
} => { } => {
let global = &self.global; let global = &self.global;
@ -840,7 +801,6 @@ impl<'a> WGPU<'a> {
descriptor, descriptor,
render_bundle_id, render_bundle_id,
device_id, device_id,
scope_id,
} => { } => {
let global = &self.global; let global = &self.global;
let st; let st;
@ -941,7 +901,6 @@ impl<'a> WGPU<'a> {
WebGPURequest::RunComputePass { WebGPURequest::RunComputePass {
command_encoder_id, command_encoder_id,
device_id, device_id,
scope_id,
compute_pass, compute_pass,
} => { } => {
let global = &self.global; let global = &self.global;
@ -954,7 +913,6 @@ impl<'a> WGPU<'a> {
WebGPURequest::RunRenderPass { WebGPURequest::RunRenderPass {
command_encoder_id, command_encoder_id,
device_id, device_id,
scope_id,
render_pass, render_pass,
} => { } => {
let global = &self.global; let global = &self.global;
@ -966,7 +924,6 @@ impl<'a> WGPU<'a> {
}, },
WebGPURequest::Submit { WebGPURequest::Submit {
queue_id, queue_id,
scope_id,
command_buffers, command_buffers,
} => { } => {
let global = &self.global; let global = &self.global;
@ -1111,7 +1068,6 @@ impl<'a> WGPU<'a> {
WebGPURequest::UnmapBuffer { WebGPURequest::UnmapBuffer {
buffer_id, buffer_id,
device_id, device_id,
scope_id,
array_buffer, array_buffer,
is_map_read, is_map_read,
offset, offset,
@ -1166,7 +1122,6 @@ impl<'a> WGPU<'a> {
}, },
WebGPURequest::WriteBuffer { WebGPURequest::WriteBuffer {
queue_id, queue_id,
scope_id,
buffer_id, buffer_id,
buffer_offset, buffer_offset,
data, data,
@ -1183,7 +1138,6 @@ impl<'a> WGPU<'a> {
}, },
WebGPURequest::WriteTexture { WebGPURequest::WriteTexture {
queue_id, queue_id,
scope_id,
texture_cv, texture_cv,
data_layout, data_layout,
size, size,
@ -1208,7 +1162,7 @@ impl<'a> WGPU<'a> {
fn send_result<U, T: std::fmt::Debug>( fn send_result<U, T: std::fmt::Debug>(
&self, &self,
device_id: id::DeviceId, device_id: id::DeviceId,
scope_id: Option<u64>, scope_id: Option<ErrorScopeId>,
result: Result<U, T>, result: Result<U, T>,
) { ) {
let &pipeline_id = self.devices.get(&WebGPUDevice(device_id)).unwrap(); let &pipeline_id = self.devices.get(&WebGPUDevice(device_id)).unwrap();