mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Add as_hal for Queue (#7182)
* add as_hal for Queue * add as_raw for dx12 queue * return Mutex + add as_raw for Vulkan * return reference * restore Cargo.lock * fix Cargo.lock --------- Co-authored-by: Marc Pabst <“marcpabst@users.noreply.github.com”>
This commit is contained in:
@@ -670,6 +670,12 @@ pub struct Queue {
|
||||
temp_lists: Mutex<Vec<Option<Direct3D12::ID3D12CommandList>>>,
|
||||
}
|
||||
|
||||
impl Queue {
|
||||
pub fn as_raw(&self) -> &Direct3D12::ID3D12CommandQueue {
|
||||
&self.raw
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Send for Queue {}
|
||||
unsafe impl Sync for Queue {}
|
||||
|
||||
|
||||
@@ -362,6 +362,10 @@ impl Queue {
|
||||
timestamp_period,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_raw(&self) -> &Arc<Mutex<metal::CommandQueue>> {
|
||||
&self.raw
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Device {
|
||||
|
||||
@@ -773,6 +773,12 @@ pub struct Queue {
|
||||
signal_semaphores: Mutex<(Vec<vk::Semaphore>, Vec<u64>)>,
|
||||
}
|
||||
|
||||
impl Queue {
|
||||
pub fn as_raw(&self) -> vk::Queue {
|
||||
self.raw
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Queue {
|
||||
fn drop(&mut self) {
|
||||
unsafe { self.relay_semaphores.lock().destroy(&self.device.raw) };
|
||||
|
||||
@@ -260,4 +260,26 @@ impl Queue {
|
||||
pub fn on_submitted_work_done(&self, callback: impl FnOnce() + Send + 'static) {
|
||||
self.inner.on_submitted_work_done(Box::new(callback));
|
||||
}
|
||||
|
||||
/// Returns the inner hal Queue using a callback. The hal queue will be `None` if the
|
||||
/// backend type argument does not match with this wgpu Queue
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - The raw handle obtained from the hal Queue must not be manually destroyed
|
||||
#[cfg(wgpu_core)]
|
||||
pub unsafe fn as_hal<A: wgc::hal_api::HalApi, F: FnOnce(Option<&A::Queue>) -> R, R>(
|
||||
&self,
|
||||
hal_queue_callback: F,
|
||||
) -> R {
|
||||
if let Some(core_queue) = self.inner.as_core_opt() {
|
||||
unsafe {
|
||||
core_queue
|
||||
.context
|
||||
.queue_as_hal::<A, F, R>(core_queue, hal_queue_callback)
|
||||
}
|
||||
} else {
|
||||
hal_queue_callback(None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,6 +367,14 @@ impl ContextWgpuCore {
|
||||
|
||||
format!("Validation Error\n\nCaused by:\n{output}")
|
||||
}
|
||||
|
||||
pub unsafe fn queue_as_hal<A: wgc::hal_api::HalApi, F: FnOnce(Option<&A::Queue>) -> R, R>(
|
||||
&self,
|
||||
queue: &CoreQueue,
|
||||
hal_queue_callback: F,
|
||||
) -> R {
|
||||
unsafe { self.0.queue_as_hal::<A, F, R>(queue.id, hal_queue_callback) }
|
||||
}
|
||||
}
|
||||
|
||||
fn map_buffer_copy_view(view: crate::TexelCopyBufferInfo<'_>) -> wgc::command::TexelCopyBufferInfo {
|
||||
|
||||
Reference in New Issue
Block a user