Implement fmt::Debug on more structs

This commit is contained in:
Pierre Krieger 2017-05-13 10:14:04 +02:00
parent 1585199830
commit 5136aeb595
15 changed files with 114 additions and 6 deletions

View File

@ -45,7 +45,6 @@ use VulkanPointers;
use vk;
/// Data storage in a GPU-accessible location.
#[derive(Debug)]
pub struct UnsafeBuffer {
buffer: vk::Buffer,
device: Arc<Device>,
@ -258,6 +257,13 @@ unsafe impl DeviceOwned for UnsafeBuffer {
}
}
impl fmt::Debug for UnsafeBuffer {
#[inline]
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(fmt, "<Vulkan buffer {:?}>", self.buffer)
}
}
impl Drop for UnsafeBuffer {
#[inline]
fn drop(&mut self) {

View File

@ -208,6 +208,15 @@ unsafe impl<F, B> DeviceOwned for BufferView<F, B>
}
}
impl<F, B> fmt::Debug for BufferView<F, B> where B: BufferAccess + fmt::Debug {
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fmt.debug_struct("BufferView")
.field("raw", &self.view)
.field("buffer", &self.buffer)
.finish()
}
}
impl<F, B> Drop for BufferView<F, B> where B: BufferAccess {
#[inline]
fn drop(&mut self) {

View File

@ -433,6 +433,15 @@ unsafe impl DeviceOwned for UnsafeDescriptorPool {
}
}
impl fmt::Debug for UnsafeDescriptorPool {
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fmt.debug_struct("UnsafeDescriptorPool")
.field("raw", &self.pool)
.field("device", &self.device)
.finish()
}
}
impl Drop for UnsafeDescriptorPool {
#[inline]
fn drop(&mut self) {
@ -484,6 +493,7 @@ impl fmt::Display for DescriptorPoolAllocError {
}
/// Iterator to the descriptor sets allocated from an unsafe descriptor pool.
#[derive(Debug)]
pub struct UnsafeDescriptorPoolAllocIter {
sets: VecIntoIter<vk::DescriptorSet>,
}
@ -708,6 +718,12 @@ unsafe impl VulkanObject for UnsafeDescriptorSet {
}
}
impl fmt::Debug for UnsafeDescriptorSet {
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(fmt, "<Vulkan descriptor set {:?}>", self.set)
}
}
/// Represents a single write entry to a descriptor set.
///
/// Use the various constructors to build a `DescriptorWrite`. While it is safe to build a

View File

