Skip to content

Commit

Permalink
Merge #1576
Browse files Browse the repository at this point in the history
1576: Switch all bitflag names to plural r=cwfitzgerald a=kvark

**Connections**
#1471 added a lot of singular bitflag names. Previously, we weren't really consistent.

**Description**
This PR changes all of the names to be plural, except for a few that don't imply singularity, and are matching WebGPU upstream. Maybe we need to convert them too?

**Testing**
self-tested


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
  • Loading branch information
bors[bot] and kvark committed Jun 30, 2021
2 parents c9ab6d0 + ba006cf commit d8888cc
Show file tree
Hide file tree
Showing 74 changed files with 818 additions and 819 deletions.
7 changes: 2 additions & 5 deletions player/src/bin/play.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ fn main() {
.build(&event_loop)
.unwrap();

let global = wgc::hub::Global::new(
"player",
IdentityPassThroughFactory,
wgt::BackendBit::PRIMARY,
);
let global =
wgc::hub::Global::new("player", IdentityPassThroughFactory, wgt::Backends::PRIMARY);
let mut command_buffer_id_manager = wgc::hub::IdentityManager::default();

#[cfg(feature = "winit")]
Expand Down
2 changes: 1 addition & 1 deletion player/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl Test<'_> {

#[derive(serde::Deserialize)]
struct Corpus {
backends: wgt::BackendBit,
backends: wgt::Backends,
tests: Vec<String>,
}

Expand Down
38 changes: 19 additions & 19 deletions wgpu-core/src/binding_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ pub enum CreateBindGroupError {
#[derive(Clone, Debug, Error)]
pub enum BindingZone {
#[error("stage {0:?}")]
Stage(wgt::ShaderStage),
Stage(wgt::ShaderStages),
#[error("whole pipeline")]
Pipeline,
}
Expand Down Expand Up @@ -191,29 +191,29 @@ pub(crate) struct PerStageBindingTypeCounter {
}

impl PerStageBindingTypeCounter {
pub(crate) fn add(&mut self, stage: wgt::ShaderStage, count: u32) {
if stage.contains(wgt::ShaderStage::VERTEX) {
pub(crate) fn add(&mut self, stage: wgt::ShaderStages, count: u32) {
if stage.contains(wgt::ShaderStages::VERTEX) {
self.vertex += count;
}
if stage.contains(wgt::ShaderStage::FRAGMENT) {
if stage.contains(wgt::ShaderStages::FRAGMENT) {
self.fragment += count;
}
if stage.contains(wgt::ShaderStage::COMPUTE) {
if stage.contains(wgt::ShaderStages::COMPUTE) {
self.compute += count;
}
}

pub(crate) fn max(&self) -> (BindingZone, u32) {
let max_value = self.vertex.max(self.fragment.max(self.compute));
let mut stage = wgt::ShaderStage::NONE;
let mut stage = wgt::ShaderStages::NONE;
if max_value == self.vertex {
stage |= wgt::ShaderStage::VERTEX
stage |= wgt::ShaderStages::VERTEX
}
if max_value == self.fragment {
stage |= wgt::ShaderStage::FRAGMENT
stage |= wgt::ShaderStages::FRAGMENT
}
if max_value == self.compute {
stage |= wgt::ShaderStage::COMPUTE
stage |= wgt::ShaderStages::COMPUTE
}
(BindingZone::Stage(stage), max_value)
}
Expand Down Expand Up @@ -426,8 +426,8 @@ pub enum CreatePipelineLayoutError {
#[error("push constant range (index {index}) provides for stage(s) {provided:?} but there exists another range that provides stage(s) {intersected:?}. Each stage may only be provided by one range")]
MoreThanOnePushConstantRangePerStage {
index: usize,
provided: wgt::ShaderStage,
intersected: wgt::ShaderStage,
provided: wgt::ShaderStages,
intersected: wgt::ShaderStages,
},
#[error("push constant at index {index} has range {}..{} which exceeds device push constant size limit 0..{max}", range.start, range.end)]
PushConstantRangeTooLarge {
Expand All @@ -452,20 +452,20 @@ pub enum PushConstantUploadError {
},
#[error("provided push constant is for stage(s) {actual:?}, stage with a partial match found at index {idx} with stage(s) {matched:?}, however push constants must be complete matches")]
PartialRangeMatch {
actual: wgt::ShaderStage,
actual: wgt::ShaderStages,
idx: usize,
matched: wgt::ShaderStage,
matched: wgt::ShaderStages,
},
#[error("provided push constant is for stage(s) {actual:?}, but intersects a push constant range (at index {idx}) with stage(s) {missing:?}. Push constants must provide the stages for all ranges they intersect")]
MissingStages {
actual: wgt::ShaderStage,
actual: wgt::ShaderStages,
idx: usize,
missing: wgt::ShaderStage,
missing: wgt::ShaderStages,
},
#[error("provided push constant is for stage(s) {actual:?}, however the pipeline layout has no push constant range for the stage(s) {unmatched:?}")]
UnmatchedStages {
actual: wgt::ShaderStage,
unmatched: wgt::ShaderStage,
actual: wgt::ShaderStages,
unmatched: wgt::ShaderStages,
},
#[error("provided push constant offset {0} does not respect `PUSH_CONSTANT_ALIGNMENT`")]
Unaligned(u32),
Expand Down Expand Up @@ -504,7 +504,7 @@ impl<A: hal::Api> PipelineLayout<A> {
/// Validate push constants match up with expected ranges.
pub(crate) fn validate_push_constant_ranges(
&self,
stages: wgt::ShaderStage,
stages: wgt::ShaderStages,
offset: u32,
end_offset: u32,
) -> Result<(), PushConstantUploadError> {
Expand Down Expand Up @@ -535,7 +535,7 @@ impl<A: hal::Api> PipelineLayout<A> {
// when we check for 1, we can simply check that our entire updated range
// is within a push constant range. i.e. our range for a specific stage cannot
// intersect more than one push constant range.
let mut used_stages = wgt::ShaderStage::NONE;
let mut used_stages = wgt::ShaderStages::NONE;
for (idx, range) in self.push_constant_ranges.iter().enumerate() {
// contains not intersects due to 2
if stages.contains(range.stages) {
Expand Down
4 changes: 2 additions & 2 deletions wgpu-core/src/command/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl Binder {
}

struct PushConstantChange {
stages: wgt::ShaderStage,
stages: wgt::ShaderStages,
offset: u32,
enable: bool,
}
Expand Down Expand Up @@ -251,7 +251,7 @@ pub fn compute_nonoverlapping_ranges(

let mut output_ranges = ArrayVec::new();
let mut position = 0_u32;
let mut stages = wgt::ShaderStage::NONE;
let mut stages = wgt::ShaderStages::NONE;

for bk in breaks {
if bk.offset - position > 0 && !stages.is_empty() {
Expand Down
18 changes: 9 additions & 9 deletions wgpu-core/src/command/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -1221,7 +1221,7 @@ pub mod bundle_ffi {
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_bundle_set_push_constants(
pass: &mut RenderBundleEncoder,
stages: wgt::ShaderStage,
stages: wgt::ShaderStages,
offset: u32,
size_bytes: u32,
data: *const u8,
Expand Down
14 changes: 7 additions & 7 deletions wgpu-core/src/command/clear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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));
}

Expand Down Expand Up @@ -181,8 +181,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.map_err(|_| ClearError::InvalidTexture(dst))?;

// Check if subresource aspects are valid.
let requested_aspects = hal::FormatAspect::from(subresource_range.aspect);
let clear_aspects = hal::FormatAspect::from(dst_texture.desc.format) & requested_aspects;
let requested_aspects = hal::FormatAspects::from(subresource_range.aspect);
let clear_aspects = hal::FormatAspects::from(dst_texture.desc.format) & requested_aspects;
if clear_aspects.is_empty() {
return Err(ClearError::MissingTextureAspect {
texture_format: dst_texture.desc.format,
Expand Down Expand Up @@ -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)));
}

Expand Down
13 changes: 6 additions & 7 deletions wgpu-core/src/command/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use crate::{

use hal::CommandEncoder as _;
use thiserror::Error;
use wgt::{BufferAddress, BufferUsage, ShaderStage};

use std::{fmt, mem, str};

Expand Down Expand Up @@ -46,7 +45,7 @@ pub enum ComputeCommand {
Dispatch([u32; 3]),
DispatchIndirect {
buffer_id: id::BufferId,
offset: BufferAddress,
offset: wgt::BufferAddress,
},
PushDebugGroup {
color: u32,
Expand Down Expand Up @@ -430,7 +429,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|clear_offset, clear_data| unsafe {
raw.set_push_constants(
&pipeline_layout.raw,
wgt::ShaderStage::COMPUTE,
wgt::ShaderStages::COMPUTE,
clear_offset,
clear_data,
);
Expand Down Expand Up @@ -464,7 +463,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {

pipeline_layout
.validate_push_constant_ranges(
ShaderStage::COMPUTE,
wgt::ShaderStages::COMPUTE,
offset,
end_offset_bytes,
)
Expand All @@ -473,7 +472,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
unsafe {
raw.set_push_constants(
&pipeline_layout.raw,
wgt::ShaderStage::COMPUTE,
wgt::ShaderStages::COMPUTE,
offset,
data_slice,
);
Expand Down Expand Up @@ -514,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, 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;
Expand Down
4 changes: 2 additions & 2 deletions wgpu-core/src/command/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -149,7 +149,7 @@ pub enum RenderCommand {
},
SetScissor(Rect<u32>),
SetPushConstant {
stages: wgt::ShaderStage,
stages: wgt::ShaderStages,
offset: u32,
size_bytes: u32,
/// None means there is no data and the data should be an array of zeros.
Expand Down
4 changes: 2 additions & 2 deletions wgpu-core/src/command/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
Loading

0 comments on commit d8888cc

Please sign in to comment.