Rename InputStepMode to VertexStepMode

This commit is contained in:
Dzmitry Malyshau 2021-07-21 17:47:12 -04:00
parent d1068e915c
commit 1a9a855ea9
20 changed files with 52 additions and 51 deletions

View File

@ -7,7 +7,8 @@
- `cross` feature is removed entirely. Only Rust code from now on. - `cross` feature is removed entirely. Only Rust code from now on.
- processing SPIR-V inputs for later translation now requires `spirv` compile feature enabled - processing SPIR-V inputs for later translation now requires `spirv` compile feature enabled
- new `Features::SPIRV_SHADER_PASSTHROUGH` run-time feature allows providing pass-through SPIR-V (orthogonal to the compile feature) - new `Features::SPIRV_SHADER_PASSTHROUGH` run-time feature allows providing pass-through SPIR-V (orthogonal to the compile feature)
- Several bitflag names are renamed to plural: `TextureUsage`, `BufferUsage`, `ColorWrite`. - several bitflag names are renamed to plural: `TextureUsage`, `BufferUsage`, `ColorWrite`.
- renamed `InputStepMode` to `VertexStepMode`
- Fixed: - Fixed:
- `Device::create_query_set` would return an error when creating exactly `QUERY_SET_MAX_QUERIES` (8192) queries. Now it only returns an error when trying to create *more* than `QUERY_SET_MAX_QUERIES` queries. - `Device::create_query_set` would return an error when creating exactly `QUERY_SET_MAX_QUERIES` (8192) queries. Now it only returns an error when trying to create *more* than `QUERY_SET_MAX_QUERIES` queries.

View File

@ -833,7 +833,7 @@ struct VertexState {
buffer: Option<id::BufferId>, buffer: Option<id::BufferId>,
range: Range<wgt::BufferAddress>, range: Range<wgt::BufferAddress>,
stride: wgt::BufferAddress, stride: wgt::BufferAddress,
rate: wgt::InputStepMode, rate: wgt::VertexStepMode,
is_dirty: bool, is_dirty: bool,
} }
@ -843,7 +843,7 @@ impl VertexState {
buffer: None, buffer: None,
range: 0..0, range: 0..0,
stride: 0, stride: 0,
rate: wgt::InputStepMode::Vertex, rate: wgt::VertexStepMode::Vertex,
is_dirty: false, is_dirty: false,
} }
} }
@ -967,13 +967,13 @@ impl State {
} }
let limit = ((vbs.range.end - vbs.range.start) / vbs.stride) as u32; let limit = ((vbs.range.end - vbs.range.start) / vbs.stride) as u32;
match vbs.rate { match vbs.rate {
wgt::InputStepMode::Vertex => { wgt::VertexStepMode::Vertex => {
if limit < vert_state.vertex_limit { if limit < vert_state.vertex_limit {
vert_state.vertex_limit = limit; vert_state.vertex_limit = limit;
vert_state.vertex_limit_slot = idx as _; vert_state.vertex_limit_slot = idx as _;
} }
} }
wgt::InputStepMode::Instance => { wgt::VertexStepMode::Instance => {
if limit < vert_state.instance_limit { if limit < vert_state.instance_limit {
vert_state.instance_limit = limit; vert_state.instance_limit = limit;
vert_state.instance_limit_slot = idx as _; vert_state.instance_limit_slot = idx as _;
@ -1013,7 +1013,7 @@ impl State {
fn set_pipeline( fn set_pipeline(
&mut self, &mut self,
index_format: Option<wgt::IndexFormat>, index_format: Option<wgt::IndexFormat>,
vertex_strides: &[(wgt::BufferAddress, wgt::InputStepMode)], vertex_strides: &[(wgt::BufferAddress, wgt::VertexStepMode)],
layout_ids: &[id::Valid<id::BindGroupLayoutId>], layout_ids: &[id::Valid<id::BindGroupLayoutId>],
push_constant_layouts: &[wgt::PushConstantRange], push_constant_layouts: &[wgt::PushConstantRange],
) { ) {

View File

@ -27,7 +27,7 @@ use arrayvec::ArrayVec;
use hal::CommandEncoder as _; use hal::CommandEncoder as _;
use thiserror::Error; use thiserror::Error;
use wgt::{ use wgt::{
BufferAddress, BufferSize, BufferUsages, Color, IndexFormat, InputStepMode, TextureUsages, BufferAddress, BufferSize, BufferUsages, Color, IndexFormat, TextureUsages, VertexStepMode,
}; };
#[cfg(any(feature = "serial-pass", feature = "replay"))] #[cfg(any(feature = "serial-pass", feature = "replay"))]
@ -263,7 +263,7 @@ impl IndexState {
struct VertexBufferState { struct VertexBufferState {
total_size: BufferAddress, total_size: BufferAddress,
stride: BufferAddress, stride: BufferAddress,
rate: InputStepMode, rate: VertexStepMode,
bound: bool, bound: bool,
} }
@ -271,7 +271,7 @@ impl VertexBufferState {
const EMPTY: Self = VertexBufferState { const EMPTY: Self = VertexBufferState {
total_size: 0, total_size: 0,
stride: 0, stride: 0,
rate: InputStepMode::Vertex, rate: VertexStepMode::Vertex,
bound: false, bound: false,
}; };
} }
@ -301,13 +301,13 @@ impl VertexState {
} }
let limit = (vbs.total_size / vbs.stride) as u32; let limit = (vbs.total_size / vbs.stride) as u32;
match vbs.rate { match vbs.rate {
InputStepMode::Vertex => { VertexStepMode::Vertex => {
if limit < self.vertex_limit { if limit < self.vertex_limit {
self.vertex_limit = limit; self.vertex_limit = limit;
self.vertex_limit_slot = idx as _; self.vertex_limit_slot = idx as _;
} }
} }
InputStepMode::Instance => { VertexStepMode::Instance => {
if limit < self.instance_limit { if limit < self.instance_limit {
self.instance_limit = limit; self.instance_limit = limit;
self.instance_limit_slot = idx as _; self.instance_limit_slot = idx as _;
@ -1084,7 +1084,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
} }
for vbs in state.vertex.inputs.iter_mut().skip(vertex_strides_len) { for vbs in state.vertex.inputs.iter_mut().skip(vertex_strides_len) {
vbs.stride = 0; vbs.stride = 0;
vbs.rate = InputStepMode::Vertex; vbs.rate = VertexStepMode::Vertex;
} }
state.vertex.update_limits(); state.vertex.update_limits();
} }

View File

@ -137,7 +137,7 @@ pub struct VertexBufferLayout<'a> {
/// The stride, in bytes, between elements of this buffer. /// The stride, in bytes, between elements of this buffer.
pub array_stride: wgt::BufferAddress, pub array_stride: wgt::BufferAddress,
/// How often this vertex buffer is "stepped" forward. /// How often this vertex buffer is "stepped" forward.
pub step_mode: wgt::InputStepMode, pub step_mode: wgt::VertexStepMode,
/// The list of attributes which comprise a single vertex. /// The list of attributes which comprise a single vertex.
pub attributes: Cow<'a, [wgt::VertexAttribute]>, pub attributes: Cow<'a, [wgt::VertexAttribute]>,
} }
@ -287,7 +287,7 @@ pub struct RenderPipeline<A: hal::Api> {
pub(crate) pass_context: RenderPassContext, pub(crate) pass_context: RenderPassContext,
pub(crate) flags: PipelineFlags, pub(crate) flags: PipelineFlags,
pub(crate) strip_index_format: Option<wgt::IndexFormat>, pub(crate) strip_index_format: Option<wgt::IndexFormat>,
pub(crate) vertex_strides: Vec<(wgt::BufferAddress, wgt::InputStepMode)>, pub(crate) vertex_strides: Vec<(wgt::BufferAddress, wgt::VertexStepMode)>,
pub(crate) life_guard: LifeGuard, pub(crate) life_guard: LifeGuard,
} }

View File

@ -1431,10 +1431,10 @@ impl crate::Device<super::Api> for super::Device {
{ {
*stride = NonZeroU32::new(vbuf.array_stride as u32); *stride = NonZeroU32::new(vbuf.array_stride as u32);
let (slot_class, step_rate) = match vbuf.step_mode { let (slot_class, step_rate) = match vbuf.step_mode {
wgt::InputStepMode::Vertex => { wgt::VertexStepMode::Vertex => {
(d3d12::D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0) (d3d12::D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0)
} }
wgt::InputStepMode::Instance => { wgt::VertexStepMode::Instance => {
(d3d12::D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA, 1) (d3d12::D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA, 1)
} }
}; };

View File

@ -79,8 +79,8 @@ impl super::CommandEncoder {
continue; continue;
} }
let instance_offset = match vb_desc.step { let instance_offset = match vb_desc.step {
wgt::InputStepMode::Vertex => 0, wgt::VertexStepMode::Vertex => 0,
wgt::InputStepMode::Instance => first_instance * vb_desc.stride, wgt::VertexStepMode::Instance => first_instance * vb_desc.stride,
}; };
self.cmd_buffer.commands.push(C::SetVertexBuffer { self.cmd_buffer.commands.push(C::SetVertexBuffer {
index: index as u32, index: index as u32,
@ -101,7 +101,7 @@ impl super::CommandEncoder {
let mut attribute_desc = attribute.clone(); let mut attribute_desc = attribute.clone();
attribute_desc.offset += buffer.offset as u32; attribute_desc.offset += buffer.offset as u32;
if buffer_desc.step == wgt::InputStepMode::Instance { if buffer_desc.step == wgt::VertexStepMode::Instance {
attribute_desc.offset += buffer_desc.stride * first_instance; attribute_desc.offset += buffer_desc.stride * first_instance;
} }
@ -634,7 +634,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
.zip(pipeline.vertex_buffers.iter()) .zip(pipeline.vertex_buffers.iter())
.enumerate() .enumerate()
{ {
if pipe_desc.step == wgt::InputStepMode::Instance { if pipe_desc.step == wgt::VertexStepMode::Instance {
self.state.instance_vbuf_mask |= 1 << index; self.state.instance_vbuf_mask |= 1 << index;
} }
if state_desc != pipe_desc { if state_desc != pipe_desc {

View File

@ -318,7 +318,7 @@ struct ImageBinding {
#[derive(Clone, Debug, Default, PartialEq)] #[derive(Clone, Debug, Default, PartialEq)]
struct VertexBufferDesc { struct VertexBufferDesc {
step: wgt::InputStepMode, step: wgt::VertexStepMode,
stride: u32, stride: u32,
} }

View File

@ -916,7 +916,7 @@ pub struct VertexBufferLayout<'a> {
/// The stride, in bytes, between elements of this buffer. /// The stride, in bytes, between elements of this buffer.
pub array_stride: wgt::BufferAddress, pub array_stride: wgt::BufferAddress,
/// How often this vertex buffer is "stepped" forward. /// How often this vertex buffer is "stepped" forward.
pub step_mode: wgt::InputStepMode, pub step_mode: wgt::VertexStepMode,
/// The list of attributes which comprise a single vertex. /// The list of attributes which comprise a single vertex.
pub attributes: &'a [wgt::VertexAttribute], pub attributes: &'a [wgt::VertexAttribute],
} }

View File

@ -216,10 +216,10 @@ pub fn map_vertex_format(format: wgt::VertexFormat) -> mtl::MTLVertexFormat {
} }
} }
pub fn map_step_mode(mode: wgt::InputStepMode) -> mtl::MTLVertexStepFunction { pub fn map_step_mode(mode: wgt::VertexStepMode) -> mtl::MTLVertexStepFunction {
match mode { match mode {
wgt::InputStepMode::Vertex => mtl::MTLVertexStepFunction::PerVertex, wgt::VertexStepMode::Vertex => mtl::MTLVertexStepFunction::PerVertex,
wgt::InputStepMode::Instance => mtl::MTLVertexStepFunction::PerInstance, wgt::VertexStepMode::Instance => mtl::MTLVertexStepFunction::PerInstance,
} }
} }

View File

@ -1143,8 +1143,8 @@ impl crate::Device<super::Api> for super::Device {
binding: i as u32, binding: i as u32,
stride: vb.array_stride as u32, stride: vb.array_stride as u32,
input_rate: match vb.step_mode { input_rate: match vb.step_mode {
wgt::InputStepMode::Vertex => vk::VertexInputRate::VERTEX, wgt::VertexStepMode::Vertex => vk::VertexInputRate::VERTEX,
wgt::InputStepMode::Instance => vk::VertexInputRate::INSTANCE, wgt::VertexStepMode::Instance => vk::VertexInputRate::INSTANCE,
}, },
}); });
for at in vb.attributes { for at in vb.attributes {

View File

@ -2045,16 +2045,16 @@ impl CompareFunction {
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "trace", derive(Serialize))] #[cfg_attr(feature = "trace", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))] #[cfg_attr(feature = "replay", derive(Deserialize))]
pub enum InputStepMode { pub enum VertexStepMode {
/// Input data is advanced every vertex. This is the standard value for vertex data. /// Vertex data is advanced every vertex.
Vertex = 0, Vertex = 0,
/// Input data is advanced every instance. /// Vertex data is advanced every instance.
Instance = 1, Instance = 1,
} }
impl Default for InputStepMode { impl Default for VertexStepMode {
fn default() -> Self { fn default() -> Self {
InputStepMode::Vertex VertexStepMode::Vertex
} }
} }

View File

@ -130,12 +130,12 @@ impl framework::Example for Example {
buffers: &[ buffers: &[
wgpu::VertexBufferLayout { wgpu::VertexBufferLayout {
array_stride: 4 * 4, array_stride: 4 * 4,
step_mode: wgpu::InputStepMode::Instance, step_mode: wgpu::VertexStepMode::Instance,
attributes: &wgpu::vertex_attr_array![0 => Float32x2, 1 => Float32x2], attributes: &wgpu::vertex_attr_array![0 => Float32x2, 1 => Float32x2],
}, },
wgpu::VertexBufferLayout { wgpu::VertexBufferLayout {
array_stride: 2 * 4, array_stride: 2 * 4,
step_mode: wgpu::InputStepMode::Vertex, step_mode: wgpu::VertexStepMode::Vertex,
attributes: &wgpu::vertex_attr_array![2 => Float32x2], attributes: &wgpu::vertex_attr_array![2 => Float32x2],
}, },
], ],

View File

@ -226,7 +226,7 @@ impl framework::Example for Example {
let vertex_buffers = [wgpu::VertexBufferLayout { let vertex_buffers = [wgpu::VertexBufferLayout {
array_stride: vertex_size as wgpu::BufferAddress, array_stride: vertex_size as wgpu::BufferAddress,
step_mode: wgpu::InputStepMode::Vertex, step_mode: wgpu::VertexStepMode::Vertex,
attributes: &[ attributes: &[
wgpu::VertexAttribute { wgpu::VertexAttribute {
format: wgpu::VertexFormat::Float32x4, format: wgpu::VertexFormat::Float32x4,

View File

@ -53,7 +53,7 @@ impl Example {
entry_point: "vs_main", entry_point: "vs_main",
buffers: &[wgpu::VertexBufferLayout { buffers: &[wgpu::VertexBufferLayout {
array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress, array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
step_mode: wgpu::InputStepMode::Vertex, step_mode: wgpu::VertexStepMode::Vertex,
attributes: &wgpu::vertex_attr_array![0 => Float32x2, 1 => Float32x4], attributes: &wgpu::vertex_attr_array![0 => Float32x2, 1 => Float32x4],
}], }],
}, },

View File

@ -436,7 +436,7 @@ impl framework::Example for Example {
let vertex_attr = wgpu::vertex_attr_array![0 => Sint8x4, 1 => Sint8x4]; let vertex_attr = wgpu::vertex_attr_array![0 => Sint8x4, 1 => Sint8x4];
let vb_desc = wgpu::VertexBufferLayout { let vb_desc = wgpu::VertexBufferLayout {
array_stride: vertex_size as wgpu::BufferAddress, array_stride: vertex_size as wgpu::BufferAddress,
step_mode: wgpu::InputStepMode::Vertex, step_mode: wgpu::VertexStepMode::Vertex,
attributes: &vertex_attr, attributes: &vertex_attr,
}; };

View File

@ -235,7 +235,7 @@ impl framework::Example for Skybox {
entry_point: "vs_entity", entry_point: "vs_entity",
buffers: &[wgpu::VertexBufferLayout { buffers: &[wgpu::VertexBufferLayout {
array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress, array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
step_mode: wgpu::InputStepMode::Vertex, step_mode: wgpu::VertexStepMode::Vertex,
attributes: &wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x3], attributes: &wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x3],
}], }],
}, },

View File

@ -235,7 +235,7 @@ impl framework::Example for Example {
entry_point: "main", entry_point: "main",
buffers: &[wgpu::VertexBufferLayout { buffers: &[wgpu::VertexBufferLayout {
array_stride: vertex_size as wgpu::BufferAddress, array_stride: vertex_size as wgpu::BufferAddress,
step_mode: wgpu::InputStepMode::Vertex, step_mode: wgpu::VertexStepMode::Vertex,
attributes: &wgpu::vertex_attr_array![0 => Float32x2, 1 => Float32x2, 2 => Sint32], attributes: &wgpu::vertex_attr_array![0 => Float32x2, 1 => Float32x2, 2 => Sint32],
}], }],
}, },

View File

@ -513,7 +513,7 @@ impl framework::Example for Example {
// one item, which is itself `repr(C)`. // one item, which is itself `repr(C)`.
buffers: &[wgpu::VertexBufferLayout { buffers: &[wgpu::VertexBufferLayout {
array_stride: water_vertex_size as wgpu::BufferAddress, array_stride: water_vertex_size as wgpu::BufferAddress,
step_mode: wgpu::InputStepMode::Vertex, step_mode: wgpu::VertexStepMode::Vertex,
attributes: &wgpu::vertex_attr_array![0 => Sint16x2, 1 => Sint8x4], attributes: &wgpu::vertex_attr_array![0 => Sint16x2, 1 => Sint8x4],
}], }],
}, },
@ -576,7 +576,7 @@ impl framework::Example for Example {
entry_point: "vs_main", entry_point: "vs_main",
buffers: &[wgpu::VertexBufferLayout { buffers: &[wgpu::VertexBufferLayout {
array_stride: terrain_vertex_size as wgpu::BufferAddress, array_stride: terrain_vertex_size as wgpu::BufferAddress,
step_mode: wgpu::InputStepMode::Vertex, step_mode: wgpu::VertexStepMode::Vertex,
attributes: &wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x3, 2 => Unorm8x4], attributes: &wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x3, 2 => Unorm8x4],
}], }],
}, },

View File

@ -754,12 +754,12 @@ fn map_vertex_format(format: wgt::VertexFormat) -> web_sys::GpuVertexFormat {
} }
} }
fn map_input_step_mode(mode: wgt::InputStepMode) -> web_sys::GpuInputStepMode { fn map_input_step_mode(mode: wgt::VertexStepMode) -> web_sys::GpuInputStepMode {
use web_sys::GpuInputStepMode as sm; use web_sys::GpuInputStepMode as sm;
use wgt::InputStepMode; use wgt::VertexStepMode;
match mode { match mode {
InputStepMode::Vertex => sm::Vertex, VertexStepMode::Vertex => sm::Vertex,
InputStepMode::Instance => sm::Instance, VertexStepMode::Instance => sm::Instance,
} }
} }

View File

@ -30,15 +30,15 @@ pub use wgt::{
BufferUsages, Color, ColorTargetState, ColorWrites, CommandBufferDescriptor, CompareFunction, BufferUsages, Color, ColorTargetState, ColorWrites, CommandBufferDescriptor, CompareFunction,
DepthBiasState, DepthStencilState, DeviceType, DownlevelCapabilities, DownlevelFlags, DepthBiasState, DepthStencilState, DeviceType, DownlevelCapabilities, DownlevelFlags,
DynamicOffset, Extent3d, Face, Features, FilterMode, FrontFace, ImageDataLayout, IndexFormat, DynamicOffset, Extent3d, Face, Features, FilterMode, FrontFace, ImageDataLayout, IndexFormat,
InputStepMode, Limits, MultisampleState, Origin3d, PipelineStatisticsTypes, PolygonMode, Limits, MultisampleState, Origin3d, PipelineStatisticsTypes, PolygonMode, PowerPreference,
PowerPreference, PresentMode, PrimitiveState, PrimitiveTopology, PushConstantRange, QueryType, PresentMode, PrimitiveState, PrimitiveTopology, PushConstantRange, QueryType,
SamplerBorderColor, ShaderLocation, ShaderModel, ShaderStages, StencilFaceState, SamplerBorderColor, ShaderLocation, ShaderModel, ShaderStages, StencilFaceState,
StencilOperation, StencilState, StorageTextureAccess, SwapChainDescriptor, SwapChainStatus, StencilOperation, StencilState, StorageTextureAccess, SwapChainDescriptor, SwapChainStatus,
TextureAspect, TextureDimension, TextureFormat, TextureFormatFeatureFlags, TextureAspect, TextureDimension, TextureFormat, TextureFormatFeatureFlags,
TextureFormatFeatures, TextureSampleType, TextureUsages, TextureViewDimension, VertexAttribute, TextureFormatFeatures, TextureSampleType, TextureUsages, TextureViewDimension, VertexAttribute,
VertexFormat, BIND_BUFFER_ALIGNMENT, COPY_BUFFER_ALIGNMENT, COPY_BYTES_PER_ROW_ALIGNMENT, VertexFormat, VertexStepMode, BIND_BUFFER_ALIGNMENT, COPY_BUFFER_ALIGNMENT,
MAP_ALIGNMENT, PUSH_CONSTANT_ALIGNMENT, QUERY_SET_MAX_QUERIES, QUERY_SIZE, COPY_BYTES_PER_ROW_ALIGNMENT, MAP_ALIGNMENT, PUSH_CONSTANT_ALIGNMENT, QUERY_SET_MAX_QUERIES,
VERTEX_STRIDE_ALIGNMENT, QUERY_SIZE, VERTEX_STRIDE_ALIGNMENT,
}; };
use backend::{BufferMappedRange, Context as C}; use backend::{BufferMappedRange, Context as C};
@ -1229,7 +1229,7 @@ pub struct VertexBufferLayout<'a> {
/// The stride, in bytes, between elements of this buffer. /// The stride, in bytes, between elements of this buffer.
pub array_stride: BufferAddress, pub array_stride: BufferAddress,
/// How often this vertex buffer is "stepped" forward. /// How often this vertex buffer is "stepped" forward.
pub step_mode: InputStepMode, pub step_mode: VertexStepMode,
/// The list of attributes which comprise a single vertex. /// The list of attributes which comprise a single vertex.
pub attributes: &'a [VertexAttribute], pub attributes: &'a [VertexAttribute],
} }