@ -7,6 +7,7 @@
// notice may not be copied, modified, or distributed except
// according to those terms.
use std::fmt;
use std::mem;
use std::ptr;
use std::sync::Arc;
@ -109,6 +110,15 @@ unsafe impl DeviceOwned for UnsafeDescriptorSetLayout {
}
}
impl fmt::Debug for UnsafeDescriptorSetLayout {
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fmt.debug_struct("UnsafeDescriptorSetLayout")
.field("raw", &self.layout)
.field("device", &self.device)
.finish()
}
}
unsafe impl VulkanObject for UnsafeDescriptorSetLayout {
type Object = vk::DescriptorSetLayout;

View File

@ -191,6 +191,16 @@ unsafe impl<D> DeviceOwned for PipelineLayout<D> {
}
}
impl<D> fmt::Debug for PipelineLayout<D> where D: fmt::Debug {
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fmt.debug_struct("PipelineLayout")
.field("raw", &self.layout)
.field("device", &self.device)
.field("desc", &self.desc)
.finish()
}
}
impl<L> Drop for PipelineLayout<L> {
#[inline]
fn drop(&mut self) {

View File

@ -408,7 +408,7 @@ impl Device {
impl fmt::Debug for Device {
#[inline]
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(fmt, "<Vulkan device>")
write!(fmt, "<Vulkan device {:?}>", self.device)
}
}

View File

@ -118,6 +118,7 @@ use vk;
/// };
/// # }
/// ```
#[derive(Debug)]
pub struct Framebuffer<Rp, A> {
device: Arc<Device>,
render_pass: Rp,

View File

@ -393,6 +393,16 @@ unsafe impl<D> DeviceOwned for RenderPass<D> {
}
}
impl<D> fmt::Debug for RenderPass<D> where D: fmt::Debug {
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fmt.debug_struct("RenderPass")
.field("raw", &self.render_pass)
.field("device", &self.device)
.field("desc", &self.desc)
.finish()
}
}
impl<D> Drop for RenderPass<D> {
#[inline]
fn drop(&mut self) {

View File

@ -51,7 +51,6 @@ use vk;
/// - The usage must be manually enforced.
/// - The image layout must be manually enforced and transitionned.
///
#[derive(Debug)]
pub struct UnsafeImage {
image: vk::Image,
device: Arc<Device>,
@ -680,6 +679,13 @@ unsafe impl VulkanObject for UnsafeImage {
}
}
impl fmt::Debug for UnsafeImage {
#[inline]
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(fmt, "<Vulkan image {:?}>", self.image)
}
}
impl Drop for UnsafeImage {
#[inline]
fn drop(&mut self) {
@ -793,7 +799,6 @@ pub struct LinearLayout {
pub depth_pitch: usize,
}
#[derive(Debug)]
pub struct UnsafeImageView {
view: vk::ImageView,
device: Arc<Device>,
@ -950,6 +955,13 @@ unsafe impl VulkanObject for UnsafeImageView {
}
}
impl fmt::Debug for UnsafeImageView {
#[inline]
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(fmt, "<Vulkan image view {:?}>", self.view)
}
}
impl Drop for UnsafeImageView {
#[inline]
fn drop(&mut self) {

View File

@ -311,7 +311,7 @@ impl Instance {
impl fmt::Debug for Instance {
#[inline]
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(fmt, "<Vulkan instance>")
write!(fmt, "<Vulkan instance {:?}>", self.instance)
}
}

View File

@ -114,6 +114,13 @@ impl ComputePipeline<()> {
}
}
impl<Pl> fmt::Debug for ComputePipeline<Pl> {
#[inline]
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(fmt, "<Vulkan compute pipeline {:?}>", self.inner.pipeline)
}
}
impl<Pl> ComputePipeline<Pl> {
/// Returns the `Device` this compute pipeline was created with.
#[inline]

View File

@ -1097,6 +1097,13 @@ unsafe impl<Mv, L, Rp> DeviceOwned for GraphicsPipeline<Mv, L, Rp> {
}
}
impl<Mv, L, Rp> fmt::Debug for GraphicsPipeline<Mv, L, Rp> {
#[inline]
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(fmt, "<Vulkan graphics pipeline {:?}>", self.inner.pipeline)
}
}
unsafe impl<Mv, L, Rp> RenderPassAbstract for GraphicsPipeline<Mv, L, Rp>
where Rp: RenderPassAbstract
{

View File

@ -421,6 +421,13 @@ unsafe impl VulkanObject for Sampler {
}
}
impl fmt::Debug for Sampler {
#[inline]
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(fmt, "<Vulkan sampler {:?}>", self.sampler)
}
}
impl Drop for Sampler {
#[inline]
fn drop(&mut self) {

View File

@ -35,7 +35,6 @@ use vk;
/// Represents a surface on the screen.
///
/// Creating a `Surface` is platform-specific.
#[derive(Debug)]
pub struct Surface {
instance: Arc<Instance>,
surface: vk::SurfaceKHR,
@ -487,6 +486,13 @@ unsafe impl VulkanObject for Surface {
}
}
impl fmt::Debug for Surface {
#[inline]
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(fmt, "<Vulkan surface {:?}>", self.surface)
}
}
impl Drop for Surface {
#[inline]
fn drop(&mut self) {

View File

@ -409,6 +409,13 @@ unsafe impl VulkanObject for Swapchain {
}
}
impl fmt::Debug for Swapchain {
#[inline]
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(fmt, "<Vulkan swapchain {:?}>", self.swapchain)
}
}
impl Drop for Swapchain {
#[inline]
fn drop(&mut self) {