Rename ColorWrite, TextureUsage, and BufferUsage

This commit is contained in:
Dzmitry Malyshau 2021-06-30 14:57:38 -04:00
parent 568ac3fa24
commit ba006cfaa7
55 changed files with 474 additions and 468 deletions

View File

@ -261,9 +261,9 @@ impl RenderBundleEncoder {
let buffer = state
.trackers
.buffers
.use_extend(&*buffer_guard, buffer_id, (), hal::BufferUse::INDEX)
.use_extend(&*buffer_guard, buffer_id, (), hal::BufferUses::INDEX)
.unwrap();
check_buffer_usage(buffer.usage, wgt::BufferUsage::INDEX)
check_buffer_usage(buffer.usage, wgt::BufferUsages::INDEX)
.map_pass_err(scope)?;
let end = match size {
@ -288,9 +288,9 @@ impl RenderBundleEncoder {
let buffer = state
.trackers
.buffers
.use_extend(&*buffer_guard, buffer_id, (), hal::BufferUse::VERTEX)
.use_extend(&*buffer_guard, buffer_id, (), hal::BufferUses::VERTEX)
.unwrap();
check_buffer_usage(buffer.usage, wgt::BufferUsage::VERTEX)
check_buffer_usage(buffer.usage, wgt::BufferUsages::VERTEX)
.map_pass_err(scope)?;
let end = match size {
@ -413,9 +413,9 @@ impl RenderBundleEncoder {
let buffer = state
.trackers
.buffers
.use_extend(&*buffer_guard, buffer_id, (), hal::BufferUse::INDIRECT)
.use_extend(&*buffer_guard, buffer_id, (), hal::BufferUses::INDIRECT)
.unwrap();
check_buffer_usage(buffer.usage, wgt::BufferUsage::INDIRECT)
check_buffer_usage(buffer.usage, wgt::BufferUsages::INDIRECT)
.map_pass_err(scope)?;
buffer_memory_init_actions.extend(
@ -453,10 +453,10 @@ impl RenderBundleEncoder {
let buffer = state
.trackers
.buffers
.use_extend(&*buffer_guard, buffer_id, (), hal::BufferUse::INDIRECT)
.use_extend(&*buffer_guard, buffer_id, (), hal::BufferUses::INDIRECT)
.map_err(|err| RenderCommandError::Buffer(buffer_id, err))
.map_pass_err(scope)?;
check_buffer_usage(buffer.usage, wgt::BufferUsage::INDIRECT)
check_buffer_usage(buffer.usage, wgt::BufferUsages::INDIRECT)
.map_pass_err(scope)?;
buffer_memory_init_actions.extend(

View File

@ -13,7 +13,7 @@ use crate::{
use hal::CommandEncoder as _;
use thiserror::Error;
use wgt::{
BufferAddress, BufferSize, BufferUsage, ImageSubresourceRange, TextureAspect, TextureUsage,
BufferAddress, BufferSize, BufferUsages, ImageSubresourceRange, TextureAspect, TextureUsages,
};
/// Error encountered while attempting a clear.
@ -89,13 +89,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let (dst_buffer, dst_pending) = cmd_buf
.trackers
.buffers
.use_replace(&*buffer_guard, dst, (), hal::BufferUse::COPY_DST)
.use_replace(&*buffer_guard, dst, (), hal::BufferUses::COPY_DST)
.map_err(ClearError::InvalidBuffer)?;
let dst_raw = dst_buffer
.raw
.as_ref()
.ok_or(ClearError::InvalidBuffer(dst))?;
if !dst_buffer.usage.contains(BufferUsage::COPY_DST) {
if !dst_buffer.usage.contains(BufferUsages::COPY_DST) {
return Err(ClearError::MissingCopyDstUsageFlag(Some(dst), None));
}
@ -229,14 +229,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
levels: subresource_range.base_mip_level..subresource_level_end,
layers: subresource_range.base_array_layer..subresource_layer_end,
},
hal::TextureUse::COPY_DST,
hal::TextureUses::COPY_DST,
)
.map_err(ClearError::InvalidTexture)?;
let _dst_raw = dst_texture
.raw
.as_ref()
.ok_or(ClearError::InvalidTexture(dst))?;
if !dst_texture.desc.usage.contains(TextureUsage::COPY_DST) {
if !dst_texture.desc.usage.contains(TextureUsages::COPY_DST) {
return Err(ClearError::MissingCopyDstUsageFlag(None, Some(dst)));
}

View File

@ -513,10 +513,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let indirect_buffer = state
.trackers
.buffers
.use_extend(&*buffer_guard, buffer_id, (), hal::BufferUse::INDIRECT)
.use_extend(&*buffer_guard, buffer_id, (), hal::BufferUses::INDIRECT)
.map_err(|_| ComputePassErrorInner::InvalidIndirectBuffer(buffer_id))
.map_pass_err(scope)?;
check_buffer_usage(indirect_buffer.usage, wgt::BufferUsage::INDIRECT)
check_buffer_usage(indirect_buffer.usage, wgt::BufferUsages::INDIRECT)
.map_pass_err(scope)?;
let end_offset = offset + mem::size_of::<wgt::DispatchIndirectArgs>() as u64;

View File

@ -12,7 +12,7 @@ use wgt::{BufferAddress, BufferSize, Color};
use std::num::NonZeroU32;
use thiserror::Error;
pub type BufferError = UseExtendError<hal::BufferUse>;
pub type BufferError = UseExtendError<hal::BufferUses>;
/// Error validating a draw call.
#[derive(Clone, Debug, Error, PartialEq)]

View File

@ -351,11 +351,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let (dst_buffer, dst_pending) = cmd_buf
.trackers
.buffers
.use_replace(&*buffer_guard, destination, (), hal::BufferUse::COPY_DST)
.use_replace(&*buffer_guard, destination, (), hal::BufferUses::COPY_DST)
.map_err(QueryError::InvalidBuffer)?;
let dst_barrier = dst_pending.map(|pending| pending.into_hal(dst_buffer));
if !dst_buffer.usage.contains(wgt::BufferUsage::COPY_DST) {
if !dst_buffer.usage.contains(wgt::BufferUsages::COPY_DST) {
return Err(ResolveError::MissingBufferUsage.into());
}

View File

@ -26,7 +26,7 @@ use arrayvec::ArrayVec;
use hal::CommandEncoder as _;
use thiserror::Error;
use wgt::{
BufferAddress, BufferSize, BufferUsage, Color, IndexFormat, InputStepMode, TextureUsage,
BufferAddress, BufferSize, BufferUsages, Color, IndexFormat, InputStepMode, TextureUsages,
};
#[cfg(any(feature = "serial-pass", feature = "replay"))]
@ -491,8 +491,8 @@ where
struct RenderAttachment<'a> {
texture_id: &'a Stored<id::TextureId>,
selector: &'a TextureSelector,
previous_use: Option<hal::TextureUse>,
new_use: hal::TextureUse,
previous_use: Option<hal::TextureUses>,
new_use: hal::TextureUses,
}
type AttachmentDataVec<T> = ArrayVec<[T; hal::MAX_COLOR_TARGETS + hal::MAX_COLOR_TARGETS + 1]>;
@ -584,9 +584,9 @@ impl<'a, A: HalApi> RenderPassInfo<'a, A> {
.query(source_id.value, view.selector.clone());
let new_use = if at.is_read_only(ds_aspects)? {
is_ds_read_only = true;
hal::TextureUse::DEPTH_STENCIL_READ | hal::TextureUse::SAMPLED
hal::TextureUses::DEPTH_STENCIL_READ | hal::TextureUses::SAMPLED
} else {
hal::TextureUse::DEPTH_STENCIL_WRITE
hal::TextureUses::DEPTH_STENCIL_WRITE
};
render_attachments.push(RenderAttachment {
texture_id: source_id,
@ -632,7 +632,7 @@ impl<'a, A: HalApi> RenderPassInfo<'a, A> {
.trackers
.textures
.query(source_id.value, color_view.selector.clone());
let new_use = hal::TextureUse::COLOR_TARGET;
let new_use = hal::TextureUses::COLOR_TARGET;
render_attachments.push(RenderAttachment {
texture_id: source_id,
selector: &color_view.selector,
@ -647,9 +647,9 @@ impl<'a, A: HalApi> RenderPassInfo<'a, A> {
assert!(used_swap_chain.is_none());
used_swap_chain = Some(source_id.clone());
let end = hal::TextureUse::empty();
let end = hal::TextureUses::empty();
let start = match at.channel.load_op {
LoadOp::Clear => hal::TextureUse::UNINITIALIZED,
LoadOp::Clear => hal::TextureUses::UNINITIALIZED,
LoadOp::Load => end,
};
start..end
@ -682,7 +682,7 @@ impl<'a, A: HalApi> RenderPassInfo<'a, A> {
.trackers
.textures
.query(source_id.value, resolve_view.selector.clone());
let new_use = hal::TextureUse::COLOR_TARGET;
let new_use = hal::TextureUses::COLOR_TARGET;
render_attachments.push(RenderAttachment {
texture_id: source_id,
selector: &resolve_view.selector,
@ -696,13 +696,13 @@ impl<'a, A: HalApi> RenderPassInfo<'a, A> {
TextureViewSource::SwapChain(ref source_id) => {
assert!(used_swap_chain.is_none());
used_swap_chain = Some(source_id.clone());
hal::TextureUse::UNINITIALIZED..hal::TextureUse::empty()
hal::TextureUses::UNINITIALIZED..hal::TextureUses::empty()
}
};
hal_resolve_target = Some(hal::Attachment {
view: &resolve_view.raw,
usage: hal::TextureUse::COLOR_TARGET,
usage: hal::TextureUses::COLOR_TARGET,
boundary_usage,
});
}
@ -710,7 +710,7 @@ impl<'a, A: HalApi> RenderPassInfo<'a, A> {
colors.push(hal::ColorAttachment {
target: hal::Attachment {
view: &color_view.raw,
usage: hal::TextureUse::COLOR_TARGET,
usage: hal::TextureUses::COLOR_TARGET,
boundary_usage,
},
resolve_target: hal_resolve_target,
@ -773,7 +773,7 @@ impl<'a, A: HalApi> RenderPassInfo<'a, A> {
for ra in self.render_attachments {
let texture = &texture_guard[ra.texture_id.value];
check_texture_usage(texture.desc.usage, TextureUsage::RENDER_ATTACHMENT)?;
check_texture_usage(texture.desc.usage, TextureUsages::RENDER_ATTACHMENT)?;
// the tracker set of the pass is always in "extend" mode
self.trackers
@ -1108,10 +1108,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let buffer = info
.trackers
.buffers
.use_extend(&*buffer_guard, buffer_id, (), hal::BufferUse::INDEX)
.use_extend(&*buffer_guard, buffer_id, (), hal::BufferUses::INDEX)
.map_err(|e| RenderCommandError::Buffer(buffer_id, e))
.map_pass_err(scope)?;
check_buffer_usage(buffer.usage, BufferUsage::INDEX).map_pass_err(scope)?;
check_buffer_usage(buffer.usage, BufferUsages::INDEX)
.map_pass_err(scope)?;
let buf_raw = buffer
.raw
.as_ref()
@ -1157,10 +1158,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let buffer = info
.trackers
.buffers
.use_extend(&*buffer_guard, buffer_id, (), hal::BufferUse::VERTEX)
.use_extend(&*buffer_guard, buffer_id, (), hal::BufferUses::VERTEX)
.map_err(|e| RenderCommandError::Buffer(buffer_id, e))
.map_pass_err(scope)?;
check_buffer_usage(buffer.usage, BufferUsage::VERTEX)
check_buffer_usage(buffer.usage, BufferUsages::VERTEX)
.map_pass_err(scope)?;
let buf_raw = buffer
.raw
@ -1412,10 +1413,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let indirect_buffer = info
.trackers
.buffers
.use_extend(&*buffer_guard, buffer_id, (), hal::BufferUse::INDIRECT)
.use_extend(&*buffer_guard, buffer_id, (), hal::BufferUses::INDIRECT)
.map_err(|e| RenderCommandError::Buffer(buffer_id, e))
.map_pass_err(scope)?;
check_buffer_usage(indirect_buffer.usage, BufferUsage::INDIRECT)
check_buffer_usage(indirect_buffer.usage, BufferUsages::INDIRECT)
.map_pass_err(scope)?;
let indirect_raw = indirect_buffer
.raw
@ -1486,10 +1487,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let indirect_buffer = info
.trackers
.buffers
.use_extend(&*buffer_guard, buffer_id, (), hal::BufferUse::INDIRECT)
.use_extend(&*buffer_guard, buffer_id, (), hal::BufferUses::INDIRECT)
.map_err(|e| RenderCommandError::Buffer(buffer_id, e))
.map_pass_err(scope)?;
check_buffer_usage(indirect_buffer.usage, BufferUsage::INDIRECT)
check_buffer_usage(indirect_buffer.usage, BufferUsages::INDIRECT)
.map_pass_err(scope)?;
let indirect_raw = indirect_buffer
.raw
@ -1504,11 +1505,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
&*buffer_guard,
count_buffer_id,
(),
hal::BufferUse::INDIRECT,
hal::BufferUses::INDIRECT,
)
.map_err(|e| RenderCommandError::Buffer(count_buffer_id, e))
.map_pass_err(scope)?;
check_buffer_usage(count_buffer.usage, BufferUsage::INDIRECT)
check_buffer_usage(count_buffer.usage, BufferUsages::INDIRECT)
.map_pass_err(scope)?;
let count_raw = count_buffer
.raw

View File

@ -12,7 +12,7 @@ use crate::{
use hal::CommandEncoder as _;
use thiserror::Error;
use wgt::{BufferAddress, BufferUsage, Extent3d, TextureUsage};
use wgt::{BufferAddress, BufferUsages, Extent3d, TextureUsages};
use std::iter;
@ -334,13 +334,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let (src_buffer, src_pending) = cmd_buf
.trackers
.buffers
.use_replace(&*buffer_guard, source, (), hal::BufferUse::COPY_SRC)
.use_replace(&*buffer_guard, source, (), hal::BufferUses::COPY_SRC)
.map_err(TransferError::InvalidBuffer)?;
let src_raw = src_buffer
.raw
.as_ref()
.ok_or(TransferError::InvalidBuffer(source))?;
if !src_buffer.usage.contains(BufferUsage::COPY_SRC) {
if !src_buffer.usage.contains(BufferUsages::COPY_SRC) {
return Err(TransferError::MissingCopySrcUsageFlag.into());
}
// expecting only a single barrier
@ -351,13 +351,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let (dst_buffer, dst_pending) = cmd_buf
.trackers
.buffers
.use_replace(&*buffer_guard, destination, (), hal::BufferUse::COPY_DST)
.use_replace(&*buffer_guard, destination, (), hal::BufferUses::COPY_DST)
.map_err(TransferError::InvalidBuffer)?;
let dst_raw = dst_buffer
.raw
.as_ref()
.ok_or(TransferError::InvalidBuffer(destination))?;
if !dst_buffer.usage.contains(BufferUsage::COPY_DST) {
if !dst_buffer.usage.contains(BufferUsages::COPY_DST) {
return Err(TransferError::MissingCopyDstUsageFlag(Some(destination), None).into());
}
let dst_barrier = dst_pending
@ -472,13 +472,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let (src_buffer, src_pending) = cmd_buf
.trackers
.buffers
.use_replace(&*buffer_guard, source.buffer, (), hal::BufferUse::COPY_SRC)
.use_replace(&*buffer_guard, source.buffer, (), hal::BufferUses::COPY_SRC)
.map_err(TransferError::InvalidBuffer)?;
let src_raw = src_buffer
.raw
.as_ref()
.ok_or(TransferError::InvalidBuffer(source.buffer))?;
if !src_buffer.usage.contains(BufferUsage::COPY_SRC) {
if !src_buffer.usage.contains(BufferUsages::COPY_SRC) {
return Err(TransferError::MissingCopySrcUsageFlag.into());
}
let src_barriers = src_pending.map(|pending| pending.into_hal(src_buffer));
@ -490,14 +490,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
&*texture_guard,
destination.texture,
dst_range,
hal::TextureUse::COPY_DST,
hal::TextureUses::COPY_DST,
)
.unwrap();
let dst_raw = dst_texture
.raw
.as_ref()
.ok_or(TransferError::InvalidTexture(destination.texture))?;
if !dst_texture.desc.usage.contains(TextureUsage::COPY_DST) {
if !dst_texture.desc.usage.contains(TextureUsages::COPY_DST) {
return Err(
TransferError::MissingCopyDstUsageFlag(None, Some(destination.texture)).into(),
);
@ -601,14 +601,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
&*texture_guard,
source.texture,
src_range,
hal::TextureUse::COPY_SRC,
hal::TextureUses::COPY_SRC,
)
.unwrap();
let src_raw = src_texture
.raw
.as_ref()
.ok_or(TransferError::InvalidTexture(source.texture))?;
if !src_texture.desc.usage.contains(TextureUsage::COPY_SRC) {
if !src_texture.desc.usage.contains(TextureUsages::COPY_SRC) {
return Err(TransferError::MissingCopySrcUsageFlag.into());
}
let src_barriers = src_pending.map(|pending| pending.into_hal(src_texture));
@ -620,14 +620,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
&*buffer_guard,
destination.buffer,
(),
hal::BufferUse::COPY_DST,
hal::BufferUses::COPY_DST,
)
.map_err(TransferError::InvalidBuffer)?;
let dst_raw = dst_buffer
.raw
.as_ref()
.ok_or(TransferError::InvalidBuffer(destination.buffer))?;
if !dst_buffer.usage.contains(BufferUsage::COPY_DST) {
if !dst_buffer.usage.contains(BufferUsages::COPY_DST) {
return Err(
TransferError::MissingCopyDstUsageFlag(Some(destination.buffer), None).into(),
);
@ -686,7 +686,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
cmd_buf_raw.transition_textures(src_barriers);
cmd_buf_raw.copy_texture_to_buffer(
src_raw,
hal::TextureUse::COPY_SRC,
hal::TextureUses::COPY_SRC,
dst_raw,
iter::once(region),
);
@ -740,14 +740,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
&*texture_guard,
source.texture,
src_range,
hal::TextureUse::COPY_SRC,
hal::TextureUses::COPY_SRC,
)
.unwrap();
let src_raw = src_texture
.raw
.as_ref()
.ok_or(TransferError::InvalidTexture(source.texture))?;
if !src_texture.desc.usage.contains(TextureUsage::COPY_SRC) {
if !src_texture.desc.usage.contains(TextureUsages::COPY_SRC) {
return Err(TransferError::MissingCopySrcUsageFlag.into());
}
//TODO: try to avoid this the collection. It's needed because both
@ -763,14 +763,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
&*texture_guard,
destination.texture,
dst_range,
hal::TextureUse::COPY_DST,
hal::TextureUses::COPY_DST,
)
.unwrap();
let dst_raw = dst_texture
.raw
.as_ref()
.ok_or(TransferError::InvalidTexture(destination.texture))?;
if !dst_texture.desc.usage.contains(TextureUsage::COPY_DST) {
if !dst_texture.desc.usage.contains(TextureUsages::COPY_DST) {
return Err(
TransferError::MissingCopyDstUsageFlag(None, Some(destination.texture)).into(),
);
@ -808,7 +808,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
cmd_buf_raw.transition_textures(barriers.into_iter());
cmd_buf_raw.copy_texture_to_texture(
src_raw,
hal::TextureUse::COPY_SRC,
hal::TextureUses::COPY_SRC,
dst_raw,
iter::once(region),
);

View File

@ -20,73 +20,76 @@ pub fn is_valid_copy_dst_texture_format(format: wgt::TextureFormat) -> bool {
}
}
pub fn map_buffer_usage(usage: wgt::BufferUsage) -> hal::BufferUse {
let mut u = hal::BufferUse::empty();
pub fn map_buffer_usage(usage: wgt::BufferUsages) -> hal::BufferUses {
let mut u = hal::BufferUses::empty();
u.set(
hal::BufferUse::MAP_READ,
usage.contains(wgt::BufferUsage::MAP_READ),
hal::BufferUses::MAP_READ,
usage.contains(wgt::BufferUsages::MAP_READ),
);
u.set(
hal::BufferUse::MAP_WRITE,
usage.contains(wgt::BufferUsage::MAP_WRITE),
hal::BufferUses::MAP_WRITE,
usage.contains(wgt::BufferUsages::MAP_WRITE),
);
u.set(
hal::BufferUse::COPY_SRC,
usage.contains(wgt::BufferUsage::COPY_SRC),
hal::BufferUses::COPY_SRC,
usage.contains(wgt::BufferUsages::COPY_SRC),
);
u.set(
hal::BufferUse::COPY_DST,
usage.contains(wgt::BufferUsage::COPY_DST),
hal::BufferUses::COPY_DST,
usage.contains(wgt::BufferUsages::COPY_DST),
);
u.set(
hal::BufferUse::INDEX,
usage.contains(wgt::BufferUsage::INDEX),
hal::BufferUses::INDEX,
usage.contains(wgt::BufferUsages::INDEX),
);
u.set(
hal::BufferUse::VERTEX,
usage.contains(wgt::BufferUsage::VERTEX),
hal::BufferUses::VERTEX,
usage.contains(wgt::BufferUsages::VERTEX),
);
u.set(
hal::BufferUse::UNIFORM,
usage.contains(wgt::BufferUsage::UNIFORM),
hal::BufferUses::UNIFORM,
usage.contains(wgt::BufferUsages::UNIFORM),
);
u.set(
hal::BufferUse::STORAGE_LOAD | hal::BufferUse::STORAGE_STORE,
usage.contains(wgt::BufferUsage::STORAGE),
hal::BufferUses::STORAGE_LOAD | hal::BufferUses::STORAGE_STORE,
usage.contains(wgt::BufferUsages::STORAGE),
);
u.set(
hal::BufferUse::INDIRECT,
usage.contains(wgt::BufferUsage::INDIRECT),
hal::BufferUses::INDIRECT,
usage.contains(wgt::BufferUsages::INDIRECT),
);
u
}
pub fn map_texture_usage(usage: wgt::TextureUsage, aspect: hal::FormatAspects) -> hal::TextureUse {
let mut u = hal::TextureUse::empty();
pub fn map_texture_usage(
usage: wgt::TextureUsages,
aspect: hal::FormatAspects,
) -> hal::TextureUses {
let mut u = hal::TextureUses::empty();
u.set(
hal::TextureUse::COPY_SRC,
usage.contains(wgt::TextureUsage::COPY_SRC),
hal::TextureUses::COPY_SRC,
usage.contains(wgt::TextureUsages::COPY_SRC),
);
u.set(
hal::TextureUse::COPY_DST,
usage.contains(wgt::TextureUsage::COPY_DST),
hal::TextureUses::COPY_DST,
usage.contains(wgt::TextureUsages::COPY_DST),
);
u.set(
hal::TextureUse::SAMPLED,
usage.contains(wgt::TextureUsage::SAMPLED),
hal::TextureUses::SAMPLED,
usage.contains(wgt::TextureUsages::SAMPLED),
);
u.set(
hal::TextureUse::STORAGE_LOAD | hal::TextureUse::STORAGE_STORE,
usage.contains(wgt::TextureUsage::STORAGE),
hal::TextureUses::STORAGE_LOAD | hal::TextureUses::STORAGE_STORE,
usage.contains(wgt::TextureUsages::STORAGE),
);
let is_color = aspect.contains(hal::FormatAspects::COLOR);
u.set(
hal::TextureUse::COLOR_TARGET,
usage.contains(wgt::TextureUsage::RENDER_ATTACHMENT) && is_color,
hal::TextureUses::COLOR_TARGET,
usage.contains(wgt::TextureUsages::RENDER_ATTACHMENT) && is_color,
);
u.set(
hal::TextureUse::DEPTH_STENCIL_READ | hal::TextureUse::DEPTH_STENCIL_WRITE,
usage.contains(wgt::TextureUsage::RENDER_ATTACHMENT) && !is_color,
hal::TextureUses::DEPTH_STENCIL_READ | hal::TextureUses::DEPTH_STENCIL_WRITE,
usage.contains(wgt::TextureUsages::RENDER_ATTACHMENT) && !is_color,
);
u
}

View File

@ -489,14 +489,14 @@ impl<A: HalApi> Device<A> {
if desc.size % wgt::COPY_BUFFER_ALIGNMENT != 0 {
return Err(resource::CreateBufferError::UnalignedSize);
}
if !desc.usage.contains(wgt::BufferUsage::MAP_WRITE) {
if !desc.usage.contains(wgt::BufferUsages::MAP_WRITE) {
// we are going to be copying into it, internally
usage |= hal::BufferUse::COPY_DST;
usage |= hal::BufferUses::COPY_DST;
}
} else {
// We are required to zero out (initialize) all memory.
// This is done on demand using fill_buffer which requires write transfer usage!
usage |= hal::BufferUse::COPY_DST;
usage |= hal::BufferUses::COPY_DST;
}
let mut memory_flags = hal::MemoryFlags::empty();
@ -542,7 +542,7 @@ impl<A: HalApi> Device<A> {
TextureFormat::Depth24Plus | TextureFormat::Depth24PlusStencil8 => {
if desc
.usage
.intersects(wgt::TextureUsage::COPY_SRC | wgt::TextureUsage::COPY_DST)
.intersects(wgt::TextureUsages::COPY_SRC | wgt::TextureUsages::COPY_DST)
{
return Err(resource::CreateTextureError::CannotCopyD24Plus);
}
@ -765,10 +765,10 @@ impl<A: HalApi> Device<A> {
extent,
samples: texture.desc.sample_count,
// once a storage - forever a storage
sampled_internal_use: if texture.desc.usage.contains(wgt::TextureUsage::STORAGE) {
hal::TextureUse::SAMPLED | hal::TextureUse::STORAGE_LOAD
sampled_internal_use: if texture.desc.usage.contains(wgt::TextureUsages::STORAGE) {
hal::TextureUses::SAMPLED | hal::TextureUses::STORAGE_LOAD
} else {
hal::TextureUse::SAMPLED
hal::TextureUses::SAMPLED
},
selector,
life_guard: LifeGuard::new(desc.label.borrow_or_default()),
@ -1126,16 +1126,16 @@ impl<A: HalApi> Device<A> {
};
let (pub_usage, internal_use, range_limit) = match binding_ty {
wgt::BufferBindingType::Uniform => (
wgt::BufferUsage::UNIFORM,
hal::BufferUse::UNIFORM,
wgt::BufferUsages::UNIFORM,
hal::BufferUses::UNIFORM,
limits.max_uniform_buffer_binding_size,
),
wgt::BufferBindingType::Storage { read_only } => (
wgt::BufferUsage::STORAGE,
wgt::BufferUsages::STORAGE,
if read_only {
hal::BufferUse::STORAGE_LOAD
hal::BufferUses::STORAGE_LOAD
} else {
hal::BufferUse::STORAGE_STORE
hal::BufferUses::STORAGE_STORE
},
limits.max_storage_buffer_binding_size,
),
@ -1481,7 +1481,7 @@ impl<A: HalApi> Device<A> {
decl: &wgt::BindGroupLayoutEntry,
view: &crate::resource::TextureView<A>,
expected: &'static str,
) -> Result<(wgt::TextureUsage, hal::TextureUse), binding_model::CreateBindGroupError> {
) -> Result<(wgt::TextureUsages, hal::TextureUses), binding_model::CreateBindGroupError> {
use crate::binding_model::CreateBindGroupError as Error;
if hal::FormatAspects::from(view.desc.format)
.contains(hal::FormatAspects::DEPTH | hal::FormatAspects::STENCIL)
@ -1531,7 +1531,7 @@ impl<A: HalApi> Device<A> {
view_dimension: view.desc.dimension,
});
}
Ok((wgt::TextureUsage::SAMPLED, view.sampled_internal_use))
Ok((wgt::TextureUsages::SAMPLED, view.sampled_internal_use))
}
wgt::BindingType::StorageTexture {
access,
@ -1553,8 +1553,8 @@ impl<A: HalApi> Device<A> {
});
}
let internal_use = match access {
wgt::StorageTextureAccess::ReadOnly => hal::TextureUse::STORAGE_LOAD,
wgt::StorageTextureAccess::WriteOnly => hal::TextureUse::STORAGE_STORE,
wgt::StorageTextureAccess::ReadOnly => hal::TextureUses::STORAGE_LOAD,
wgt::StorageTextureAccess::WriteOnly => hal::TextureUses::STORAGE_STORE,
wgt::StorageTextureAccess::ReadWrite => {
if !view
.format_features
@ -1564,10 +1564,10 @@ impl<A: HalApi> Device<A> {
return Err(Error::StorageReadWriteNotSupported(view.desc.format));
}
hal::TextureUse::STORAGE_STORE | hal::TextureUse::STORAGE_LOAD
hal::TextureUses::STORAGE_STORE | hal::TextureUses::STORAGE_LOAD
}
};
Ok((wgt::TextureUsage::STORAGE, internal_use))
Ok((wgt::TextureUsages::STORAGE, internal_use))
}
_ => Err(Error::WrongBindingType {
binding,
@ -1988,7 +1988,7 @@ impl<A: HalApi> Device<A> {
let format_features = self.describe_format_features(adapter, cs.format)?;
if !format_features
.allowed_usages
.contains(wgt::TextureUsage::RENDER_ATTACHMENT)
.contains(wgt::TextureUsages::RENDER_ATTACHMENT)
{
break Some(pipeline::ColorStateError::FormatNotRenderable(cs.format));
}
@ -2011,7 +2011,7 @@ impl<A: HalApi> Device<A> {
if !self
.describe_format_features(adapter, ds.format)?
.allowed_usages
.contains(wgt::TextureUsage::RENDER_ATTACHMENT)
.contains(wgt::TextureUsages::RENDER_ATTACHMENT)
{
break Some(pipeline::DepthStencilStateError::FormatNotRenderable(
ds.format,
@ -2543,8 +2543,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
if let Some(ref trace) = device.trace {
let mut desc = desc.clone();
let mapped_at_creation = mem::replace(&mut desc.mapped_at_creation, false);
if mapped_at_creation && !desc.usage.contains(wgt::BufferUsage::MAP_WRITE) {
desc.usage |= wgt::BufferUsage::COPY_DST;
if mapped_at_creation && !desc.usage.contains(wgt::BufferUsages::MAP_WRITE) {
desc.usage |= wgt::BufferUsages::COPY_DST;
}
trace
.lock()
@ -2558,8 +2558,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let ref_count = buffer.life_guard.add_ref();
let buffer_use = if !desc.mapped_at_creation {
hal::BufferUse::empty()
} else if desc.usage.contains(wgt::BufferUsage::MAP_WRITE) {
hal::BufferUses::empty()
} else if desc.usage.contains(wgt::BufferUsages::MAP_WRITE) {
// buffer is mappable, so we are just doing that at start
let map_size = buffer.size;
let ptr = match map_buffer(&device.raw, &mut buffer, 0, map_size, HostMap::Write) {
@ -2577,13 +2577,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
range: 0..map_size,
host: HostMap::Write,
};
hal::BufferUse::MAP_WRITE
hal::BufferUses::MAP_WRITE
} else {
// buffer needs staging area for initialization only
let stage_desc = wgt::BufferDescriptor {
label: Some(Cow::Borrowed("<init_buffer>")),
size: desc.size,
usage: wgt::BufferUsage::MAP_WRITE | wgt::BufferUsage::COPY_SRC,
usage: wgt::BufferUsages::MAP_WRITE | wgt::BufferUsages::COPY_SRC,
mapped_at_creation: false,
};
let mut stage = match device.create_buffer(device_id, &stage_desc, true) {
@ -2623,7 +2623,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
needs_flush: !mapping.is_coherent,
stage_buffer,
};
hal::BufferUse::COPY_DST
hal::BufferUses::COPY_DST
};
let id = fid.assign(buffer, &mut token);
@ -2686,7 +2686,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let buffer = buffer_guard
.get_mut(buffer_id)
.map_err(|_| resource::BufferAccessError::Invalid)?;
check_buffer_usage(buffer.usage, wgt::BufferUsage::MAP_WRITE)?;
check_buffer_usage(buffer.usage, wgt::BufferUsages::MAP_WRITE)?;
//assert!(buffer isn't used by the GPU);
#[cfg(feature = "trace")]
@ -2743,7 +2743,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let buffer = buffer_guard
.get_mut(buffer_id)
.map_err(|_| resource::BufferAccessError::Invalid)?;
check_buffer_usage(buffer.usage, wgt::BufferUsage::MAP_READ)?;
check_buffer_usage(buffer.usage, wgt::BufferUsages::MAP_READ)?;
//assert!(buffer isn't used by the GPU);
let raw_buf = buffer.raw.as_ref().unwrap();
@ -4409,8 +4409,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let mut token = Token::root();
let (device_guard, mut token) = hub.devices.read(&mut token);
let (pub_usage, internal_use) = match op.host {
HostMap::Read => (wgt::BufferUsage::MAP_READ, hal::BufferUse::MAP_READ),
HostMap::Write => (wgt::BufferUsage::MAP_WRITE, hal::BufferUse::MAP_WRITE),
HostMap::Read => (wgt::BufferUsages::MAP_READ, hal::BufferUses::MAP_READ),
HostMap::Write => (wgt::BufferUsages::MAP_WRITE, hal::BufferUses::MAP_WRITE),
};
if range.start % wgt::MAP_ALIGNMENT != 0 || range.end % wgt::COPY_BUFFER_ALIGNMENT != 0 {
@ -4580,11 +4580,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
});
let transition_src = hal::BufferBarrier {
buffer: &stage_buffer,
usage: hal::BufferUse::MAP_WRITE..hal::BufferUse::COPY_SRC,
usage: hal::BufferUses::MAP_WRITE..hal::BufferUses::COPY_SRC,
};
let transition_dst = hal::BufferBarrier {
buffer: raw_buf,
usage: hal::BufferUse::empty()..hal::BufferUse::COPY_DST,
usage: hal::BufferUses::empty()..hal::BufferUses::COPY_DST,
};
let encoder = device.pending_writes.activate();
unsafe {

View File

@ -207,7 +207,7 @@ impl<A: hal::Api> super::Device<A> {
let stage_desc = hal::BufferDescriptor {
label: Some("_Staging"),
size,
usage: hal::BufferUse::MAP_WRITE | hal::BufferUse::COPY_SRC,
usage: hal::BufferUses::MAP_WRITE | hal::BufferUses::COPY_SRC,
memory_flags: hal::MemoryFlags::TRANSIENT,
};
let buffer = unsafe { self.raw.create_buffer(&stage_desc)? };
@ -242,7 +242,7 @@ impl<A: hal::Api> super::Device<A> {
let transition = trackers.buffers.change_replace_tracked(
id::Valid(buffer_id),
(),
hal::BufferUse::COPY_DST,
hal::BufferUses::COPY_DST,
);
let buffer = buffer_guard.get(buffer_id).unwrap();
let raw_buf = buffer
@ -339,13 +339,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let mut trackers = device.trackers.lock();
let (dst, transition) = trackers
.buffers
.use_replace(&*buffer_guard, buffer_id, (), hal::BufferUse::COPY_DST)
.use_replace(&*buffer_guard, buffer_id, (), hal::BufferUses::COPY_DST)
.map_err(TransferError::InvalidBuffer)?;
let dst_raw = dst
.raw
.as_ref()
.ok_or(TransferError::InvalidBuffer(buffer_id))?;
if !dst.usage.contains(wgt::BufferUsage::COPY_DST) {
if !dst.usage.contains(wgt::BufferUsages::COPY_DST) {
return Err(TransferError::MissingCopyDstUsageFlag(Some(buffer_id), None).into());
}
dst.life_guard.use_at(device.active_submission_index + 1);
@ -373,7 +373,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
});
let barriers = iter::once(hal::BufferBarrier {
buffer: &stage.buffer,
usage: hal::BufferUse::MAP_WRITE..hal::BufferUse::COPY_SRC,
usage: hal::BufferUses::MAP_WRITE..hal::BufferUses::COPY_SRC,
})
.chain(transition.map(|pending| pending.into_hal(dst)));
let encoder = device.pending_writes.activate();
@ -482,7 +482,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
&*texture_guard,
destination.texture,
selector,
hal::TextureUse::COPY_DST,
hal::TextureUses::COPY_DST,
)
.unwrap();
let dst_raw = dst
@ -490,7 +490,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.as_ref()
.ok_or(TransferError::InvalidTexture(destination.texture))?;
if !dst.desc.usage.contains(wgt::TextureUsage::COPY_DST) {
if !dst.desc.usage.contains(wgt::TextureUsages::COPY_DST) {
return Err(
TransferError::MissingCopyDstUsageFlag(None, Some(destination.texture)).into(),
);
@ -562,7 +562,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let barrier = hal::BufferBarrier {
buffer: &stage.buffer,
usage: hal::BufferUse::MAP_WRITE..hal::BufferUse::COPY_SRC,
usage: hal::BufferUses::MAP_WRITE..hal::BufferUses::COPY_SRC,
};
let encoder = device.pending_writes.activate();
unsafe {

View File

@ -161,15 +161,15 @@ impl<A: HalApi> Adapter<A> {
let mut allowed_usages = format.describe().guaranteed_format_features.allowed_usages;
allowed_usages.set(
wgt::TextureUsage::SAMPLED,
wgt::TextureUsages::SAMPLED,
caps.contains(hal::TextureFormatCapabilities::SAMPLED),
);
allowed_usages.set(
wgt::TextureUsage::STORAGE,
wgt::TextureUsages::STORAGE,
caps.contains(hal::TextureFormatCapabilities::STORAGE),
);
allowed_usages.set(
wgt::TextureUsage::RENDER_ATTACHMENT,
wgt::TextureUsages::RENDER_ATTACHMENT,
caps.intersects(
hal::TextureFormatCapabilities::COLOR_ATTACHMENT
| hal::TextureFormatCapabilities::DEPTH_STENCIL_ATTACHMENT,

View File

@ -118,7 +118,7 @@ pub type BufferDescriptor<'a> = wgt::BufferDescriptor<Label<'a>>;
pub struct Buffer<A: hal::Api> {
pub(crate) raw: Option<A::Buffer>,
pub(crate) device_id: Stored<DeviceId>,
pub(crate) usage: wgt::BufferUsage,
pub(crate) usage: wgt::BufferUsages,
pub(crate) size: wgt::BufferAddress,
pub(crate) initialization_status: MemoryInitTracker,
pub(crate) sync_mapped_writes: Option<hal::MemoryRange>,
@ -137,7 +137,7 @@ pub enum CreateBufferError {
#[error("Buffers cannot have empty usage flags")]
EmptyUsage,
#[error("`MAP` usage can only be combined with the opposite `COPY`, requested {0:?}")]
UsageMismatch(wgt::BufferUsage),
UsageMismatch(wgt::BufferUsages),
}
impl<A: hal::Api> Resource for Buffer<A> {
@ -161,7 +161,7 @@ pub struct Texture<A: hal::Api> {
pub(crate) raw: Option<A::Texture>,
pub(crate) device_id: Stored<DeviceId>,
pub(crate) desc: wgt::TextureDescriptor<()>,
pub(crate) hal_usage: hal::TextureUse,
pub(crate) hal_usage: hal::TextureUses,
pub(crate) format_features: wgt::TextureFormatFeatures,
pub(crate) full_range: TextureSelector,
pub(crate) life_guard: LifeGuard,
@ -201,7 +201,7 @@ pub enum CreateTextureError {
#[error("texture descriptor mip level count ({0}) is invalid")]
InvalidMipLevelCount(u32),
#[error("The texture usages {0:?} are not allowed on a texture of type {1:?}")]
InvalidUsages(wgt::TextureUsage, wgt::TextureFormat),
InvalidUsages(wgt::TextureUsages, wgt::TextureFormat),
#[error("Texture format {0:?} can't be used")]
MissingFeatures(wgt::TextureFormat, #[source] MissingFeatures),
}
@ -266,7 +266,7 @@ pub struct TextureView<A: hal::Api> {
pub(crate) extent: wgt::Extent3d,
pub(crate) samples: u32,
/// Internal use of this texture view when used as `BindingType::Texture`.
pub(crate) sampled_internal_use: hal::TextureUse,
pub(crate) sampled_internal_use: hal::TextureUses,
pub(crate) selector: TextureSelector,
pub(crate) life_guard: LifeGuard,
}

View File

@ -170,7 +170,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
label: Some("_Frame"),
format: sc.desc.format,
dimension: wgt::TextureViewDimension::D2,
usage: hal::TextureUse::COLOR_TARGET,
usage: hal::TextureUses::COLOR_TARGET,
range: wgt::ImageSubresourceRange::default(),
};
@ -194,7 +194,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
range: wgt::ImageSubresourceRange::default(),
},
format_features: wgt::TextureFormatFeatures {
allowed_usages: wgt::TextureUsage::RENDER_ATTACHMENT,
allowed_usages: wgt::TextureUsages::RENDER_ATTACHMENT,
flags: wgt::TextureFormatFeatureFlags::empty(),
filterable: false,
},
@ -204,7 +204,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
depth_or_array_layers: 1,
},
samples: 1,
sampled_internal_use: hal::TextureUse::empty(),
sampled_internal_use: hal::TextureUses::empty(),
selector: TextureSelector {
layers: 0..1,
levels: 0..1,

View File

@ -1,14 +1,14 @@
use super::{PendingTransition, ResourceState, Unit};
use crate::id::{BufferId, Valid};
use hal::BufferUse;
use hal::BufferUses;
pub(crate) type BufferState = Unit<BufferUse>;
pub(crate) type BufferState = Unit<BufferUses>;
impl PendingTransition<BufferState> {
fn collapse(self) -> Result<BufferUse, Self> {
fn collapse(self) -> Result<BufferUses, Self> {
if self.usage.start.is_empty()
|| self.usage.start == self.usage.end
|| !BufferUse::WRITE_ALL.intersects(self.usage.start | self.usage.end)
|| !BufferUses::WRITE_ALL.intersects(self.usage.start | self.usage.end)
{
Ok(self.usage.start | self.usage.end)
} else {
@ -21,13 +21,13 @@ impl Default for BufferState {
fn default() -> Self {
Self {
first: None,
last: BufferUse::empty(),
last: BufferUses::empty(),
}
}
}
impl BufferState {
pub fn with_usage(usage: BufferUse) -> Self {
pub fn with_usage(usage: BufferUses) -> Self {
Unit::new(usage)
}
}
@ -35,7 +35,7 @@ impl BufferState {
impl ResourceState for BufferState {
type Id = BufferId;
type Selector = ();
type Usage = BufferUse;
type Usage = BufferUses;
fn query(&self, _selector: Self::Selector) -> Option<Self::Usage> {
Some(self.last)
@ -49,7 +49,7 @@ impl ResourceState for BufferState {
output: Option<&mut Vec<PendingTransition<Self>>>,
) -> Result<(), PendingTransition<Self>> {
let old = self.last;
if old != usage || !BufferUse::ORDERED.contains(usage) {
if old != usage || !BufferUses::ORDERED.contains(usage) {
let pending = PendingTransition {
id,
selector: (),
@ -102,7 +102,7 @@ impl ResourceState for BufferState {
) -> Result<(), PendingTransition<Self>> {
let old = self.last;
let new = other.port();
if old == new && BufferUse::ORDERED.contains(new) {
if old == new && BufferUses::ORDERED.contains(new) {
if output.is_some() && self.first.is_none() {
self.first = Some(old);
}
@ -144,64 +144,64 @@ mod test {
fn change_extend() {
let mut bs = Unit {
first: None,
last: BufferUse::INDEX,
last: BufferUses::INDEX,
};
let id = Id::dummy();
assert_eq!(
bs.change(id, (), BufferUse::STORAGE_STORE, None),
bs.change(id, (), BufferUses::STORAGE_STORE, None),
Err(PendingTransition {
id,
selector: (),
usage: BufferUse::INDEX..BufferUse::STORAGE_STORE,
usage: BufferUses::INDEX..BufferUses::STORAGE_STORE,
}),
);
bs.change(id, (), BufferUse::VERTEX, None).unwrap();
bs.change(id, (), BufferUse::INDEX, None).unwrap();
assert_eq!(bs, Unit::new(BufferUse::VERTEX | BufferUse::INDEX));
bs.change(id, (), BufferUses::VERTEX, None).unwrap();
bs.change(id, (), BufferUses::INDEX, None).unwrap();
assert_eq!(bs, Unit::new(BufferUses::VERTEX | BufferUses::INDEX));
}
#[test]
fn change_replace() {
let mut bs = Unit {
first: None,
last: BufferUse::STORAGE_STORE,
last: BufferUses::STORAGE_STORE,
};
let id = Id::dummy();
let mut list = Vec::new();
bs.change(id, (), BufferUse::VERTEX, Some(&mut list))
bs.change(id, (), BufferUses::VERTEX, Some(&mut list))
.unwrap();
assert_eq!(
&list,
&[PendingTransition {
id,
selector: (),
usage: BufferUse::STORAGE_STORE..BufferUse::VERTEX,
usage: BufferUses::STORAGE_STORE..BufferUses::VERTEX,
}],
);
assert_eq!(
bs,
Unit {
first: Some(BufferUse::STORAGE_STORE),
last: BufferUse::VERTEX,
first: Some(BufferUses::STORAGE_STORE),
last: BufferUses::VERTEX,
}
);
list.clear();
bs.change(id, (), BufferUse::STORAGE_STORE, Some(&mut list))
bs.change(id, (), BufferUses::STORAGE_STORE, Some(&mut list))
.unwrap();
assert_eq!(
&list,
&[PendingTransition {
id,
selector: (),
usage: BufferUse::VERTEX..BufferUse::STORAGE_STORE,
usage: BufferUses::VERTEX..BufferUses::STORAGE_STORE,
}],
);
assert_eq!(
bs,
Unit {
first: Some(BufferUse::STORAGE_STORE),
last: BufferUse::STORAGE_STORE,
first: Some(BufferUses::STORAGE_STORE),
last: BufferUses::STORAGE_STORE,
}
);
}
@ -210,24 +210,24 @@ mod test {
fn prepend() {
let mut bs = Unit {
first: None,
last: BufferUse::VERTEX,
last: BufferUses::VERTEX,
};
let id = Id::dummy();
bs.prepend(id, (), BufferUse::INDEX).unwrap();
bs.prepend(id, (), BufferUse::INDEX).unwrap();
bs.prepend(id, (), BufferUses::INDEX).unwrap();
bs.prepend(id, (), BufferUses::INDEX).unwrap();
assert_eq!(
bs.prepend(id, (), BufferUse::STORAGE_LOAD),
bs.prepend(id, (), BufferUses::STORAGE_LOAD),
Err(PendingTransition {
id,
selector: (),
usage: BufferUse::INDEX..BufferUse::STORAGE_LOAD,
usage: BufferUses::INDEX..BufferUses::STORAGE_LOAD,
})
);
assert_eq!(
bs,
Unit {
first: Some(BufferUse::INDEX),
last: BufferUse::VERTEX,
first: Some(BufferUses::INDEX),
last: BufferUses::VERTEX,
}
);
}

View File

@ -558,14 +558,14 @@ pub enum UsageConflict {
)]
Buffer {
id: id::BufferId,
combined_use: hal::BufferUse,
combined_use: hal::BufferUses,
},
#[error("Attempted to use texture {id:?} mips {mip_levels:?} layers {array_layers:?} as a combination of {combined_use:?} within a usage scope.")]
Texture {
id: id::TextureId,
mip_levels: ops::Range<u32>,
array_layers: ops::Range<u32>,
combined_use: hal::TextureUse,
combined_use: hal::TextureUses,
},
}

View File

@ -1,12 +1,12 @@
use super::{range::RangedStates, PendingTransition, ResourceState, Unit};
use crate::id::{TextureId, Valid};
use hal::TextureUse;
use hal::TextureUses;
use arrayvec::ArrayVec;
use std::{iter, ops::Range};
type PlaneStates = RangedStates<u32, Unit<TextureUse>>;
type PlaneStates = RangedStates<u32, Unit<TextureUses>>;
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct TextureSelector {
@ -24,10 +24,10 @@ pub(crate) struct TextureState {
}
impl PendingTransition<TextureState> {
fn collapse(self) -> Result<TextureUse, Self> {
fn collapse(self) -> Result<TextureUses, Self> {
if self.usage.start.is_empty()
|| self.usage.start == self.usage.end
|| !TextureUse::WRITE_ALL.intersects(self.usage.start | self.usage.end)
|| !TextureUses::WRITE_ALL.intersects(self.usage.start | self.usage.end)
{
Ok(self.usage.start | self.usage.end)
} else {
@ -40,7 +40,7 @@ impl TextureState {
pub fn new(mip_level_count: u32, array_layer_count: u32) -> Self {
Self {
mips: iter::repeat_with(|| {
PlaneStates::from_range(0..array_layer_count, Unit::new(TextureUse::UNINITIALIZED))
PlaneStates::from_range(0..array_layer_count, Unit::new(TextureUses::UNINITIALIZED))
})
.take(mip_level_count as usize)
.collect(),
@ -52,7 +52,7 @@ impl TextureState {
impl ResourceState for TextureState {
type Id = TextureId;
type Selector = TextureSelector;
type Usage = TextureUse;
type Usage = TextureUses;
fn query(&self, selector: Self::Selector) -> Option<Self::Usage> {
let mut result = None;
@ -100,7 +100,7 @@ impl ResourceState for TextureState {
let level = selector.levels.start + mip_id as u32;
let layers = mip.isolate(&selector.layers, Unit::new(usage));
for &mut (ref range, ref mut unit) in layers {
if unit.last == usage && TextureUse::ORDERED.contains(usage) {
if unit.last == usage && TextureUses::ORDERED.contains(usage) {
continue;
}
// TODO: Can't satisfy clippy here unless we modify
@ -209,7 +209,7 @@ impl ResourceState for TextureState {
end: Some(end),
} => {
let to_usage = end.port();
if start.last == to_usage && TextureUse::ORDERED.contains(to_usage) {
if start.last == to_usage && TextureUses::ORDERED.contains(to_usage) {
Unit {
first: match output {
None => start.first,
@ -275,9 +275,9 @@ mod test {
let mut ts = TextureState::default();
ts.mips.push(PlaneStates::empty());
ts.mips.push(PlaneStates::from_slice(&[
(1..3, Unit::new(TextureUse::SAMPLED)),
(3..5, Unit::new(TextureUse::SAMPLED)),
(5..6, Unit::new(TextureUse::STORAGE_LOAD)),
(1..3, Unit::new(TextureUses::SAMPLED)),
(3..5, Unit::new(TextureUses::SAMPLED)),
(5..6, Unit::new(TextureUses::STORAGE_LOAD)),
]));
assert_eq!(
@ -286,7 +286,7 @@ mod test {
layers: 2..5,
}),
// level 1 matches
Some(TextureUse::SAMPLED),
Some(TextureUses::SAMPLED),
);
assert_eq!(
ts.query(TextureSelector {
@ -294,7 +294,7 @@ mod test {
layers: 2..5,
}),
// level 0 is empty, level 1 matches
Some(TextureUse::SAMPLED),
Some(TextureUses::SAMPLED),
);
assert_eq!(
ts.query(TextureSelector {
@ -302,7 +302,7 @@ mod test {
layers: 1..5,
}),
// level 1 matches with gaps
Some(TextureUse::SAMPLED),
Some(TextureUses::SAMPLED),
);
assert_eq!(
ts.query(TextureSelector {
@ -320,7 +320,7 @@ mod test {
let mut ts1 = TextureState::default();
ts1.mips.push(PlaneStates::from_slice(&[(
1..3,
Unit::new(TextureUse::SAMPLED),
Unit::new(TextureUses::SAMPLED),
)]));
let mut ts2 = TextureState::default();
assert_eq!(
@ -331,7 +331,7 @@ mod test {
ts2.mips.push(PlaneStates::from_slice(&[(
1..2,
Unit::new(TextureUse::COPY_SRC),
Unit::new(TextureUses::COPY_SRC),
)]));
assert_eq!(
ts1.merge(Id::dummy(), &ts2, None),
@ -342,12 +342,12 @@ mod test {
ts1.mips[0].query(&(1..2), |&v| v),
Some(Ok(Unit {
first: None,
last: TextureUse::SAMPLED | TextureUse::COPY_SRC,
last: TextureUses::SAMPLED | TextureUses::COPY_SRC,
})),
"wrong extension result"
);
ts2.mips[0] = PlaneStates::from_slice(&[(1..2, Unit::new(TextureUse::COPY_DST))]);
ts2.mips[0] = PlaneStates::from_slice(&[(1..2, Unit::new(TextureUses::COPY_DST))]);
assert_eq!(
ts1.clone().merge(Id::dummy(), &ts2, None),
Err(PendingTransition {
@ -356,19 +356,19 @@ mod test {
levels: 0..1,
layers: 1..2,
},
usage: TextureUse::SAMPLED | TextureUse::COPY_SRC..TextureUse::COPY_DST,
usage: TextureUses::SAMPLED | TextureUses::COPY_SRC..TextureUses::COPY_DST,
}),
"wrong error on extending with incompatible state"
);
let mut list = Vec::new();
ts2.mips[0] = PlaneStates::from_slice(&[
(1..2, Unit::new(TextureUse::COPY_DST)),
(1..2, Unit::new(TextureUses::COPY_DST)),
(
2..3,
Unit {
first: Some(TextureUse::COPY_SRC),
last: TextureUse::COLOR_TARGET,
first: Some(TextureUses::COPY_SRC),
last: TextureUses::COLOR_TARGET,
},
),
]);
@ -382,7 +382,7 @@ mod test {
levels: 0..1,
layers: 1..2,
},
usage: TextureUse::SAMPLED | TextureUse::COPY_SRC..TextureUse::COPY_DST,
usage: TextureUses::SAMPLED | TextureUses::COPY_SRC..TextureUses::COPY_DST,
},
PendingTransition {
id,
@ -392,7 +392,7 @@ mod test {
},
// the transition links the end of the base rage (..SAMPLED)
// with the start of the next range (COPY_SRC..)
usage: TextureUse::SAMPLED..TextureUse::COPY_SRC,
usage: TextureUses::SAMPLED..TextureUses::COPY_SRC,
},
],
"replacing produced wrong transitions"
@ -400,16 +400,16 @@ mod test {
assert_eq!(
ts1.mips[0].query(&(1..2), |&v| v),
Some(Ok(Unit {
first: Some(TextureUse::SAMPLED | TextureUse::COPY_SRC),
last: TextureUse::COPY_DST,
first: Some(TextureUses::SAMPLED | TextureUses::COPY_SRC),
last: TextureUses::COPY_DST,
})),
"wrong final layer 1 state"
);
assert_eq!(
ts1.mips[0].query(&(2..3), |&v| v),
Some(Ok(Unit {
first: Some(TextureUse::SAMPLED),
last: TextureUse::COLOR_TARGET,
first: Some(TextureUses::SAMPLED),
last: TextureUses::COLOR_TARGET,
})),
"wrong final layer 2 state"
);
@ -418,8 +418,8 @@ mod test {
ts2.mips[0] = PlaneStates::from_slice(&[(
2..3,
Unit {
first: Some(TextureUse::COLOR_TARGET),
last: TextureUse::COPY_SRC,
first: Some(TextureUses::COLOR_TARGET),
last: TextureUses::COPY_SRC,
},
)]);
ts1.merge(Id::dummy(), &ts2, Some(&mut list)).unwrap();
@ -429,8 +429,8 @@ mod test {
ts2.mips[0] = PlaneStates::from_slice(&[(
2..3,
Unit {
first: Some(TextureUse::COPY_DST),
last: TextureUse::COPY_DST,
first: Some(TextureUses::COPY_DST),
last: TextureUses::COPY_DST,
},
)]);
ts1.merge(Id::dummy(), &ts2, Some(&mut list)).unwrap();
@ -442,7 +442,7 @@ mod test {
levels: 0..1,
layers: 2..3,
},
usage: TextureUse::COPY_SRC..TextureUse::COPY_DST,
usage: TextureUses::COPY_SRC..TextureUses::COPY_DST,
},],
"invalid replacing transition"
);
@ -450,8 +450,8 @@ mod test {
ts1.mips[0].query(&(2..3), |&v| v),
Some(Ok(Unit {
// the initial state here is never expected to change
first: Some(TextureUse::SAMPLED),
last: TextureUse::COPY_DST,
first: Some(TextureUses::SAMPLED),
last: TextureUses::COPY_DST,
})),
"wrong final layer 2 state"
);

View File

@ -114,15 +114,15 @@ pub struct Interface {
#[derive(Clone, Debug, Error)]
#[error("buffer usage is {actual:?} which does not contain required usage {expected:?}")]
pub struct MissingBufferUsageError {
pub(crate) actual: wgt::BufferUsage,
pub(crate) expected: wgt::BufferUsage,
pub(crate) actual: wgt::BufferUsages,
pub(crate) expected: wgt::BufferUsages,
}
/// Checks that the given buffer usage contains the required buffer usage,
/// returns an error otherwise.
pub fn check_buffer_usage(
actual: wgt::BufferUsage,
expected: wgt::BufferUsage,
actual: wgt::BufferUsages,
expected: wgt::BufferUsages,
) -> Result<(), MissingBufferUsageError> {
if !actual.contains(expected) {
Err(MissingBufferUsageError { actual, expected })
@ -134,15 +134,15 @@ pub fn check_buffer_usage(
#[derive(Clone, Debug, Error)]
#[error("texture usage is {actual:?} which does not contain required usage {expected:?}")]
pub struct MissingTextureUsageError {
pub(crate) actual: wgt::TextureUsage,
pub(crate) expected: wgt::TextureUsage,
pub(crate) actual: wgt::TextureUsages,
pub(crate) expected: wgt::TextureUsages,
}
/// Checks that the given texture usage contains the required texture usage,
/// returns an error otherwise.
pub fn check_texture_usage(
actual: wgt::TextureUsage,
expected: wgt::TextureUsage,
actual: wgt::TextureUsages,
expected: wgt::TextureUsages,
) -> Result<(), MissingTextureUsageError> {
if !actual.contains(expected) {
Err(MissingTextureUsageError { actual, expected })

View File

@ -114,7 +114,7 @@ impl<A: hal::Api> Example<A> {
height: window_size.1,
depth_or_array_layers: 1,
},
usage: hal::TextureUse::COLOR_TARGET,
usage: hal::TextureUses::COLOR_TARGET,
};
unsafe {
surface.configure(&device, &surface_config).unwrap();
@ -228,7 +228,7 @@ impl<A: hal::Api> Example<A> {
color_targets: &[wgt::ColorTargetState {
format: surface_config.format,
blend: Some(wgt::BlendState::ALPHA_BLENDING),
write_mask: wgt::ColorWrite::default(),
write_mask: wgt::ColorWrites::default(),
}],
};
let pipeline = unsafe { device.create_render_pipeline(&pipeline_desc).unwrap() };
@ -238,7 +238,7 @@ impl<A: hal::Api> Example<A> {
let staging_buffer_desc = hal::BufferDescriptor {
label: Some("stage"),
size: texture_data.len() as wgt::BufferAddress,
usage: hal::BufferUse::MAP_WRITE | hal::BufferUse::COPY_SRC,
usage: hal::BufferUses::MAP_WRITE | hal::BufferUses::COPY_SRC,
memory_flags: hal::MemoryFlags::TRANSIENT | hal::MemoryFlags::PREFER_COHERENT,
};
let staging_buffer = unsafe { device.create_buffer(&staging_buffer_desc).unwrap() };
@ -266,7 +266,7 @@ impl<A: hal::Api> Example<A> {
sample_count: 1,
dimension: wgt::TextureDimension::D2,
format: wgt::TextureFormat::Rgba8UnormSrgb,
usage: hal::TextureUse::COPY_DST | hal::TextureUse::SAMPLED,
usage: hal::TextureUses::COPY_DST | hal::TextureUses::SAMPLED,
memory_flags: hal::MemoryFlags::empty(),
};
let texture = unsafe { device.create_texture(&texture_desc).unwrap() };
@ -280,17 +280,17 @@ impl<A: hal::Api> Example<A> {
{
let buffer_barrier = hal::BufferBarrier {
buffer: &staging_buffer,
usage: hal::BufferUse::empty()..hal::BufferUse::COPY_SRC,
usage: hal::BufferUses::empty()..hal::BufferUses::COPY_SRC,
};
let texture_barrier1 = hal::TextureBarrier {
texture: &texture,
range: wgt::ImageSubresourceRange::default(),
usage: hal::TextureUse::UNINITIALIZED..hal::TextureUse::COPY_DST,
usage: hal::TextureUses::UNINITIALIZED..hal::TextureUses::COPY_DST,
};
let texture_barrier2 = hal::TextureBarrier {
texture: &texture,
range: wgt::ImageSubresourceRange::default(),
usage: hal::TextureUse::COPY_DST..hal::TextureUse::SAMPLED,
usage: hal::TextureUses::COPY_DST..hal::TextureUses::SAMPLED,
};
let copy = hal::BufferTextureCopy {
buffer_layout: wgt::ImageDataLayout {
@ -341,7 +341,7 @@ impl<A: hal::Api> Example<A> {
let global_buffer_desc = hal::BufferDescriptor {
label: Some("global"),
size: mem::size_of::<Globals>() as wgt::BufferAddress,
usage: hal::BufferUse::MAP_WRITE | hal::BufferUse::UNIFORM,
usage: hal::BufferUses::MAP_WRITE | hal::BufferUses::UNIFORM,
memory_flags: hal::MemoryFlags::PREFER_COHERENT,
};
let global_buffer = unsafe {
@ -362,7 +362,7 @@ impl<A: hal::Api> Example<A> {
let local_buffer_desc = hal::BufferDescriptor {
label: Some("local"),
size: (MAX_BUNNIES as wgt::BufferAddress) * wgt::BIND_BUFFER_ALIGNMENT,
usage: hal::BufferUse::MAP_WRITE | hal::BufferUse::UNIFORM,
usage: hal::BufferUses::MAP_WRITE | hal::BufferUses::UNIFORM,
memory_flags: hal::MemoryFlags::PREFER_COHERENT,
};
let local_buffer = unsafe { device.create_buffer(&local_buffer_desc).unwrap() };
@ -371,7 +371,7 @@ impl<A: hal::Api> Example<A> {
label: None,
format: texture_desc.format,
dimension: wgt::TextureViewDimension::D2,
usage: hal::TextureUse::SAMPLED,
usage: hal::TextureUses::SAMPLED,
range: wgt::ImageSubresourceRange::default(),
};
let texture_view = unsafe { device.create_texture_view(&texture, &view_desc).unwrap() };
@ -384,7 +384,7 @@ impl<A: hal::Api> Example<A> {
};
let texture_binding = hal::TextureBinding {
view: &texture_view,
usage: hal::TextureUse::SAMPLED,
usage: hal::TextureUses::SAMPLED,
};
let global_group_desc = hal::BindGroupDescriptor {
label: Some("global"),
@ -591,7 +591,7 @@ impl<A: hal::Api> Example<A> {
label: None,
format: self.surface_format,
dimension: wgt::TextureViewDimension::D2,
usage: hal::TextureUse::COLOR_TARGET,
usage: hal::TextureUses::COLOR_TARGET,
range: wgt::ImageSubresourceRange::default(),
};
let surface_tex_view = unsafe {
@ -610,8 +610,8 @@ impl<A: hal::Api> Example<A> {
color_attachments: &[hal::ColorAttachment {
target: hal::Attachment {
view: &surface_tex_view,
usage: hal::TextureUse::COLOR_TARGET,
boundary_usage: hal::TextureUse::UNINITIALIZED..hal::TextureUse::empty(),
usage: hal::TextureUses::COLOR_TARGET,
boundary_usage: hal::TextureUses::UNINITIALIZED..hal::TextureUses::empty(),
},
resolve_target: None,
ops: hal::AttachmentOps::STORE,

View File

@ -252,7 +252,7 @@ impl crate::CommandEncoder<Api> for Encoder {
unsafe fn copy_texture_to_texture<T>(
&mut self,
src: &Resource,
src_usage: crate::TextureUse,
src_usage: crate::TextureUses,
dst: &Resource,
regions: T,
) {
@ -263,7 +263,7 @@ impl crate::CommandEncoder<Api> for Encoder {
unsafe fn copy_texture_to_buffer<T>(
&mut self,
src: &Resource,
src_usage: crate::TextureUse,
src_usage: crate::TextureUses,
dst: &Resource,
regions: T,
) {

View File

@ -450,7 +450,7 @@ impl crate::Adapter<super::Api> for super::Adapter {
height: 4096,
depth_or_array_layers: 1,
},
usage: crate::TextureUse::COLOR_TARGET,
usage: crate::TextureUses::COLOR_TARGET,
})
} else {
None

View File

@ -196,7 +196,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
}
for bar in barriers {
// GLES only synchronizes storage -> anything explicitly
if !bar.usage.start.contains(crate::BufferUse::STORAGE_STORE) {
if !bar.usage.start.contains(crate::BufferUses::STORAGE_STORE) {
continue;
}
self.cmd_buffer
@ -216,10 +216,10 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
return;
}
let mut combined_usage = crate::TextureUse::empty();
let mut combined_usage = crate::TextureUses::empty();
for bar in barriers {
// GLES only synchronizes storage -> anything explicitly
if !bar.usage.start.contains(crate::TextureUse::STORAGE_STORE) {
if !bar.usage.start.contains(crate::TextureUses::STORAGE_STORE) {
continue;
}
// unlike buffers, there is no need for a concrete texture
@ -267,7 +267,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
unsafe fn copy_texture_to_texture<T>(
&mut self,
src: &super::Texture,
_src_usage: crate::TextureUse,
_src_usage: crate::TextureUses,
dst: &super::Texture,
regions: T,
) where
@ -310,7 +310,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
unsafe fn copy_texture_to_buffer<T>(
&mut self,
src: &super::Texture,
_src_usage: crate::TextureUse,
_src_usage: crate::TextureUses,
dst: &super::Buffer,
regions: T,
) where

View File

@ -300,7 +300,7 @@ impl crate::Device<super::Api> for super::Device {
) -> Result<super::Buffer, crate::DeviceError> {
let gl = &self.shared.context;
let target = if desc.usage.contains(crate::BufferUse::INDEX) {
let target = if desc.usage.contains(crate::BufferUses::INDEX) {
glow::ELEMENT_ARRAY_BUFFER
} else {
glow::ARRAY_BUFFER
@ -308,7 +308,7 @@ impl crate::Device<super::Api> for super::Device {
let is_host_visible = desc
.usage
.intersects(crate::BufferUse::MAP_READ | crate::BufferUse::MAP_WRITE);
.intersects(crate::BufferUses::MAP_READ | crate::BufferUses::MAP_WRITE);
let is_coherent = desc
.memory_flags
.contains(crate::MemoryFlags::PREFER_COHERENT);
@ -320,10 +320,10 @@ impl crate::Device<super::Api> for super::Device {
map_flags |= glow::MAP_COHERENT_BIT;
}
}
if desc.usage.contains(crate::BufferUse::MAP_READ) {
if desc.usage.contains(crate::BufferUses::MAP_READ) {
map_flags |= glow::MAP_READ_BIT;
}
if desc.usage.contains(crate::BufferUse::MAP_WRITE) {
if desc.usage.contains(crate::BufferUses::MAP_WRITE) {
map_flags |= glow::MAP_WRITE_BIT;
}
@ -336,7 +336,7 @@ impl crate::Device<super::Api> for super::Device {
gl.buffer_storage(target, raw_size, None, map_flags);
gl.bind_buffer(target, None);
if !is_coherent && desc.usage.contains(crate::BufferUse::MAP_WRITE) {
if !is_coherent && desc.usage.contains(crate::BufferUses::MAP_WRITE) {
map_flags |= glow::MAP_FLUSH_EXPLICIT_BIT;
}
//TODO: do we need `glow::MAP_UNSYNCHRONIZED_BIT`?
@ -413,9 +413,9 @@ impl crate::Device<super::Api> for super::Device {
) -> Result<super::Texture, crate::DeviceError> {
let gl = &self.shared.context;
let render_usage = crate::TextureUse::COLOR_TARGET
| crate::TextureUse::DEPTH_STENCIL_WRITE
| crate::TextureUse::DEPTH_STENCIL_READ;
let render_usage = crate::TextureUses::COLOR_TARGET
| crate::TextureUses::DEPTH_STENCIL_WRITE
| crate::TextureUses::DEPTH_STENCIL_READ;
let format_desc = self.shared.describe_texture_format(desc.format);
let inner = if render_usage.contains(desc.usage)

View File

@ -358,7 +358,7 @@ struct BlendDesc {
#[derive(Clone, Debug, Default, PartialEq)]
struct ColorTargetDesc {
mask: wgt::ColorWrite,
mask: wgt::ColorWrites,
blend: Option<BlendDesc>,
}
@ -565,8 +565,8 @@ enum Command {
ClearColorI(u32, [i32; 4]),
ClearDepth(f32),
ClearStencil(u32),
BufferBarrier(glow::Buffer, crate::BufferUse),
TextureBarrier(crate::TextureUse),
BufferBarrier(glow::Buffer, crate::BufferUses),
TextureBarrier(crate::TextureUses),
SetViewport {
rect: crate::Rect<i32>,
depth: Range<f32>,

View File

@ -599,35 +599,35 @@ impl super::Queue {
}
C::BufferBarrier(raw, usage) => {
let mut flags = 0;
if usage.contains(crate::BufferUse::VERTEX) {
if usage.contains(crate::BufferUses::VERTEX) {
flags |= glow::VERTEX_ATTRIB_ARRAY_BARRIER_BIT;
gl.bind_buffer(glow::ARRAY_BUFFER, Some(raw));
gl.vertex_attrib_pointer_f32(0, 1, glow::BYTE, true, 0, 0);
}
if usage.contains(crate::BufferUse::INDEX) {
if usage.contains(crate::BufferUses::INDEX) {
flags |= glow::ELEMENT_ARRAY_BARRIER_BIT;
gl.bind_buffer(glow::ELEMENT_ARRAY_BUFFER, Some(raw));
}
if usage.contains(crate::BufferUse::UNIFORM) {
if usage.contains(crate::BufferUses::UNIFORM) {
flags |= glow::UNIFORM_BARRIER_BIT;
}
if usage.contains(crate::BufferUse::INDIRECT) {
if usage.contains(crate::BufferUses::INDIRECT) {
flags |= glow::COMMAND_BARRIER_BIT;
gl.bind_buffer(glow::DRAW_INDIRECT_BUFFER, Some(raw));
}
if usage.contains(crate::BufferUse::COPY_SRC) {
if usage.contains(crate::BufferUses::COPY_SRC) {
flags |= glow::PIXEL_BUFFER_BARRIER_BIT;
gl.bind_buffer(glow::PIXEL_UNPACK_BUFFER, Some(raw));
}
if usage.contains(crate::BufferUse::COPY_DST) {
if usage.contains(crate::BufferUses::COPY_DST) {
flags |= glow::PIXEL_BUFFER_BARRIER_BIT;
gl.bind_buffer(glow::PIXEL_PACK_BUFFER, Some(raw));
}
if usage.intersects(crate::BufferUse::MAP_READ | crate::BufferUse::MAP_WRITE) {
if usage.intersects(crate::BufferUses::MAP_READ | crate::BufferUses::MAP_WRITE) {
flags |= glow::BUFFER_UPDATE_BARRIER_BIT;
}
if usage
.intersects(crate::BufferUse::STORAGE_LOAD | crate::BufferUse::STORAGE_STORE)
.intersects(crate::BufferUses::STORAGE_LOAD | crate::BufferUses::STORAGE_STORE)
{
flags |= glow::SHADER_STORAGE_BARRIER_BIT;
}
@ -635,21 +635,21 @@ impl super::Queue {
}
C::TextureBarrier(usage) => {
let mut flags = 0;
if usage.contains(crate::TextureUse::SAMPLED) {
if usage.contains(crate::TextureUses::SAMPLED) {
flags |= glow::TEXTURE_FETCH_BARRIER_BIT;
}
if usage
.intersects(crate::TextureUse::STORAGE_LOAD | crate::TextureUse::STORAGE_STORE)
{
if usage.intersects(
crate::TextureUses::STORAGE_LOAD | crate::TextureUses::STORAGE_STORE,
) {
flags |= glow::SHADER_IMAGE_ACCESS_BARRIER_BIT;
}
if usage.contains(crate::TextureUse::COPY_DST) {
if usage.contains(crate::TextureUses::COPY_DST) {
flags |= glow::TEXTURE_UPDATE_BARRIER_BIT;
}
if usage.intersects(
crate::TextureUse::COLOR_TARGET
| crate::TextureUse::DEPTH_STENCIL_READ
| crate::TextureUse::DEPTH_STENCIL_WRITE,
crate::TextureUses::COLOR_TARGET
| crate::TextureUses::DEPTH_STENCIL_READ
| crate::TextureUses::DEPTH_STENCIL_WRITE,
) {
flags |= glow::FRAMEBUFFER_BARRIER_BIT;
}
@ -797,7 +797,7 @@ impl super::Queue {
draw_buffer_index,
desc: super::ColorTargetDesc { mask, ref blend },
} => {
use wgt::ColorWrite as Cw;
use wgt::ColorWrites as Cw;
if let Some(index) = draw_buffer_index {
gl.color_mask_draw_buffer(
index,

View File

@ -201,7 +201,7 @@ pub trait Device<A: Api>: Send + Sync {
unsafe fn exit(self);
/// Creates a new buffer.
///
/// The initial usage is `BufferUse::empty()`.
/// The initial usage is `BufferUses::empty()`.
unsafe fn create_buffer(&self, desc: &BufferDescriptor) -> Result<A::Buffer, DeviceError>;
unsafe fn destroy_buffer(&self, buffer: A::Buffer);
//TODO: clarify if zero-sized mapping is allowed
@ -220,7 +220,7 @@ pub trait Device<A: Api>: Send + Sync {
/// Creates a new texture.
///
/// The initial usage for all subresources is `TextureUse::UNINITIALIZED`.
/// The initial usage for all subresources is `TextureUses::UNINITIALIZED`.
unsafe fn create_texture(&self, desc: &TextureDescriptor) -> Result<A::Texture, DeviceError>;
unsafe fn destroy_texture(&self, texture: A::Texture);
unsafe fn create_texture_view(
@ -345,17 +345,17 @@ pub trait CommandEncoder<A: Api>: Send + Sync {
where
T: Iterator<Item = BufferCopy>;
/// Note: `dst` current usage has to be `TextureUse::COPY_DST`.
/// Note: `dst` current usage has to be `TextureUses::COPY_DST`.
unsafe fn copy_texture_to_texture<T>(
&mut self,
src: &A::Texture,
src_usage: TextureUse,
src_usage: TextureUses,
dst: &A::Texture,
regions: T,
) where
T: Iterator<Item = TextureCopy>;
/// Note: `dst` current usage has to be `TextureUse::COPY_DST`.
/// Note: `dst` current usage has to be `TextureUses::COPY_DST`.
unsafe fn copy_buffer_to_texture<T>(&mut self, src: &A::Buffer, dst: &A::Texture, regions: T)
where
T: Iterator<Item = BufferTextureCopy>;
@ -363,7 +363,7 @@ pub trait CommandEncoder<A: Api>: Send + Sync {
unsafe fn copy_texture_to_buffer<T>(
&mut self,
src: &A::Texture,
src_usage: TextureUse,
src_usage: TextureUses,
dst: &A::Buffer,
regions: T,
) where
@ -570,8 +570,8 @@ bitflags!(
);
bitflags::bitflags! {
/// Similar to `wgt::BufferUsage` but for internal use.
pub struct BufferUse: u32 {
/// Similar to `wgt::BufferUsages` but for internal use.
pub struct BufferUses: u32 {
const MAP_READ = 1;
const MAP_WRITE = 2;
const COPY_SRC = 4;
@ -596,8 +596,8 @@ bitflags::bitflags! {
}
bitflags::bitflags! {
/// Similar to `wgt::TextureUsage` but for internal use.
pub struct TextureUse: u32 {
/// Similar to `wgt::TextureUsages` but for internal use.
pub struct TextureUses: u32 {
const COPY_SRC = 1;
const COPY_DST = 2;
const SAMPLED = 4;
@ -675,8 +675,8 @@ pub struct SurfaceCapabilities {
/// Supported texture usage flags.
///
/// Must have at least `TextureUse::COLOR_TARGET`
pub usage: TextureUse,
/// Must have at least `TextureUses::COLOR_TARGET`
pub usage: TextureUses,
/// List of supported V-sync modes.
///
@ -714,7 +714,7 @@ pub struct BufferMapping {
pub struct BufferDescriptor<'a> {
pub label: Label<'a>,
pub size: wgt::BufferAddress,
pub usage: BufferUse,
pub usage: BufferUses,
pub memory_flags: MemoryFlags,
}
@ -726,7 +726,7 @@ pub struct TextureDescriptor<'a> {
pub sample_count: u32,
pub dimension: wgt::TextureDimension,
pub format: wgt::TextureFormat,
pub usage: TextureUse,
pub usage: TextureUses,
pub memory_flags: MemoryFlags,
}
@ -742,7 +742,7 @@ pub struct TextureViewDescriptor<'a> {
pub label: Label<'a>,
pub format: wgt::TextureFormat,
pub dimension: wgt::TextureViewDimension,
pub usage: TextureUse,
pub usage: TextureUses,
pub range: wgt::ImageSubresourceRange,
}
@ -797,7 +797,7 @@ impl<A: Api> Clone for BufferBinding<'_, A> {
#[derive(Debug)]
pub struct TextureBinding<'a, A: Api> {
pub view: &'a A::TextureView,
pub usage: TextureUse,
pub usage: TextureUses,
}
// Rust gets confused about the impl requirements for `A`
@ -966,7 +966,7 @@ pub struct SurfaceConfiguration {
/// `SurfaceCapabilities::extents` range.
pub extent: wgt::Extent3d,
/// Allowed usage of surface textures,
pub usage: TextureUse,
pub usage: TextureUses,
}
#[derive(Debug, Clone)]
@ -980,14 +980,14 @@ pub struct Rect<T> {
#[derive(Debug, Clone)]
pub struct BufferBarrier<'a, A: Api> {
pub buffer: &'a A::Buffer,
pub usage: Range<BufferUse>,
pub usage: Range<BufferUses>,
}
#[derive(Debug, Clone)]
pub struct TextureBarrier<'a, A: Api> {
pub texture: &'a A::Texture,
pub range: wgt::ImageSubresourceRange,
pub usage: Range<TextureUse>,
pub usage: Range<TextureUses>,
}
#[derive(Clone, Copy, Debug)]
@ -1023,11 +1023,11 @@ pub struct Attachment<'a, A: Api> {
pub view: &'a A::TextureView,
/// Contains either a single mutating usage as a target, or a valid combination
/// of read-only usages.
pub usage: TextureUse,
pub usage: TextureUses,
/// Defines the boundary usages for the attachment.
/// It is expected to begin a render pass with `boundary_usage.start` usage,
/// and will end it with `boundary_usage.end` usage.
pub boundary_usage: Range<TextureUse>,
pub boundary_usage: Range<TextureUses>,
}
// Rust gets confused about the impl requirements for `A`

View File

@ -309,7 +309,7 @@ impl crate::Adapter<super::Api> for super::Adapter {
height: 4096,
depth_or_array_layers: 1,
},
usage: crate::TextureUse::COLOR_TARGET, //TODO: expose more
usage: crate::TextureUses::COLOR_TARGET, //TODO: expose more
})
}
}

View File

@ -148,7 +148,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
unsafe fn copy_texture_to_texture<T>(
&mut self,
src: &super::Texture,
_src_usage: crate::TextureUse,
_src_usage: crate::TextureUses,
dst: &super::Texture,
regions: T,
) where
@ -216,7 +216,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
unsafe fn copy_texture_to_buffer<T>(
&mut self,
src: &super::Texture,
_src_usage: crate::TextureUse,
_src_usage: crate::TextureUses,
dst: &super::Buffer,
regions: T,
) where

View File

@ -1,5 +1,5 @@
pub fn map_texture_usage(usage: crate::TextureUse) -> mtl::MTLTextureUsage {
use crate::TextureUse as Tu;
pub fn map_texture_usage(usage: crate::TextureUses) -> mtl::MTLTextureUsage {
use crate::TextureUses as Tu;
let mut mtl_usage = mtl::MTLTextureUsage::Unknown;
@ -104,19 +104,19 @@ pub fn map_primitive_topology(
}
}
pub fn map_color_write(mask: wgt::ColorWrite) -> mtl::MTLColorWriteMask {
pub fn map_color_write(mask: wgt::ColorWrites) -> mtl::MTLColorWriteMask {
let mut raw_mask = mtl::MTLColorWriteMask::empty();
if mask.contains(wgt::ColorWrite::RED) {
if mask.contains(wgt::ColorWrites::RED) {
raw_mask |= mtl::MTLColorWriteMask::Red;
}
if mask.contains(wgt::ColorWrite::GREEN) {
if mask.contains(wgt::ColorWrites::GREEN) {
raw_mask |= mtl::MTLColorWriteMask::Green;
}
if mask.contains(wgt::ColorWrite::BLUE) {
if mask.contains(wgt::ColorWrites::BLUE) {
raw_mask |= mtl::MTLColorWriteMask::Blue;
}
if mask.contains(wgt::ColorWrite::ALPHA) {
if mask.contains(wgt::ColorWrites::ALPHA) {
raw_mask |= mtl::MTLColorWriteMask::Alpha;
}

View File

@ -135,8 +135,8 @@ impl crate::Device<super::Api> for super::Device {
unsafe fn exit(self) {}
unsafe fn create_buffer(&self, desc: &crate::BufferDescriptor) -> DeviceResult<super::Buffer> {
let map_read = desc.usage.contains(crate::BufferUse::MAP_READ);
let map_write = desc.usage.contains(crate::BufferUse::MAP_WRITE);
let map_read = desc.usage.contains(crate::BufferUses::MAP_READ);
let map_write = desc.usage.contains(crate::BufferUses::MAP_WRITE);
let mut options = mtl::MTLResourceOptions::empty();
options |= if map_read || map_write {

View File

@ -172,7 +172,7 @@ impl crate::Surface<super::Api> for super::Surface {
self.raw_swapchain_format = caps.map_format(config.format);
let render_layer = self.render_layer.lock();
let framebuffer_only = config.usage == crate::TextureUse::COLOR_TARGET;
let framebuffer_only = config.usage == crate::TextureUses::COLOR_TARGET;
let display_sync = config.present_mode != wgt::PresentMode::Immediate;
let drawable_size = CGSize::new(config.extent.width as f64, config.extent.height as f64);

View File

@ -219,7 +219,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
unsafe fn copy_texture_to_texture<T>(
&mut self,
src: &super::Texture,
src_usage: crate::TextureUse,
src_usage: crate::TextureUses,
dst: &super::Texture,
regions: T,
) where
@ -278,7 +278,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
unsafe fn copy_texture_to_buffer<T>(
&mut self,
src: &super::Texture,
src_usage: crate::TextureUse,
src_usage: crate::TextureUses,
dst: &super::Buffer,
regions: T,
) where
@ -746,7 +746,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
#[test]
fn check_dst_image_layout() {
assert_eq!(
conv::derive_image_layout(crate::TextureUse::COPY_DST, crate::FormatAspects::empty()),
conv::derive_image_layout(crate::TextureUses::COPY_DST, crate::FormatAspects::empty()),
DST_IMAGE_LAYOUT
);
}

View File

@ -154,18 +154,20 @@ impl crate::ColorAttachment<'_, super::Api> {
}
pub fn derive_image_layout(
usage: crate::TextureUse,
usage: crate::TextureUses,
aspects: crate::FormatAspects,
) -> vk::ImageLayout {
//Note: depth textures are always sampled with RODS layout
let is_color = aspects.contains(crate::FormatAspects::COLOR);
match usage {
crate::TextureUse::UNINITIALIZED => vk::ImageLayout::UNDEFINED,
crate::TextureUse::COPY_SRC => vk::ImageLayout::TRANSFER_SRC_OPTIMAL,
crate::TextureUse::COPY_DST => vk::ImageLayout::TRANSFER_DST_OPTIMAL,
crate::TextureUse::SAMPLED if is_color => vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL,
crate::TextureUse::COLOR_TARGET => vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
crate::TextureUse::DEPTH_STENCIL_WRITE => vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
crate::TextureUses::UNINITIALIZED => vk::ImageLayout::UNDEFINED,
crate::TextureUses::COPY_SRC => vk::ImageLayout::TRANSFER_SRC_OPTIMAL,
crate::TextureUses::COPY_DST => vk::ImageLayout::TRANSFER_DST_OPTIMAL,
crate::TextureUses::SAMPLED if is_color => vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL,
crate::TextureUses::COLOR_TARGET => vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
crate::TextureUses::DEPTH_STENCIL_WRITE => {
vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL
}
_ => {
if usage.is_empty() {
vk::ImageLayout::PRESENT_SRC_KHR
@ -178,33 +180,33 @@ pub fn derive_image_layout(
}
}
pub fn map_texture_usage(usage: crate::TextureUse) -> vk::ImageUsageFlags {
pub fn map_texture_usage(usage: crate::TextureUses) -> vk::ImageUsageFlags {
let mut flags = vk::ImageUsageFlags::empty();
if usage.contains(crate::TextureUse::COPY_SRC) {
if usage.contains(crate::TextureUses::COPY_SRC) {
flags |= vk::ImageUsageFlags::TRANSFER_SRC;
}
if usage.contains(crate::TextureUse::COPY_DST) {
if usage.contains(crate::TextureUses::COPY_DST) {
flags |= vk::ImageUsageFlags::TRANSFER_DST;
}
if usage.contains(crate::TextureUse::SAMPLED) {
if usage.contains(crate::TextureUses::SAMPLED) {
flags |= vk::ImageUsageFlags::SAMPLED;
}
if usage.contains(crate::TextureUse::COLOR_TARGET) {
if usage.contains(crate::TextureUses::COLOR_TARGET) {
flags |= vk::ImageUsageFlags::COLOR_ATTACHMENT;
}
if usage
.intersects(crate::TextureUse::DEPTH_STENCIL_READ | crate::TextureUse::DEPTH_STENCIL_WRITE)
{
if usage.intersects(
crate::TextureUses::DEPTH_STENCIL_READ | crate::TextureUses::DEPTH_STENCIL_WRITE,
) {
flags |= vk::ImageUsageFlags::DEPTH_STENCIL_ATTACHMENT;
}
if usage.intersects(crate::TextureUse::STORAGE_LOAD | crate::TextureUse::STORAGE_STORE) {
if usage.intersects(crate::TextureUses::STORAGE_LOAD | crate::TextureUses::STORAGE_STORE) {
flags |= vk::ImageUsageFlags::STORAGE;
}
flags
}
pub fn map_texture_usage_to_barrier(
usage: crate::TextureUse,
usage: crate::TextureUses,
) -> (vk::PipelineStageFlags, vk::AccessFlags) {
let mut stages = vk::PipelineStageFlags::empty();
let mut access = vk::AccessFlags::empty();
@ -212,43 +214,43 @@ pub fn map_texture_usage_to_barrier(
| vk::PipelineStageFlags::FRAGMENT_SHADER
| vk::PipelineStageFlags::COMPUTE_SHADER;
if usage.contains(crate::TextureUse::COPY_SRC) {
if usage.contains(crate::TextureUses::COPY_SRC) {
stages |= vk::PipelineStageFlags::TRANSFER;
access |= vk::AccessFlags::TRANSFER_READ;
}
if usage.contains(crate::TextureUse::COPY_DST) {
if usage.contains(crate::TextureUses::COPY_DST) {
stages |= vk::PipelineStageFlags::TRANSFER;
access |= vk::AccessFlags::TRANSFER_WRITE;
}
if usage.contains(crate::TextureUse::SAMPLED) {
if usage.contains(crate::TextureUses::SAMPLED) {
stages |= shader_stages;
access |= vk::AccessFlags::SHADER_READ;
}
if usage.contains(crate::TextureUse::COLOR_TARGET) {
if usage.contains(crate::TextureUses::COLOR_TARGET) {
stages |= vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT;
access |= vk::AccessFlags::COLOR_ATTACHMENT_READ | vk::AccessFlags::COLOR_ATTACHMENT_WRITE;
}
if usage.intersects(crate::TextureUse::DEPTH_STENCIL_READ) {
if usage.intersects(crate::TextureUses::DEPTH_STENCIL_READ) {
stages |= vk::PipelineStageFlags::EARLY_FRAGMENT_TESTS
| vk::PipelineStageFlags::LATE_FRAGMENT_TESTS;
access |= vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ;
}
if usage.intersects(crate::TextureUse::DEPTH_STENCIL_WRITE) {
if usage.intersects(crate::TextureUses::DEPTH_STENCIL_WRITE) {
stages |= vk::PipelineStageFlags::EARLY_FRAGMENT_TESTS
| vk::PipelineStageFlags::LATE_FRAGMENT_TESTS;
access |= vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ
| vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE;
}
if usage.contains(crate::TextureUse::STORAGE_LOAD) {
if usage.contains(crate::TextureUses::STORAGE_LOAD) {
stages |= shader_stages;
access |= vk::AccessFlags::SHADER_READ;
}
if usage.contains(crate::TextureUse::STORAGE_STORE) {
if usage.contains(crate::TextureUses::STORAGE_STORE) {
stages |= shader_stages;
access |= vk::AccessFlags::SHADER_WRITE;
}
if usage == crate::TextureUse::UNINITIALIZED {
if usage == crate::TextureUses::UNINITIALIZED {
(
vk::PipelineStageFlags::TOP_OF_PIPE,
vk::AccessFlags::empty(),
@ -258,25 +260,25 @@ pub fn map_texture_usage_to_barrier(
}
}
pub fn map_vk_image_usage(usage: vk::ImageUsageFlags) -> crate::TextureUse {
let mut bits = crate::TextureUse::empty();
pub fn map_vk_image_usage(usage: vk::ImageUsageFlags) -> crate::TextureUses {
let mut bits = crate::TextureUses::empty();
if usage.contains(vk::ImageUsageFlags::TRANSFER_SRC) {
bits |= crate::TextureUse::COPY_SRC;
bits |= crate::TextureUses::COPY_SRC;
}
if usage.contains(vk::ImageUsageFlags::TRANSFER_DST) {
bits |= crate::TextureUse::COPY_DST;
bits |= crate::TextureUses::COPY_DST;
}
if usage.contains(vk::ImageUsageFlags::SAMPLED) {
bits |= crate::TextureUse::SAMPLED;
bits |= crate::TextureUses::SAMPLED;
}
if usage.contains(vk::ImageUsageFlags::COLOR_ATTACHMENT) {
bits |= crate::TextureUse::COLOR_TARGET;
bits |= crate::TextureUses::COLOR_TARGET;
}
if usage.contains(vk::ImageUsageFlags::DEPTH_STENCIL_ATTACHMENT) {
bits |= crate::TextureUse::DEPTH_STENCIL_READ | crate::TextureUse::DEPTH_STENCIL_WRITE;
bits |= crate::TextureUses::DEPTH_STENCIL_READ | crate::TextureUses::DEPTH_STENCIL_WRITE;
}
if usage.contains(vk::ImageUsageFlags::STORAGE) {
bits |= crate::TextureUse::STORAGE_LOAD | crate::TextureUse::STORAGE_STORE;
bits |= crate::TextureUses::STORAGE_LOAD | crate::TextureUses::STORAGE_STORE;
}
bits
}
@ -449,34 +451,34 @@ pub fn map_vk_composite_alpha(flags: vk::CompositeAlphaFlagsKHR) -> Vec<crate::C
modes
}
pub fn map_buffer_usage(usage: crate::BufferUse) -> vk::BufferUsageFlags {
pub fn map_buffer_usage(usage: crate::BufferUses) -> vk::BufferUsageFlags {
let mut flags = vk::BufferUsageFlags::empty();
if usage.contains(crate::BufferUse::COPY_SRC) {
if usage.contains(crate::BufferUses::COPY_SRC) {
flags |= vk::BufferUsageFlags::TRANSFER_SRC;
}
if usage.contains(crate::BufferUse::COPY_DST) {
if usage.contains(crate::BufferUses::COPY_DST) {
flags |= vk::BufferUsageFlags::TRANSFER_DST;
}
if usage.contains(crate::BufferUse::UNIFORM) {
if usage.contains(crate::BufferUses::UNIFORM) {
flags |= vk::BufferUsageFlags::UNIFORM_BUFFER;
}
if usage.intersects(crate::BufferUse::STORAGE_LOAD | crate::BufferUse::STORAGE_STORE) {
if usage.intersects(crate::BufferUses::STORAGE_LOAD | crate::BufferUses::STORAGE_STORE) {
flags |= vk::BufferUsageFlags::STORAGE_BUFFER;
}
if usage.contains(crate::BufferUse::INDEX) {
if usage.contains(crate::BufferUses::INDEX) {
flags |= vk::BufferUsageFlags::INDEX_BUFFER;
}
if usage.contains(crate::BufferUse::VERTEX) {
if usage.contains(crate::BufferUses::VERTEX) {
flags |= vk::BufferUsageFlags::VERTEX_BUFFER;
}
if usage.contains(crate::BufferUse::INDIRECT) {
if usage.contains(crate::BufferUses::INDIRECT) {
flags |= vk::BufferUsageFlags::INDIRECT_BUFFER;
}
flags
}
pub fn map_buffer_usage_to_barrier(
usage: crate::BufferUse,
usage: crate::BufferUses,
) -> (vk::PipelineStageFlags, vk::AccessFlags) {
let mut stages = vk::PipelineStageFlags::empty();
let mut access = vk::AccessFlags::empty();
@ -484,43 +486,43 @@ pub fn map_buffer_usage_to_barrier(
| vk::PipelineStageFlags::FRAGMENT_SHADER
| vk::PipelineStageFlags::COMPUTE_SHADER;
if usage.contains(crate::BufferUse::MAP_READ) {
if usage.contains(crate::BufferUses::MAP_READ) {
stages |= vk::PipelineStageFlags::HOST;
access |= vk::AccessFlags::HOST_READ;
}
if usage.contains(crate::BufferUse::MAP_WRITE) {
if usage.contains(crate::BufferUses::MAP_WRITE) {
stages |= vk::PipelineStageFlags::HOST;
access |= vk::AccessFlags::HOST_WRITE;
}
if usage.contains(crate::BufferUse::COPY_SRC) {
if usage.contains(crate::BufferUses::COPY_SRC) {
stages |= vk::PipelineStageFlags::TRANSFER;
access |= vk::AccessFlags::TRANSFER_READ;
}
if usage.contains(crate::BufferUse::COPY_DST) {
if usage.contains(crate::BufferUses::COPY_DST) {
stages |= vk::PipelineStageFlags::TRANSFER;
access |= vk::AccessFlags::TRANSFER_WRITE;
}
if usage.contains(crate::BufferUse::UNIFORM) {
if usage.contains(crate::BufferUses::UNIFORM) {
stages |= shader_stages;
access |= vk::AccessFlags::UNIFORM_READ;
}
if usage.intersects(crate::BufferUse::STORAGE_LOAD) {
if usage.intersects(crate::BufferUses::STORAGE_LOAD) {
stages |= shader_stages;
access |= vk::AccessFlags::SHADER_READ;
}
if usage.intersects(crate::BufferUse::STORAGE_STORE) {
if usage.intersects(crate::BufferUses::STORAGE_STORE) {
stages |= shader_stages;
access |= vk::AccessFlags::SHADER_WRITE;
}
if usage.contains(crate::BufferUse::INDEX) {
if usage.contains(crate::BufferUses::INDEX) {
stages |= vk::PipelineStageFlags::VERTEX_INPUT;
access |= vk::AccessFlags::INDEX_READ;
}
if usage.contains(crate::BufferUse::VERTEX) {
if usage.contains(crate::BufferUses::VERTEX) {
stages |= vk::PipelineStageFlags::VERTEX_INPUT;
access |= vk::AccessFlags::VERTEX_ATTRIBUTE_READ;
}
if usage.contains(crate::BufferUse::INDIRECT) {
if usage.contains(crate::BufferUses::INDIRECT) {
stages |= vk::PipelineStageFlags::VERTEX_INPUT;
access |= vk::AccessFlags::INDIRECT_COMMAND_READ;
}

View File

@ -554,17 +554,17 @@ impl crate::Device<super::Api> for super::Device {
let mut alloc_usage = if desc
.usage
.intersects(crate::BufferUse::MAP_READ | crate::BufferUse::MAP_WRITE)
.intersects(crate::BufferUses::MAP_READ | crate::BufferUses::MAP_WRITE)
{
let mut flags = gpu_alloc::UsageFlags::HOST_ACCESS;
//TODO: find a way to use `crate::MemoryFlags::PREFER_COHERENT`
flags.set(
gpu_alloc::UsageFlags::DOWNLOAD,
desc.usage.contains(crate::BufferUse::MAP_READ),
desc.usage.contains(crate::BufferUses::MAP_READ),
);
flags.set(
gpu_alloc::UsageFlags::UPLOAD,
desc.usage.contains(crate::BufferUse::MAP_WRITE),
desc.usage.contains(crate::BufferUses::MAP_WRITE),
);
flags
} else {

View File

@ -197,7 +197,7 @@ struct RenderPassKey {
struct FramebufferAttachment {
/// Can be NULL if the framebuffer is image-less
raw: vk::ImageView,
texture_usage: crate::TextureUse,
texture_usage: crate::TextureUses,
raw_image_flags: vk::ImageCreateFlags,
view_format: wgt::TextureFormat,
}
@ -247,7 +247,7 @@ pub struct Buffer {
pub struct Texture {
raw: vk::Image,
block: Option<gpu_alloc::MemoryBlock<vk::DeviceMemory>>,
usage: crate::TextureUse,
usage: crate::TextureUses,
dim: wgt::TextureDimension,
aspects: crate::FormatAspects,
format_info: wgt::TextureFormatInfo,

View File

@ -182,7 +182,7 @@ bitflags::bitflags! {
/// Compressed textures sacrifice some quality in exchange for significantly reduced
/// bandwidth usage.
///
/// Support for this feature guarantees availability of [`TextureUsage::COPY_SRC | TextureUsage::COPY_DST | TextureUsage::SAMPLED`] for BCn formats.
/// Support for this feature guarantees availability of [`TextureUsages::COPY_SRC | TextureUsages::COPY_DST | TextureUsages::SAMPLED`] for BCn formats.
/// [`Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES`] may enable additional usages.
///
/// Supported Platforms:
@ -388,7 +388,7 @@ bitflags::bitflags! {
/// Compressed textures sacrifice some quality in exchange for significantly reduced
/// bandwidth usage.
///
/// Support for this feature guarantees availability of [`TextureUsage::COPY_SRC | TextureUsage::COPY_DST | TextureUsage::SAMPLED`] for ETC2 formats.
/// Support for this feature guarantees availability of [`TextureUsages::COPY_SRC | TextureUsages::COPY_DST | TextureUsages::SAMPLED`] for ETC2 formats.
/// [`Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES`] may enable additional usages.
///
/// Supported Platforms:
@ -403,7 +403,7 @@ bitflags::bitflags! {
/// Compressed textures sacrifice some quality in exchange for significantly reduced
/// bandwidth usage.
///
/// Support for this feature guarantees availability of [`TextureUsage::COPY_SRC | TextureUsage::COPY_DST | TextureUsage::SAMPLED`] for ASTC formats.
/// Support for this feature guarantees availability of [`TextureUsages::COPY_SRC | TextureUsages::COPY_DST | TextureUsages::SAMPLED`] for ASTC formats.
/// [`Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES`] may enable additional usages.
///
/// Supported Platforms:
@ -958,7 +958,7 @@ pub struct ColorTargetState {
pub blend: Option<BlendState>,
/// Mask which enables/disables writes to different color/alpha channel.
#[cfg_attr(any(feature = "trace", feature = "replay"), serde(default))]
pub write_mask: ColorWrite,
pub write_mask: ColorWrites,
}
impl From<TextureFormat> for ColorTargetState {
@ -966,7 +966,7 @@ impl From<TextureFormat> for ColorTargetState {
Self {
format,
blend: None,
write_mask: ColorWrite::ALL,
write_mask: ColorWrites::ALL,
}
}
}
@ -1152,7 +1152,7 @@ bitflags::bitflags! {
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub struct TextureFormatFeatures {
/// Valid bits for `TextureDescriptor::Usage` provided for format creation.
pub allowed_usages: TextureUsage,
pub allowed_usages: TextureUsages,
/// Additional property flags for the format.
pub flags: TextureFormatFeatureFlags,
/// If `filterable` is false, the texture can't be sampled with a filtering sampler.
@ -1585,10 +1585,10 @@ impl TextureFormat {
let srgb = true;
// Flags
let basic = TextureUsage::COPY_SRC | TextureUsage::COPY_DST | TextureUsage::SAMPLED;
let attachment = basic | TextureUsage::RENDER_ATTACHMENT;
let storage = basic | TextureUsage::STORAGE;
let all_flags = TextureUsage::all();
let basic = TextureUsages::COPY_SRC | TextureUsages::COPY_DST | TextureUsages::SAMPLED;
let attachment = basic | TextureUsages::RENDER_ATTACHMENT;
let storage = basic | TextureUsages::STORAGE;
let all_flags = TextureUsages::all();
// See <https://gpuweb.github.io/gpuweb/#texture-format-caps> for reference
let (required_features, sample_type, srgb, block_dimensions, block_size, allowed_usages) =
@ -1724,7 +1724,7 @@ bitflags::bitflags! {
#[repr(transparent)]
#[cfg_attr(feature = "trace", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
pub struct ColorWrite: u32 {
pub struct ColorWrites: u32 {
/// Enable red channel writes
const RED = 1;
/// Enable green channel writes
@ -1740,7 +1740,7 @@ bitflags::bitflags! {
}
}
impl Default for ColorWrite {
impl Default for ColorWrites {
fn default() -> Self {
Self::ALL
}
@ -2106,7 +2106,7 @@ bitflags::bitflags! {
#[repr(transparent)]
#[cfg_attr(feature = "trace", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
pub struct BufferUsage: u32 {
pub struct BufferUsages: u32 {
/// Allow a buffer to be mapped for reading using [`Buffer::map_async`] + [`Buffer::get_mapped_range`].
/// This does not include creating a buffer with [`BufferDescriptor::mapped_at_creation`] set.
///
@ -2150,9 +2150,9 @@ pub struct BufferDescriptor<L> {
pub size: BufferAddress,
/// Usages of a buffer. If the buffer is used in any way that isn't specified here, the operation
/// will panic.
pub usage: BufferUsage,
/// Allows a buffer to be mapped immediately after they are made. It does not have to be [`BufferUsage::MAP_READ`] or
/// [`BufferUsage::MAP_WRITE`], all buffers are allowed to be mapped at creation.
pub usage: BufferUsages,
/// Allows a buffer to be mapped immediately after they are made. It does not have to be [`BufferUsages::MAP_READ`] or
/// [`BufferUsages::MAP_WRITE`], all buffers are allowed to be mapped at creation.
pub mapped_at_creation: bool,
}
@ -2223,7 +2223,7 @@ bitflags::bitflags! {
#[repr(transparent)]
#[cfg_attr(feature = "trace", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
pub struct TextureUsage: u32 {
pub struct TextureUsages: u32 {
/// Allows a texture to be the source in a [`CommandEncoder::copy_texture_to_buffer`] or
/// [`CommandEncoder::copy_texture_to_texture`] operation.
const COPY_SRC = 1;
@ -2246,7 +2246,7 @@ bitflags::bitflags! {
#[cfg_attr(feature = "replay", derive(Deserialize))]
pub struct SwapChainDescriptor {
/// The usage of the swap chain. The only supported usage is `RENDER_ATTACHMENT`.
pub usage: TextureUsage,
pub usage: TextureUsages,
/// The texture format of the swap chain. The only formats that are guaranteed are
/// `Bgra8Unorm` and `Bgra8UnormSrgb`
pub format: TextureFormat,
@ -2474,7 +2474,7 @@ pub struct TextureDescriptor<L> {
/// Format of the texture.
pub format: TextureFormat,
/// Allowed usages of the texture. If used in other ways, the operation will panic.
pub usage: TextureUsage,
pub usage: TextureUsages,
}
impl<L> TextureDescriptor<L> {
@ -2507,7 +2507,7 @@ impl<L> TextureDescriptor<L> {
/// sample_count: 1,
/// dimension: wgpu::TextureDimension::D3,
/// format: wgpu::TextureFormat::Rgba8Sint,
/// usage: wgpu::TextureUsage::empty(),
/// usage: wgpu::TextureUsages::empty(),
/// };
///
/// assert_eq!(desc.mip_level_size(0), Some(wgpu::Extent3d { width: 100, height: 60, depth_or_array_layers: 1 }));

View File

@ -62,7 +62,7 @@ impl framework::Example for Example {
let sim_param_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Simulation Parameter Buffer"),
contents: bytemuck::cast_slice(&sim_param_data),
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
});
// create compute bind layout group and compute pipeline layout
@ -165,7 +165,7 @@ impl framework::Example for Example {
let vertices_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Vertex Buffer"),
contents: bytemuck::bytes_of(&vertex_buffer_data),
usage: wgpu::BufferUsage::VERTEX | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::VERTEX | wgpu::BufferUsages::COPY_DST,
});
// buffer for all particles data of type [(posx,posy,velx,vely),...]
@ -190,9 +190,9 @@ impl framework::Example for Example {
device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some(&format!("Particle Buffer {}", i)),
contents: bytemuck::cast_slice(&initial_particle_data),
usage: wgpu::BufferUsage::VERTEX
| wgpu::BufferUsage::STORAGE
| wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::VERTEX
| wgpu::BufferUsages::STORAGE
| wgpu::BufferUsages::COPY_DST,
}),
);
}

View File

@ -120,7 +120,7 @@ impl framework::Example for Example {
targets: &[wgpu::ColorTargetState {
format: sc_desc.format,
blend: Some(wgpu::BlendState::ALPHA_BLENDING),
write_mask: wgpu::ColorWrite::default(),
write_mask: wgpu::ColorWrites::default(),
}],
}),
primitive: wgpu::PrimitiveState {
@ -150,7 +150,7 @@ impl framework::Example for Example {
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Rgba8UnormSrgb,
usage: wgpu::TextureUsage::COPY_DST | wgpu::TextureUsage::SAMPLED,
usage: wgpu::TextureUsages::COPY_DST | wgpu::TextureUsages::SAMPLED,
});
queue.write_texture(
texture.as_image_copy(),
@ -192,12 +192,12 @@ impl framework::Example for Example {
let global_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("global"),
contents: bytemuck::bytes_of(&globals),
usage: wgpu::BufferUsage::COPY_DST | wgpu::BufferUsage::UNIFORM,
usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::UNIFORM,
});
let local_buffer = device.create_buffer(&wgpu::BufferDescriptor {
label: Some("local"),
size: (MAX_BUNNIES as wgpu::BufferAddress) * wgpu::BIND_BUFFER_ALIGNMENT,
usage: wgpu::BufferUsage::COPY_DST | wgpu::BufferUsage::UNIFORM,
usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::UNIFORM,
mapped_at_creation: false,
});

View File

@ -54,7 +54,7 @@ async fn create_red_image_with_dimensions(
let output_buffer = device.create_buffer(&wgpu::BufferDescriptor {
label: None,
size: (buffer_dimensions.padded_bytes_per_row * buffer_dimensions.height) as u64,
usage: wgpu::BufferUsage::MAP_READ | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::MAP_READ | wgpu::BufferUsages::COPY_DST,
mapped_at_creation: false,
});
@ -71,7 +71,7 @@ async fn create_red_image_with_dimensions(
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Rgba8UnormSrgb,
usage: wgpu::TextureUsage::RENDER_ATTACHMENT | wgpu::TextureUsage::COPY_SRC,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_SRC,
label: None,
});

View File

@ -34,7 +34,7 @@ impl Example {
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: RENDER_TARGET_FORMAT,
usage: wgpu::TextureUsage::SAMPLED | wgpu::TextureUsage::RENDER_ATTACHMENT,
usage: wgpu::TextureUsages::SAMPLED | wgpu::TextureUsages::RENDER_ATTACHMENT,
})
.create_view(&Default::default());

View File

@ -124,13 +124,13 @@ impl framework::Example for Example {
let vertex_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Vertex Buffer"),
contents: bytemuck::cast_slice(&vertex_data),
usage: wgpu::BufferUsage::VERTEX,
usage: wgpu::BufferUsages::VERTEX,
});
let index_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Index Buffer"),
contents: bytemuck::cast_slice(&index_data),
usage: wgpu::BufferUsage::INDEX,
usage: wgpu::BufferUsages::INDEX,
});
// Create pipeline layout
@ -180,7 +180,7 @@ impl framework::Example for Example {
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::R8Uint,
usage: wgpu::TextureUsage::SAMPLED | wgpu::TextureUsage::COPY_DST,
usage: wgpu::TextureUsages::SAMPLED | wgpu::TextureUsages::COPY_DST,
});
let texture_view = texture.create_view(&wgpu::TextureViewDescriptor::default());
queue.write_texture(
@ -200,7 +200,7 @@ impl framework::Example for Example {
let uniform_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Uniform Buffer"),
contents: bytemuck::cast_slice(mx_ref),
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
});
// Create bind group
@ -287,7 +287,7 @@ impl framework::Example for Example {
},
alpha: wgpu::BlendComponent::REPLACE,
}),
write_mask: wgpu::ColorWrite::ALL,
write_mask: wgpu::ColorWrites::ALL,
}],
}),
primitive: wgpu::PrimitiveState {

View File

@ -178,7 +178,7 @@ fn start<E: Example>(
) {
let spawner = Spawner::new();
let mut sc_desc = wgpu::SwapChainDescriptor {
usage: wgpu::TextureUsage::RENDER_ATTACHMENT,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
format: adapter.get_swap_chain_preferred_format(&surface).unwrap(),
width: size.width,
height: size.height,
@ -407,7 +407,7 @@ pub fn test<E: Example>(mut params: FrameworkRefTest) {
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Rgba8UnormSrgb,
usage: wgpu::TextureUsage::RENDER_ATTACHMENT | wgpu::TextureUsage::COPY_SRC,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_SRC,
});
let dst_view = dst_texture.create_view(&wgpu::TextureViewDescriptor::default());
@ -415,13 +415,13 @@ pub fn test<E: Example>(mut params: FrameworkRefTest) {
let dst_buffer = ctx.device.create_buffer(&wgpu::BufferDescriptor {
label: Some("image map buffer"),
size: params.width as u64 * params.height as u64 * 4,
usage: wgpu::BufferUsage::COPY_DST | wgpu::BufferUsage::MAP_READ,
usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::MAP_READ,
mapped_at_creation: false,
});
let mut example = E::init(
&wgpu::SwapChainDescriptor {
usage: wgpu::TextureUsage::RENDER_ATTACHMENT,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
format: wgpu::TextureFormat::Rgba8UnormSrgb,
width: params.width,
height: params.height,

View File

@ -80,12 +80,12 @@ async fn execute_gpu_inner(
// Instantiates buffer without data.
// `usage` of buffer specifies how it can be used:
// `BufferUsage::MAP_READ` allows it to be read (outside the shader).
// `BufferUsage::COPY_DST` allows it to be the destination of the copy.
// `BufferUsages::MAP_READ` allows it to be read (outside the shader).
// `BufferUsages::COPY_DST` allows it to be the destination of the copy.
let staging_buffer = device.create_buffer(&wgpu::BufferDescriptor {
label: None,
size,
usage: wgpu::BufferUsage::MAP_READ | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::MAP_READ | wgpu::BufferUsages::COPY_DST,
mapped_at_creation: false,
});
@ -97,9 +97,9 @@ async fn execute_gpu_inner(
let storage_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Storage Buffer"),
contents: bytemuck::cast_slice(numbers),
usage: wgpu::BufferUsage::STORAGE
| wgpu::BufferUsage::COPY_DST
| wgpu::BufferUsage::COPY_SRC,
usage: wgpu::BufferUsages::STORAGE
| wgpu::BufferUsages::COPY_DST
| wgpu::BufferUsages::COPY_SRC,
});
// A bind group defines how buffers are accessed by shaders.

View File

@ -64,7 +64,7 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
});
let mut sc_desc = wgpu::SwapChainDescriptor {
usage: wgpu::TextureUsage::RENDER_ATTACHMENT,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
format: swapchain_format,
width: size.width,
height: size.height,

View File

@ -31,7 +31,7 @@ impl ViewportDesc {
let size = self.window.inner_size();
let sc_desc = wgpu::SwapChainDescriptor {
usage: wgpu::TextureUsage::RENDER_ATTACHMENT,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
format: adapter
.get_swap_chain_preferred_format(&self.surface)
.unwrap(),

View File

@ -225,9 +225,9 @@ impl framework::Example for Example {
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: TEXTURE_FORMAT,
usage: wgpu::TextureUsage::SAMPLED
| wgpu::TextureUsage::RENDER_ATTACHMENT
| wgpu::TextureUsage::COPY_DST,
usage: wgpu::TextureUsages::SAMPLED
| wgpu::TextureUsages::RENDER_ATTACHMENT
| wgpu::TextureUsages::COPY_DST,
label: None,
});
let texture_view = texture.create_view(&wgpu::TextureViewDescriptor::default());
@ -236,7 +236,7 @@ impl framework::Example for Example {
let temp_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Temporary Buffer"),
contents: texels.as_slice(),
usage: wgpu::BufferUsage::COPY_SRC,
usage: wgpu::BufferUsages::COPY_SRC,
});
init_encoder.copy_buffer_to_texture(
wgpu::ImageCopyBuffer {
@ -267,7 +267,7 @@ impl framework::Example for Example {
let uniform_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Uniform Buffer"),
contents: bytemuck::cast_slice(mx_ref),
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
});
// Create the render pipeline
@ -355,7 +355,7 @@ impl framework::Example for Example {
size: mip_passes as wgpu::BufferAddress
* 3
* mem::size_of::<u64>() as wgpu::BufferAddress,
usage: wgpu::BufferUsage::COPY_DST | wgpu::BufferUsage::MAP_READ,
usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::MAP_READ,
mapped_at_creation: false,
});

View File

@ -104,7 +104,7 @@ impl Example {
sample_count,
dimension: wgpu::TextureDimension::D2,
format: sc_desc.format,
usage: wgpu::TextureUsage::RENDER_ATTACHMENT,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
label: None,
};
@ -157,7 +157,7 @@ impl framework::Example for Example {
let vertex_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Vertex Buffer"),
contents: bytemuck::cast_slice(&vertex_data),
usage: wgpu::BufferUsage::VERTEX,
usage: wgpu::BufferUsages::VERTEX,
});
let vertex_count = vertex_data.len() as u32;

View File

@ -200,7 +200,7 @@ impl Example {
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: Self::DEPTH_FORMAT,
usage: wgpu::TextureUsage::RENDER_ATTACHMENT,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
label: None,
});
@ -226,7 +226,7 @@ impl framework::Example for Example {
&wgpu::util::BufferInitDescriptor {
label: Some("Cubes Vertex Buffer"),
contents: bytemuck::cast_slice(&cube_vertex_data),
usage: wgpu::BufferUsage::VERTEX,
usage: wgpu::BufferUsages::VERTEX,
},
));
@ -234,7 +234,7 @@ impl framework::Example for Example {
&wgpu::util::BufferInitDescriptor {
label: Some("Cubes Index Buffer"),
contents: bytemuck::cast_slice(&cube_index_data),
usage: wgpu::BufferUsage::INDEX,
usage: wgpu::BufferUsages::INDEX,
},
));
@ -242,13 +242,13 @@ impl framework::Example for Example {
let plane_vertex_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Plane Vertex Buffer"),
contents: bytemuck::cast_slice(&plane_vertex_data),
usage: wgpu::BufferUsage::VERTEX,
usage: wgpu::BufferUsages::VERTEX,
});
let plane_index_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Plane Index Buffer"),
contents: bytemuck::cast_slice(&plane_index_data),
usage: wgpu::BufferUsage::INDEX,
usage: wgpu::BufferUsages::INDEX,
});
struct CubeDesc {
@ -291,7 +291,7 @@ impl framework::Example for Example {
let entity_uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {
label: None,
size: num_entities * wgpu::BIND_BUFFER_ALIGNMENT,
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
mapped_at_creation: false,
});
@ -377,7 +377,7 @@ impl framework::Example for Example {
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: Self::SHADOW_FORMAT,
usage: wgpu::TextureUsage::RENDER_ATTACHMENT | wgpu::TextureUsage::SAMPLED,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::SAMPLED,
label: None,
});
let shadow_view = shadow_texture.create_view(&wgpu::TextureViewDescriptor::default());
@ -427,9 +427,9 @@ impl framework::Example for Example {
let light_storage_buf = device.create_buffer(&wgpu::BufferDescriptor {
label: None,
size: light_uniform_size,
usage: wgpu::BufferUsage::STORAGE
| wgpu::BufferUsage::COPY_SRC
| wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::STORAGE
| wgpu::BufferUsages::COPY_SRC
| wgpu::BufferUsages::COPY_DST,
mapped_at_creation: false,
});
@ -471,7 +471,7 @@ impl framework::Example for Example {
let uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {
label: None,
size: uniform_size,
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
mapped_at_creation: false,
});
@ -586,7 +586,7 @@ impl framework::Example for Example {
let uniform_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Uniform Buffer"),
contents: bytemuck::bytes_of(&forward_uniforms),
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
});
// Create bind group

View File

@ -86,7 +86,7 @@ impl Skybox {
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: Self::DEPTH_FORMAT,
usage: wgpu::TextureUsage::RENDER_ATTACHMENT,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
label: None,
});
@ -130,7 +130,7 @@ impl framework::Example for Skybox {
let vertex_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Vertex"),
contents: bytemuck::cast_slice(&vertices),
usage: wgpu::BufferUsage::VERTEX,
usage: wgpu::BufferUsages::VERTEX,
});
entities.push(Entity {
vertex_count: vertices.len() as u32,
@ -191,7 +191,7 @@ impl framework::Example for Skybox {
let uniform_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Buffer"),
contents: bytemuck::cast_slice(&raw_uniforms),
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
});
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
@ -324,7 +324,7 @@ impl framework::Example for Skybox {
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: skybox_format,
usage: wgpu::TextureUsage::SAMPLED | wgpu::TextureUsage::COPY_DST,
usage: wgpu::TextureUsages::SAMPLED | wgpu::TextureUsages::COPY_DST,
label: None,
},
&image.data,

View File

@ -112,14 +112,14 @@ impl framework::Example for Example {
let vertex_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Vertex Buffer"),
contents: bytemuck::cast_slice(&vertex_data),
usage: wgpu::BufferUsage::VERTEX,
usage: wgpu::BufferUsages::VERTEX,
});
let index_data = create_indices();
let index_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Index Buffer"),
contents: bytemuck::cast_slice(&index_data),
usage: wgpu::BufferUsage::INDEX,
usage: wgpu::BufferUsages::INDEX,
});
let red_texture_data = create_texture_data(Color::RED);
@ -131,7 +131,7 @@ impl framework::Example for Example {
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Rgba8UnormSrgb,
usage: wgpu::TextureUsage::SAMPLED | wgpu::TextureUsage::COPY_DST,
usage: wgpu::TextureUsages::SAMPLED | wgpu::TextureUsages::COPY_DST,
label: None,
};
let red_texture = device.create_texture(&wgpu::TextureDescriptor {

View File

@ -198,9 +198,9 @@ impl Example {
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: sc_desc.format,
usage: wgpu::TextureUsage::SAMPLED
| wgpu::TextureUsage::COPY_DST
| wgpu::TextureUsage::RENDER_ATTACHMENT,
usage: wgpu::TextureUsages::SAMPLED
| wgpu::TextureUsages::COPY_DST
| wgpu::TextureUsages::RENDER_ATTACHMENT,
});
let draw_depth_buffer = device.create_texture(&wgpu::TextureDescriptor {
@ -210,9 +210,9 @@ impl Example {
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Depth32Float,
usage: wgpu::TextureUsage::SAMPLED
| wgpu::TextureUsage::COPY_DST
| wgpu::TextureUsage::RENDER_ATTACHMENT,
usage: wgpu::TextureUsages::SAMPLED
| wgpu::TextureUsages::COPY_DST
| wgpu::TextureUsages::RENDER_ATTACHMENT,
});
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
@ -338,13 +338,13 @@ impl framework::Example for Example {
let water_vertex_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Water vertices"),
contents: bytemuck::cast_slice(&water_vertices),
usage: wgpu::BufferUsage::VERTEX,
usage: wgpu::BufferUsages::VERTEX,
});
let terrain_vertex_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Terrain vertices"),
contents: bytemuck::cast_slice(&terrain_vertices),
usage: wgpu::BufferUsage::VERTEX,
usage: wgpu::BufferUsages::VERTEX,
});
// Create the bind group layout. This is what our uniforms will look like.
@ -438,21 +438,21 @@ impl framework::Example for Example {
let water_uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {
label: Some("Water Uniforms"),
size: mem::size_of::<WaterUniforms>() as _,
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
mapped_at_creation: false,
});
let terrain_normal_uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {
label: Some("Normal Terrain Uniforms"),
size: mem::size_of::<TerrainUniforms>() as _,
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
mapped_at_creation: false,
});
let terrain_flipped_uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {
label: Some("Flipped Terrain Uniforms"),
size: mem::size_of::<TerrainUniforms>() as _,
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
mapped_at_creation: false,
});
@ -537,7 +537,7 @@ impl framework::Example for Example {
operation: wgpu::BlendOperation::Max,
},
}),
write_mask: wgpu::ColorWrite::ALL,
write_mask: wgpu::ColorWrites::ALL,
}],
}),
// How the triangles will be rasterized. This is more important

View File

@ -27,7 +27,7 @@ use parking_lot::Mutex;
pub use wgt::{
AdapterInfo, AddressMode, Backend, Backends, BindGroupLayoutEntry, BindingType, BlendComponent,
BlendFactor, BlendOperation, BlendState, BufferAddress, BufferBindingType, BufferSize,
BufferUsage, Color, ColorTargetState, ColorWrite, CommandBufferDescriptor, CompareFunction,
BufferUsages, Color, ColorTargetState, ColorWrites, CommandBufferDescriptor, CompareFunction,
DepthBiasState, DepthStencilState, DeviceType, DownlevelCapabilities, DownlevelFlags,
DynamicOffset, Extent3d, Face, Features, FilterMode, FrontFace, ImageDataLayout, IndexFormat,
InputStepMode, Limits, MultisampleState, Origin3d, PipelineStatisticsTypes, PolygonMode,
@ -35,7 +35,7 @@ pub use wgt::{
SamplerBorderColor, ShaderLocation, ShaderModel, ShaderStages, StencilFaceState,
StencilOperation, StencilState, StorageTextureAccess, SwapChainDescriptor, SwapChainStatus,
TextureAspect, TextureDimension, TextureFormat, TextureFormatFeatureFlags,
TextureFormatFeatures, TextureSampleType, TextureUsage, TextureViewDimension, VertexAttribute,
TextureFormatFeatures, TextureSampleType, TextureUsages, TextureViewDimension, VertexAttribute,
VertexFormat, BIND_BUFFER_ALIGNMENT, COPY_BUFFER_ALIGNMENT, COPY_BYTES_PER_ROW_ALIGNMENT,
MAP_ALIGNMENT, PUSH_CONSTANT_ALIGNMENT, QUERY_SET_MAX_QUERIES, QUERY_SIZE,
VERTEX_STRIDE_ALIGNMENT,
@ -591,7 +591,7 @@ pub struct Buffer {
context: Arc<C>,
id: <C as Context>::BufferId,
map_context: Mutex<MapContext>,
usage: BufferUsage,
usage: BufferUsages,
}
/// Slice into a [`Buffer`].
@ -1990,7 +1990,7 @@ impl<'a> BufferSlice<'a> {
BufferViewMut {
slice: *self,
data,
readable: self.buffer.usage.contains(BufferUsage::MAP_READ),
readable: self.buffer.usage.contains(BufferUsages::MAP_READ),
}
}
}

View File

@ -1,5 +1,5 @@
use crate::{
Buffer, BufferAddress, BufferDescriptor, BufferSize, BufferUsage, BufferViewMut,
Buffer, BufferAddress, BufferDescriptor, BufferSize, BufferUsages, BufferViewMut,
CommandEncoder, Device, MapMode,
};
use std::pin::Pin;
@ -116,7 +116,7 @@ impl StagingBelt {
buffer: device.create_buffer(&BufferDescriptor {
label: Some("staging"),
size,
usage: BufferUsage::MAP_WRITE | BufferUsage::COPY_SRC,
usage: BufferUsages::MAP_WRITE | BufferUsages::COPY_SRC,
mapped_at_creation: true,
}),
size,

View File

@ -9,7 +9,7 @@ pub struct BufferInitDescriptor<'a> {
pub contents: &'a [u8],
/// Usages of a buffer. If the buffer is used in any way that isn't specified here, the operation
/// will panic.
pub usage: crate::BufferUsage,
pub usage: crate::BufferUsages,
}
/// Utility methods not meant to be in the main API.

View File

@ -85,7 +85,7 @@ impl DownloadBuffer {
let download = device.create_buffer(&super::BufferDescriptor {
size,
usage: super::BufferUsage::COPY_DST | super::BufferUsage::MAP_READ,
usage: super::BufferUsages::COPY_DST | super::BufferUsages::MAP_READ,
mapped_at_creation: false,
label: None,
});

View File

@ -32,9 +32,9 @@ fn pulling_common(
let buffer = ctx.device.create_buffer(&wgpu::BufferDescriptor {
label: None,
size: 4 * expected.len() as u64,
usage: wgpu::BufferUsage::COPY_SRC
| wgpu::BufferUsage::STORAGE
| wgpu::BufferUsage::MAP_READ,
usage: wgpu::BufferUsages::COPY_SRC
| wgpu::BufferUsages::STORAGE
| wgpu::BufferUsages::MAP_READ,
mapped_at_creation: false,
});
@ -74,7 +74,7 @@ fn pulling_common(
targets: &[wgpu::ColorTargetState {
format: wgpu::TextureFormat::Rgba8Unorm,
blend: None,
write_mask: wgpu::ColorWrite::ALL,
write_mask: wgpu::ColorWrites::ALL,
}],
}),
});
@ -94,7 +94,7 @@ fn pulling_common(
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Rgba8Unorm,
usage: wgpu::TextureUsage::RENDER_ATTACHMENT | wgpu::TextureUsage::COPY_DST,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_DST,
},
&[0, 0, 0, 1],
)