From c6ab7257dcb2a3489a7dc419b8c111331814a535 Mon Sep 17 00:00:00 2001 From: msiglreith Date: Thu, 21 Jun 2018 22:24:30 +0200 Subject: [PATCH] doc: Improve wording and name shortening of buffer errors --- src/backend/dx11/src/device.rs | 4 ++-- src/backend/dx12/src/device.rs | 6 +++--- src/backend/empty/src/lib.rs | 4 ++-- src/backend/gl/src/device.rs | 8 ++++---- src/backend/metal/src/device.rs | 10 +++++----- src/backend/vulkan/src/device.rs | 4 ++-- src/hal/src/buffer.rs | 6 +++--- src/hal/src/device.rs | 4 ++-- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/backend/dx11/src/device.rs b/src/backend/dx11/src/device.rs index 11edb761d09..eb1061d0102 100644 --- a/src/backend/dx11/src/device.rs +++ b/src/backend/dx11/src/device.rs @@ -453,7 +453,7 @@ impl hal::Device for Device { &self, mut size: u64, usage: buffer::Usage, - ) -> Result { + ) -> Result { use buffer::Usage; let mut bind = 0; @@ -666,7 +666,7 @@ impl hal::Device for Device { buffer: &Buffer, format: Option, range: R, - ) -> Result { + ) -> Result { unimplemented!() } diff --git a/src/backend/dx12/src/device.rs b/src/backend/dx12/src/device.rs index 954c6d6bead..76d18f27c0a 100644 --- a/src/backend/dx12/src/device.rs +++ b/src/backend/dx12/src/device.rs @@ -1791,7 +1791,7 @@ impl d::Device for Device { &self, mut size: u64, usage: buffer::Usage, - ) -> Result { + ) -> Result { if usage.contains(buffer::Usage::UNIFORM) { // Constant buffer view sizes need to be aligned. // Coupled with the offset alignment we can enforce an aligned CBV size @@ -1910,14 +1910,14 @@ impl d::Device for Device { buffer: &n::Buffer, format: Option, range: R, - ) -> Result { + ) -> Result { let buffer_features = { let idx = format.map(|fmt| fmt as usize).unwrap_or(0); self.format_properties[idx].buffer_features }; let (format, format_desc) = match format.and_then(conv::map_format) { Some(fmt) => (fmt, format.unwrap().surface_desc()), - None => return Err(buffer::BufferViewCreationError::UnsupportedFormat { format }), + None => return Err(buffer::ViewCreationError::UnsupportedFormat { format }), }; let start = *range.start().unwrap_or(&0); diff --git a/src/backend/empty/src/lib.rs b/src/backend/empty/src/lib.rs index d56a1d239da..93775ab818e 100644 --- a/src/backend/empty/src/lib.rs +++ b/src/backend/empty/src/lib.rs @@ -165,7 +165,7 @@ impl hal::Device for Device { fn create_sampler(&self, _: image::SamplerInfo) -> () { unimplemented!() } - fn create_buffer(&self, _: u64, _: buffer::Usage) -> Result<(), buffer::BufferCreationError> { + fn create_buffer(&self, _: u64, _: buffer::Usage) -> Result<(), buffer::CreationError> { unimplemented!() } @@ -177,7 +177,7 @@ impl hal::Device for Device { unimplemented!() } - fn create_buffer_view>(&self, _: &(), _: Option, _: R) -> Result<(), buffer::BufferViewCreationError> { + fn create_buffer_view>(&self, _: &(), _: Option, _: R) -> Result<(), buffer::ViewCreationError> { unimplemented!() } diff --git a/src/backend/gl/src/device.rs b/src/backend/gl/src/device.rs index 6d937a31d07..25d54d7f84c 100644 --- a/src/backend/gl/src/device.rs +++ b/src/backend/gl/src/device.rs @@ -669,10 +669,10 @@ impl d::Device for Device { fn create_buffer( &self, size: u64, usage: buffer::Usage, - ) -> Result { + ) -> Result { if !self.share.legacy_features.contains(LegacyFeatures::CONSTANT_BUFFER) && usage.contains(buffer::Usage::UNIFORM) { - return Err(buffer::BufferCreationError::UnsupportedUsage { usage }); + return Err(buffer::CreationError::UnsupportedUsage { usage }); } let target = if self.share.private_caps.buffer_role_change { @@ -680,7 +680,7 @@ impl d::Device for Device { } else { match conv::buffer_usage_to_gl_target(usage) { Some(target) => target, - None => return Err(buffer::BufferCreationError::UnsupportedUsage { usage }), + None => return Err(buffer::CreationError::UnsupportedUsage { usage }), } }; @@ -837,7 +837,7 @@ impl d::Device for Device { fn create_buffer_view>( &self, _: &n::Buffer, _: Option, _: R - ) -> Result { + ) -> Result { unimplemented!() } diff --git a/src/backend/metal/src/device.rs b/src/backend/metal/src/device.rs index eaf06f8cb2b..0baad0c8b95 100644 --- a/src/backend/metal/src/device.rs +++ b/src/backend/metal/src/device.rs @@ -1573,7 +1573,7 @@ impl hal::Device for Device { fn create_buffer( &self, size: u64, usage: buffer::Usage - ) -> Result { + ) -> Result { debug!("create_buffer of size {} and usage {:?}", size, usage); Ok(n::UnboundBuffer { size, @@ -1667,22 +1667,22 @@ impl hal::Device for Device { fn create_buffer_view>( &self, buffer: &n::Buffer, format_maybe: Option, range: R - ) -> Result { + ) -> Result { let start = buffer.range.start + *range.start().unwrap_or(&0); let end_rough = *range.end().unwrap_or(&buffer.raw.length()); let format = match format_maybe { Some(fmt) => fmt, - None => return Err(buffer::BufferViewCreationError::UnsupportedFormat { format: format_maybe }), + None => return Err(buffer::ViewCreationError::UnsupportedFormat { format: format_maybe }), }; let format_desc = format.surface_desc(); if format_desc.aspects != format::Aspects::COLOR { // no depth/stencil support for buffer views here - return Err(buffer::BufferViewCreationError::UnsupportedFormat { format: format_maybe }) + return Err(buffer::ViewCreationError::UnsupportedFormat { format: format_maybe }) } let block_count = (end_rough - start) * 8 / format_desc.bits as u64; let mtl_format = self.private_caps .map_format(format) - .ok_or(buffer::BufferViewCreationError::UnsupportedFormat { format: format_maybe })?; + .ok_or(buffer::ViewCreationError::UnsupportedFormat { format: format_maybe })?; let descriptor = metal::TextureDescriptor::new(); descriptor.set_texture_type(MTLTextureType::D2); diff --git a/src/backend/vulkan/src/device.rs b/src/backend/vulkan/src/device.rs index eb51a23da57..6512c370510 100644 --- a/src/backend/vulkan/src/device.rs +++ b/src/backend/vulkan/src/device.rs @@ -886,7 +886,7 @@ impl d::Device for Device { } /// - fn create_buffer(&self, size: u64, usage: buffer::Usage) -> Result { + fn create_buffer(&self, size: u64, usage: buffer::Usage) -> Result { let info = vk::BufferCreateInfo { s_type: vk::StructureType::BufferCreateInfo, p_next: ptr::null(), @@ -930,7 +930,7 @@ impl d::Device for Device { fn create_buffer_view>( &self, buffer: &n::Buffer, format: Option, range: R - ) -> Result { + ) -> Result { let (offset, size) = conv::map_range_arg(&range); let info = vk::BufferViewCreateInfo { s_type: vk::StructureType::BufferViewCreateInfo, diff --git a/src/hal/src/buffer.rs b/src/hal/src/buffer.rs index 57bfca79eb8..e965a7793bf 100644 --- a/src/hal/src/buffer.rs +++ b/src/hal/src/buffer.rs @@ -17,7 +17,7 @@ pub type State = Access; /// Error creating a buffer. #[derive(Fail, Debug, Clone, PartialEq, Eq)] -pub enum BufferCreationError { +pub enum CreationError { /// Memory allocation on the host side failed. /// This could be caused by a lack of memory. #[fail(display = "Host memory allocation failed.")] @@ -38,7 +38,7 @@ pub enum BufferCreationError { /// Error creating a buffer view. #[derive(Fail, Debug, Clone, PartialEq, Eq)] -pub enum BufferViewCreationError { +pub enum ViewCreationError { /// Memory allocation on the host side failed. /// This could be caused by a lack of memory. #[fail(display = "Host memory allocation failed.")] @@ -127,7 +127,7 @@ bitflags!( /// Index buffer view for `bind_index_buffer`. /// /// Defines a buffer slice used for acquiring the indicies on draw commands. -/// Indices are used to lookup the vertex indices in the vertex buffers. +/// Indices are used to lookup vertex indices in the vertex buffers. pub struct IndexBufferView<'a, B: Backend> { /// The buffer to bind. pub buffer: &'a B::Buffer, diff --git a/src/hal/src/device.rs b/src/hal/src/device.rs index 0e7c4386848..95852519346 100644 --- a/src/hal/src/device.rs +++ b/src/hal/src/device.rs @@ -285,7 +285,7 @@ pub trait Device: Any + Send + Sync { /// The created buffer won't have associated memory until `bind_buffer_memory` is called. fn create_buffer( &self, size: u64, usage: buffer::Usage, - ) -> Result; + ) -> Result; /// fn get_buffer_requirements(&self, buf: &B::UnboundBuffer) -> Requirements; @@ -308,7 +308,7 @@ pub trait Device: Any + Send + Sync { /// fn create_buffer_view>( &self, buf: &B::Buffer, fmt: Option, range: R - ) -> Result; + ) -> Result; /// fn destroy_buffer_view(&self, view: B::BufferView);