From 1a9a855ea97f86ecfdc268b49ef8a201103a1b95 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Wed, 21 Jul 2021 17:47:12 -0400 Subject: [PATCH] Rename InputStepMode to VertexStepMode --- CHANGELOG.md | 3 ++- wgpu-core/src/command/bundle.rs | 10 +++++----- wgpu-core/src/command/render.rs | 12 ++++++------ wgpu-core/src/pipeline.rs | 4 ++-- wgpu-hal/src/dx12/device.rs | 4 ++-- wgpu-hal/src/gles/command.rs | 8 ++++---- wgpu-hal/src/gles/mod.rs | 2 +- wgpu-hal/src/lib.rs | 2 +- wgpu-hal/src/metal/conv.rs | 6 +++--- wgpu-hal/src/vulkan/device.rs | 4 ++-- wgpu-types/src/lib.rs | 10 +++++----- wgpu/examples/boids/main.rs | 4 ++-- wgpu/examples/cube/main.rs | 2 +- wgpu/examples/msaa-line/main.rs | 2 +- wgpu/examples/shadow/main.rs | 2 +- wgpu/examples/skybox/main.rs | 2 +- wgpu/examples/texture-arrays/main.rs | 2 +- wgpu/examples/water/main.rs | 4 ++-- wgpu/src/backend/web.rs | 8 ++++---- wgpu/src/lib.rs | 12 ++++++------ 20 files changed, 52 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4189bf2c5..6d9878b9e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ - `cross` feature is removed entirely. Only Rust code from now on. - 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) - - 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: - `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. diff --git a/wgpu-core/src/command/bundle.rs b/wgpu-core/src/command/bundle.rs index 8a011e1890..3f62056b90 100644 --- a/wgpu-core/src/command/bundle.rs +++ b/wgpu-core/src/command/bundle.rs @@ -833,7 +833,7 @@ struct VertexState { buffer: Option, range: Range, stride: wgt::BufferAddress, - rate: wgt::InputStepMode, + rate: wgt::VertexStepMode, is_dirty: bool, } @@ -843,7 +843,7 @@ impl VertexState { buffer: None, range: 0..0, stride: 0, - rate: wgt::InputStepMode::Vertex, + rate: wgt::VertexStepMode::Vertex, is_dirty: false, } } @@ -967,13 +967,13 @@ impl State { } let limit = ((vbs.range.end - vbs.range.start) / vbs.stride) as u32; match vbs.rate { - wgt::InputStepMode::Vertex => { + wgt::VertexStepMode::Vertex => { if limit < vert_state.vertex_limit { vert_state.vertex_limit = limit; vert_state.vertex_limit_slot = idx as _; } } - wgt::InputStepMode::Instance => { + wgt::VertexStepMode::Instance => { if limit < vert_state.instance_limit { vert_state.instance_limit = limit; vert_state.instance_limit_slot = idx as _; @@ -1013,7 +1013,7 @@ impl State { fn set_pipeline( &mut self, index_format: Option, - vertex_strides: &[(wgt::BufferAddress, wgt::InputStepMode)], + vertex_strides: &[(wgt::BufferAddress, wgt::VertexStepMode)], layout_ids: &[id::Valid], push_constant_layouts: &[wgt::PushConstantRange], ) { diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 7cafb9956f..133c7b5748 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -27,7 +27,7 @@ use arrayvec::ArrayVec; use hal::CommandEncoder as _; use thiserror::Error; use wgt::{ - BufferAddress, BufferSize, BufferUsages, Color, IndexFormat, InputStepMode, TextureUsages, + BufferAddress, BufferSize, BufferUsages, Color, IndexFormat, TextureUsages, VertexStepMode, }; #[cfg(any(feature = "serial-pass", feature = "replay"))] @@ -263,7 +263,7 @@ impl IndexState { struct VertexBufferState { total_size: BufferAddress, stride: BufferAddress, - rate: InputStepMode, + rate: VertexStepMode, bound: bool, } @@ -271,7 +271,7 @@ impl VertexBufferState { const EMPTY: Self = VertexBufferState { total_size: 0, stride: 0, - rate: InputStepMode::Vertex, + rate: VertexStepMode::Vertex, bound: false, }; } @@ -301,13 +301,13 @@ impl VertexState { } let limit = (vbs.total_size / vbs.stride) as u32; match vbs.rate { - InputStepMode::Vertex => { + VertexStepMode::Vertex => { if limit < self.vertex_limit { self.vertex_limit = limit; self.vertex_limit_slot = idx as _; } } - InputStepMode::Instance => { + VertexStepMode::Instance => { if limit < self.instance_limit { self.instance_limit = limit; self.instance_limit_slot = idx as _; @@ -1084,7 +1084,7 @@ impl Global { } for vbs in state.vertex.inputs.iter_mut().skip(vertex_strides_len) { vbs.stride = 0; - vbs.rate = InputStepMode::Vertex; + vbs.rate = VertexStepMode::Vertex; } state.vertex.update_limits(); } diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index 30272e343c..14a7f6b01d 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -137,7 +137,7 @@ pub struct VertexBufferLayout<'a> { /// The stride, in bytes, between elements of this buffer. pub array_stride: wgt::BufferAddress, /// 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. pub attributes: Cow<'a, [wgt::VertexAttribute]>, } @@ -287,7 +287,7 @@ pub struct RenderPipeline { pub(crate) pass_context: RenderPassContext, pub(crate) flags: PipelineFlags, pub(crate) strip_index_format: Option, - pub(crate) vertex_strides: Vec<(wgt::BufferAddress, wgt::InputStepMode)>, + pub(crate) vertex_strides: Vec<(wgt::BufferAddress, wgt::VertexStepMode)>, pub(crate) life_guard: LifeGuard, } diff --git a/wgpu-hal/src/dx12/device.rs b/wgpu-hal/src/dx12/device.rs index 8364c0ff13..10e420485b 100644 --- a/wgpu-hal/src/dx12/device.rs +++ b/wgpu-hal/src/dx12/device.rs @@ -1431,10 +1431,10 @@ impl crate::Device for super::Device { { *stride = NonZeroU32::new(vbuf.array_stride as u32); let (slot_class, step_rate) = match vbuf.step_mode { - wgt::InputStepMode::Vertex => { + wgt::VertexStepMode::Vertex => { (d3d12::D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0) } - wgt::InputStepMode::Instance => { + wgt::VertexStepMode::Instance => { (d3d12::D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA, 1) } }; diff --git a/wgpu-hal/src/gles/command.rs b/wgpu-hal/src/gles/command.rs index 2bd1f205c8..42a6b15dac 100644 --- a/wgpu-hal/src/gles/command.rs +++ b/wgpu-hal/src/gles/command.rs @@ -79,8 +79,8 @@ impl super::CommandEncoder { continue; } let instance_offset = match vb_desc.step { - wgt::InputStepMode::Vertex => 0, - wgt::InputStepMode::Instance => first_instance * vb_desc.stride, + wgt::VertexStepMode::Vertex => 0, + wgt::VertexStepMode::Instance => first_instance * vb_desc.stride, }; self.cmd_buffer.commands.push(C::SetVertexBuffer { index: index as u32, @@ -101,7 +101,7 @@ impl super::CommandEncoder { let mut attribute_desc = attribute.clone(); 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; } @@ -634,7 +634,7 @@ impl crate::CommandEncoder for super::CommandEncoder { .zip(pipeline.vertex_buffers.iter()) .enumerate() { - if pipe_desc.step == wgt::InputStepMode::Instance { + if pipe_desc.step == wgt::VertexStepMode::Instance { self.state.instance_vbuf_mask |= 1 << index; } if state_desc != pipe_desc { diff --git a/wgpu-hal/src/gles/mod.rs b/wgpu-hal/src/gles/mod.rs index 59903324f8..3c881fb61d 100644 --- a/wgpu-hal/src/gles/mod.rs +++ b/wgpu-hal/src/gles/mod.rs @@ -318,7 +318,7 @@ struct ImageBinding { #[derive(Clone, Debug, Default, PartialEq)] struct VertexBufferDesc { - step: wgt::InputStepMode, + step: wgt::VertexStepMode, stride: u32, } diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index 67cb905270..b4c38a80c4 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -916,7 +916,7 @@ pub struct VertexBufferLayout<'a> { /// The stride, in bytes, between elements of this buffer. pub array_stride: wgt::BufferAddress, /// 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. pub attributes: &'a [wgt::VertexAttribute], } diff --git a/wgpu-hal/src/metal/conv.rs b/wgpu-hal/src/metal/conv.rs index bc15fe1ef0..0eafe472e1 100644 --- a/wgpu-hal/src/metal/conv.rs +++ b/wgpu-hal/src/metal/conv.rs @@ -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 { - wgt::InputStepMode::Vertex => mtl::MTLVertexStepFunction::PerVertex, - wgt::InputStepMode::Instance => mtl::MTLVertexStepFunction::PerInstance, + wgt::VertexStepMode::Vertex => mtl::MTLVertexStepFunction::PerVertex, + wgt::VertexStepMode::Instance => mtl::MTLVertexStepFunction::PerInstance, } } diff --git a/wgpu-hal/src/vulkan/device.rs b/wgpu-hal/src/vulkan/device.rs index ffc7f70472..3aa0881c97 100644 --- a/wgpu-hal/src/vulkan/device.rs +++ b/wgpu-hal/src/vulkan/device.rs @@ -1143,8 +1143,8 @@ impl crate::Device for super::Device { binding: i as u32, stride: vb.array_stride as u32, input_rate: match vb.step_mode { - wgt::InputStepMode::Vertex => vk::VertexInputRate::VERTEX, - wgt::InputStepMode::Instance => vk::VertexInputRate::INSTANCE, + wgt::VertexStepMode::Vertex => vk::VertexInputRate::VERTEX, + wgt::VertexStepMode::Instance => vk::VertexInputRate::INSTANCE, }, }); for at in vb.attributes { diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index dd13f16155..b328d7f28d 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -2045,16 +2045,16 @@ impl CompareFunction { #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] #[cfg_attr(feature = "trace", derive(Serialize))] #[cfg_attr(feature = "replay", derive(Deserialize))] -pub enum InputStepMode { - /// Input data is advanced every vertex. This is the standard value for vertex data. +pub enum VertexStepMode { + /// Vertex data is advanced every vertex. Vertex = 0, - /// Input data is advanced every instance. + /// Vertex data is advanced every instance. Instance = 1, } -impl Default for InputStepMode { +impl Default for VertexStepMode { fn default() -> Self { - InputStepMode::Vertex + VertexStepMode::Vertex } } diff --git a/wgpu/examples/boids/main.rs b/wgpu/examples/boids/main.rs index 8a022b9261..2231531b75 100644 --- a/wgpu/examples/boids/main.rs +++ b/wgpu/examples/boids/main.rs @@ -130,12 +130,12 @@ impl framework::Example for Example { buffers: &[ wgpu::VertexBufferLayout { array_stride: 4 * 4, - step_mode: wgpu::InputStepMode::Instance, + step_mode: wgpu::VertexStepMode::Instance, attributes: &wgpu::vertex_attr_array![0 => Float32x2, 1 => Float32x2], }, wgpu::VertexBufferLayout { array_stride: 2 * 4, - step_mode: wgpu::InputStepMode::Vertex, + step_mode: wgpu::VertexStepMode::Vertex, attributes: &wgpu::vertex_attr_array![2 => Float32x2], }, ], diff --git a/wgpu/examples/cube/main.rs b/wgpu/examples/cube/main.rs index 2bd815f6b2..f80ba3fbc8 100644 --- a/wgpu/examples/cube/main.rs +++ b/wgpu/examples/cube/main.rs @@ -226,7 +226,7 @@ impl framework::Example for Example { let vertex_buffers = [wgpu::VertexBufferLayout { array_stride: vertex_size as wgpu::BufferAddress, - step_mode: wgpu::InputStepMode::Vertex, + step_mode: wgpu::VertexStepMode::Vertex, attributes: &[ wgpu::VertexAttribute { format: wgpu::VertexFormat::Float32x4, diff --git a/wgpu/examples/msaa-line/main.rs b/wgpu/examples/msaa-line/main.rs index a198d7ccd6..2430767b60 100644 --- a/wgpu/examples/msaa-line/main.rs +++ b/wgpu/examples/msaa-line/main.rs @@ -53,7 +53,7 @@ impl Example { entry_point: "vs_main", buffers: &[wgpu::VertexBufferLayout { array_stride: std::mem::size_of::() as wgpu::BufferAddress, - step_mode: wgpu::InputStepMode::Vertex, + step_mode: wgpu::VertexStepMode::Vertex, attributes: &wgpu::vertex_attr_array![0 => Float32x2, 1 => Float32x4], }], }, diff --git a/wgpu/examples/shadow/main.rs b/wgpu/examples/shadow/main.rs index 49beff0bb4..07ca92d715 100644 --- a/wgpu/examples/shadow/main.rs +++ b/wgpu/examples/shadow/main.rs @@ -436,7 +436,7 @@ impl framework::Example for Example { let vertex_attr = wgpu::vertex_attr_array![0 => Sint8x4, 1 => Sint8x4]; let vb_desc = wgpu::VertexBufferLayout { array_stride: vertex_size as wgpu::BufferAddress, - step_mode: wgpu::InputStepMode::Vertex, + step_mode: wgpu::VertexStepMode::Vertex, attributes: &vertex_attr, }; diff --git a/wgpu/examples/skybox/main.rs b/wgpu/examples/skybox/main.rs index 1ffe9d4b05..da1166b371 100644 --- a/wgpu/examples/skybox/main.rs +++ b/wgpu/examples/skybox/main.rs @@ -235,7 +235,7 @@ impl framework::Example for Skybox { entry_point: "vs_entity", buffers: &[wgpu::VertexBufferLayout { array_stride: std::mem::size_of::() as wgpu::BufferAddress, - step_mode: wgpu::InputStepMode::Vertex, + step_mode: wgpu::VertexStepMode::Vertex, attributes: &wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x3], }], }, diff --git a/wgpu/examples/texture-arrays/main.rs b/wgpu/examples/texture-arrays/main.rs index f8ebfa152d..3bdab8632b 100644 --- a/wgpu/examples/texture-arrays/main.rs +++ b/wgpu/examples/texture-arrays/main.rs @@ -235,7 +235,7 @@ impl framework::Example for Example { entry_point: "main", buffers: &[wgpu::VertexBufferLayout { 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], }], }, diff --git a/wgpu/examples/water/main.rs b/wgpu/examples/water/main.rs index 858cdbdb4d..3ae067dd40 100644 --- a/wgpu/examples/water/main.rs +++ b/wgpu/examples/water/main.rs @@ -513,7 +513,7 @@ impl framework::Example for Example { // one item, which is itself `repr(C)`. buffers: &[wgpu::VertexBufferLayout { 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], }], }, @@ -576,7 +576,7 @@ impl framework::Example for Example { entry_point: "vs_main", buffers: &[wgpu::VertexBufferLayout { 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], }], }, diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index 46f881f34a..b786656444 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -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 wgt::InputStepMode; + use wgt::VertexStepMode; match mode { - InputStepMode::Vertex => sm::Vertex, - InputStepMode::Instance => sm::Instance, + VertexStepMode::Vertex => sm::Vertex, + VertexStepMode::Instance => sm::Instance, } } diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 0440bb82b2..fe3d8ea9bf 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -30,15 +30,15 @@ pub use wgt::{ 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, - PowerPreference, PresentMode, PrimitiveState, PrimitiveTopology, PushConstantRange, QueryType, + Limits, MultisampleState, Origin3d, PipelineStatisticsTypes, PolygonMode, PowerPreference, + PresentMode, PrimitiveState, PrimitiveTopology, PushConstantRange, QueryType, SamplerBorderColor, ShaderLocation, ShaderModel, ShaderStages, StencilFaceState, StencilOperation, StencilState, StorageTextureAccess, SwapChainDescriptor, SwapChainStatus, TextureAspect, TextureDimension, TextureFormat, TextureFormatFeatureFlags, 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, + VertexFormat, VertexStepMode, 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, }; use backend::{BufferMappedRange, Context as C}; @@ -1229,7 +1229,7 @@ pub struct VertexBufferLayout<'a> { /// The stride, in bytes, between elements of this buffer. pub array_stride: BufferAddress, /// 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. pub attributes: &'a [VertexAttribute], }