Skip to content

Commit

Permalink
Debug improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
attackgoat committed Oct 11, 2023
1 parent a915c92 commit e98444c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/driver/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ impl Buffer {

trace!("create: {:?}", info);

debug_assert_ne!(info.size, 0, "Size must be non-zero");

let device = Arc::clone(device);
let buffer_info = vk::BufferCreateInfo::builder()
.size(info.size)
Expand Down Expand Up @@ -331,6 +333,8 @@ impl Buffer {
/// # Ok(()) }
/// ```
pub fn mapped_slice(this: &Self) -> &[u8] {
debug_assert!(this.info.can_map, "Buffer is not mappable - create using can_map flag");

&this.allocation.as_ref().unwrap().mapped_slice().unwrap()[0..this.info.size as usize]
}

Expand Down Expand Up @@ -363,6 +367,8 @@ impl Buffer {
/// # Ok(()) }
/// ```
pub fn mapped_slice_mut(this: &mut Self) -> &mut [u8] {
debug_assert!(this.info.can_map, "Buffer is not mappable - create using can_map flag");

&mut this
.allocation
.as_mut()
Expand Down
4 changes: 2 additions & 2 deletions src/driver/shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use {
super::{device::Device, DescriptorSetLayout, DriverError, VertexInputState},
ash::vk,
derive_builder::{Builder, UninitializedFieldError},
log::{debug, error, info, trace, warn},
log::{debug, error, trace, warn},
ordered_float::OrderedFloat,
spirq::{
ty::{ScalarType, Type},
Expand Down Expand Up @@ -1062,7 +1062,7 @@ impl Shader {
vertex_attribute_description.offset = offset;
offset += stride;

info!(
debug!(
"vertex attribute {}.{}: {:?} (offset={})",
vertex_attribute_description.binding,
vertex_attribute_description.location,
Expand Down
4 changes: 2 additions & 2 deletions src/driver/swapchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,15 @@ impl Swapchain {
continue;
}

if !Device::image_format_properties(
if Device::image_format_properties(
&self.device,
self.info.format.format,
vk::ImageType::TYPE_2D,
vk::ImageTiling::OPTIMAL,
usage,
vk::ImageCreateFlags::empty(),
)
.is_ok()
.is_err()
{
surface_capabilities.supported_usage_flags &= !usage;
}
Expand Down

0 comments on commit e98444c

Please sign in to comment.