Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove additional trait impls from CommandBuffer #6960

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions wgpu/src/api/command_buffer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
use std::sync::Arc;

use parking_lot::Mutex;

use crate::*;

/// Handle to a command buffer on the GPU.
Expand All @@ -11,11 +7,9 @@ use crate::*;
/// a [`CommandEncoder`] and then calling [`CommandEncoder::finish`].
///
/// Corresponds to [WebGPU `GPUCommandBuffer`](https://gpuweb.github.io/gpuweb/#command-buffer).
#[derive(Debug, Clone)]
#[derive(Debug)]
pub struct CommandBuffer {
pub(crate) inner: Arc<Mutex<Option<dispatch::DispatchCommandBuffer>>>,
pub(crate) buffer: dispatch::DispatchCommandBuffer,
}
#[cfg(send_sync)]
static_assertions::assert_impl_all!(CommandBuffer: Send, Sync);

crate::cmp::impl_eq_ord_hash_arc_address!(CommandBuffer => .inner);
7 changes: 2 additions & 5 deletions wgpu/src/api/command_encoder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{ops::Range, sync::Arc};
use std::ops::Range;

use crate::{
api::{
Expand Down Expand Up @@ -35,7 +35,6 @@ crate::cmp::impl_eq_ord_hash_proxy!(CommandEncoder => .inner);
pub type CommandEncoderDescriptor<'a> = wgt::CommandEncoderDescriptor<Label<'a>>;
static_assertions::assert_impl_all!(CommandEncoderDescriptor<'_>: Send, Sync);

use parking_lot::Mutex;
pub use wgt::TexelCopyBufferInfo as TexelCopyBufferInfoBase;
/// View of a buffer which can be used to copy to/from a texture.
///
Expand All @@ -59,9 +58,7 @@ impl CommandEncoder {
pub fn finish(mut self) -> CommandBuffer {
let buffer = self.inner.finish();

CommandBuffer {
inner: Arc::new(Mutex::new(Some(buffer))),
}
CommandBuffer { buffer }
}

/// Begins recording of a render pass.
Expand Down
7 changes: 1 addition & 6 deletions wgpu/src/api/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,7 @@ impl Queue {
&self,
command_buffers: I,
) -> SubmissionIndex {
let mut command_buffers = command_buffers.into_iter().map(|comb| {
comb.inner
.lock()
.take()
.expect("Command buffer already submitted")
});
let mut command_buffers = command_buffers.into_iter().map(|comb| comb.buffer);

let index = self.inner.submit(&mut command_buffers);

Expand Down
2 changes: 2 additions & 0 deletions wgpu/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ macro_rules! impl_eq_ord_hash_proxy {
/// ```ignore
/// impl_eq_ord_hash_arc_address!(MyType => .field);
/// ```
#[cfg_attr(not(wgpu_core), expect(unused_macros))]
cwfitzgerald marked this conversation as resolved.
Show resolved Hide resolved
macro_rules! impl_eq_ord_hash_arc_address {
($type:ty => $($access:tt)*) => {
impl PartialEq for $type {
Expand Down Expand Up @@ -102,4 +103,5 @@ macro_rules! impl_eq_ord_hash_arc_address {
};
}

#[cfg_attr(not(wgpu_core), expect(unused_imports))]
pub(crate) use {impl_eq_ord_hash_arc_address, impl_eq_ord_hash_proxy};
2 changes: 1 addition & 1 deletion wgpu/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ dispatch_types! {
{mut type DispatchCommandEncoder = InterfaceTypes::CommandEncoder: CommandEncoderInterface};
{mut type DispatchComputePass = InterfaceTypes::ComputePass: ComputePassInterface};
{mut type DispatchRenderPass = InterfaceTypes::RenderPass: RenderPassInterface};
{ref type DispatchCommandBuffer = InterfaceTypes::CommandBuffer: CommandBufferInterface};
{mut type DispatchCommandBuffer = InterfaceTypes::CommandBuffer: CommandBufferInterface};
{mut type DispatchRenderBundleEncoder = InterfaceTypes::RenderBundleEncoder: RenderBundleEncoderInterface};
{ref type DispatchRenderBundle = InterfaceTypes::RenderBundle: RenderBundleInterface};
{ref type DispatchSurface = InterfaceTypes::Surface: SurfaceInterface};
Expand Down
Loading