mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
separate Queue&Device Id (#32966)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
a5df51ea56
commit
f989d3776e
7 changed files with 54 additions and 32 deletions
|
@ -130,6 +130,7 @@ pub enum WebGPURequest {
|
|||
},
|
||||
CreateSwapChain {
|
||||
device_id: id::DeviceId,
|
||||
queue_id: id::QueueId,
|
||||
buffer_ids: ArrayVec<id::BufferId, PRESENTATION_BUFFER_COUNT>,
|
||||
external_id: u64,
|
||||
sender: IpcSender<ImageKey>,
|
||||
|
@ -191,6 +192,7 @@ pub enum WebGPURequest {
|
|||
adapter_id: WebGPUAdapter,
|
||||
descriptor: wgt::DeviceDescriptor<Option<String>>,
|
||||
device_id: id::DeviceId,
|
||||
queue_id: id::QueueId,
|
||||
pipeline_id: PipelineId,
|
||||
},
|
||||
// Compute Pass
|
||||
|
@ -250,6 +252,7 @@ pub enum WebGPURequest {
|
|||
command_encoder_id: id::CommandEncoderId,
|
||||
},
|
||||
Submit {
|
||||
device_id: id::DeviceId,
|
||||
queue_id: id::QueueId,
|
||||
command_buffers: Vec<id::CommandBufferId>,
|
||||
},
|
||||
|
@ -267,12 +270,14 @@ pub enum WebGPURequest {
|
|||
size: u64,
|
||||
},
|
||||
WriteBuffer {
|
||||
device_id: id::DeviceId,
|
||||
queue_id: id::QueueId,
|
||||
buffer_id: id::BufferId,
|
||||
buffer_offset: u64,
|
||||
data: IpcSharedMemory,
|
||||
},
|
||||
WriteTexture {
|
||||
device_id: id::DeviceId,
|
||||
queue_id: id::QueueId,
|
||||
texture_cv: ImageCopyTexture,
|
||||
data_layout: wgt::ImageDataLayout,
|
||||
|
@ -282,6 +287,7 @@ pub enum WebGPURequest {
|
|||
QueueOnSubmittedWorkDone {
|
||||
sender: IpcSender<WebGPUResponse>,
|
||||
queue_id: id::QueueId,
|
||||
device_id: id::DeviceId,
|
||||
},
|
||||
PushErrorScope {
|
||||
device_id: id::DeviceId,
|
||||
|
|
|
@ -143,21 +143,3 @@ pub struct PresentationData {
|
|||
image_desc: ImageDescriptor,
|
||||
image_data: ImageData,
|
||||
}
|
||||
|
||||
pub trait Transmute<U: id::Marker> {
|
||||
fn transmute(self) -> id::Id<U>;
|
||||
}
|
||||
|
||||
impl Transmute<id::markers::Queue> for id::Id<id::markers::Device> {
|
||||
fn transmute(self) -> id::Id<id::markers::Queue> {
|
||||
// if this is removed next one should be removed too.
|
||||
self.into_queue_id()
|
||||
}
|
||||
}
|
||||
|
||||
impl Transmute<id::markers::Device> for id::Id<id::markers::Queue> {
|
||||
fn transmute(self) -> id::Id<id::markers::Device> {
|
||||
// SAFETY: This is safe because queue_id = device_id in wgpu
|
||||
unsafe { id::Id::from_raw(self.into_raw()) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ use crate::gpu_error::ErrorScope;
|
|||
use crate::poll_thread::Poller;
|
||||
use crate::render_commands::apply_render_command;
|
||||
use crate::{
|
||||
Adapter, ComputePassId, Error, PopError, PresentationData, RenderPassId, Transmute, WebGPU,
|
||||
WebGPUAdapter, WebGPUDevice, WebGPUMsg, WebGPUQueue, WebGPURequest, WebGPUResponse,
|
||||
Adapter, ComputePassId, Error, PopError, PresentationData, RenderPassId, WebGPU, WebGPUAdapter,
|
||||
WebGPUDevice, WebGPUMsg, WebGPUQueue, WebGPURequest, WebGPUResponse,
|
||||
};
|
||||
|
||||
pub const PRESENTATION_BUFFER_COUNT: usize = 10;
|
||||
|
@ -491,6 +491,7 @@ impl WGPU {
|
|||
},
|
||||
WebGPURequest::CreateSwapChain {
|
||||
device_id,
|
||||
queue_id,
|
||||
buffer_ids,
|
||||
external_id,
|
||||
sender,
|
||||
|
@ -510,7 +511,7 @@ impl WGPU {
|
|||
external_id,
|
||||
PresentationData {
|
||||
device_id,
|
||||
queue_id: device_id.transmute(),
|
||||
queue_id,
|
||||
data: vec![255; (buffer_stride * height as u32) as usize],
|
||||
size: Size2D::new(width, height),
|
||||
unassigned_buffer_ids: buffer_ids,
|
||||
|
@ -704,6 +705,7 @@ impl WGPU {
|
|||
adapter_id,
|
||||
descriptor,
|
||||
device_id,
|
||||
queue_id,
|
||||
pipeline_id,
|
||||
} => {
|
||||
let desc = DeviceDescriptor {
|
||||
|
@ -718,7 +720,7 @@ impl WGPU {
|
|||
&desc,
|
||||
None,
|
||||
Some(device_id),
|
||||
Some(device_id.transmute()),
|
||||
Some(queue_id),
|
||||
));
|
||||
let device = WebGPUDevice(device_id);
|
||||
let queue = WebGPUQueue(queue_id);
|
||||
|
@ -991,6 +993,7 @@ impl WGPU {
|
|||
};
|
||||
},
|
||||
WebGPURequest::Submit {
|
||||
device_id,
|
||||
queue_id,
|
||||
command_buffers,
|
||||
} => {
|
||||
|
@ -1008,7 +1011,7 @@ impl WGPU {
|
|||
gfx_select!(queue_id => global.queue_submit(queue_id, &command_buffers))
|
||||
.map_err(Error::from_error)
|
||||
};
|
||||
self.maybe_dispatch_error(queue_id.transmute(), result.err());
|
||||
self.maybe_dispatch_error(device_id, result.err());
|
||||
},
|
||||
WebGPURequest::SwapChainPresent {
|
||||
external_id,
|
||||
|
@ -1195,6 +1198,7 @@ impl WGPU {
|
|||
self.maybe_dispatch_wgpu_error(device_id, result.err());
|
||||
},
|
||||
WebGPURequest::WriteBuffer {
|
||||
device_id,
|
||||
queue_id,
|
||||
buffer_id,
|
||||
buffer_offset,
|
||||
|
@ -1208,9 +1212,10 @@ impl WGPU {
|
|||
buffer_offset as wgt::BufferAddress,
|
||||
&data
|
||||
));
|
||||
self.maybe_dispatch_wgpu_error(queue_id.transmute(), result.err());
|
||||
self.maybe_dispatch_wgpu_error(device_id, result.err());
|
||||
},
|
||||
WebGPURequest::WriteTexture {
|
||||
device_id,
|
||||
queue_id,
|
||||
texture_cv,
|
||||
data_layout,
|
||||
|
@ -1228,9 +1233,13 @@ impl WGPU {
|
|||
&size
|
||||
));
|
||||
drop(_guard);
|
||||
self.maybe_dispatch_wgpu_error(queue_id.transmute(), result.err());
|
||||
self.maybe_dispatch_wgpu_error(device_id, result.err());
|
||||
},
|
||||
WebGPURequest::QueueOnSubmittedWorkDone { sender, queue_id } => {
|
||||
WebGPURequest::QueueOnSubmittedWorkDone {
|
||||
sender,
|
||||
queue_id,
|
||||
device_id,
|
||||
} => {
|
||||
let global = &self.global;
|
||||
let token = self.poller.token();
|
||||
let callback = SubmittedWorkDoneClosure::from_rust(Box::from(move || {
|
||||
|
@ -1241,7 +1250,7 @@ impl WGPU {
|
|||
}));
|
||||
let result = gfx_select!(queue_id => global.queue_on_submitted_work_done(queue_id, callback));
|
||||
self.poller.wake();
|
||||
self.maybe_dispatch_wgpu_error(queue_id.transmute(), result.err());
|
||||
self.maybe_dispatch_wgpu_error(device_id, result.err());
|
||||
},
|
||||
WebGPURequest::DropTexture(id) => {
|
||||
let global = &self.global;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue