upgrade to latest wgpu
This commit is contained in:
parent
7a79dcc46c
commit
7c3b49cb6f
@ -3,7 +3,7 @@ use bevy_render::{
|
|||||||
pipeline::{
|
pipeline::{
|
||||||
BlendDescriptor, BlendFactor, BlendOperation, ColorStateDescriptor, ColorWrite,
|
BlendDescriptor, BlendFactor, BlendOperation, ColorStateDescriptor, ColorWrite,
|
||||||
CompareFunction, CullMode, DepthStencilStateDescriptor, FrontFace, PipelineDescriptor,
|
CompareFunction, CullMode, DepthStencilStateDescriptor, FrontFace, PipelineDescriptor,
|
||||||
RasterizationStateDescriptor, StencilStateFaceDescriptor,
|
RasterizationStateDescriptor, StencilStateFaceDescriptor, StencilStateDescriptor,
|
||||||
},
|
},
|
||||||
shader::{Shader, ShaderStage, ShaderStages},
|
shader::{Shader, ShaderStage, ShaderStages},
|
||||||
texture::TextureFormat,
|
texture::TextureFormat,
|
||||||
@ -20,15 +20,18 @@ pub(crate) fn build_forward_pipeline(shaders: &mut Assets<Shader>) -> PipelineDe
|
|||||||
depth_bias: 0,
|
depth_bias: 0,
|
||||||
depth_bias_slope_scale: 0.0,
|
depth_bias_slope_scale: 0.0,
|
||||||
depth_bias_clamp: 0.0,
|
depth_bias_clamp: 0.0,
|
||||||
|
clamp_depth: false,
|
||||||
}),
|
}),
|
||||||
depth_stencil_state: Some(DepthStencilStateDescriptor {
|
depth_stencil_state: Some(DepthStencilStateDescriptor {
|
||||||
format: TextureFormat::Depth32Float,
|
format: TextureFormat::Depth32Float,
|
||||||
depth_write_enabled: true,
|
depth_write_enabled: true,
|
||||||
depth_compare: CompareFunction::Less,
|
depth_compare: CompareFunction::Less,
|
||||||
stencil_front: StencilStateFaceDescriptor::IGNORE,
|
stencil: StencilStateDescriptor {
|
||||||
stencil_back: StencilStateFaceDescriptor::IGNORE,
|
front: StencilStateFaceDescriptor::IGNORE,
|
||||||
stencil_read_mask: 0,
|
back: StencilStateFaceDescriptor::IGNORE,
|
||||||
stencil_write_mask: 0,
|
read_mask: 0,
|
||||||
|
write_mask: 0,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
color_states: vec![ColorStateDescriptor {
|
color_states: vec![ColorStateDescriptor {
|
||||||
format: TextureFormat::Bgra8UnormSrgb,
|
format: TextureFormat::Bgra8UnormSrgb,
|
||||||
|
@ -4,7 +4,7 @@ use super::{
|
|||||||
CompareFunction, CullMode, DepthStencilStateDescriptor, FrontFace, IndexFormat,
|
CompareFunction, CullMode, DepthStencilStateDescriptor, FrontFace, IndexFormat,
|
||||||
PrimitiveTopology, RasterizationStateDescriptor, StencilStateFaceDescriptor,
|
PrimitiveTopology, RasterizationStateDescriptor, StencilStateFaceDescriptor,
|
||||||
},
|
},
|
||||||
BindType, DynamicBinding, PipelineLayout, VertexBufferDescriptors,
|
BindType, DynamicBinding, PipelineLayout, VertexBufferDescriptors, StencilStateDescriptor,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
shader::{Shader, ShaderStages},
|
shader::{Shader, ShaderStages},
|
||||||
@ -77,15 +77,18 @@ impl PipelineDescriptor {
|
|||||||
depth_bias: 0,
|
depth_bias: 0,
|
||||||
depth_bias_slope_scale: 0.0,
|
depth_bias_slope_scale: 0.0,
|
||||||
depth_bias_clamp: 0.0,
|
depth_bias_clamp: 0.0,
|
||||||
|
clamp_depth: false,
|
||||||
}),
|
}),
|
||||||
depth_stencil_state: Some(DepthStencilStateDescriptor {
|
depth_stencil_state: Some(DepthStencilStateDescriptor {
|
||||||
format: TextureFormat::Depth32Float,
|
format: TextureFormat::Depth32Float,
|
||||||
depth_write_enabled: true,
|
depth_write_enabled: true,
|
||||||
depth_compare: CompareFunction::Less,
|
depth_compare: CompareFunction::Less,
|
||||||
stencil_front: StencilStateFaceDescriptor::IGNORE,
|
stencil: StencilStateDescriptor {
|
||||||
stencil_back: StencilStateFaceDescriptor::IGNORE,
|
front: StencilStateFaceDescriptor::IGNORE,
|
||||||
stencil_read_mask: 0,
|
back: StencilStateFaceDescriptor::IGNORE,
|
||||||
stencil_write_mask: 0,
|
read_mask: 0,
|
||||||
|
write_mask: 0,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
color_states: vec![ColorStateDescriptor {
|
color_states: vec![ColorStateDescriptor {
|
||||||
format: TextureFormat::Bgra8UnormSrgb,
|
format: TextureFormat::Bgra8UnormSrgb,
|
||||||
|
@ -7,11 +7,17 @@ pub struct DepthStencilStateDescriptor {
|
|||||||
pub format: TextureFormat,
|
pub format: TextureFormat,
|
||||||
pub depth_write_enabled: bool,
|
pub depth_write_enabled: bool,
|
||||||
pub depth_compare: CompareFunction,
|
pub depth_compare: CompareFunction,
|
||||||
pub stencil_front: StencilStateFaceDescriptor,
|
pub stencil: StencilStateDescriptor,
|
||||||
pub stencil_back: StencilStateFaceDescriptor,
|
|
||||||
pub stencil_read_mask: u32,
|
|
||||||
pub stencil_write_mask: u32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct StencilStateDescriptor {
|
||||||
|
pub front: StencilStateFaceDescriptor,
|
||||||
|
pub back: StencilStateFaceDescriptor,
|
||||||
|
pub read_mask: u32,
|
||||||
|
pub write_mask: u32,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||||
pub enum StencilOperation {
|
pub enum StencilOperation {
|
||||||
Keep = 0,
|
Keep = 0,
|
||||||
@ -100,6 +106,7 @@ pub struct RasterizationStateDescriptor {
|
|||||||
pub depth_bias: i32,
|
pub depth_bias: i32,
|
||||||
pub depth_bias_slope_scale: f32,
|
pub depth_bias_slope_scale: f32,
|
||||||
pub depth_bias_clamp: f32,
|
pub depth_bias_clamp: f32,
|
||||||
|
pub clamp_depth: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
@ -10,15 +10,15 @@ use std::{
|
|||||||
pub struct BindGroupId(pub u64);
|
pub struct BindGroupId(pub u64);
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Debug)]
|
#[derive(Eq, PartialEq, Debug)]
|
||||||
pub struct IndexedBinding {
|
pub struct IndexedBindGroupEntry {
|
||||||
pub index: u32,
|
pub index: u32,
|
||||||
pub binding: RenderResourceBinding,
|
pub entry: RenderResourceBinding,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Eq, PartialEq, Debug)]
|
#[derive(Clone, Eq, PartialEq, Debug)]
|
||||||
pub struct BindGroup {
|
pub struct BindGroup {
|
||||||
pub id: BindGroupId,
|
pub id: BindGroupId,
|
||||||
pub indexed_bindings: Arc<Vec<IndexedBinding>>,
|
pub indexed_bindings: Arc<Vec<IndexedBindGroupEntry>>,
|
||||||
pub dynamic_uniform_indices: Option<Arc<Vec<u32>>>,
|
pub dynamic_uniform_indices: Option<Arc<Vec<u32>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ impl BindGroup {
|
|||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct BindGroupBuilder {
|
pub struct BindGroupBuilder {
|
||||||
pub indexed_bindings: Vec<IndexedBinding>,
|
pub indexed_bindings: Vec<IndexedBindGroupEntry>,
|
||||||
pub dynamic_uniform_indices: Vec<u32>,
|
pub dynamic_uniform_indices: Vec<u32>,
|
||||||
pub hasher: DefaultHasher,
|
pub hasher: DefaultHasher,
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ impl BindGroupBuilder {
|
|||||||
|
|
||||||
binding.hash(&mut self.hasher);
|
binding.hash(&mut self.hasher);
|
||||||
self.indexed_bindings
|
self.indexed_bindings
|
||||||
.push(IndexedBinding { index, binding });
|
.push(IndexedBindGroupEntry { index, entry: binding });
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use super::Texture;
|
use super::Texture;
|
||||||
use crate::pipeline::CompareFunction;
|
use crate::pipeline::CompareFunction;
|
||||||
|
use std::num::NonZeroU8;
|
||||||
|
|
||||||
/// Describes a sampler
|
/// Describes a sampler
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
@ -13,7 +14,7 @@ pub struct SamplerDescriptor {
|
|||||||
pub lod_min_clamp: f32,
|
pub lod_min_clamp: f32,
|
||||||
pub lod_max_clamp: f32,
|
pub lod_max_clamp: f32,
|
||||||
pub compare_function: Option<CompareFunction>,
|
pub compare_function: Option<CompareFunction>,
|
||||||
pub anisotropy_clamp: Option<u8>,
|
pub anisotropy_clamp: Option<NonZeroU8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for SamplerDescriptor {
|
impl Default for SamplerDescriptor {
|
||||||
|
@ -5,7 +5,7 @@ use bevy_render::{
|
|||||||
pipeline::{
|
pipeline::{
|
||||||
BlendDescriptor, BlendFactor, BlendOperation, ColorStateDescriptor, ColorWrite,
|
BlendDescriptor, BlendFactor, BlendOperation, ColorStateDescriptor, ColorWrite,
|
||||||
CompareFunction, CullMode, DepthStencilStateDescriptor, FrontFace, PipelineDescriptor,
|
CompareFunction, CullMode, DepthStencilStateDescriptor, FrontFace, PipelineDescriptor,
|
||||||
RasterizationStateDescriptor, StencilStateFaceDescriptor,
|
RasterizationStateDescriptor, StencilStateDescriptor, StencilStateFaceDescriptor,
|
||||||
},
|
},
|
||||||
render_graph::{base, AssetRenderResourcesNode, RenderGraph, RenderResourcesNode},
|
render_graph::{base, AssetRenderResourcesNode, RenderGraph, RenderResourcesNode},
|
||||||
shader::{Shader, ShaderStage, ShaderStages},
|
shader::{Shader, ShaderStage, ShaderStages},
|
||||||
@ -26,15 +26,18 @@ pub fn build_sprite_sheet_pipeline(shaders: &mut Assets<Shader>) -> PipelineDesc
|
|||||||
depth_bias: 0,
|
depth_bias: 0,
|
||||||
depth_bias_slope_scale: 0.0,
|
depth_bias_slope_scale: 0.0,
|
||||||
depth_bias_clamp: 0.0,
|
depth_bias_clamp: 0.0,
|
||||||
|
clamp_depth: false,
|
||||||
}),
|
}),
|
||||||
depth_stencil_state: Some(DepthStencilStateDescriptor {
|
depth_stencil_state: Some(DepthStencilStateDescriptor {
|
||||||
format: TextureFormat::Depth32Float,
|
format: TextureFormat::Depth32Float,
|
||||||
depth_write_enabled: true,
|
depth_write_enabled: true,
|
||||||
depth_compare: CompareFunction::Less,
|
depth_compare: CompareFunction::Less,
|
||||||
stencil_front: StencilStateFaceDescriptor::IGNORE,
|
stencil: StencilStateDescriptor {
|
||||||
stencil_back: StencilStateFaceDescriptor::IGNORE,
|
front: StencilStateFaceDescriptor::IGNORE,
|
||||||
stencil_read_mask: 0,
|
back: StencilStateFaceDescriptor::IGNORE,
|
||||||
stencil_write_mask: 0,
|
read_mask: 0,
|
||||||
|
write_mask: 0,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
color_states: vec![ColorStateDescriptor {
|
color_states: vec![ColorStateDescriptor {
|
||||||
format: TextureFormat::Bgra8UnormSrgb,
|
format: TextureFormat::Bgra8UnormSrgb,
|
||||||
@ -71,15 +74,18 @@ pub fn build_sprite_pipeline(shaders: &mut Assets<Shader>) -> PipelineDescriptor
|
|||||||
depth_bias: 0,
|
depth_bias: 0,
|
||||||
depth_bias_slope_scale: 0.0,
|
depth_bias_slope_scale: 0.0,
|
||||||
depth_bias_clamp: 0.0,
|
depth_bias_clamp: 0.0,
|
||||||
|
clamp_depth: false,
|
||||||
}),
|
}),
|
||||||
depth_stencil_state: Some(DepthStencilStateDescriptor {
|
depth_stencil_state: Some(DepthStencilStateDescriptor {
|
||||||
format: TextureFormat::Depth32Float,
|
format: TextureFormat::Depth32Float,
|
||||||
depth_write_enabled: true,
|
depth_write_enabled: true,
|
||||||
depth_compare: CompareFunction::Less,
|
depth_compare: CompareFunction::Less,
|
||||||
stencil_front: StencilStateFaceDescriptor::IGNORE,
|
stencil: StencilStateDescriptor {
|
||||||
stencil_back: StencilStateFaceDescriptor::IGNORE,
|
front: StencilStateFaceDescriptor::IGNORE,
|
||||||
stencil_read_mask: 0,
|
back: StencilStateFaceDescriptor::IGNORE,
|
||||||
stencil_write_mask: 0,
|
read_mask: 0,
|
||||||
|
write_mask: 0,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
color_states: vec![ColorStateDescriptor {
|
color_states: vec![ColorStateDescriptor {
|
||||||
format: TextureFormat::Bgra8UnormSrgb,
|
format: TextureFormat::Bgra8UnormSrgb,
|
||||||
|
@ -28,15 +28,18 @@ pub fn build_ui_pipeline(shaders: &mut Assets<Shader>) -> PipelineDescriptor {
|
|||||||
depth_bias: 0,
|
depth_bias: 0,
|
||||||
depth_bias_slope_scale: 0.0,
|
depth_bias_slope_scale: 0.0,
|
||||||
depth_bias_clamp: 0.0,
|
depth_bias_clamp: 0.0,
|
||||||
|
clamp_depth: false,
|
||||||
}),
|
}),
|
||||||
depth_stencil_state: Some(DepthStencilStateDescriptor {
|
depth_stencil_state: Some(DepthStencilStateDescriptor {
|
||||||
format: TextureFormat::Depth32Float,
|
format: TextureFormat::Depth32Float,
|
||||||
depth_write_enabled: true,
|
depth_write_enabled: true,
|
||||||
depth_compare: CompareFunction::Less,
|
depth_compare: CompareFunction::Less,
|
||||||
stencil_front: StencilStateFaceDescriptor::IGNORE,
|
stencil: StencilStateDescriptor {
|
||||||
stencil_back: StencilStateFaceDescriptor::IGNORE,
|
front: StencilStateFaceDescriptor::IGNORE,
|
||||||
stencil_read_mask: 0,
|
back: StencilStateFaceDescriptor::IGNORE,
|
||||||
stencil_write_mask: 0,
|
read_mask: 0,
|
||||||
|
write_mask: 0,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
color_states: vec![ColorStateDescriptor {
|
color_states: vec![ColorStateDescriptor {
|
||||||
format: TextureFormat::Bgra8UnormSrgb,
|
format: TextureFormat::Bgra8UnormSrgb,
|
||||||
|
@ -25,7 +25,7 @@ bevy_window = { path = "../bevy_window", version = "0.1" }
|
|||||||
bevy_winit = { path = "../bevy_winit", optional = true, version = "0.1" }
|
bevy_winit = { path = "../bevy_winit", optional = true, version = "0.1" }
|
||||||
|
|
||||||
# other
|
# other
|
||||||
wgpu = { version = "0.1.0", package = "cart-tmp-wgpu" }
|
wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "333aeb73c103037abdae62abc078c4fcf745aef7" }
|
||||||
pollster = "0.2.0"
|
pollster = "0.2.0"
|
||||||
log = { version = "0.4", features = ["release_max_level_info"] }
|
log = { version = "0.4", features = ["release_max_level_info"] }
|
||||||
crossbeam-channel = "0.4.2"
|
crossbeam-channel = "0.4.2"
|
||||||
|
@ -16,7 +16,8 @@ use bevy_render::{
|
|||||||
texture::{Extent3d, SamplerDescriptor, TextureDescriptor},
|
texture::{Extent3d, SamplerDescriptor, TextureDescriptor},
|
||||||
};
|
};
|
||||||
use bevy_window::{Window, WindowId};
|
use bevy_window::{Window, WindowId};
|
||||||
use std::{ops::Range, sync::Arc};
|
use std::{ops::Range, sync::Arc, borrow::Cow};
|
||||||
|
use wgpu::util::DeviceExt;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct WgpuRenderResourceContext {
|
pub struct WgpuRenderResourceContext {
|
||||||
@ -111,7 +112,7 @@ impl WgpuRenderResourceContext {
|
|||||||
|
|
||||||
let mut bind_group_layouts = self.resources.bind_group_layouts.write();
|
let mut bind_group_layouts = self.resources.bind_group_layouts.write();
|
||||||
// TODO: consider re-checking existence here
|
// TODO: consider re-checking existence here
|
||||||
let bind_group_layout_binding = descriptor
|
let bind_group_layout_entries = descriptor
|
||||||
.bindings
|
.bindings
|
||||||
.iter()
|
.iter()
|
||||||
.map(|binding| {
|
.map(|binding| {
|
||||||
@ -126,15 +127,16 @@ impl WgpuRenderResourceContext {
|
|||||||
} else {
|
} else {
|
||||||
panic!("Invalid binding shader stage.")
|
panic!("Invalid binding shader stage.")
|
||||||
};
|
};
|
||||||
wgpu::BindGroupLayoutEntry::new(
|
wgpu::BindGroupLayoutEntry {
|
||||||
binding.index,
|
binding: binding.index,
|
||||||
shader_stage,
|
visibility: shader_stage,
|
||||||
(&binding.bind_type).wgpu_into(),
|
ty: (&binding.bind_type).wgpu_into(),
|
||||||
)
|
count: None,
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<wgpu::BindGroupLayoutEntry>>();
|
.collect::<Vec<wgpu::BindGroupLayoutEntry>>();
|
||||||
let wgpu_descriptor = wgpu::BindGroupLayoutDescriptor {
|
let wgpu_descriptor = wgpu::BindGroupLayoutDescriptor {
|
||||||
bindings: bind_group_layout_binding.as_slice(),
|
entries: bind_group_layout_entries.as_slice(),
|
||||||
label: None,
|
label: None,
|
||||||
};
|
};
|
||||||
let bind_group_layout = self.device.create_bind_group_layout(&wgpu_descriptor);
|
let bind_group_layout = self.device.create_bind_group_layout(&wgpu_descriptor);
|
||||||
@ -146,7 +148,7 @@ impl WgpuRenderResourceContext {
|
|||||||
let mut swap_chain_outputs = self.resources.swap_chain_frames.write();
|
let mut swap_chain_outputs = self.resources.swap_chain_frames.write();
|
||||||
|
|
||||||
let window_swap_chain = window_swap_chains.get_mut(&window_id).unwrap();
|
let window_swap_chain = window_swap_chains.get_mut(&window_id).unwrap();
|
||||||
let next_texture = window_swap_chain.get_next_frame().ok()?;
|
let next_texture = window_swap_chain.get_current_frame().ok()?;
|
||||||
let id = TextureId::new();
|
let id = TextureId::new();
|
||||||
swap_chain_outputs.insert(id, next_texture);
|
swap_chain_outputs.insert(id, next_texture);
|
||||||
Some(id)
|
Some(id)
|
||||||
@ -172,7 +174,7 @@ impl RenderResourceContext for WgpuRenderResourceContext {
|
|||||||
|
|
||||||
let descriptor: wgpu::TextureDescriptor = (&texture_descriptor).wgpu_into();
|
let descriptor: wgpu::TextureDescriptor = (&texture_descriptor).wgpu_into();
|
||||||
let texture = self.device.create_texture(&descriptor);
|
let texture = self.device.create_texture(&descriptor);
|
||||||
let texture_view = texture.create_default_view();
|
let texture_view = texture.create_view(&wgpu::TextureViewDescriptor::default());
|
||||||
|
|
||||||
let id = TextureId::new();
|
let id = TextureId::new();
|
||||||
texture_descriptors.insert(id, texture_descriptor);
|
texture_descriptors.insert(id, texture_descriptor);
|
||||||
@ -207,7 +209,11 @@ impl RenderResourceContext for WgpuRenderResourceContext {
|
|||||||
buffer_info.size = data.len();
|
buffer_info.size = data.len();
|
||||||
let buffer = self
|
let buffer = self
|
||||||
.device
|
.device
|
||||||
.create_buffer_with_data(data, buffer_info.buffer_usage.wgpu_into());
|
.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||||
|
contents: data,
|
||||||
|
label: None,
|
||||||
|
usage: buffer_info.buffer_usage.wgpu_into(),
|
||||||
|
});
|
||||||
|
|
||||||
let id = BufferId::new();
|
let id = BufferId::new();
|
||||||
buffer_infos.insert(id, buffer_info);
|
buffer_infos.insert(id, buffer_info);
|
||||||
@ -240,9 +246,10 @@ impl RenderResourceContext for WgpuRenderResourceContext {
|
|||||||
|
|
||||||
fn create_shader_module_from_source(&self, shader_handle: Handle<Shader>, shader: &Shader) {
|
fn create_shader_module_from_source(&self, shader_handle: Handle<Shader>, shader: &Shader) {
|
||||||
let mut shader_modules = self.resources.shader_modules.write();
|
let mut shader_modules = self.resources.shader_modules.write();
|
||||||
|
let spirv: Cow<[u32]> = shader.get_spirv(None).into();
|
||||||
let shader_module = self
|
let shader_module = self
|
||||||
.device
|
.device
|
||||||
.create_shader_module(wgpu::ShaderModuleSource::SpirV(&shader.get_spirv(None)));
|
.create_shader_module(wgpu::ShaderModuleSource::SpirV(spirv));
|
||||||
shader_modules.insert(shader_handle, shader_module);
|
shader_modules.insert(shader_handle, shader_module);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,7 +359,9 @@ impl RenderResourceContext for WgpuRenderResourceContext {
|
|||||||
let pipeline_layout = self
|
let pipeline_layout = self
|
||||||
.device
|
.device
|
||||||
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
||||||
|
label: None,
|
||||||
bind_group_layouts: bind_group_layouts.as_slice(),
|
bind_group_layouts: bind_group_layouts.as_slice(),
|
||||||
|
push_constant_ranges: &[],
|
||||||
});
|
});
|
||||||
|
|
||||||
let owned_vertex_buffer_descriptors = layout
|
let owned_vertex_buffer_descriptors = layout
|
||||||
@ -384,7 +393,8 @@ impl RenderResourceContext for WgpuRenderResourceContext {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let render_pipeline_descriptor = wgpu::RenderPipelineDescriptor {
|
let render_pipeline_descriptor = wgpu::RenderPipelineDescriptor {
|
||||||
layout: &pipeline_layout,
|
label: None,
|
||||||
|
layout: Some(&pipeline_layout),
|
||||||
vertex_stage: wgpu::ProgrammableStageDescriptor {
|
vertex_stage: wgpu::ProgrammableStageDescriptor {
|
||||||
module: &vertex_shader_module,
|
module: &vertex_shader_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
@ -452,11 +462,11 @@ impl RenderResourceContext for WgpuRenderResourceContext {
|
|||||||
let bind_group_layouts = self.resources.bind_group_layouts.read();
|
let bind_group_layouts = self.resources.bind_group_layouts.read();
|
||||||
let mut bind_groups = self.resources.bind_groups.write();
|
let mut bind_groups = self.resources.bind_groups.write();
|
||||||
|
|
||||||
let bindings = bind_group
|
let entries = bind_group
|
||||||
.indexed_bindings
|
.indexed_bindings
|
||||||
.iter()
|
.iter()
|
||||||
.map(|indexed_binding| {
|
.map(|indexed_binding| {
|
||||||
let wgpu_resource = match &indexed_binding.binding {
|
let wgpu_resource = match &indexed_binding.entry {
|
||||||
RenderResourceBinding::Texture(resource) => {
|
RenderResourceBinding::Texture(resource) => {
|
||||||
let texture_view = texture_views
|
let texture_view = texture_views
|
||||||
.get(&resource)
|
.get(&resource)
|
||||||
@ -472,18 +482,18 @@ impl RenderResourceContext for WgpuRenderResourceContext {
|
|||||||
wgpu::BindingResource::Buffer(wgpu_buffer.slice(range.clone()))
|
wgpu::BindingResource::Buffer(wgpu_buffer.slice(range.clone()))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
wgpu::Binding {
|
wgpu::BindGroupEntry {
|
||||||
binding: indexed_binding.index,
|
binding: indexed_binding.index,
|
||||||
resource: wgpu_resource,
|
resource: wgpu_resource,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<wgpu::Binding>>();
|
.collect::<Vec<wgpu::BindGroupEntry>>();
|
||||||
|
|
||||||
let bind_group_layout = bind_group_layouts.get(&bind_group_descriptor_id).unwrap();
|
let bind_group_layout = bind_group_layouts.get(&bind_group_descriptor_id).unwrap();
|
||||||
let wgpu_bind_group_descriptor = wgpu::BindGroupDescriptor {
|
let wgpu_bind_group_descriptor = wgpu::BindGroupDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
layout: bind_group_layout,
|
layout: bind_group_layout,
|
||||||
bindings: bindings.as_slice(),
|
entries: entries.as_slice(),
|
||||||
};
|
};
|
||||||
let wgpu_bind_group = self.device.create_bind_group(&wgpu_bind_group_descriptor);
|
let wgpu_bind_group = self.device.create_bind_group(&wgpu_bind_group_descriptor);
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ use bevy_render::{
|
|||||||
CompareFunction, CullMode, DepthStencilStateDescriptor, FrontFace, IndexFormat,
|
CompareFunction, CullMode, DepthStencilStateDescriptor, FrontFace, IndexFormat,
|
||||||
InputStepMode, PrimitiveTopology, RasterizationStateDescriptor, StencilOperation,
|
InputStepMode, PrimitiveTopology, RasterizationStateDescriptor, StencilOperation,
|
||||||
StencilStateFaceDescriptor, VertexAttributeDescriptor, VertexBufferDescriptor,
|
StencilStateFaceDescriptor, VertexAttributeDescriptor, VertexBufferDescriptor,
|
||||||
VertexFormat,
|
VertexFormat, StencilStateDescriptor,
|
||||||
},
|
},
|
||||||
renderer::BufferUsage,
|
renderer::BufferUsage,
|
||||||
texture::{
|
texture::{
|
||||||
@ -322,16 +322,24 @@ impl WgpuFrom<TextureUsage> for wgpu::TextureUsage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl WgpuFrom<&StencilStateDescriptor> for wgpu::StencilStateDescriptor {
|
||||||
|
fn from(val: &StencilStateDescriptor) -> Self {
|
||||||
|
wgpu::StencilStateDescriptor {
|
||||||
|
back: (&val.back).wgpu_into(),
|
||||||
|
front: (&val.front).wgpu_into(),
|
||||||
|
read_mask: val.read_mask,
|
||||||
|
write_mask: val.write_mask,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl WgpuFrom<&DepthStencilStateDescriptor> for wgpu::DepthStencilStateDescriptor {
|
impl WgpuFrom<&DepthStencilStateDescriptor> for wgpu::DepthStencilStateDescriptor {
|
||||||
fn from(val: &DepthStencilStateDescriptor) -> Self {
|
fn from(val: &DepthStencilStateDescriptor) -> Self {
|
||||||
wgpu::DepthStencilStateDescriptor {
|
wgpu::DepthStencilStateDescriptor {
|
||||||
depth_compare: val.depth_compare.wgpu_into(),
|
depth_compare: val.depth_compare.wgpu_into(),
|
||||||
depth_write_enabled: val.depth_write_enabled,
|
depth_write_enabled: val.depth_write_enabled,
|
||||||
format: val.format.wgpu_into(),
|
format: val.format.wgpu_into(),
|
||||||
stencil_back: (&val.stencil_back).wgpu_into(),
|
stencil: (&val.stencil).wgpu_into(),
|
||||||
stencil_front: (&val.stencil_front).wgpu_into(),
|
|
||||||
stencil_read_mask: val.stencil_read_mask,
|
|
||||||
stencil_write_mask: val.stencil_write_mask,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -440,6 +448,7 @@ impl WgpuFrom<&RasterizationStateDescriptor> for wgpu::RasterizationStateDescrip
|
|||||||
depth_bias: val.depth_bias,
|
depth_bias: val.depth_bias,
|
||||||
depth_bias_slope_scale: val.depth_bias_slope_scale,
|
depth_bias_slope_scale: val.depth_bias_slope_scale,
|
||||||
depth_bias_clamp: val.depth_bias_clamp,
|
depth_bias_clamp: val.depth_bias_clamp,
|
||||||
|
clamp_depth: val.clamp_depth,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user