Skip to content

Commit

Permalink
doc: Improve wording and name shortening of buffer errors
Browse files Browse the repository at this point in the history
  • Loading branch information
msiglreith committed Jun 21, 2018
1 parent 55e33d5 commit c6ab725
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/backend/dx11/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ impl hal::Device<Backend> for Device {
&self,
mut size: u64,
usage: buffer::Usage,
) -> Result<UnboundBuffer, buffer::BufferCreationError> {
) -> Result<UnboundBuffer, buffer::CreationError> {
use buffer::Usage;

let mut bind = 0;
Expand Down Expand Up @@ -666,7 +666,7 @@ impl hal::Device<Backend> for Device {
buffer: &Buffer,
format: Option<format::Format>,
range: R,
) -> Result<BufferView, buffer::BufferViewCreationError> {
) -> Result<BufferView, buffer::ViewCreationError> {
unimplemented!()
}

Expand Down
6 changes: 3 additions & 3 deletions src/backend/dx12/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1791,7 +1791,7 @@ impl d::Device<B> for Device {
&self,
mut size: u64,
usage: buffer::Usage,
) -> Result<UnboundBuffer, buffer::BufferCreationError> {
) -> Result<UnboundBuffer, buffer::CreationError> {
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
Expand Down Expand Up @@ -1910,14 +1910,14 @@ impl d::Device<B> for Device {
buffer: &n::Buffer,
format: Option<format::Format>,
range: R,
) -> Result<n::BufferView, buffer::BufferViewCreationError> {
) -> Result<n::BufferView, buffer::ViewCreationError> {
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);
Expand Down
4 changes: 2 additions & 2 deletions src/backend/empty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl hal::Device<Backend> 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!()
}

Expand All @@ -177,7 +177,7 @@ impl hal::Device<Backend> for Device {
unimplemented!()
}

fn create_buffer_view<R: RangeArg<u64>>(&self, _: &(), _: Option<format::Format>, _: R) -> Result<(), buffer::BufferViewCreationError> {
fn create_buffer_view<R: RangeArg<u64>>(&self, _: &(), _: Option<format::Format>, _: R) -> Result<(), buffer::ViewCreationError> {
unimplemented!()
}

Expand Down
8 changes: 4 additions & 4 deletions src/backend/gl/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,18 +669,18 @@ impl d::Device<B> for Device {

fn create_buffer(
&self, size: u64, usage: buffer::Usage,
) -> Result<UnboundBuffer, buffer::BufferCreationError> {
) -> Result<UnboundBuffer, buffer::CreationError> {
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 {
gl::ARRAY_BUFFER
} 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 }),
}
};

Expand Down Expand Up @@ -837,7 +837,7 @@ impl d::Device<B> for Device {

fn create_buffer_view<R: RangeArg<u64>>(
&self, _: &n::Buffer, _: Option<Format>, _: R
) -> Result<n::BufferView, buffer::BufferViewCreationError> {
) -> Result<n::BufferView, buffer::ViewCreationError> {
unimplemented!()
}

Expand Down
10 changes: 5 additions & 5 deletions src/backend/metal/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ impl hal::Device<Backend> for Device {

fn create_buffer(
&self, size: u64, usage: buffer::Usage
) -> Result<n::UnboundBuffer, buffer::BufferCreationError> {
) -> Result<n::UnboundBuffer, buffer::CreationError> {
debug!("create_buffer of size {} and usage {:?}", size, usage);
Ok(n::UnboundBuffer {
size,
Expand Down Expand Up @@ -1667,22 +1667,22 @@ impl hal::Device<Backend> for Device {

fn create_buffer_view<R: RangeArg<u64>>(
&self, buffer: &n::Buffer, format_maybe: Option<format::Format>, range: R
) -> Result<n::BufferView, buffer::BufferViewCreationError> {
) -> Result<n::BufferView, buffer::ViewCreationError> {
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);
Expand Down
4 changes: 2 additions & 2 deletions src/backend/vulkan/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ impl d::Device<B> for Device {
}

///
fn create_buffer(&self, size: u64, usage: buffer::Usage) -> Result<UnboundBuffer, buffer::BufferCreationError> {
fn create_buffer(&self, size: u64, usage: buffer::Usage) -> Result<UnboundBuffer, buffer::CreationError> {
let info = vk::BufferCreateInfo {
s_type: vk::StructureType::BufferCreateInfo,
p_next: ptr::null(),
Expand Down Expand Up @@ -930,7 +930,7 @@ impl d::Device<B> for Device {

fn create_buffer_view<R: RangeArg<u64>>(
&self, buffer: &n::Buffer, format: Option<format::Format>, range: R
) -> Result<n::BufferView, buffer::BufferViewCreationError> {
) -> Result<n::BufferView, buffer::ViewCreationError> {
let (offset, size) = conv::map_range_arg(&range);
let info = vk::BufferViewCreateInfo {
s_type: vk::StructureType::BufferViewCreateInfo,
Expand Down
6 changes: 3 additions & 3 deletions src/hal/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]
Expand All @@ -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.")]
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/hal/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ pub trait Device<B: Backend>: 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<B::UnboundBuffer, buffer::BufferCreationError>;
) -> Result<B::UnboundBuffer, buffer::CreationError>;

///
fn get_buffer_requirements(&self, buf: &B::UnboundBuffer) -> Requirements;
Expand All @@ -308,7 +308,7 @@ pub trait Device<B: Backend>: Any + Send + Sync {
///
fn create_buffer_view<R: RangeArg<u64>>(
&self, buf: &B::Buffer, fmt: Option<format::Format>, range: R
) -> Result<B::BufferView, buffer::BufferViewCreationError>;
) -> Result<B::BufferView, buffer::ViewCreationError>;

///
fn destroy_buffer_view(&self, view: B::BufferView);
Expand Down

0 comments on commit c6ab725

Please sign in to comment.