mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 16:24:24 +00:00
Make hal::CommandEncoder and hal::CommandBuffer extend Debug. (#3060)
This commit is contained in:
parent
7b8dd4e0bd
commit
b79c455144
@ -72,8 +72,10 @@ unsafe impl Sync for Device {}
|
||||
|
||||
pub struct Queue {}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CommandEncoder {}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CommandBuffer {}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -45,7 +45,7 @@ use crate::auxil::{self, dxgi::result::HResult as _};
|
||||
|
||||
use arrayvec::ArrayVec;
|
||||
use parking_lot::Mutex;
|
||||
use std::{ffi, mem, num::NonZeroU32, sync::Arc};
|
||||
use std::{ffi, fmt, mem, num::NonZeroU32, sync::Arc};
|
||||
use winapi::{
|
||||
shared::{dxgi, dxgi1_4, dxgitype, windef, winerror},
|
||||
um::{d3d12, dcomp, synchapi, winbase, winnt},
|
||||
@ -347,6 +347,16 @@ pub struct CommandEncoder {
|
||||
unsafe impl Send for CommandEncoder {}
|
||||
unsafe impl Sync for CommandEncoder {}
|
||||
|
||||
impl fmt::Debug for CommandEncoder {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("CommandEncoder")
|
||||
.field("allocator", &self.allocator)
|
||||
.field("device", &self.allocator)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CommandBuffer {
|
||||
raw: native::GraphicsCommandList,
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ use std::ops::Range;
|
||||
#[derive(Clone)]
|
||||
pub struct Api;
|
||||
pub struct Context;
|
||||
#[derive(Debug)]
|
||||
pub struct Encoder;
|
||||
#[derive(Debug)]
|
||||
pub struct Resource;
|
||||
|
@ -82,7 +82,7 @@ use arrayvec::ArrayVec;
|
||||
|
||||
use glow::HasContext;
|
||||
|
||||
use std::{ops::Range, sync::Arc};
|
||||
use std::{fmt, ops::Range, sync::Arc};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Api;
|
||||
@ -758,6 +758,16 @@ pub struct CommandBuffer {
|
||||
queries: Vec<glow::Query>,
|
||||
}
|
||||
|
||||
impl fmt::Debug for CommandBuffer {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let mut builder = f.debug_struct("CommandBuffer");
|
||||
if let Some(ref label) = self.label {
|
||||
builder.field("label", label);
|
||||
}
|
||||
builder.finish()
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: we would have something like `Arc<typed_arena::Arena>`
|
||||
// here and in the command buffers. So that everything grows
|
||||
// inside the encoder and stays there until `reset_all`.
|
||||
@ -767,3 +777,11 @@ pub struct CommandEncoder {
|
||||
state: command::State,
|
||||
private_caps: PrivateCapabilities,
|
||||
}
|
||||
|
||||
impl fmt::Debug for CommandEncoder {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("CommandEncoder")
|
||||
.field("cmd_buffer", &self.cmd_buffer)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ pub trait Api: Clone + Sized {
|
||||
|
||||
type Queue: Queue<Self>;
|
||||
type CommandEncoder: CommandEncoder<Self>;
|
||||
type CommandBuffer: Send + Sync;
|
||||
type CommandBuffer: Send + Sync + fmt::Debug;
|
||||
|
||||
type Buffer: fmt::Debug + Send + Sync + 'static;
|
||||
type Texture: fmt::Debug + Send + Sync + 'static;
|
||||
@ -350,7 +350,7 @@ pub trait Queue<A: Api>: Send + Sync {
|
||||
/// Serves as a parent for all the encoded command buffers.
|
||||
/// Works in bursts of action: one or more command buffers are recorded,
|
||||
/// then submitted to a queue, and then it needs to be `reset_all()`.
|
||||
pub trait CommandEncoder<A: Api>: Send + Sync {
|
||||
pub trait CommandEncoder<A: Api>: Send + Sync + fmt::Debug {
|
||||
/// Begin encoding a new command buffer.
|
||||
unsafe fn begin_encoding(&mut self, label: Label) -> Result<(), DeviceError>;
|
||||
/// Discard currently recorded list, if any.
|
||||
|
@ -20,7 +20,7 @@ mod device;
|
||||
mod surface;
|
||||
|
||||
use std::{
|
||||
iter, ops,
|
||||
fmt, iter, ops,
|
||||
ptr::NonNull,
|
||||
sync::{atomic, Arc},
|
||||
thread,
|
||||
@ -727,9 +727,19 @@ pub struct CommandEncoder {
|
||||
temp: Temp,
|
||||
}
|
||||
|
||||
impl fmt::Debug for CommandEncoder {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("CommandEncoder")
|
||||
.field("raw_queue", &self.raw_queue)
|
||||
.field("raw_cmd_buf", &self.raw_cmd_buf)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Send for CommandEncoder {}
|
||||
unsafe impl Sync for CommandEncoder {}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CommandBuffer {
|
||||
raw: mtl::CommandBuffer,
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ mod conv;
|
||||
mod device;
|
||||
mod instance;
|
||||
|
||||
use std::{borrow::Borrow, ffi::CStr, num::NonZeroU32, sync::Arc};
|
||||
use std::{borrow::Borrow, ffi::CStr, fmt, num::NonZeroU32, sync::Arc};
|
||||
|
||||
use arrayvec::ArrayVec;
|
||||
use ash::{
|
||||
@ -443,6 +443,15 @@ pub struct CommandEncoder {
|
||||
rpass_debug_marker_active: bool,
|
||||
}
|
||||
|
||||
impl fmt::Debug for CommandEncoder {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("CommandEncoder")
|
||||
.field("raw", &self.raw)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CommandBuffer {
|
||||
raw: vk::CommandBuffer,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user