mirror of
https://github.com/bevyengine/bevy
synced 2024-11-25 22:20:20 +00:00
update for wgpu 0.8 (#1959)
Changes to get Bevy to compile with wgpu master. With this, on a Mac: * 2d examples look fine * ~~3d examples crash with an error specific to metal about a compilation error~~ * 3d examples work fine after enabling feature `wgpu/cross` Feature `wgpu/cross` seems to be needed only on some platforms, not sure how to know which. It was introduced in https://github.com/gfx-rs/wgpu-rs/pull/826
This commit is contained in:
parent
b399a374cb
commit
afaf4ad3da
25 changed files with 556 additions and 521 deletions
|
@ -82,9 +82,6 @@ bevy_ci_testing = ["bevy_internal/bevy_ci_testing"]
|
|||
bevy_dylib = {path = "crates/bevy_dylib", version = "0.5.0", default-features = false, optional = true}
|
||||
bevy_internal = {path = "crates/bevy_internal", version = "0.5.0", default-features = false}
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
syn = "=1.0.65"
|
||||
|
||||
[dev-dependencies]
|
||||
anyhow = "1.0"
|
||||
rand = "0.8.0"
|
||||
|
|
|
@ -116,35 +116,35 @@ async fn load_gltf<'a, 'b>(
|
|||
|
||||
if let Some(vertex_attribute) = reader
|
||||
.read_positions()
|
||||
.map(|v| VertexAttributeValues::Float3(v.collect()))
|
||||
.map(|v| VertexAttributeValues::Float32x3(v.collect()))
|
||||
{
|
||||
mesh.set_attribute(Mesh::ATTRIBUTE_POSITION, vertex_attribute);
|
||||
}
|
||||
|
||||
if let Some(vertex_attribute) = reader
|
||||
.read_normals()
|
||||
.map(|v| VertexAttributeValues::Float3(v.collect()))
|
||||
.map(|v| VertexAttributeValues::Float32x3(v.collect()))
|
||||
{
|
||||
mesh.set_attribute(Mesh::ATTRIBUTE_NORMAL, vertex_attribute);
|
||||
}
|
||||
|
||||
if let Some(vertex_attribute) = reader
|
||||
.read_tangents()
|
||||
.map(|v| VertexAttributeValues::Float4(v.collect()))
|
||||
.map(|v| VertexAttributeValues::Float32x4(v.collect()))
|
||||
{
|
||||
mesh.set_attribute(Mesh::ATTRIBUTE_TANGENT, vertex_attribute);
|
||||
}
|
||||
|
||||
if let Some(vertex_attribute) = reader
|
||||
.read_tex_coords(0)
|
||||
.map(|v| VertexAttributeValues::Float2(v.into_f32().collect()))
|
||||
.map(|v| VertexAttributeValues::Float32x2(v.into_f32().collect()))
|
||||
{
|
||||
mesh.set_attribute(Mesh::ATTRIBUTE_UV_0, vertex_attribute);
|
||||
}
|
||||
|
||||
if let Some(vertex_attribute) = reader
|
||||
.read_colors(0)
|
||||
.map(|v| VertexAttributeValues::Float4(v.into_rgba_f32().collect()))
|
||||
.map(|v| VertexAttributeValues::Float32x4(v.into_rgba_f32().collect()))
|
||||
{
|
||||
mesh.set_attribute(Mesh::ATTRIBUTE_COLOR, vertex_attribute);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,9 @@ use bevy_asset::{Assets, HandleUntyped};
|
|||
use bevy_reflect::TypeUuid;
|
||||
use bevy_render::{
|
||||
pipeline::{
|
||||
BlendFactor, BlendOperation, BlendState, ColorTargetState, ColorWrite, CompareFunction,
|
||||
DepthBiasState, DepthStencilState, PipelineDescriptor, StencilFaceState, StencilState,
|
||||
BlendComponent, BlendFactor, BlendOperation, BlendState, ColorTargetState, ColorWrite,
|
||||
CompareFunction, DepthBiasState, DepthStencilState, PipelineDescriptor, StencilFaceState,
|
||||
StencilState,
|
||||
},
|
||||
shader::{Shader, ShaderStage, ShaderStages},
|
||||
texture::TextureFormat,
|
||||
|
@ -29,20 +30,21 @@ pub(crate) fn build_pbr_pipeline(shaders: &mut Assets<Shader>) -> PipelineDescri
|
|||
slope_scale: 0.0,
|
||||
clamp: 0.0,
|
||||
},
|
||||
clamp_depth: false,
|
||||
}),
|
||||
color_target_states: vec![ColorTargetState {
|
||||
format: TextureFormat::default(),
|
||||
color_blend: BlendState {
|
||||
src_factor: BlendFactor::SrcAlpha,
|
||||
dst_factor: BlendFactor::OneMinusSrcAlpha,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
alpha_blend: BlendState {
|
||||
src_factor: BlendFactor::One,
|
||||
dst_factor: BlendFactor::One,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
blend: Some(BlendState {
|
||||
color: BlendComponent {
|
||||
src_factor: BlendFactor::SrcAlpha,
|
||||
dst_factor: BlendFactor::OneMinusSrcAlpha,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
alpha: BlendComponent {
|
||||
src_factor: BlendFactor::One,
|
||||
dst_factor: BlendFactor::One,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
}),
|
||||
write_mask: ColorWrite::ALL,
|
||||
}],
|
||||
..PipelineDescriptor::new(ShaderStages {
|
||||
|
|
|
@ -27,34 +27,34 @@ pub const VERTEX_ATTRIBUTE_BUFFER_ID: u64 = 10;
|
|||
/// An array where each entry describes a property of a single vertex.
|
||||
#[derive(Clone, Debug, EnumVariantMeta)]
|
||||
pub enum VertexAttributeValues {
|
||||
Float(Vec<f32>),
|
||||
Int(Vec<i32>),
|
||||
Uint(Vec<u32>),
|
||||
Float2(Vec<[f32; 2]>),
|
||||
Int2(Vec<[i32; 2]>),
|
||||
Uint2(Vec<[u32; 2]>),
|
||||
Float3(Vec<[f32; 3]>),
|
||||
Int3(Vec<[i32; 3]>),
|
||||
Uint3(Vec<[u32; 3]>),
|
||||
Float4(Vec<[f32; 4]>),
|
||||
Int4(Vec<[i32; 4]>),
|
||||
Uint4(Vec<[u32; 4]>),
|
||||
Short2(Vec<[i16; 2]>),
|
||||
Short2Norm(Vec<[i16; 2]>),
|
||||
Ushort2(Vec<[u16; 2]>),
|
||||
Ushort2Norm(Vec<[u16; 2]>),
|
||||
Short4(Vec<[i16; 4]>),
|
||||
Short4Norm(Vec<[i16; 4]>),
|
||||
Ushort4(Vec<[u16; 4]>),
|
||||
Ushort4Norm(Vec<[u16; 4]>),
|
||||
Char2(Vec<[i8; 2]>),
|
||||
Char2Norm(Vec<[i8; 2]>),
|
||||
Uchar2(Vec<[u8; 2]>),
|
||||
Uchar2Norm(Vec<[u8; 2]>),
|
||||
Char4(Vec<[i8; 4]>),
|
||||
Char4Norm(Vec<[i8; 4]>),
|
||||
Uchar4(Vec<[u8; 4]>),
|
||||
Uchar4Norm(Vec<[u8; 4]>),
|
||||
Float32(Vec<f32>),
|
||||
Sint32(Vec<i32>),
|
||||
Uint32(Vec<u32>),
|
||||
Float32x2(Vec<[f32; 2]>),
|
||||
Sint32x2(Vec<[i32; 2]>),
|
||||
Uint32x2(Vec<[u32; 2]>),
|
||||
Float32x3(Vec<[f32; 3]>),
|
||||
Sint32x3(Vec<[i32; 3]>),
|
||||
Uint32x3(Vec<[u32; 3]>),
|
||||
Float32x4(Vec<[f32; 4]>),
|
||||
Sint32x4(Vec<[i32; 4]>),
|
||||
Uint32x4(Vec<[u32; 4]>),
|
||||
Sint16x2(Vec<[i16; 2]>),
|
||||
Snorm16x2(Vec<[i16; 2]>),
|
||||
Uint16x2(Vec<[u16; 2]>),
|
||||
Unorm16x2(Vec<[u16; 2]>),
|
||||
Sint16x4(Vec<[i16; 4]>),
|
||||
Snorm16x4(Vec<[i16; 4]>),
|
||||
Uint16x4(Vec<[u16; 4]>),
|
||||
Unorm16x4(Vec<[u16; 4]>),
|
||||
Sint8x2(Vec<[i8; 2]>),
|
||||
Snorm8x2(Vec<[i8; 2]>),
|
||||
Uint8x2(Vec<[u8; 2]>),
|
||||
Unorm8x2(Vec<[u8; 2]>),
|
||||
Sint8x4(Vec<[i8; 4]>),
|
||||
Snorm8x4(Vec<[i8; 4]>),
|
||||
Uint8x4(Vec<[u8; 4]>),
|
||||
Unorm8x4(Vec<[u8; 4]>),
|
||||
}
|
||||
|
||||
impl VertexAttributeValues {
|
||||
|
@ -62,34 +62,34 @@ impl VertexAttributeValues {
|
|||
/// mesh, all of the VertexAttributeValues must have the same length.
|
||||
pub fn len(&self) -> usize {
|
||||
match *self {
|
||||
VertexAttributeValues::Float(ref values) => values.len(),
|
||||
VertexAttributeValues::Int(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint(ref values) => values.len(),
|
||||
VertexAttributeValues::Float2(ref values) => values.len(),
|
||||
VertexAttributeValues::Int2(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint2(ref values) => values.len(),
|
||||
VertexAttributeValues::Float3(ref values) => values.len(),
|
||||
VertexAttributeValues::Int3(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint3(ref values) => values.len(),
|
||||
VertexAttributeValues::Float4(ref values) => values.len(),
|
||||
VertexAttributeValues::Int4(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint4(ref values) => values.len(),
|
||||
VertexAttributeValues::Short2(ref values) => values.len(),
|
||||
VertexAttributeValues::Short2Norm(ref values) => values.len(),
|
||||
VertexAttributeValues::Ushort2(ref values) => values.len(),
|
||||
VertexAttributeValues::Ushort2Norm(ref values) => values.len(),
|
||||
VertexAttributeValues::Short4(ref values) => values.len(),
|
||||
VertexAttributeValues::Short4Norm(ref values) => values.len(),
|
||||
VertexAttributeValues::Ushort4(ref values) => values.len(),
|
||||
VertexAttributeValues::Ushort4Norm(ref values) => values.len(),
|
||||
VertexAttributeValues::Char2(ref values) => values.len(),
|
||||
VertexAttributeValues::Char2Norm(ref values) => values.len(),
|
||||
VertexAttributeValues::Uchar2(ref values) => values.len(),
|
||||
VertexAttributeValues::Uchar2Norm(ref values) => values.len(),
|
||||
VertexAttributeValues::Char4(ref values) => values.len(),
|
||||
VertexAttributeValues::Char4Norm(ref values) => values.len(),
|
||||
VertexAttributeValues::Uchar4(ref values) => values.len(),
|
||||
VertexAttributeValues::Uchar4Norm(ref values) => values.len(),
|
||||
VertexAttributeValues::Float32(ref values) => values.len(),
|
||||
VertexAttributeValues::Sint32(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint32(ref values) => values.len(),
|
||||
VertexAttributeValues::Float32x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Sint32x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint32x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Float32x3(ref values) => values.len(),
|
||||
VertexAttributeValues::Sint32x3(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint32x3(ref values) => values.len(),
|
||||
VertexAttributeValues::Float32x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Sint32x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint32x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Sint16x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Snorm16x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint16x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Unorm16x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Sint16x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Snorm16x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint16x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Unorm16x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Sint8x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Snorm8x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint8x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Unorm8x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Sint8x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Snorm8x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint8x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Unorm8x4(ref values) => values.len(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ impl VertexAttributeValues {
|
|||
|
||||
fn as_float3(&self) -> Option<&[[f32; 3]]> {
|
||||
match self {
|
||||
VertexAttributeValues::Float3(values) => Some(values),
|
||||
VertexAttributeValues::Float32x3(values) => Some(values),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -110,34 +110,34 @@ impl VertexAttributeValues {
|
|||
/// useful for serialization and sending to the GPU.
|
||||
pub fn get_bytes(&self) -> &[u8] {
|
||||
match self {
|
||||
VertexAttributeValues::Float(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Int(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Uint(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Float2(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Int2(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Uint2(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Float3(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Int3(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Uint3(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Float4(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Int4(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Uint4(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Short2(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Short2Norm(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Ushort2(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Ushort2Norm(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Short4(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Short4Norm(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Ushort4(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Ushort4Norm(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Char2(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Char2Norm(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Uchar2(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Uchar2Norm(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Char4(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Char4Norm(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Uchar4(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Uchar4Norm(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Float32(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Sint32(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Uint32(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Float32x2(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Sint32x2(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Uint32x2(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Float32x3(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Sint32x3(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Uint32x3(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Float32x4(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Sint32x4(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Uint32x4(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Sint16x2(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Snorm16x2(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Uint16x2(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Unorm16x2(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Sint16x4(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Snorm16x4(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Uint16x4(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Unorm16x4(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Sint8x2(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Snorm8x2(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Uint8x2(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Unorm8x2(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Sint8x4(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Snorm8x4(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Uint8x4(values) => values.as_slice().as_bytes(),
|
||||
VertexAttributeValues::Unorm8x4(values) => values.as_slice().as_bytes(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,34 +145,34 @@ impl VertexAttributeValues {
|
|||
impl From<&VertexAttributeValues> for VertexFormat {
|
||||
fn from(values: &VertexAttributeValues) -> Self {
|
||||
match values {
|
||||
VertexAttributeValues::Float(_) => VertexFormat::Float,
|
||||
VertexAttributeValues::Int(_) => VertexFormat::Int,
|
||||
VertexAttributeValues::Uint(_) => VertexFormat::Uint,
|
||||
VertexAttributeValues::Float2(_) => VertexFormat::Float2,
|
||||
VertexAttributeValues::Int2(_) => VertexFormat::Int2,
|
||||
VertexAttributeValues::Uint2(_) => VertexFormat::Uint2,
|
||||
VertexAttributeValues::Float3(_) => VertexFormat::Float3,
|
||||
VertexAttributeValues::Int3(_) => VertexFormat::Int3,
|
||||
VertexAttributeValues::Uint3(_) => VertexFormat::Uint3,
|
||||
VertexAttributeValues::Float4(_) => VertexFormat::Float4,
|
||||
VertexAttributeValues::Int4(_) => VertexFormat::Int4,
|
||||
VertexAttributeValues::Uint4(_) => VertexFormat::Uint4,
|
||||
VertexAttributeValues::Short2(_) => VertexFormat::Short2,
|
||||
VertexAttributeValues::Short2Norm(_) => VertexFormat::Short2Norm,
|
||||
VertexAttributeValues::Ushort2(_) => VertexFormat::Ushort2,
|
||||
VertexAttributeValues::Ushort2Norm(_) => VertexFormat::Ushort2Norm,
|
||||
VertexAttributeValues::Short4(_) => VertexFormat::Short4,
|
||||
VertexAttributeValues::Short4Norm(_) => VertexFormat::Short4Norm,
|
||||
VertexAttributeValues::Ushort4(_) => VertexFormat::Ushort4,
|
||||
VertexAttributeValues::Ushort4Norm(_) => VertexFormat::Ushort4Norm,
|
||||
VertexAttributeValues::Char2(_) => VertexFormat::Char2,
|
||||
VertexAttributeValues::Char2Norm(_) => VertexFormat::Char2Norm,
|
||||
VertexAttributeValues::Uchar2(_) => VertexFormat::Uchar2,
|
||||
VertexAttributeValues::Uchar2Norm(_) => VertexFormat::Uchar2Norm,
|
||||
VertexAttributeValues::Char4(_) => VertexFormat::Char4,
|
||||
VertexAttributeValues::Char4Norm(_) => VertexFormat::Char4Norm,
|
||||
VertexAttributeValues::Uchar4(_) => VertexFormat::Uchar4,
|
||||
VertexAttributeValues::Uchar4Norm(_) => VertexFormat::Uchar4Norm,
|
||||
VertexAttributeValues::Float32(_) => VertexFormat::Float32,
|
||||
VertexAttributeValues::Sint32(_) => VertexFormat::Sint32,
|
||||
VertexAttributeValues::Uint32(_) => VertexFormat::Uint32,
|
||||
VertexAttributeValues::Float32x2(_) => VertexFormat::Float32x2,
|
||||
VertexAttributeValues::Sint32x2(_) => VertexFormat::Sint32x2,
|
||||
VertexAttributeValues::Uint32x2(_) => VertexFormat::Uint32x2,
|
||||
VertexAttributeValues::Float32x3(_) => VertexFormat::Float32x3,
|
||||
VertexAttributeValues::Sint32x3(_) => VertexFormat::Sint32x3,
|
||||
VertexAttributeValues::Uint32x3(_) => VertexFormat::Uint32x3,
|
||||
VertexAttributeValues::Float32x4(_) => VertexFormat::Float32x4,
|
||||
VertexAttributeValues::Sint32x4(_) => VertexFormat::Sint32x4,
|
||||
VertexAttributeValues::Uint32x4(_) => VertexFormat::Uint32x4,
|
||||
VertexAttributeValues::Sint16x2(_) => VertexFormat::Sint16x2,
|
||||
VertexAttributeValues::Snorm16x2(_) => VertexFormat::Snorm16x2,
|
||||
VertexAttributeValues::Uint16x2(_) => VertexFormat::Uint16x2,
|
||||
VertexAttributeValues::Unorm16x2(_) => VertexFormat::Unorm16x2,
|
||||
VertexAttributeValues::Sint16x4(_) => VertexFormat::Sint16x4,
|
||||
VertexAttributeValues::Snorm16x4(_) => VertexFormat::Snorm16x4,
|
||||
VertexAttributeValues::Uint16x4(_) => VertexFormat::Uint16x4,
|
||||
VertexAttributeValues::Unorm16x4(_) => VertexFormat::Unorm16x4,
|
||||
VertexAttributeValues::Sint8x2(_) => VertexFormat::Sint8x2,
|
||||
VertexAttributeValues::Snorm8x2(_) => VertexFormat::Snorm8x2,
|
||||
VertexAttributeValues::Uint8x2(_) => VertexFormat::Uint8x2,
|
||||
VertexAttributeValues::Unorm8x2(_) => VertexFormat::Unorm8x2,
|
||||
VertexAttributeValues::Sint8x4(_) => VertexFormat::Sint8x4,
|
||||
VertexAttributeValues::Snorm8x4(_) => VertexFormat::Snorm8x4,
|
||||
VertexAttributeValues::Uint8x4(_) => VertexFormat::Uint8x4,
|
||||
VertexAttributeValues::Unorm8x4(_) => VertexFormat::Unorm8x4,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -408,34 +408,34 @@ impl Mesh {
|
|||
for (_, attributes) in self.attributes.iter_mut() {
|
||||
let indices = indices.iter();
|
||||
match attributes {
|
||||
VertexAttributeValues::Float(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Int(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Uint(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Float2(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Int2(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Uint2(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Float3(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Int3(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Uint3(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Int4(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Uint4(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Float4(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Short2(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Short2Norm(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Ushort2(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Ushort2Norm(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Short4(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Short4Norm(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Ushort4(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Ushort4Norm(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Char2(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Char2Norm(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Uchar2(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Uchar2Norm(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Char4(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Char4Norm(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Uchar4(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Uchar4Norm(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Float32(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Sint32(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Uint32(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Float32x2(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Sint32x2(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Uint32x2(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Float32x3(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Sint32x3(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Uint32x3(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Sint32x4(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Uint32x4(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Float32x4(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Sint16x2(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Snorm16x2(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Uint16x2(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Unorm16x2(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Sint16x4(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Snorm16x4(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Uint16x4(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Unorm16x4(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Sint8x2(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Snorm8x2(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Uint8x2(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Unorm8x2(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Sint8x4(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Snorm8x4(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Uint8x4(vec) => *vec = duplicate(&vec, indices),
|
||||
VertexAttributeValues::Unorm8x4(vec) => *vec = duplicate(&vec, indices),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,79 +50,79 @@ impl FromVertexAttributeError {
|
|||
|
||||
impl From<Vec<f32>> for VertexAttributeValues {
|
||||
fn from(vec: Vec<f32>) -> Self {
|
||||
VertexAttributeValues::Float(vec)
|
||||
VertexAttributeValues::Float32(vec)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<i32>> for VertexAttributeValues {
|
||||
fn from(vec: Vec<i32>) -> Self {
|
||||
VertexAttributeValues::Int(vec)
|
||||
VertexAttributeValues::Sint32(vec)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<u32>> for VertexAttributeValues {
|
||||
fn from(vec: Vec<u32>) -> Self {
|
||||
VertexAttributeValues::Uint(vec)
|
||||
VertexAttributeValues::Uint32(vec)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<[f32; 2]>> for VertexAttributeValues {
|
||||
fn from(vec: Vec<[f32; 2]>) -> Self {
|
||||
VertexAttributeValues::Float2(vec)
|
||||
VertexAttributeValues::Float32x2(vec)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<[i32; 2]>> for VertexAttributeValues {
|
||||
fn from(vec: Vec<[i32; 2]>) -> Self {
|
||||
VertexAttributeValues::Int2(vec)
|
||||
VertexAttributeValues::Sint32x2(vec)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<[u32; 2]>> for VertexAttributeValues {
|
||||
fn from(vec: Vec<[u32; 2]>) -> Self {
|
||||
VertexAttributeValues::Uint2(vec)
|
||||
VertexAttributeValues::Uint32x2(vec)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<[f32; 3]>> for VertexAttributeValues {
|
||||
fn from(vec: Vec<[f32; 3]>) -> Self {
|
||||
VertexAttributeValues::Float3(vec)
|
||||
VertexAttributeValues::Float32x3(vec)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<[i32; 3]>> for VertexAttributeValues {
|
||||
fn from(vec: Vec<[i32; 3]>) -> Self {
|
||||
VertexAttributeValues::Int3(vec)
|
||||
VertexAttributeValues::Sint32x3(vec)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<[u32; 3]>> for VertexAttributeValues {
|
||||
fn from(vec: Vec<[u32; 3]>) -> Self {
|
||||
VertexAttributeValues::Uint3(vec)
|
||||
VertexAttributeValues::Uint32x3(vec)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<[f32; 4]>> for VertexAttributeValues {
|
||||
fn from(vec: Vec<[f32; 4]>) -> Self {
|
||||
VertexAttributeValues::Float4(vec)
|
||||
VertexAttributeValues::Float32x4(vec)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<[i32; 4]>> for VertexAttributeValues {
|
||||
fn from(vec: Vec<[i32; 4]>) -> Self {
|
||||
VertexAttributeValues::Int4(vec)
|
||||
VertexAttributeValues::Sint32x4(vec)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<[u32; 4]>> for VertexAttributeValues {
|
||||
fn from(vec: Vec<[u32; 4]>) -> Self {
|
||||
VertexAttributeValues::Uint4(vec)
|
||||
VertexAttributeValues::Uint32x4(vec)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<[u8; 4]>> for VertexAttributeValues {
|
||||
fn from(vec: Vec<[u8; 4]>) -> Self {
|
||||
VertexAttributeValues::Uchar4Norm(vec)
|
||||
VertexAttributeValues::Unorm8x4(vec)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,8 +131,8 @@ impl TryFrom<VertexAttributeValues> for Vec<[u8; 4]> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Uchar4(value) => Ok(value),
|
||||
VertexAttributeValues::Uchar4Norm(value) => Ok(value),
|
||||
VertexAttributeValues::Uint8x4(value) => Ok(value),
|
||||
VertexAttributeValues::Unorm8x4(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -143,8 +143,8 @@ impl TryFrom<VertexAttributeValues> for Vec<[i8; 4]> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Char4(value) => Ok(value),
|
||||
VertexAttributeValues::Char4Norm(value) => Ok(value),
|
||||
VertexAttributeValues::Sint8x4(value) => Ok(value),
|
||||
VertexAttributeValues::Snorm8x4(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -155,8 +155,8 @@ impl TryFrom<VertexAttributeValues> for Vec<[u8; 2]> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Uchar2(value) => Ok(value),
|
||||
VertexAttributeValues::Uchar2Norm(value) => Ok(value),
|
||||
VertexAttributeValues::Uint8x2(value) => Ok(value),
|
||||
VertexAttributeValues::Unorm8x2(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -167,8 +167,8 @@ impl TryFrom<VertexAttributeValues> for Vec<[i8; 2]> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Char2(value) => Ok(value),
|
||||
VertexAttributeValues::Char2Norm(value) => Ok(value),
|
||||
VertexAttributeValues::Sint8x2(value) => Ok(value),
|
||||
VertexAttributeValues::Snorm8x2(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -179,8 +179,8 @@ impl TryFrom<VertexAttributeValues> for Vec<[i16; 4]> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Short4(value) => Ok(value),
|
||||
VertexAttributeValues::Short4Norm(value) => Ok(value),
|
||||
VertexAttributeValues::Sint16x4(value) => Ok(value),
|
||||
VertexAttributeValues::Snorm16x4(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -191,8 +191,8 @@ impl TryFrom<VertexAttributeValues> for Vec<[u16; 4]> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Ushort4(value) => Ok(value),
|
||||
VertexAttributeValues::Ushort4Norm(value) => Ok(value),
|
||||
VertexAttributeValues::Uint16x4(value) => Ok(value),
|
||||
VertexAttributeValues::Unorm16x4(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -203,8 +203,8 @@ impl TryFrom<VertexAttributeValues> for Vec<[u16; 2]> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Ushort2(value) => Ok(value),
|
||||
VertexAttributeValues::Ushort2Norm(value) => Ok(value),
|
||||
VertexAttributeValues::Uint16x2(value) => Ok(value),
|
||||
VertexAttributeValues::Unorm16x2(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -215,8 +215,8 @@ impl TryFrom<VertexAttributeValues> for Vec<[i16; 2]> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Short2(value) => Ok(value),
|
||||
VertexAttributeValues::Short2Norm(value) => Ok(value),
|
||||
VertexAttributeValues::Sint16x2(value) => Ok(value),
|
||||
VertexAttributeValues::Snorm16x2(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ impl TryFrom<VertexAttributeValues> for Vec<[u32; 4]> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Uint4(value) => Ok(value),
|
||||
VertexAttributeValues::Uint32x4(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ impl TryFrom<VertexAttributeValues> for Vec<[i32; 4]> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Int4(value) => Ok(value),
|
||||
VertexAttributeValues::Sint32x4(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ impl TryFrom<VertexAttributeValues> for Vec<[f32; 4]> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Float4(value) => Ok(value),
|
||||
VertexAttributeValues::Float32x4(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ impl TryFrom<VertexAttributeValues> for Vec<[u32; 3]> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Uint3(value) => Ok(value),
|
||||
VertexAttributeValues::Uint32x3(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ impl TryFrom<VertexAttributeValues> for Vec<[i32; 3]> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Int3(value) => Ok(value),
|
||||
VertexAttributeValues::Sint32x3(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ impl TryFrom<VertexAttributeValues> for Vec<[f32; 3]> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Float3(value) => Ok(value),
|
||||
VertexAttributeValues::Float32x3(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ impl TryFrom<VertexAttributeValues> for Vec<[u32; 2]> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Uint2(value) => Ok(value),
|
||||
VertexAttributeValues::Uint32x2(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ impl TryFrom<VertexAttributeValues> for Vec<[i32; 2]> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Int2(value) => Ok(value),
|
||||
VertexAttributeValues::Sint32x2(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ impl TryFrom<VertexAttributeValues> for Vec<[f32; 2]> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Float2(value) => Ok(value),
|
||||
VertexAttributeValues::Float32x2(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ impl TryFrom<VertexAttributeValues> for Vec<u32> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Uint(value) => Ok(value),
|
||||
VertexAttributeValues::Uint32(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ impl TryFrom<VertexAttributeValues> for Vec<i32> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Int(value) => Ok(value),
|
||||
VertexAttributeValues::Sint32(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ impl TryFrom<VertexAttributeValues> for Vec<f32> {
|
|||
|
||||
fn try_from(value: VertexAttributeValues) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
VertexAttributeValues::Float(value) => Ok(value),
|
||||
VertexAttributeValues::Float32(value) => Ok(value),
|
||||
_ => Err(FromVertexAttributeError::new::<Self>(value)),
|
||||
}
|
||||
}
|
||||
|
@ -513,9 +513,9 @@ mod tests {
|
|||
};
|
||||
assert_eq!(
|
||||
format!("{}", error),
|
||||
"cannot convert VertexAttributeValues::Uint4 to alloc::vec::Vec<u32>"
|
||||
"cannot convert VertexAttributeValues::Uint32x4 to alloc::vec::Vec<u32>"
|
||||
);
|
||||
assert_eq!(format!("{:?}", error),
|
||||
"FromVertexAttributeError { from: Uint4([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]), variant: \"Uint4\", into: \"alloc::vec::Vec<u32>\" }");
|
||||
"FromVertexAttributeError { from: Uint32x4([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]), variant: \"Uint32x4\", into: \"alloc::vec::Vec<u32>\" }");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ impl Default for ClearColor {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RenderPassColorAttachmentDescriptor {
|
||||
pub struct RenderPassColorAttachment {
|
||||
/// The actual color attachment.
|
||||
pub attachment: TextureAttachment,
|
||||
|
||||
|
@ -40,7 +40,7 @@ pub struct RenderPassColorAttachmentDescriptor {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RenderPassDepthStencilAttachmentDescriptor {
|
||||
pub struct RenderPassDepthStencilAttachment {
|
||||
pub attachment: TextureAttachment,
|
||||
/// What operations will be performed on the depth part of the attachment.
|
||||
pub depth_ops: Option<Operations<f32>>,
|
||||
|
@ -51,7 +51,7 @@ pub struct RenderPassDepthStencilAttachmentDescriptor {
|
|||
// A set of pipeline bindings and draw calls with color and depth outputs
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PassDescriptor {
|
||||
pub color_attachments: Vec<RenderPassColorAttachmentDescriptor>,
|
||||
pub depth_stencil_attachment: Option<RenderPassDepthStencilAttachmentDescriptor>,
|
||||
pub color_attachments: Vec<RenderPassColorAttachment>,
|
||||
pub depth_stencil_attachment: Option<RenderPassDepthStencilAttachment>,
|
||||
pub sample_count: u32,
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use super::{
|
||||
state_descriptors::{
|
||||
BlendFactor, BlendOperation, ColorWrite, CompareFunction, CullMode, FrontFace,
|
||||
BlendFactor, BlendOperation, ColorWrite, CompareFunction, Face, FrontFace,
|
||||
PrimitiveTopology,
|
||||
},
|
||||
PipelineLayout,
|
||||
};
|
||||
use crate::{
|
||||
pipeline::{
|
||||
BlendState, ColorTargetState, DepthBiasState, DepthStencilState, MultisampleState,
|
||||
PolygonMode, PrimitiveState, StencilFaceState, StencilState,
|
||||
BlendComponent, BlendState, ColorTargetState, DepthBiasState, DepthStencilState,
|
||||
MultisampleState, PolygonMode, PrimitiveState, StencilFaceState, StencilState,
|
||||
},
|
||||
shader::ShaderStages,
|
||||
texture::TextureFormat,
|
||||
|
@ -41,8 +41,10 @@ impl PipelineDescriptor {
|
|||
topology: PrimitiveTopology::TriangleList,
|
||||
strip_index_format: None,
|
||||
front_face: FrontFace::Ccw,
|
||||
cull_mode: CullMode::Back,
|
||||
cull_mode: Some(Face::Back),
|
||||
polygon_mode: PolygonMode::Fill,
|
||||
clamp_depth: false,
|
||||
conservative: false,
|
||||
},
|
||||
multisample: MultisampleState {
|
||||
count: 1,
|
||||
|
@ -59,8 +61,10 @@ impl PipelineDescriptor {
|
|||
topology: PrimitiveTopology::TriangleList,
|
||||
strip_index_format: None,
|
||||
front_face: FrontFace::Ccw,
|
||||
cull_mode: CullMode::Back,
|
||||
cull_mode: Some(Face::Back),
|
||||
polygon_mode: PolygonMode::Fill,
|
||||
clamp_depth: false,
|
||||
conservative: false,
|
||||
},
|
||||
layout: None,
|
||||
depth_stencil: Some(DepthStencilState {
|
||||
|
@ -78,20 +82,21 @@ impl PipelineDescriptor {
|
|||
slope_scale: 0.0,
|
||||
clamp: 0.0,
|
||||
},
|
||||
clamp_depth: false,
|
||||
}),
|
||||
color_target_states: vec![ColorTargetState {
|
||||
format: TextureFormat::default(),
|
||||
color_blend: BlendState {
|
||||
src_factor: BlendFactor::SrcAlpha,
|
||||
dst_factor: BlendFactor::OneMinusSrcAlpha,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
alpha_blend: BlendState {
|
||||
src_factor: BlendFactor::One,
|
||||
dst_factor: BlendFactor::One,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
blend: Some(BlendState {
|
||||
color: BlendComponent {
|
||||
src_factor: BlendFactor::SrcAlpha,
|
||||
dst_factor: BlendFactor::OneMinusSrcAlpha,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
alpha: BlendComponent {
|
||||
src_factor: BlendFactor::One,
|
||||
dst_factor: BlendFactor::One,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
}),
|
||||
write_mask: ColorWrite::ALL,
|
||||
}],
|
||||
multisample: MultisampleState {
|
||||
|
|
|
@ -9,7 +9,6 @@ pub struct DepthStencilState {
|
|||
pub depth_compare: CompareFunction,
|
||||
pub stencil: StencilState,
|
||||
pub bias: DepthBiasState,
|
||||
pub clamp_depth: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -117,16 +116,9 @@ impl Default for FrontFace {
|
|||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub enum CullMode {
|
||||
None = 0,
|
||||
Front = 1,
|
||||
Back = 2,
|
||||
}
|
||||
|
||||
impl Default for CullMode {
|
||||
fn default() -> Self {
|
||||
CullMode::None
|
||||
}
|
||||
pub enum Face {
|
||||
Front = 0,
|
||||
Back = 1,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
|
@ -150,31 +142,30 @@ pub struct PrimitiveState {
|
|||
pub topology: PrimitiveTopology,
|
||||
pub strip_index_format: Option<IndexFormat>,
|
||||
pub front_face: FrontFace,
|
||||
pub cull_mode: CullMode,
|
||||
pub cull_mode: Option<Face>,
|
||||
pub polygon_mode: PolygonMode,
|
||||
pub clamp_depth: bool,
|
||||
pub conservative: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ColorTargetState {
|
||||
pub format: TextureFormat,
|
||||
pub alpha_blend: BlendState,
|
||||
pub color_blend: BlendState,
|
||||
pub blend: Option<BlendState>,
|
||||
pub write_mask: ColorWrite,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct BlendState {
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct BlendComponent {
|
||||
pub src_factor: BlendFactor,
|
||||
pub dst_factor: BlendFactor,
|
||||
pub operation: BlendOperation,
|
||||
}
|
||||
|
||||
impl BlendState {
|
||||
pub const REPLACE: Self = BlendState {
|
||||
src_factor: BlendFactor::One,
|
||||
dst_factor: BlendFactor::Zero,
|
||||
operation: BlendOperation::Add,
|
||||
};
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct BlendState {
|
||||
pub alpha: BlendComponent,
|
||||
pub color: BlendComponent,
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
|
@ -199,17 +190,17 @@ impl Default for ColorWrite {
|
|||
pub enum BlendFactor {
|
||||
Zero = 0,
|
||||
One = 1,
|
||||
SrcColor = 2,
|
||||
OneMinusSrcColor = 3,
|
||||
Src = 2,
|
||||
OneMinusSrc = 3,
|
||||
SrcAlpha = 4,
|
||||
OneMinusSrcAlpha = 5,
|
||||
DstColor = 6,
|
||||
OneMinusDstColor = 7,
|
||||
Dst = 6,
|
||||
OneMinusDst = 7,
|
||||
DstAlpha = 8,
|
||||
OneMinusDstAlpha = 9,
|
||||
SrcAlphaSaturated = 10,
|
||||
BlendColor = 11,
|
||||
OneMinusBlendColor = 12,
|
||||
Constant = 11,
|
||||
OneMinusConstant = 12,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
|
|
|
@ -3,71 +3,71 @@ use bevy_math::{Mat4, Vec2, Vec3, Vec4};
|
|||
use serde::{Deserialize, Serialize};
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub enum VertexFormat {
|
||||
Uchar2 = 1,
|
||||
Uchar4 = 3,
|
||||
Char2 = 5,
|
||||
Char4 = 7,
|
||||
Uchar2Norm = 9,
|
||||
Uchar4Norm = 11,
|
||||
Char2Norm = 14,
|
||||
Char4Norm = 16,
|
||||
Ushort2 = 18,
|
||||
Ushort4 = 20,
|
||||
Short2 = 22,
|
||||
Short4 = 24,
|
||||
Ushort2Norm = 26,
|
||||
Ushort4Norm = 28,
|
||||
Short2Norm = 30,
|
||||
Short4Norm = 32,
|
||||
Half2 = 34,
|
||||
Half4 = 36,
|
||||
Float = 37,
|
||||
Float2 = 38,
|
||||
Float3 = 39,
|
||||
Float4 = 40,
|
||||
Uint = 41,
|
||||
Uint2 = 42,
|
||||
Uint3 = 43,
|
||||
Uint4 = 44,
|
||||
Int = 45,
|
||||
Int2 = 46,
|
||||
Int3 = 47,
|
||||
Int4 = 48,
|
||||
Uint8x2 = 1,
|
||||
Uint8x4 = 3,
|
||||
Sint8x2 = 5,
|
||||
Sint8x4 = 7,
|
||||
Unorm8x2 = 9,
|
||||
Unorm8x4 = 11,
|
||||
Snorm8x2 = 14,
|
||||
Snorm8x4 = 16,
|
||||
Uint16x2 = 18,
|
||||
Uint16x4 = 20,
|
||||
Sint16x2 = 22,
|
||||
Sint16x4 = 24,
|
||||
Unorm16x2 = 26,
|
||||
Unorm16x4 = 28,
|
||||
Snorm16x2 = 30,
|
||||
Snorm16x4 = 32,
|
||||
Float16x2 = 34,
|
||||
Float16x4 = 36,
|
||||
Float32 = 37,
|
||||
Float32x2 = 38,
|
||||
Float32x3 = 39,
|
||||
Float32x4 = 40,
|
||||
Uint32 = 41,
|
||||
Uint32x2 = 42,
|
||||
Uint32x3 = 43,
|
||||
Uint32x4 = 44,
|
||||
Sint32 = 45,
|
||||
Sint32x2 = 46,
|
||||
Sint32x3 = 47,
|
||||
Sint32x4 = 48,
|
||||
}
|
||||
|
||||
impl VertexFormat {
|
||||
pub fn get_size(&self) -> u64 {
|
||||
match *self {
|
||||
VertexFormat::Uchar2 => 2,
|
||||
VertexFormat::Uchar4 => 4,
|
||||
VertexFormat::Char2 => 2,
|
||||
VertexFormat::Char4 => 4,
|
||||
VertexFormat::Uchar2Norm => 2,
|
||||
VertexFormat::Uchar4Norm => 4,
|
||||
VertexFormat::Char2Norm => 2,
|
||||
VertexFormat::Char4Norm => 4,
|
||||
VertexFormat::Ushort2 => 2 * 2,
|
||||
VertexFormat::Ushort4 => 2 * 4,
|
||||
VertexFormat::Short2 => 2 * 2,
|
||||
VertexFormat::Short4 => 2 * 4,
|
||||
VertexFormat::Ushort2Norm => 2 * 2,
|
||||
VertexFormat::Ushort4Norm => 2 * 4,
|
||||
VertexFormat::Short2Norm => 2 * 2,
|
||||
VertexFormat::Short4Norm => 2 * 4,
|
||||
VertexFormat::Half2 => 2 * 2,
|
||||
VertexFormat::Half4 => 2 * 4,
|
||||
VertexFormat::Float => 4,
|
||||
VertexFormat::Float2 => 4 * 2,
|
||||
VertexFormat::Float3 => 4 * 3,
|
||||
VertexFormat::Float4 => 4 * 4,
|
||||
VertexFormat::Uint => 4,
|
||||
VertexFormat::Uint2 => 4 * 2,
|
||||
VertexFormat::Uint3 => 4 * 3,
|
||||
VertexFormat::Uint4 => 4 * 4,
|
||||
VertexFormat::Int => 4,
|
||||
VertexFormat::Int2 => 4 * 2,
|
||||
VertexFormat::Int3 => 4 * 3,
|
||||
VertexFormat::Int4 => 4 * 4,
|
||||
VertexFormat::Uint8x2 => 2,
|
||||
VertexFormat::Uint8x4 => 4,
|
||||
VertexFormat::Sint8x2 => 2,
|
||||
VertexFormat::Sint8x4 => 4,
|
||||
VertexFormat::Unorm8x2 => 2,
|
||||
VertexFormat::Unorm8x4 => 4,
|
||||
VertexFormat::Snorm8x2 => 2,
|
||||
VertexFormat::Snorm8x4 => 4,
|
||||
VertexFormat::Uint16x2 => 2 * 2,
|
||||
VertexFormat::Uint16x4 => 2 * 4,
|
||||
VertexFormat::Sint16x2 => 2 * 2,
|
||||
VertexFormat::Sint16x4 => 2 * 4,
|
||||
VertexFormat::Unorm16x2 => 2 * 2,
|
||||
VertexFormat::Unorm16x4 => 2 * 4,
|
||||
VertexFormat::Snorm16x2 => 2 * 2,
|
||||
VertexFormat::Snorm16x4 => 2 * 4,
|
||||
VertexFormat::Float16x2 => 2 * 2,
|
||||
VertexFormat::Float16x4 => 2 * 4,
|
||||
VertexFormat::Float32 => 4,
|
||||
VertexFormat::Float32x2 => 4 * 2,
|
||||
VertexFormat::Float32x3 => 4 * 3,
|
||||
VertexFormat::Float32x4 => 4 * 4,
|
||||
VertexFormat::Uint32 => 4,
|
||||
VertexFormat::Uint32x2 => 4 * 2,
|
||||
VertexFormat::Uint32x3 => 4 * 3,
|
||||
VertexFormat::Uint32x4 => 4 * 4,
|
||||
VertexFormat::Sint32 => 4,
|
||||
VertexFormat::Sint32x2 => 4 * 2,
|
||||
VertexFormat::Sint32x3 => 4 * 3,
|
||||
VertexFormat::Sint32x4 => 4 * 4,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,59 +78,59 @@ pub trait AsVertexFormats {
|
|||
|
||||
impl AsVertexFormats for f32 {
|
||||
fn as_vertex_formats() -> &'static [VertexFormat] {
|
||||
&[VertexFormat::Float]
|
||||
&[VertexFormat::Float32]
|
||||
}
|
||||
}
|
||||
|
||||
impl AsVertexFormats for Vec2 {
|
||||
fn as_vertex_formats() -> &'static [VertexFormat] {
|
||||
&[VertexFormat::Float2]
|
||||
&[VertexFormat::Float32x2]
|
||||
}
|
||||
}
|
||||
|
||||
impl AsVertexFormats for Vec3 {
|
||||
fn as_vertex_formats() -> &'static [VertexFormat] {
|
||||
&[VertexFormat::Float3]
|
||||
&[VertexFormat::Float32x3]
|
||||
}
|
||||
}
|
||||
|
||||
impl AsVertexFormats for Vec4 {
|
||||
fn as_vertex_formats() -> &'static [VertexFormat] {
|
||||
&[VertexFormat::Float4]
|
||||
&[VertexFormat::Float32x4]
|
||||
}
|
||||
}
|
||||
|
||||
impl AsVertexFormats for Mat4 {
|
||||
fn as_vertex_formats() -> &'static [VertexFormat] {
|
||||
&[
|
||||
VertexFormat::Float4,
|
||||
VertexFormat::Float4,
|
||||
VertexFormat::Float4,
|
||||
VertexFormat::Float4,
|
||||
VertexFormat::Float32x4,
|
||||
VertexFormat::Float32x4,
|
||||
VertexFormat::Float32x4,
|
||||
VertexFormat::Float32x4,
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
impl AsVertexFormats for Color {
|
||||
fn as_vertex_formats() -> &'static [VertexFormat] {
|
||||
&[VertexFormat::Float4]
|
||||
&[VertexFormat::Float32x4]
|
||||
}
|
||||
}
|
||||
|
||||
impl AsVertexFormats for [f32; 2] {
|
||||
fn as_vertex_formats() -> &'static [VertexFormat] {
|
||||
&[VertexFormat::Float2]
|
||||
&[VertexFormat::Float32x2]
|
||||
}
|
||||
}
|
||||
|
||||
impl AsVertexFormats for [f32; 3] {
|
||||
fn as_vertex_formats() -> &'static [VertexFormat] {
|
||||
&[VertexFormat::Float3]
|
||||
&[VertexFormat::Float32x3]
|
||||
}
|
||||
}
|
||||
|
||||
impl AsVertexFormats for [f32; 4] {
|
||||
fn as_vertex_formats() -> &'static [VertexFormat] {
|
||||
&[VertexFormat::Float4]
|
||||
&[VertexFormat::Float32x4]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ use super::{
|
|||
};
|
||||
use crate::{
|
||||
pass::{
|
||||
LoadOp, Operations, PassDescriptor, RenderPassColorAttachmentDescriptor,
|
||||
RenderPassDepthStencilAttachmentDescriptor, TextureAttachment,
|
||||
LoadOp, Operations, PassDescriptor, RenderPassColorAttachment,
|
||||
RenderPassDepthStencilAttachment, TextureAttachment,
|
||||
},
|
||||
texture::{Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsage},
|
||||
Color,
|
||||
|
@ -31,20 +31,20 @@ impl Default for Msaa {
|
|||
}
|
||||
|
||||
impl Msaa {
|
||||
pub fn color_attachment_descriptor(
|
||||
pub fn color_attachment(
|
||||
&self,
|
||||
attachment: TextureAttachment,
|
||||
resolve_target: TextureAttachment,
|
||||
ops: Operations<Color>,
|
||||
) -> RenderPassColorAttachmentDescriptor {
|
||||
) -> RenderPassColorAttachment {
|
||||
if self.samples > 1 {
|
||||
RenderPassColorAttachmentDescriptor {
|
||||
RenderPassColorAttachment {
|
||||
attachment,
|
||||
resolve_target: Some(resolve_target),
|
||||
ops,
|
||||
}
|
||||
} else {
|
||||
RenderPassColorAttachmentDescriptor {
|
||||
RenderPassColorAttachment {
|
||||
attachment,
|
||||
resolve_target: None,
|
||||
ops,
|
||||
|
@ -117,7 +117,7 @@ pub(crate) fn add_base_graph(config: &BaseRenderGraphConfig, world: &mut World)
|
|||
WindowId::primary(),
|
||||
TextureDescriptor {
|
||||
size: Extent3d {
|
||||
depth: 1,
|
||||
depth_or_array_layers: 1,
|
||||
width: 1,
|
||||
height: 1,
|
||||
},
|
||||
|
@ -134,7 +134,7 @@ pub(crate) fn add_base_graph(config: &BaseRenderGraphConfig, world: &mut World)
|
|||
|
||||
if config.add_main_pass {
|
||||
let mut main_pass_node = PassNode::<&MainPass>::new(PassDescriptor {
|
||||
color_attachments: vec![msaa.color_attachment_descriptor(
|
||||
color_attachments: vec![msaa.color_attachment(
|
||||
TextureAttachment::Input("color_attachment".to_string()),
|
||||
TextureAttachment::Input("color_resolve_target".to_string()),
|
||||
Operations {
|
||||
|
@ -142,7 +142,7 @@ pub(crate) fn add_base_graph(config: &BaseRenderGraphConfig, world: &mut World)
|
|||
store: true,
|
||||
},
|
||||
)],
|
||||
depth_stencil_attachment: Some(RenderPassDepthStencilAttachmentDescriptor {
|
||||
depth_stencil_attachment: Some(RenderPassDepthStencilAttachment {
|
||||
attachment: TextureAttachment::Input("depth".to_string()),
|
||||
depth_ops: Some(Operations {
|
||||
load: LoadOp::Clear(1.0),
|
||||
|
@ -212,7 +212,7 @@ pub(crate) fn add_base_graph(config: &BaseRenderGraphConfig, world: &mut World)
|
|||
WindowId::primary(),
|
||||
TextureDescriptor {
|
||||
size: Extent3d {
|
||||
depth: 1,
|
||||
depth_or_array_layers: 1,
|
||||
width: 1,
|
||||
height: 1,
|
||||
},
|
||||
|
|
|
@ -42,7 +42,8 @@ impl Node for TextureCopyNode {
|
|||
format_size
|
||||
* aligned_width
|
||||
* texture.size.height as usize
|
||||
* texture.size.depth as usize
|
||||
* texture.size.depth_or_array_layers
|
||||
as usize
|
||||
];
|
||||
texture
|
||||
.data
|
||||
|
|
|
@ -148,7 +148,7 @@ fn reflect_binding(
|
|||
&binding.name,
|
||||
BindType::Sampler {
|
||||
comparison: false,
|
||||
filtering: false,
|
||||
filtering: true,
|
||||
},
|
||||
),
|
||||
_ => panic!("Unsupported bind type {:?}.", binding.descriptor_type),
|
||||
|
@ -269,28 +269,28 @@ fn reflect_vertex_format(type_description: &ReflectTypeDescription) -> VertexFor
|
|||
let width = traits.numeric.scalar.width;
|
||||
|
||||
match (number_type, traits.numeric.vector.component_count, width) {
|
||||
(NumberType::UInt, 2, 8) => VertexFormat::Uchar2,
|
||||
(NumberType::UInt, 4, 8) => VertexFormat::Uchar4,
|
||||
(NumberType::Int, 2, 8) => VertexFormat::Char2,
|
||||
(NumberType::Int, 4, 8) => VertexFormat::Char4,
|
||||
(NumberType::UInt, 2, 16) => VertexFormat::Ushort2,
|
||||
(NumberType::UInt, 4, 16) => VertexFormat::Ushort4,
|
||||
(NumberType::Int, 2, 16) => VertexFormat::Short2,
|
||||
(NumberType::Int, 8, 16) => VertexFormat::Short4,
|
||||
(NumberType::Float, 2, 16) => VertexFormat::Half2,
|
||||
(NumberType::Float, 4, 16) => VertexFormat::Half4,
|
||||
(NumberType::Float, 0, 32) => VertexFormat::Float,
|
||||
(NumberType::Float, 2, 32) => VertexFormat::Float2,
|
||||
(NumberType::Float, 3, 32) => VertexFormat::Float3,
|
||||
(NumberType::Float, 4, 32) => VertexFormat::Float4,
|
||||
(NumberType::UInt, 0, 32) => VertexFormat::Uint,
|
||||
(NumberType::UInt, 2, 32) => VertexFormat::Uint2,
|
||||
(NumberType::UInt, 3, 32) => VertexFormat::Uint3,
|
||||
(NumberType::UInt, 4, 32) => VertexFormat::Uint4,
|
||||
(NumberType::Int, 0, 32) => VertexFormat::Int,
|
||||
(NumberType::Int, 2, 32) => VertexFormat::Int2,
|
||||
(NumberType::Int, 3, 32) => VertexFormat::Int3,
|
||||
(NumberType::Int, 4, 32) => VertexFormat::Int4,
|
||||
(NumberType::UInt, 2, 8) => VertexFormat::Uint8x2,
|
||||
(NumberType::UInt, 4, 8) => VertexFormat::Uint8x4,
|
||||
(NumberType::Int, 2, 8) => VertexFormat::Sint8x2,
|
||||
(NumberType::Int, 4, 8) => VertexFormat::Sint8x4,
|
||||
(NumberType::UInt, 2, 16) => VertexFormat::Uint16x2,
|
||||
(NumberType::UInt, 4, 16) => VertexFormat::Uint16x4,
|
||||
(NumberType::Int, 2, 16) => VertexFormat::Sint16x2,
|
||||
(NumberType::Int, 8, 16) => VertexFormat::Sint16x4,
|
||||
(NumberType::Float, 2, 16) => VertexFormat::Float16x2,
|
||||
(NumberType::Float, 4, 16) => VertexFormat::Float16x4,
|
||||
(NumberType::Float, 0, 32) => VertexFormat::Float32,
|
||||
(NumberType::Float, 2, 32) => VertexFormat::Float32x2,
|
||||
(NumberType::Float, 3, 32) => VertexFormat::Float32x3,
|
||||
(NumberType::Float, 4, 32) => VertexFormat::Float32x4,
|
||||
(NumberType::UInt, 0, 32) => VertexFormat::Uint32,
|
||||
(NumberType::UInt, 2, 32) => VertexFormat::Uint32x2,
|
||||
(NumberType::UInt, 3, 32) => VertexFormat::Uint32x3,
|
||||
(NumberType::UInt, 4, 32) => VertexFormat::Uint32x4,
|
||||
(NumberType::Int, 0, 32) => VertexFormat::Sint32,
|
||||
(NumberType::Int, 2, 32) => VertexFormat::Sint32x2,
|
||||
(NumberType::Int, 3, 32) => VertexFormat::Sint32x3,
|
||||
(NumberType::Int, 4, 32) => VertexFormat::Sint32x4,
|
||||
(number_type, component_count, width) => panic!(
|
||||
"unexpected uniform property format {:?} {} {}",
|
||||
number_type, component_count, width
|
||||
|
@ -343,7 +343,7 @@ mod tests {
|
|||
VertexBufferLayout::new_from_attribute(
|
||||
VertexAttribute {
|
||||
name: "Vertex_Position".into(),
|
||||
format: VertexFormat::Float4,
|
||||
format: VertexFormat::Float32x4,
|
||||
offset: 0,
|
||||
shader_location: 0,
|
||||
},
|
||||
|
@ -353,7 +353,7 @@ mod tests {
|
|||
VertexBufferLayout::new_from_attribute(
|
||||
VertexAttribute {
|
||||
name: "Vertex_Normal".into(),
|
||||
format: VertexFormat::Uint4,
|
||||
format: VertexFormat::Uint32x4,
|
||||
offset: 0,
|
||||
shader_location: 1,
|
||||
},
|
||||
|
@ -363,7 +363,7 @@ mod tests {
|
|||
VertexBufferLayout::new_from_attribute(
|
||||
VertexAttribute {
|
||||
name: "I_TestInstancing_Property".into(),
|
||||
format: VertexFormat::Uint4,
|
||||
format: VertexFormat::Uint32x4,
|
||||
offset: 0,
|
||||
shader_location: 2,
|
||||
},
|
||||
|
|
|
@ -31,7 +31,7 @@ impl Default for Texture {
|
|||
size: Extent3d {
|
||||
width: 1,
|
||||
height: 1,
|
||||
depth: 1,
|
||||
depth_or_array_layers: 1,
|
||||
},
|
||||
format: TextureFormat::Rgba8UnormSrgb,
|
||||
dimension: TextureDimension::D2,
|
||||
|
@ -119,13 +119,13 @@ impl Texture {
|
|||
pub fn reinterpret_stacked_2d_as_array(&mut self, layers: u32) {
|
||||
// Must be a stacked image, and the height must be divisible by layers.
|
||||
assert!(self.dimension == TextureDimension::D2);
|
||||
assert!(self.size.depth == 1);
|
||||
assert!(self.size.depth_or_array_layers == 1);
|
||||
assert_eq!(self.size.height % layers, 0);
|
||||
|
||||
self.reinterpret_size(Extent3d {
|
||||
width: self.size.width,
|
||||
height: self.size.height / layers,
|
||||
depth: layers,
|
||||
depth_or_array_layers: layers,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ impl Default for TextureDescriptor {
|
|||
size: Extent3d {
|
||||
width: 1,
|
||||
height: 1,
|
||||
depth: 1,
|
||||
depth_or_array_layers: 1,
|
||||
},
|
||||
mip_level_count: 1,
|
||||
sample_count: 1,
|
||||
|
|
|
@ -26,24 +26,28 @@ pub enum TextureDimension {
|
|||
pub struct Extent3d {
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub depth: u32,
|
||||
pub depth_or_array_layers: u32,
|
||||
}
|
||||
|
||||
impl Extent3d {
|
||||
pub fn new(width: u32, height: u32, depth: u32) -> Self {
|
||||
pub fn new(width: u32, height: u32, depth_or_array_layers: u32) -> Self {
|
||||
Self {
|
||||
width,
|
||||
height,
|
||||
depth,
|
||||
depth_or_array_layers,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn volume(&self) -> usize {
|
||||
(self.width * self.height * self.depth) as usize
|
||||
(self.width * self.height * self.depth_or_array_layers) as usize
|
||||
}
|
||||
|
||||
pub fn as_vec3(&self) -> Vec3 {
|
||||
Vec3::new(self.width as f32, self.height as f32, self.depth as f32)
|
||||
Vec3::new(
|
||||
self.width as f32,
|
||||
self.height as f32,
|
||||
self.depth_or_array_layers as f32,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
use crate::{
|
||||
pipeline::{
|
||||
CullMode, FrontFace, PipelineDescriptor, PolygonMode, PrimitiveState, PrimitiveTopology,
|
||||
},
|
||||
pipeline::{FrontFace, PipelineDescriptor, PolygonMode, PrimitiveState, PrimitiveTopology},
|
||||
shader::{Shader, ShaderStage, ShaderStages},
|
||||
};
|
||||
use bevy_asset::Assets;
|
||||
|
@ -13,8 +11,10 @@ pub(crate) fn build_wireframe_pipeline(shaders: &mut Assets<Shader>) -> Pipeline
|
|||
topology: PrimitiveTopology::TriangleList,
|
||||
strip_index_format: None,
|
||||
front_face: FrontFace::Ccw,
|
||||
cull_mode: CullMode::None,
|
||||
cull_mode: None,
|
||||
polygon_mode: PolygonMode::Line,
|
||||
clamp_depth: false,
|
||||
conservative: false,
|
||||
},
|
||||
..PipelineDescriptor::default_config(ShaderStages {
|
||||
vertex: shaders.add(Shader::from_glsl(
|
||||
|
|
|
@ -3,9 +3,9 @@ use bevy_asset::{Assets, HandleUntyped};
|
|||
use bevy_reflect::TypeUuid;
|
||||
use bevy_render::{
|
||||
pipeline::{
|
||||
BlendFactor, BlendOperation, BlendState, ColorTargetState, ColorWrite, CompareFunction,
|
||||
CullMode, DepthBiasState, DepthStencilState, FrontFace, PipelineDescriptor, PolygonMode,
|
||||
PrimitiveState, PrimitiveTopology, StencilFaceState, StencilState,
|
||||
BlendComponent, BlendFactor, BlendOperation, BlendState, ColorTargetState, ColorWrite,
|
||||
CompareFunction, DepthBiasState, DepthStencilState, FrontFace, PipelineDescriptor,
|
||||
PolygonMode, PrimitiveState, PrimitiveTopology, StencilFaceState, StencilState,
|
||||
},
|
||||
render_graph::{base, AssetRenderResourcesNode, RenderGraph, RenderResourcesNode},
|
||||
shader::{Shader, ShaderStage, ShaderStages},
|
||||
|
@ -35,28 +35,31 @@ pub fn build_sprite_sheet_pipeline(shaders: &mut Assets<Shader>) -> PipelineDesc
|
|||
slope_scale: 0.0,
|
||||
clamp: 0.0,
|
||||
},
|
||||
clamp_depth: false,
|
||||
}),
|
||||
color_target_states: vec![ColorTargetState {
|
||||
format: TextureFormat::default(),
|
||||
color_blend: BlendState {
|
||||
src_factor: BlendFactor::SrcAlpha,
|
||||
dst_factor: BlendFactor::OneMinusSrcAlpha,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
alpha_blend: BlendState {
|
||||
src_factor: BlendFactor::One,
|
||||
dst_factor: BlendFactor::One,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
blend: Some(BlendState {
|
||||
color: BlendComponent {
|
||||
src_factor: BlendFactor::SrcAlpha,
|
||||
dst_factor: BlendFactor::OneMinusSrcAlpha,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
alpha: BlendComponent {
|
||||
src_factor: BlendFactor::One,
|
||||
dst_factor: BlendFactor::One,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
}),
|
||||
write_mask: ColorWrite::ALL,
|
||||
}],
|
||||
primitive: PrimitiveState {
|
||||
topology: PrimitiveTopology::TriangleList,
|
||||
strip_index_format: None,
|
||||
front_face: FrontFace::Ccw,
|
||||
cull_mode: CullMode::None,
|
||||
cull_mode: None,
|
||||
polygon_mode: PolygonMode::Fill,
|
||||
clamp_depth: false,
|
||||
conservative: false,
|
||||
},
|
||||
..PipelineDescriptor::new(ShaderStages {
|
||||
vertex: shaders.add(Shader::from_glsl(
|
||||
|
@ -88,28 +91,31 @@ pub fn build_sprite_pipeline(shaders: &mut Assets<Shader>) -> PipelineDescriptor
|
|||
slope_scale: 0.0,
|
||||
clamp: 0.0,
|
||||
},
|
||||
clamp_depth: false,
|
||||
}),
|
||||
color_target_states: vec![ColorTargetState {
|
||||
format: TextureFormat::default(),
|
||||
color_blend: BlendState {
|
||||
src_factor: BlendFactor::SrcAlpha,
|
||||
dst_factor: BlendFactor::OneMinusSrcAlpha,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
alpha_blend: BlendState {
|
||||
src_factor: BlendFactor::One,
|
||||
dst_factor: BlendFactor::One,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
blend: Some(BlendState {
|
||||
color: BlendComponent {
|
||||
src_factor: BlendFactor::SrcAlpha,
|
||||
dst_factor: BlendFactor::OneMinusSrcAlpha,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
alpha: BlendComponent {
|
||||
src_factor: BlendFactor::One,
|
||||
dst_factor: BlendFactor::One,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
}),
|
||||
write_mask: ColorWrite::ALL,
|
||||
}],
|
||||
primitive: PrimitiveState {
|
||||
topology: PrimitiveTopology::TriangleList,
|
||||
strip_index_format: None,
|
||||
front_face: FrontFace::Ccw,
|
||||
cull_mode: CullMode::None,
|
||||
cull_mode: None,
|
||||
polygon_mode: PolygonMode::Fill,
|
||||
clamp_depth: false,
|
||||
conservative: false,
|
||||
},
|
||||
..PipelineDescriptor::new(ShaderStages {
|
||||
vertex: shaders.add(Shader::from_glsl(
|
||||
|
|
|
@ -5,8 +5,7 @@ use bevy_reflect::TypeUuid;
|
|||
use bevy_render::{
|
||||
camera::ActiveCameras,
|
||||
pass::{
|
||||
LoadOp, Operations, PassDescriptor, RenderPassDepthStencilAttachmentDescriptor,
|
||||
TextureAttachment,
|
||||
LoadOp, Operations, PassDescriptor, RenderPassDepthStencilAttachment, TextureAttachment,
|
||||
},
|
||||
pipeline::*,
|
||||
prelude::Msaa,
|
||||
|
@ -38,20 +37,21 @@ pub fn build_ui_pipeline(shaders: &mut Assets<Shader>) -> PipelineDescriptor {
|
|||
slope_scale: 0.0,
|
||||
clamp: 0.0,
|
||||
},
|
||||
clamp_depth: false,
|
||||
}),
|
||||
color_target_states: vec![ColorTargetState {
|
||||
format: TextureFormat::default(),
|
||||
color_blend: BlendState {
|
||||
src_factor: BlendFactor::SrcAlpha,
|
||||
dst_factor: BlendFactor::OneMinusSrcAlpha,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
alpha_blend: BlendState {
|
||||
src_factor: BlendFactor::One,
|
||||
dst_factor: BlendFactor::One,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
blend: Some(BlendState {
|
||||
color: BlendComponent {
|
||||
src_factor: BlendFactor::SrcAlpha,
|
||||
dst_factor: BlendFactor::OneMinusSrcAlpha,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
alpha: BlendComponent {
|
||||
src_factor: BlendFactor::One,
|
||||
dst_factor: BlendFactor::One,
|
||||
operation: BlendOperation::Add,
|
||||
},
|
||||
}),
|
||||
write_mask: ColorWrite::ALL,
|
||||
}],
|
||||
..PipelineDescriptor::new(ShaderStages {
|
||||
|
@ -90,7 +90,7 @@ pub(crate) fn add_ui_graph(world: &mut World) {
|
|||
pipelines.set_untracked(UI_PIPELINE_HANDLE, build_ui_pipeline(&mut shaders));
|
||||
|
||||
let mut ui_pass_node = PassNode::<&Node>::new(PassDescriptor {
|
||||
color_attachments: vec![msaa.color_attachment_descriptor(
|
||||
color_attachments: vec![msaa.color_attachment(
|
||||
TextureAttachment::Input("color_attachment".to_string()),
|
||||
TextureAttachment::Input("color_resolve_target".to_string()),
|
||||
Operations {
|
||||
|
@ -98,7 +98,7 @@ pub(crate) fn add_ui_graph(world: &mut World) {
|
|||
store: true,
|
||||
},
|
||||
)],
|
||||
depth_stencil_attachment: Some(RenderPassDepthStencilAttachmentDescriptor {
|
||||
depth_stencil_attachment: Some(RenderPassDepthStencilAttachment {
|
||||
attachment: TextureAttachment::Input("depth".to_string()),
|
||||
depth_ops: Some(Operations {
|
||||
load: LoadOp::Clear(1.0),
|
||||
|
|
|
@ -29,7 +29,7 @@ bevy_winit = { path = "../bevy_winit", optional = true, version = "0.5.0" }
|
|||
bevy_utils = { path = "../bevy_utils", version = "0.5.0" }
|
||||
|
||||
# other
|
||||
wgpu = "0.7"
|
||||
wgpu = "0.8"
|
||||
futures-lite = "1.4.0"
|
||||
crossbeam-channel = "0.5.0"
|
||||
crossbeam-utils = "0.8.1"
|
||||
|
|
|
@ -62,6 +62,14 @@ pub struct WgpuLimits {
|
|||
pub max_uniform_buffers_per_shader_stage: u32,
|
||||
pub max_uniform_buffer_binding_size: u32,
|
||||
pub max_push_constant_size: u32,
|
||||
pub max_texture_dimension_1d: u32,
|
||||
pub max_texture_dimension_2d: u32,
|
||||
pub max_texture_dimension_3d: u32,
|
||||
pub max_texture_array_layers: u32,
|
||||
pub max_storage_buffer_binding_size: u32,
|
||||
pub max_vertex_buffers: u32,
|
||||
pub max_vertex_attributes: u32,
|
||||
pub max_vertex_buffer_array_stride: u32,
|
||||
}
|
||||
|
||||
impl Default for WgpuLimits {
|
||||
|
@ -80,6 +88,14 @@ impl Default for WgpuLimits {
|
|||
max_uniform_buffers_per_shader_stage: default.max_uniform_buffers_per_shader_stage,
|
||||
max_uniform_buffer_binding_size: default.max_uniform_buffer_binding_size,
|
||||
max_push_constant_size: default.max_push_constant_size,
|
||||
max_texture_dimension_1d: default.max_texture_dimension_1d,
|
||||
max_texture_dimension_2d: default.max_texture_dimension_2d,
|
||||
max_texture_dimension_3d: default.max_texture_dimension_3d,
|
||||
max_texture_array_layers: default.max_texture_array_layers,
|
||||
max_storage_buffer_binding_size: default.max_storage_buffer_binding_size,
|
||||
max_vertex_buffers: default.max_vertex_buffers,
|
||||
max_vertex_attributes: default.max_vertex_attributes,
|
||||
max_vertex_buffer_array_stride: default.max_vertex_buffer_array_stride,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ use crate::{wgpu_type_converter::WgpuInto, WgpuRenderPass, WgpuResourceRefs};
|
|||
|
||||
use bevy_render::{
|
||||
pass::{
|
||||
PassDescriptor, RenderPass, RenderPassColorAttachmentDescriptor,
|
||||
RenderPassDepthStencilAttachmentDescriptor, TextureAttachment,
|
||||
PassDescriptor, RenderPass, RenderPassColorAttachment, RenderPassDepthStencilAttachment,
|
||||
TextureAttachment,
|
||||
},
|
||||
renderer::{
|
||||
BufferId, RenderContext, RenderResourceBinding, RenderResourceBindings,
|
||||
|
@ -211,16 +211,10 @@ pub fn create_render_pass<'a, 'b>(
|
|||
color_attachments: &pass_descriptor
|
||||
.color_attachments
|
||||
.iter()
|
||||
.map(|c| {
|
||||
create_wgpu_color_attachment_descriptor(global_render_resource_bindings, refs, c)
|
||||
})
|
||||
.collect::<Vec<wgpu::RenderPassColorAttachmentDescriptor>>(),
|
||||
.map(|c| create_wgpu_color_attachment(global_render_resource_bindings, refs, c))
|
||||
.collect::<Vec<wgpu::RenderPassColorAttachment>>(),
|
||||
depth_stencil_attachment: pass_descriptor.depth_stencil_attachment.as_ref().map(|d| {
|
||||
create_wgpu_depth_stencil_attachment_descriptor(
|
||||
global_render_resource_bindings,
|
||||
refs,
|
||||
d,
|
||||
)
|
||||
create_wgpu_depth_stencil_attachment(global_render_resource_bindings, refs, d)
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
@ -242,47 +236,47 @@ fn get_texture_view<'a>(
|
|||
}
|
||||
}
|
||||
|
||||
fn create_wgpu_color_attachment_descriptor<'a>(
|
||||
fn create_wgpu_color_attachment<'a>(
|
||||
global_render_resource_bindings: &RenderResourceBindings,
|
||||
refs: &WgpuResourceRefs<'a>,
|
||||
color_attachment_descriptor: &RenderPassColorAttachmentDescriptor,
|
||||
) -> wgpu::RenderPassColorAttachmentDescriptor<'a> {
|
||||
let attachment = get_texture_view(
|
||||
color_attachment: &RenderPassColorAttachment,
|
||||
) -> wgpu::RenderPassColorAttachment<'a> {
|
||||
let view = get_texture_view(
|
||||
global_render_resource_bindings,
|
||||
refs,
|
||||
&color_attachment_descriptor.attachment,
|
||||
&color_attachment.attachment,
|
||||
);
|
||||
|
||||
let resolve_target = color_attachment_descriptor
|
||||
let resolve_target = color_attachment
|
||||
.resolve_target
|
||||
.as_ref()
|
||||
.map(|target| get_texture_view(global_render_resource_bindings, refs, &target));
|
||||
|
||||
wgpu::RenderPassColorAttachmentDescriptor {
|
||||
ops: (&color_attachment_descriptor.ops).wgpu_into(),
|
||||
attachment,
|
||||
wgpu::RenderPassColorAttachment {
|
||||
ops: (&color_attachment.ops).wgpu_into(),
|
||||
view,
|
||||
resolve_target,
|
||||
}
|
||||
}
|
||||
|
||||
fn create_wgpu_depth_stencil_attachment_descriptor<'a>(
|
||||
fn create_wgpu_depth_stencil_attachment<'a>(
|
||||
global_render_resource_bindings: &RenderResourceBindings,
|
||||
refs: &WgpuResourceRefs<'a>,
|
||||
depth_stencil_attachment_descriptor: &RenderPassDepthStencilAttachmentDescriptor,
|
||||
) -> wgpu::RenderPassDepthStencilAttachmentDescriptor<'a> {
|
||||
let attachment = get_texture_view(
|
||||
depth_stencil_attachment: &RenderPassDepthStencilAttachment,
|
||||
) -> wgpu::RenderPassDepthStencilAttachment<'a> {
|
||||
let view = get_texture_view(
|
||||
global_render_resource_bindings,
|
||||
refs,
|
||||
&depth_stencil_attachment_descriptor.attachment,
|
||||
&depth_stencil_attachment.attachment,
|
||||
);
|
||||
|
||||
wgpu::RenderPassDepthStencilAttachmentDescriptor {
|
||||
attachment,
|
||||
depth_ops: depth_stencil_attachment_descriptor
|
||||
wgpu::RenderPassDepthStencilAttachment {
|
||||
view,
|
||||
depth_ops: depth_stencil_attachment
|
||||
.depth_ops
|
||||
.as_ref()
|
||||
.map(|ops| ops.wgpu_into()),
|
||||
stencil_ops: depth_stencil_attachment_descriptor
|
||||
stencil_ops: depth_stencil_attachment
|
||||
.stencil_ops
|
||||
.as_ref()
|
||||
.map(|ops| ops.wgpu_into()),
|
||||
|
|
|
@ -16,7 +16,12 @@ use bevy_render::{
|
|||
use bevy_utils::tracing::trace;
|
||||
use bevy_window::{Window, WindowId};
|
||||
use futures_lite::future;
|
||||
use std::{borrow::Cow, num::NonZeroU64, ops::Range, sync::Arc};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
num::{NonZeroU32, NonZeroU64},
|
||||
ops::Range,
|
||||
sync::Arc,
|
||||
};
|
||||
use wgpu::util::DeviceExt;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -81,7 +86,7 @@ impl WgpuRenderResourceContext {
|
|||
let source = textures.get(&source_texture).unwrap();
|
||||
let destination = textures.get(&destination_texture).unwrap();
|
||||
command_encoder.copy_texture_to_texture(
|
||||
wgpu::TextureCopyView {
|
||||
wgpu::ImageCopyTexture {
|
||||
texture: source,
|
||||
mip_level: source_mip_level,
|
||||
origin: wgpu::Origin3d {
|
||||
|
@ -90,7 +95,7 @@ impl WgpuRenderResourceContext {
|
|||
z: source_origin[2],
|
||||
},
|
||||
},
|
||||
wgpu::TextureCopyView {
|
||||
wgpu::ImageCopyTexture {
|
||||
texture: destination,
|
||||
mip_level: destination_mip_level,
|
||||
origin: wgpu::Origin3d {
|
||||
|
@ -121,7 +126,7 @@ impl WgpuRenderResourceContext {
|
|||
let source = textures.get(&source_texture).unwrap();
|
||||
let destination = buffers.get(&destination_buffer).unwrap();
|
||||
command_encoder.copy_texture_to_buffer(
|
||||
wgpu::TextureCopyView {
|
||||
wgpu::ImageCopyTexture {
|
||||
texture: source,
|
||||
mip_level: source_mip_level,
|
||||
origin: wgpu::Origin3d {
|
||||
|
@ -130,12 +135,12 @@ impl WgpuRenderResourceContext {
|
|||
z: source_origin[2],
|
||||
},
|
||||
},
|
||||
wgpu::BufferCopyView {
|
||||
wgpu::ImageCopyBuffer {
|
||||
buffer: destination,
|
||||
layout: wgpu::TextureDataLayout {
|
||||
layout: wgpu::ImageDataLayout {
|
||||
offset: destination_offset,
|
||||
bytes_per_row: destination_bytes_per_row,
|
||||
rows_per_image: size.height,
|
||||
bytes_per_row: NonZeroU32::new(destination_bytes_per_row),
|
||||
rows_per_image: NonZeroU32::new(size.height),
|
||||
},
|
||||
},
|
||||
size.wgpu_into(),
|
||||
|
@ -160,15 +165,15 @@ impl WgpuRenderResourceContext {
|
|||
let source = buffers.get(&source_buffer).unwrap();
|
||||
let destination = textures.get(&destination_texture).unwrap();
|
||||
command_encoder.copy_buffer_to_texture(
|
||||
wgpu::BufferCopyView {
|
||||
wgpu::ImageCopyBuffer {
|
||||
buffer: source,
|
||||
layout: wgpu::TextureDataLayout {
|
||||
layout: wgpu::ImageDataLayout {
|
||||
offset: source_offset,
|
||||
bytes_per_row: source_bytes_per_row,
|
||||
rows_per_image: size.height,
|
||||
bytes_per_row: NonZeroU32::new(source_bytes_per_row),
|
||||
rows_per_image: NonZeroU32::new(size.height),
|
||||
},
|
||||
},
|
||||
wgpu::TextureCopyView {
|
||||
wgpu::ImageCopyTexture {
|
||||
texture: destination,
|
||||
mip_level: destination_mip_level,
|
||||
origin: wgpu::Origin3d {
|
||||
|
@ -562,11 +567,11 @@ impl RenderResourceContext for WgpuRenderResourceContext {
|
|||
let wgpu_buffer = buffers.get(&buffer).unwrap();
|
||||
let size = NonZeroU64::new(range.end - range.start)
|
||||
.expect("Size of the buffer needs to be greater than 0!");
|
||||
wgpu::BindingResource::Buffer {
|
||||
wgpu::BindingResource::Buffer(wgpu::BufferBinding {
|
||||
buffer: wgpu_buffer,
|
||||
offset: range.start,
|
||||
size: Some(size),
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
wgpu::BindGroupEntry {
|
||||
|
|
|
@ -4,7 +4,7 @@ use bevy_render::{
|
|||
pass::{LoadOp, Operations},
|
||||
pipeline::{
|
||||
BindType, BlendFactor, BlendOperation, BlendState, ColorTargetState, ColorWrite,
|
||||
CompareFunction, CullMode, DepthBiasState, DepthStencilState, FrontFace, IndexFormat,
|
||||
CompareFunction, DepthBiasState, DepthStencilState, Face, FrontFace, IndexFormat,
|
||||
InputStepMode, MultisampleState, PolygonMode, PrimitiveState, PrimitiveTopology,
|
||||
StencilFaceState, StencilOperation, StencilState, VertexAttribute, VertexBufferLayout,
|
||||
VertexFormat,
|
||||
|
@ -39,36 +39,36 @@ where
|
|||
impl WgpuFrom<VertexFormat> for wgpu::VertexFormat {
|
||||
fn from(val: VertexFormat) -> Self {
|
||||
match val {
|
||||
VertexFormat::Uchar2 => wgpu::VertexFormat::Uchar2,
|
||||
VertexFormat::Uchar4 => wgpu::VertexFormat::Uchar4,
|
||||
VertexFormat::Char2 => wgpu::VertexFormat::Char2,
|
||||
VertexFormat::Char4 => wgpu::VertexFormat::Char4,
|
||||
VertexFormat::Uchar2Norm => wgpu::VertexFormat::Uchar2Norm,
|
||||
VertexFormat::Uchar4Norm => wgpu::VertexFormat::Uchar4Norm,
|
||||
VertexFormat::Char2Norm => wgpu::VertexFormat::Char2Norm,
|
||||
VertexFormat::Char4Norm => wgpu::VertexFormat::Char4Norm,
|
||||
VertexFormat::Ushort2 => wgpu::VertexFormat::Ushort2,
|
||||
VertexFormat::Ushort4 => wgpu::VertexFormat::Ushort4,
|
||||
VertexFormat::Short2 => wgpu::VertexFormat::Short2,
|
||||
VertexFormat::Short4 => wgpu::VertexFormat::Short4,
|
||||
VertexFormat::Ushort2Norm => wgpu::VertexFormat::Ushort2Norm,
|
||||
VertexFormat::Ushort4Norm => wgpu::VertexFormat::Ushort4Norm,
|
||||
VertexFormat::Short2Norm => wgpu::VertexFormat::Short2Norm,
|
||||
VertexFormat::Short4Norm => wgpu::VertexFormat::Short4Norm,
|
||||
VertexFormat::Half2 => wgpu::VertexFormat::Half2,
|
||||
VertexFormat::Half4 => wgpu::VertexFormat::Half4,
|
||||
VertexFormat::Float => wgpu::VertexFormat::Float,
|
||||
VertexFormat::Float2 => wgpu::VertexFormat::Float2,
|
||||
VertexFormat::Float3 => wgpu::VertexFormat::Float3,
|
||||
VertexFormat::Float4 => wgpu::VertexFormat::Float4,
|
||||
VertexFormat::Uint => wgpu::VertexFormat::Uint,
|
||||
VertexFormat::Uint2 => wgpu::VertexFormat::Uint2,
|
||||
VertexFormat::Uint3 => wgpu::VertexFormat::Uint3,
|
||||
VertexFormat::Uint4 => wgpu::VertexFormat::Uint4,
|
||||
VertexFormat::Int => wgpu::VertexFormat::Int,
|
||||
VertexFormat::Int2 => wgpu::VertexFormat::Int2,
|
||||
VertexFormat::Int3 => wgpu::VertexFormat::Int3,
|
||||
VertexFormat::Int4 => wgpu::VertexFormat::Int4,
|
||||
VertexFormat::Uint8x2 => wgpu::VertexFormat::Uint8x2,
|
||||
VertexFormat::Uint8x4 => wgpu::VertexFormat::Uint8x4,
|
||||
VertexFormat::Sint8x2 => wgpu::VertexFormat::Sint8x2,
|
||||
VertexFormat::Sint8x4 => wgpu::VertexFormat::Sint8x4,
|
||||
VertexFormat::Unorm8x2 => wgpu::VertexFormat::Unorm8x2,
|
||||
VertexFormat::Unorm8x4 => wgpu::VertexFormat::Unorm8x4,
|
||||
VertexFormat::Snorm8x2 => wgpu::VertexFormat::Snorm8x2,
|
||||
VertexFormat::Snorm8x4 => wgpu::VertexFormat::Snorm8x4,
|
||||
VertexFormat::Uint16x2 => wgpu::VertexFormat::Uint16x2,
|
||||
VertexFormat::Uint16x4 => wgpu::VertexFormat::Uint16x4,
|
||||
VertexFormat::Sint16x2 => wgpu::VertexFormat::Sint16x2,
|
||||
VertexFormat::Sint16x4 => wgpu::VertexFormat::Sint16x4,
|
||||
VertexFormat::Unorm16x2 => wgpu::VertexFormat::Unorm16x2,
|
||||
VertexFormat::Unorm16x4 => wgpu::VertexFormat::Unorm16x4,
|
||||
VertexFormat::Snorm16x2 => wgpu::VertexFormat::Snorm16x2,
|
||||
VertexFormat::Snorm16x4 => wgpu::VertexFormat::Snorm16x4,
|
||||
VertexFormat::Float16x2 => wgpu::VertexFormat::Float16x2,
|
||||
VertexFormat::Float16x4 => wgpu::VertexFormat::Float16x4,
|
||||
VertexFormat::Float32 => wgpu::VertexFormat::Float32,
|
||||
VertexFormat::Float32x2 => wgpu::VertexFormat::Float32x2,
|
||||
VertexFormat::Float32x3 => wgpu::VertexFormat::Float32x3,
|
||||
VertexFormat::Float32x4 => wgpu::VertexFormat::Float32x4,
|
||||
VertexFormat::Uint32 => wgpu::VertexFormat::Uint32,
|
||||
VertexFormat::Uint32x2 => wgpu::VertexFormat::Uint32x2,
|
||||
VertexFormat::Uint32x3 => wgpu::VertexFormat::Uint32x3,
|
||||
VertexFormat::Uint32x4 => wgpu::VertexFormat::Uint32x4,
|
||||
VertexFormat::Sint32 => wgpu::VertexFormat::Sint32,
|
||||
VertexFormat::Sint32x2 => wgpu::VertexFormat::Sint32x2,
|
||||
VertexFormat::Sint32x3 => wgpu::VertexFormat::Sint32x3,
|
||||
VertexFormat::Sint32x4 => wgpu::VertexFormat::Sint32x4,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -257,9 +257,9 @@ impl WgpuFrom<StorageTextureAccess> for wgpu::StorageTextureAccess {
|
|||
impl WgpuFrom<Extent3d> for wgpu::Extent3d {
|
||||
fn from(val: Extent3d) -> Self {
|
||||
wgpu::Extent3d {
|
||||
depth: val.depth,
|
||||
height: val.height,
|
||||
width: val.width,
|
||||
depth_or_array_layers: val.depth_or_array_layers,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -371,7 +371,6 @@ impl WgpuFrom<DepthStencilState> for wgpu::DepthStencilState {
|
|||
format: val.format.wgpu_into(),
|
||||
stencil: (&val.stencil).wgpu_into(),
|
||||
bias: val.bias.wgpu_into(),
|
||||
clamp_depth: val.clamp_depth,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -472,12 +471,11 @@ impl WgpuFrom<FrontFace> for wgpu::FrontFace {
|
|||
}
|
||||
}
|
||||
|
||||
impl WgpuFrom<CullMode> for wgpu::CullMode {
|
||||
fn from(val: CullMode) -> Self {
|
||||
impl WgpuFrom<Face> for wgpu::Face {
|
||||
fn from(val: Face) -> Self {
|
||||
match val {
|
||||
CullMode::None => wgpu::CullMode::None,
|
||||
CullMode::Front => wgpu::CullMode::Front,
|
||||
CullMode::Back => wgpu::CullMode::Back,
|
||||
Face::Front => wgpu::Face::Front,
|
||||
Face::Back => wgpu::Face::Back,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -506,9 +504,8 @@ impl WgpuFrom<&ColorTargetState> for wgpu::ColorTargetState {
|
|||
fn from(val: &ColorTargetState) -> Self {
|
||||
wgpu::ColorTargetState {
|
||||
format: val.format.wgpu_into(),
|
||||
alpha_blend: (&val.alpha_blend).wgpu_into(),
|
||||
color_blend: (&val.color_blend).wgpu_into(),
|
||||
write_mask: val.write_mask.wgpu_into(),
|
||||
blend: val.blend.map(|blend| blend.wgpu_into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -521,8 +518,10 @@ impl WgpuFrom<PrimitiveState> for wgpu::PrimitiveState {
|
|||
.strip_index_format
|
||||
.map(|index_format| index_format.wgpu_into()),
|
||||
front_face: val.front_face.wgpu_into(),
|
||||
cull_mode: val.cull_mode.wgpu_into(),
|
||||
cull_mode: val.cull_mode.map(|face| face.wgpu_into()),
|
||||
polygon_mode: val.polygon_mode.wgpu_into(),
|
||||
clamp_depth: val.clamp_depth,
|
||||
conservative: val.conservative,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -533,12 +532,19 @@ impl WgpuFrom<ColorWrite> for wgpu::ColorWrite {
|
|||
}
|
||||
}
|
||||
|
||||
impl WgpuFrom<&BlendState> for wgpu::BlendState {
|
||||
fn from(val: &BlendState) -> Self {
|
||||
impl WgpuFrom<BlendState> for wgpu::BlendState {
|
||||
fn from(val: BlendState) -> Self {
|
||||
wgpu::BlendState {
|
||||
src_factor: val.src_factor.wgpu_into(),
|
||||
dst_factor: val.dst_factor.wgpu_into(),
|
||||
operation: val.operation.wgpu_into(),
|
||||
color: wgpu::BlendComponent {
|
||||
src_factor: val.color.src_factor.wgpu_into(),
|
||||
dst_factor: val.color.dst_factor.wgpu_into(),
|
||||
operation: val.color.operation.wgpu_into(),
|
||||
},
|
||||
alpha: wgpu::BlendComponent {
|
||||
src_factor: val.alpha.src_factor.wgpu_into(),
|
||||
dst_factor: val.alpha.dst_factor.wgpu_into(),
|
||||
operation: val.alpha.operation.wgpu_into(),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -548,17 +554,17 @@ impl WgpuFrom<BlendFactor> for wgpu::BlendFactor {
|
|||
match val {
|
||||
BlendFactor::Zero => wgpu::BlendFactor::Zero,
|
||||
BlendFactor::One => wgpu::BlendFactor::One,
|
||||
BlendFactor::SrcColor => wgpu::BlendFactor::SrcColor,
|
||||
BlendFactor::OneMinusSrcColor => wgpu::BlendFactor::OneMinusSrcColor,
|
||||
BlendFactor::Src => wgpu::BlendFactor::Src,
|
||||
BlendFactor::OneMinusSrc => wgpu::BlendFactor::OneMinusSrc,
|
||||
BlendFactor::SrcAlpha => wgpu::BlendFactor::SrcAlpha,
|
||||
BlendFactor::OneMinusSrcAlpha => wgpu::BlendFactor::OneMinusSrcAlpha,
|
||||
BlendFactor::DstColor => wgpu::BlendFactor::DstColor,
|
||||
BlendFactor::OneMinusDstColor => wgpu::BlendFactor::OneMinusDstColor,
|
||||
BlendFactor::Dst => wgpu::BlendFactor::Dst,
|
||||
BlendFactor::OneMinusDst => wgpu::BlendFactor::OneMinusDst,
|
||||
BlendFactor::DstAlpha => wgpu::BlendFactor::DstAlpha,
|
||||
BlendFactor::OneMinusDstAlpha => wgpu::BlendFactor::OneMinusDstAlpha,
|
||||
BlendFactor::SrcAlphaSaturated => wgpu::BlendFactor::SrcAlphaSaturated,
|
||||
BlendFactor::BlendColor => wgpu::BlendFactor::BlendColor,
|
||||
BlendFactor::OneMinusBlendColor => wgpu::BlendFactor::OneMinusBlendColor,
|
||||
BlendFactor::Constant => wgpu::BlendFactor::Constant,
|
||||
BlendFactor::OneMinusConstant => wgpu::BlendFactor::OneMinusConstant,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -710,6 +716,14 @@ impl WgpuFrom<WgpuLimits> for wgpu::Limits {
|
|||
max_uniform_buffers_per_shader_stage: val.max_uniform_buffers_per_shader_stage,
|
||||
max_uniform_buffer_binding_size: val.max_uniform_buffer_binding_size,
|
||||
max_push_constant_size: val.max_push_constant_size,
|
||||
max_texture_dimension_1d: val.max_texture_dimension_1d,
|
||||
max_texture_dimension_2d: val.max_texture_dimension_2d,
|
||||
max_texture_dimension_3d: val.max_texture_dimension_3d,
|
||||
max_texture_array_layers: val.max_texture_array_layers,
|
||||
max_storage_buffer_binding_size: val.max_storage_buffer_binding_size,
|
||||
max_vertex_buffers: val.max_vertex_buffers,
|
||||
max_vertex_attributes: val.max_vertex_attributes,
|
||||
max_vertex_buffer_array_stride: val.max_vertex_buffer_array_stride,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ use bevy::{
|
|||
render::{
|
||||
camera::{ActiveCameras, Camera, CameraProjection},
|
||||
pass::{
|
||||
LoadOp, Operations, PassDescriptor, RenderPassColorAttachmentDescriptor,
|
||||
RenderPassDepthStencilAttachmentDescriptor, TextureAttachment,
|
||||
LoadOp, Operations, PassDescriptor, RenderPassColorAttachment,
|
||||
RenderPassDepthStencilAttachment, TextureAttachment,
|
||||
},
|
||||
render_graph::{
|
||||
base::{node::MAIN_PASS, MainPass},
|
||||
|
@ -31,7 +31,7 @@ pub const FIRST_PASS_CAMERA: &str = "first_pass_camera";
|
|||
|
||||
fn add_render_to_texture_graph(graph: &mut RenderGraph, size: Extent3d) {
|
||||
let mut pass_node = PassNode::<&FirstPass>::new(PassDescriptor {
|
||||
color_attachments: vec![RenderPassColorAttachmentDescriptor {
|
||||
color_attachments: vec![RenderPassColorAttachment {
|
||||
attachment: TextureAttachment::Input("color_attachment".to_string()),
|
||||
resolve_target: None,
|
||||
ops: Operations {
|
||||
|
@ -39,7 +39,7 @@ fn add_render_to_texture_graph(graph: &mut RenderGraph, size: Extent3d) {
|
|||
store: true,
|
||||
},
|
||||
}],
|
||||
depth_stencil_attachment: Some(RenderPassDepthStencilAttachmentDescriptor {
|
||||
depth_stencil_attachment: Some(RenderPassDepthStencilAttachment {
|
||||
attachment: TextureAttachment::Input("depth".to_string()),
|
||||
depth_ops: Some(Operations {
|
||||
load: LoadOp::Clear(1.0),
|
||||
|
|
|
@ -102,7 +102,7 @@ fn setup_pipeline(
|
|||
|
||||
// add a new render pass for our new window / camera
|
||||
let mut second_window_pass = PassNode::<&MainPass>::new(PassDescriptor {
|
||||
color_attachments: vec![msaa.color_attachment_descriptor(
|
||||
color_attachments: vec![msaa.color_attachment(
|
||||
TextureAttachment::Input("color_attachment".to_string()),
|
||||
TextureAttachment::Input("color_resolve_target".to_string()),
|
||||
Operations {
|
||||
|
@ -110,7 +110,7 @@ fn setup_pipeline(
|
|||
store: true,
|
||||
},
|
||||
)],
|
||||
depth_stencil_attachment: Some(RenderPassDepthStencilAttachmentDescriptor {
|
||||
depth_stencil_attachment: Some(RenderPassDepthStencilAttachment {
|
||||
attachment: TextureAttachment::Input("depth".to_string()),
|
||||
depth_ops: Some(Operations {
|
||||
load: LoadOp::Clear(1.0),
|
||||
|
@ -159,7 +159,7 @@ fn setup_pipeline(
|
|||
window_id,
|
||||
TextureDescriptor {
|
||||
size: Extent3d {
|
||||
depth: 1,
|
||||
depth_or_array_layers: 1,
|
||||
width: 1,
|
||||
height: 1,
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue