776: Update wgpu with the new vertex format r=kvark a=kvark

Based on https://github.com/gfx-rs/wgpu/pull/1235

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
This commit is contained in:
bors[bot]
2021-02-28 03:57:40 +00:00
committed by GitHub
11 changed files with 50 additions and 49 deletions

View File

@@ -26,20 +26,20 @@ webgl = ["wgc"]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "ce4668a7ac6a2cd43e0081166f6d0b7c4b7c2cde"
rev = "ecbddedfaf67299bc2c507f69d138b2c3e3226b3"
features = ["raw-window-handle", "cross"]
[target.'cfg(target_arch = "wasm32")'.dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "ce4668a7ac6a2cd43e0081166f6d0b7c4b7c2cde"
rev = "ecbddedfaf67299bc2c507f69d138b2c3e3226b3"
features = ["raw-window-handle", "cross"]
optional = true
[dependencies.wgt]
package = "wgpu-types"
git = "https://github.com/gfx-rs/wgpu"
rev = "ce4668a7ac6a2cd43e0081166f6d0b7c4b7c2cde"
rev = "ecbddedfaf67299bc2c507f69d138b2c3e3226b3"
[dependencies]
arrayvec = "0.5"

View File

@@ -41,6 +41,7 @@ All framework-based examples render to the window.
| - polygon mode | | :star: | | | | | | |
| - queries | | | :star: | | | | | |
| *integrations* | | | | | | | | |
| - staging belt | | | | | | | | |
| - typed arena | | | | | | | | |
| - obj loading | | | | | | :star: | | |

View File

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

View File

@@ -266,12 +266,12 @@ impl framework::Example for Example {
step_mode: wgpu::InputStepMode::Vertex,
attributes: &[
wgpu::VertexAttribute {
format: wgpu::VertexFormat::Float4,
format: wgpu::VertexFormat::Float32x4,
offset: 0,
shader_location: 0,
},
wgpu::VertexAttribute {
format: wgpu::VertexFormat::Float2,
format: wgpu::VertexFormat::Float32x2,
offset: 4 * 4,
shader_location: 1,
},

View File

@@ -54,7 +54,7 @@ impl Example {
buffers: &[wgpu::VertexBufferLayout {
array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
step_mode: wgpu::InputStepMode::Vertex,
attributes: &wgpu::vertex_attr_array![0 => Float2, 1 => Float4],
attributes: &wgpu::vertex_attr_array![0 => Float32x2, 1 => Float32x4],
}],
},
fragment: Some(wgpu::FragmentState {

View File

@@ -412,7 +412,7 @@ impl framework::Example for Example {
mapped_at_creation: false,
});
let vertex_attr = wgpu::vertex_attr_array![0 => Char4, 1 => Char4];
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,

View File

@@ -222,7 +222,7 @@ impl framework::Example for Skybox {
buffers: &[wgpu::VertexBufferLayout {
array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
step_mode: wgpu::InputStepMode::Vertex,
attributes: &wgpu::vertex_attr_array![0 => Float3, 1 => Float3],
attributes: &wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x3],
}],
},
fragment: Some(wgpu::FragmentState {

View File

@@ -260,7 +260,7 @@ impl framework::Example for Example {
buffers: &[wgpu::VertexBufferLayout {
array_stride: vertex_size as wgpu::BufferAddress,
step_mode: wgpu::InputStepMode::Vertex,
attributes: &wgpu::vertex_attr_array![0 => Float2, 1 => Float2, 2 => Int],
attributes: &wgpu::vertex_attr_array![0 => Float32x2, 1 => Float32x2, 2 => Sint32],
}],
},
fragment: Some(wgpu::FragmentState {

View File

@@ -513,7 +513,7 @@ impl framework::Example for Example {
buffers: &[wgpu::VertexBufferLayout {
array_stride: water_vertex_size as wgpu::BufferAddress,
step_mode: wgpu::InputStepMode::Vertex,
attributes: &wgpu::vertex_attr_array![0 => Short2, 1 => Char4],
attributes: &wgpu::vertex_attr_array![0 => Sint16x2, 1 => Sint8x4],
}],
},
// Fragment shader and output targets
@@ -577,7 +577,7 @@ impl framework::Example for Example {
buffers: &[wgpu::VertexBufferLayout {
array_stride: terrain_vertex_size as wgpu::BufferAddress,
step_mode: wgpu::InputStepMode::Vertex,
attributes: &wgpu::vertex_attr_array![0 => Float3, 1 => Float3, 2 => Uchar4Norm],
attributes: &wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x3, 2 => Unorm8x4],
}],
},
fragment: Some(wgpu::FragmentState {

View File

@@ -647,40 +647,40 @@ fn map_vertex_format(format: wgt::VertexFormat) -> web_sys::GpuVertexFormat {
use web_sys::GpuVertexFormat as vf;
use wgt::VertexFormat;
match format {
VertexFormat::Uchar2 => vf::Uchar2,
VertexFormat::Uchar4 => vf::Uchar4,
VertexFormat::Char2 => vf::Char2,
VertexFormat::Char4 => vf::Char4,
VertexFormat::Uchar2Norm => vf::Uchar2norm,
VertexFormat::Uchar4Norm => vf::Uchar4norm,
VertexFormat::Char2Norm => vf::Char2norm,
VertexFormat::Char4Norm => vf::Char4norm,
VertexFormat::Ushort2 => vf::Ushort2,
VertexFormat::Ushort4 => vf::Ushort4,
VertexFormat::Short2 => vf::Short2,
VertexFormat::Short4 => vf::Short4,
VertexFormat::Ushort2Norm => vf::Ushort2norm,
VertexFormat::Ushort4Norm => vf::Ushort4norm,
VertexFormat::Short2Norm => vf::Short2norm,
VertexFormat::Short4Norm => vf::Short4norm,
VertexFormat::Half2 => vf::Half2,
VertexFormat::Half4 => vf::Half4,
VertexFormat::Float => vf::Float,
VertexFormat::Float2 => vf::Float2,
VertexFormat::Float3 => vf::Float3,
VertexFormat::Float4 => vf::Float4,
VertexFormat::Uint => vf::Uint,
VertexFormat::Uint2 => vf::Uint2,
VertexFormat::Uint3 => vf::Uint3,
VertexFormat::Uint4 => vf::Uint4,
VertexFormat::Int => vf::Int,
VertexFormat::Int2 => vf::Int2,
VertexFormat::Int3 => vf::Int3,
VertexFormat::Int4 => vf::Int4,
VertexFormat::Double
| VertexFormat::Double2
| VertexFormat::Double3
| VertexFormat::Double4 => {
VertexFormat::Uint8x2 => vf::Uchar2,
VertexFormat::Uint8x4 => vf::Uchar4,
VertexFormat::Sint8x2 => vf::Char2,
VertexFormat::Sint8x4 => vf::Char4,
VertexFormat::Unorm8x2 => vf::Uchar2norm,
VertexFormat::Unorm8x4 => vf::Uchar4norm,
VertexFormat::Snorm8x2 => vf::Char2norm,
VertexFormat::Snorm8x4 => vf::Char4norm,
VertexFormat::Uint16x2 => vf::Ushort2,
VertexFormat::Uint16x4 => vf::Ushort4,
VertexFormat::Sint16x2 => vf::Short2,
VertexFormat::Sint16x4 => vf::Short4,
VertexFormat::Unorm16x2 => vf::Ushort2norm,
VertexFormat::Unorm16x4 => vf::Ushort4norm,
VertexFormat::Snorm16x2 => vf::Short2norm,
VertexFormat::Snorm16x4 => vf::Short4norm,
VertexFormat::Float16x2 => vf::Half2,
VertexFormat::Float16x4 => vf::Half4,
VertexFormat::Float32 => vf::Float,
VertexFormat::Float32x2 => vf::Float2,
VertexFormat::Float32x3 => vf::Float3,
VertexFormat::Float32x4 => vf::Float4,
VertexFormat::Uint32 => vf::Uint,
VertexFormat::Uint32x2 => vf::Uint2,
VertexFormat::Uint32x3 => vf::Uint3,
VertexFormat::Uint32x4 => vf::Uint4,
VertexFormat::Sint32 => vf::Int,
VertexFormat::Sint32x2 => vf::Int2,
VertexFormat::Sint32x3 => vf::Int3,
VertexFormat::Sint32x4 => vf::Int4,
VertexFormat::Float64
| VertexFormat::Float64x2
| VertexFormat::Float64x3
| VertexFormat::Float64x4 => {
panic!("VERTEX_ATTRIBUTE_64BIT feature must be enabled to use Double formats")
}
}

View File

@@ -5,7 +5,7 @@
/// Output has type: `[VertexAttribute; _]`. Usage is as follows:
/// ```
/// # use wgpu::vertex_attr_array;
/// let attrs = vertex_attr_array![0 => Float2, 1 => Float, 2 => Ushort4];
/// let attrs = vertex_attr_array![0 => Float32x2, 1 => Float32, 2 => Uint16x4];
/// ```
/// This example specifies a list of three [VertexAttribute](crate::VertexAttribute),
/// each with the given `shader_location` and `format`.
@@ -32,7 +32,7 @@ macro_rules! vertex_attr_array {
#[test]
fn test_vertex_attr_array() {
let attrs = vertex_attr_array![0 => Float2, 3 => Ushort4];
let attrs = vertex_attr_array![0 => Float32x2, 3 => Uint16x4];
// VertexAttribute does not support PartialEq, so we cannot test directly
assert_eq!(attrs.len(), 2);
assert_eq!(attrs[0].offset, 0);