Update to latest wgpu git (around 0.7), temporarily disable shader validation due to naga bug, rebase fixes!!

This commit is contained in:
Imbris 2021-02-03 22:30:43 -05:00
parent c532f50e64
commit 843529c7bb
16 changed files with 447 additions and 445 deletions

View File

@ -45,7 +45,7 @@ i18n = {package = "veloren-i18n", path = "i18n"}
# Graphics # Graphics
winit = {version = "0.24.0", features = ["serde"]} winit = {version = "0.24.0", features = ["serde"]}
wgpu = { git = "https://github.com/gfx-rs/wgpu-rs.git", rev = "ab8b0e3766558d541206da2790dfd63f15b13bc4" } wgpu = { git = "https://github.com/gfx-rs/wgpu-rs.git", rev = "f891e86e87f0733f04a8078f4be8ead2f24551cf" }
bytemuck = { version="1.4", features=["derive"] } bytemuck = { version="1.4", features=["derive"] }
shaderc = "0.6.2" shaderc = "0.6.2"

View File

@ -171,30 +171,34 @@ impl CloudsPipeline {
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("Clouds pipeline"), label: Some("Clouds pipeline"),
layout: Some(&render_pipeline_layout), layout: Some(&render_pipeline_layout),
vertex_stage: wgpu::ProgrammableStageDescriptor { vertex: wgpu::VertexState {
module: vs_module, module: vs_module,
entry_point: "main", entry_point: "main",
buffers: &[],
}, },
fragment_stage: Some(wgpu::ProgrammableStageDescriptor { primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
strip_index_format: None,
front_face: wgpu::FrontFace::Ccw,
cull_mode: wgpu::CullMode::None,
polygon_mode: wgpu::PolygonMode::Fill,
},
depth_stencil: None,
multisample: wgpu::MultisampleState {
count: samples,
mask: !0,
alpha_to_coverage_enabled: false,
},
fragment: Some(wgpu::FragmentState {
module: fs_module, module: fs_module,
entry_point: "main", entry_point: "main",
}), targets: &[wgpu::ColorTargetState {
rasterization_state: None,
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
color_states: &[wgpu::ColorStateDescriptor {
format: sc_desc.format, format: sc_desc.format,
color_blend: wgpu::BlendDescriptor::REPLACE, alpha_blend: wgpu::BlendState::REPLACE,
alpha_blend: wgpu::BlendDescriptor::REPLACE, color_blend: wgpu::BlendState::REPLACE,
write_mask: wgpu::ColorWrite::ALL, write_mask: wgpu::ColorWrite::ALL,
}], }],
depth_stencil_state: None, }),
vertex_state: wgpu::VertexStateDescriptor {
index_format: None,
vertex_buffers: &[],
},
sample_count: samples,
sample_mask: !0,
alpha_to_coverage_enabled: false,
}); });
Self { Self {

View File

@ -202,48 +202,50 @@ impl FigurePipeline {
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("Figure pipeline"), label: Some("Figure pipeline"),
layout: Some(&render_pipeline_layout), layout: Some(&render_pipeline_layout),
vertex_stage: wgpu::ProgrammableStageDescriptor { vertex: wgpu::VertexState {
module: vs_module, module: vs_module,
entry_point: "main", entry_point: "main",
buffers: &[Vertex::desc()],
}, },
fragment_stage: Some(wgpu::ProgrammableStageDescriptor { primitive: wgpu::PrimitiveState {
module: fs_module, topology: wgpu::PrimitiveTopology::TriangleList,
entry_point: "main", strip_index_format: None,
}),
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
front_face: wgpu::FrontFace::Ccw, front_face: wgpu::FrontFace::Ccw,
cull_mode: wgpu::CullMode::Back, cull_mode: wgpu::CullMode::Back,
polygon_mode: wgpu::PolygonMode::Fill, polygon_mode: wgpu::PolygonMode::Fill,
clamp_depth: false, },
depth_bias: 0, depth_stencil: Some(wgpu::DepthStencilState {
depth_bias_slope_scale: 0.0,
depth_bias_clamp: 0.0,
}),
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
color_states: &[wgpu::ColorStateDescriptor {
format: sc_desc.format,
color_blend: wgpu::BlendDescriptor::REPLACE,
alpha_blend: wgpu::BlendDescriptor::REPLACE,
write_mask: wgpu::ColorWrite::ALL,
}],
depth_stencil_state: Some(wgpu::DepthStencilStateDescriptor {
format: wgpu::TextureFormat::Depth32Float, format: wgpu::TextureFormat::Depth32Float,
depth_write_enabled: true, depth_write_enabled: true,
depth_compare: wgpu::CompareFunction::GreaterEqual, depth_compare: wgpu::CompareFunction::GreaterEqual,
stencil: wgpu::StencilStateDescriptor { stencil: wgpu::StencilState {
front: wgpu::StencilStateFaceDescriptor::IGNORE, front: wgpu::StencilFaceState::IGNORE,
back: wgpu::StencilStateFaceDescriptor::IGNORE, back: wgpu::StencilFaceState::IGNORE,
read_mask: !0, read_mask: !0,
write_mask: !0, write_mask: !0,
}, },
}), bias: wgpu::DepthBiasState {
vertex_state: wgpu::VertexStateDescriptor { constant: 0,
index_format: None, slope_scale: 0.0,
vertex_buffers: &[Vertex::desc()], clamp: 0.0,
}, },
sample_count: samples, clamp_depth: false,
sample_mask: !0, }),
multisample: wgpu::MultisampleState {
count: samples,
mask: !0,
alpha_to_coverage_enabled: false, alpha_to_coverage_enabled: false,
},
fragment: Some(wgpu::FragmentState {
module: fs_module,
entry_point: "main",
targets: &[wgpu::ColorTargetState {
format: sc_desc.format,
color_blend: wgpu::BlendState::REPLACE,
alpha_blend: wgpu::BlendState::REPLACE,
write_mask: wgpu::ColorWrite::ALL,
}],
}),
}); });
Self { Self {

View File

@ -32,11 +32,10 @@ impl Vertex {
} }
} }
fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> { fn desc<'a>() -> wgpu::VertexBufferLayout<'a> {
const ATTRIBUTES: [wgpu::VertexAttributeDescriptor; 1] = const ATTRIBUTES: [wgpu::VertexAttribute; 1] = wgpu::vertex_attr_array![0 => Uint];
wgpu::vertex_attr_array![0 => Uint]; wgpu::VertexBufferLayout {
wgpu::VertexBufferDescriptor { array_stride: Self::STRIDE,
stride: Self::STRIDE,
step_mode: wgpu::InputStepMode::Vertex, step_mode: wgpu::InputStepMode::Vertex,
attributes: &ATTRIBUTES, attributes: &ATTRIBUTES,
} }
@ -145,56 +144,58 @@ impl FluidPipeline {
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("Fluid pipeline"), label: Some("Fluid pipeline"),
layout: Some(&render_pipeline_layout), layout: Some(&render_pipeline_layout),
vertex_stage: wgpu::ProgrammableStageDescriptor { vertex: wgpu::VertexState {
module: vs_module, module: vs_module,
entry_point: "main", entry_point: "main",
buffers: &[Vertex::desc()],
}, },
fragment_stage: Some(wgpu::ProgrammableStageDescriptor { primitive: wgpu::PrimitiveState {
module: fs_module, topology: wgpu::PrimitiveTopology::TriangleList,
entry_point: "main", strip_index_format: None,
}),
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
front_face: wgpu::FrontFace::Ccw, front_face: wgpu::FrontFace::Ccw,
cull_mode: wgpu::CullMode::None, cull_mode: wgpu::CullMode::None,
polygon_mode: wgpu::PolygonMode::Fill, polygon_mode: wgpu::PolygonMode::Fill,
},
depth_stencil: Some(wgpu::DepthStencilState {
format: wgpu::TextureFormat::Depth32Float,
depth_write_enabled: false,
depth_compare: wgpu::CompareFunction::GreaterEqual,
stencil: wgpu::StencilState {
front: wgpu::StencilFaceState::IGNORE,
back: wgpu::StencilFaceState::IGNORE,
read_mask: !0,
write_mask: !0,
},
bias: wgpu::DepthBiasState {
constant: 0,
slope_scale: 0.0,
clamp: 0.0,
},
clamp_depth: false, clamp_depth: false,
depth_bias: 0,
depth_bias_slope_scale: 0.0,
depth_bias_clamp: 0.0,
}), }),
primitive_topology: wgpu::PrimitiveTopology::TriangleList, multisample: wgpu::MultisampleState {
color_states: &[wgpu::ColorStateDescriptor { count: samples,
mask: !0,
alpha_to_coverage_enabled: false,
},
fragment: Some(wgpu::FragmentState {
module: fs_module,
entry_point: "main",
targets: &[wgpu::ColorTargetState {
format: sc_desc.format, format: sc_desc.format,
color_blend: wgpu::BlendDescriptor { color_blend: wgpu::BlendState {
src_factor: wgpu::BlendFactor::SrcAlpha, src_factor: wgpu::BlendFactor::SrcAlpha,
dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha, dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,
operation: wgpu::BlendOperation::Add, operation: wgpu::BlendOperation::Add,
}, },
alpha_blend: wgpu::BlendDescriptor { alpha_blend: wgpu::BlendState {
src_factor: wgpu::BlendFactor::One, src_factor: wgpu::BlendFactor::One,
dst_factor: wgpu::BlendFactor::One, dst_factor: wgpu::BlendFactor::One,
operation: wgpu::BlendOperation::Add, operation: wgpu::BlendOperation::Add,
}, },
write_mask: wgpu::ColorWrite::ALL, write_mask: wgpu::ColorWrite::ALL,
}], }],
depth_stencil_state: Some(wgpu::DepthStencilStateDescriptor {
format: wgpu::TextureFormat::Depth32Float,
depth_write_enabled: false,
depth_compare: wgpu::CompareFunction::GreaterEqual,
stencil: wgpu::StencilStateDescriptor {
front: wgpu::StencilStateFaceDescriptor::IGNORE,
back: wgpu::StencilStateFaceDescriptor::IGNORE,
read_mask: !0,
write_mask: !0,
},
}), }),
vertex_state: wgpu::VertexStateDescriptor {
index_format: None,
vertex_buffers: &[Vertex::desc()],
},
sample_count: samples,
sample_mask: !0,
alpha_to_coverage_enabled: false,
}); });
Self { Self {

View File

@ -16,11 +16,10 @@ impl Vertex {
} }
} }
fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> { fn desc<'a>() -> wgpu::VertexBufferLayout<'a> {
const ATTRIBUTES: [wgpu::VertexAttributeDescriptor; 1] = const ATTRIBUTES: [wgpu::VertexAttribute; 1] = wgpu::vertex_attr_array![0 => Float2];
wgpu::vertex_attr_array![0 => Float2]; wgpu::VertexBufferLayout {
wgpu::VertexBufferDescriptor { array_stride: Self::STRIDE,
stride: Self::STRIDE,
step_mode: wgpu::InputStepMode::Vertex, step_mode: wgpu::InputStepMode::Vertex,
attributes: &ATTRIBUTES, attributes: &ATTRIBUTES,
} }
@ -162,48 +161,50 @@ impl LodTerrainPipeline {
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("Lod terrain pipeline"), label: Some("Lod terrain pipeline"),
layout: Some(&render_pipeline_layout), layout: Some(&render_pipeline_layout),
vertex_stage: wgpu::ProgrammableStageDescriptor { vertex: wgpu::VertexState {
module: vs_module, module: vs_module,
entry_point: "main", entry_point: "main",
buffers: &[Vertex::desc()],
}, },
fragment_stage: Some(wgpu::ProgrammableStageDescriptor { primitive: wgpu::PrimitiveState {
module: fs_module, topology: wgpu::PrimitiveTopology::TriangleList,
entry_point: "main", strip_index_format: None,
}),
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
front_face: wgpu::FrontFace::Ccw, front_face: wgpu::FrontFace::Ccw,
cull_mode: wgpu::CullMode::Back, cull_mode: wgpu::CullMode::Back,
polygon_mode: wgpu::PolygonMode::Fill, polygon_mode: wgpu::PolygonMode::Fill,
clamp_depth: false, },
depth_bias: 0, depth_stencil: Some(wgpu::DepthStencilState {
depth_bias_slope_scale: 0.0,
depth_bias_clamp: 0.0,
}),
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
color_states: &[wgpu::ColorStateDescriptor {
format: sc_desc.format,
color_blend: wgpu::BlendDescriptor::REPLACE,
alpha_blend: wgpu::BlendDescriptor::REPLACE,
write_mask: wgpu::ColorWrite::ALL,
}],
depth_stencil_state: Some(wgpu::DepthStencilStateDescriptor {
format: wgpu::TextureFormat::Depth32Float, format: wgpu::TextureFormat::Depth32Float,
depth_write_enabled: true, depth_write_enabled: true,
depth_compare: wgpu::CompareFunction::GreaterEqual, depth_compare: wgpu::CompareFunction::GreaterEqual,
stencil: wgpu::StencilStateDescriptor { stencil: wgpu::StencilState {
front: wgpu::StencilStateFaceDescriptor::IGNORE, front: wgpu::StencilFaceState::IGNORE,
back: wgpu::StencilStateFaceDescriptor::IGNORE, back: wgpu::StencilFaceState::IGNORE,
read_mask: !0, read_mask: !0,
write_mask: !0, write_mask: !0,
}, },
}), bias: wgpu::DepthBiasState {
vertex_state: wgpu::VertexStateDescriptor { constant: 0,
index_format: None, slope_scale: 0.0,
vertex_buffers: &[Vertex::desc()], clamp: 0.0,
}, },
sample_count: samples, clamp_depth: false,
sample_mask: !0, }),
multisample: wgpu::MultisampleState {
count: samples,
mask: !0,
alpha_to_coverage_enabled: false, alpha_to_coverage_enabled: false,
},
fragment: Some(wgpu::FragmentState {
module: fs_module,
entry_point: "main",
targets: &[wgpu::ColorTargetState {
format: sc_desc.format,
color_blend: wgpu::BlendState::REPLACE,
alpha_blend: wgpu::BlendState::REPLACE,
write_mask: wgpu::ColorWrite::ALL,
}],
}),
}); });
Self { Self {

View File

@ -32,11 +32,11 @@ impl Vertex {
} }
} }
fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> { fn desc<'a>() -> wgpu::VertexBufferLayout<'a> {
const ATTRIBUTES: [wgpu::VertexAttributeDescriptor; 2] = const ATTRIBUTES: [wgpu::VertexAttribute; 2] =
wgpu::vertex_attr_array![0 => Float3, 1 => Uint]; wgpu::vertex_attr_array![0 => Float3, 1 => Uint];
wgpu::VertexBufferDescriptor { wgpu::VertexBufferLayout {
stride: Self::STRIDE, array_stride: Self::STRIDE,
step_mode: wgpu::InputStepMode::Vertex, step_mode: wgpu::InputStepMode::Vertex,
attributes: &ATTRIBUTES, attributes: &ATTRIBUTES,
} }
@ -154,10 +154,10 @@ impl Instance {
} }
} }
fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> { fn desc<'a>() -> wgpu::VertexBufferLayout<'a> {
const ATTRIBUTES: [wgpu::VertexAttributeDescriptor; 6] = wgpu::vertex_attr_array![2 => Float, 3 => Float, 4 => Float, 5 => Int, 6 => Float3, 7 => Float3]; const ATTRIBUTES: [wgpu::VertexAttribute; 6] = wgpu::vertex_attr_array![2 => Float, 3 => Float, 4 => Float, 5 => Int, 6 => Float3, 7 => Float3];
wgpu::VertexBufferDescriptor { wgpu::VertexBufferLayout {
stride: mem::size_of::<Self>() as wgpu::BufferAddress, array_stride: mem::size_of::<Self>() as wgpu::BufferAddress,
step_mode: wgpu::InputStepMode::Instance, step_mode: wgpu::InputStepMode::Instance,
attributes: &ATTRIBUTES, attributes: &ATTRIBUTES,
} }
@ -200,56 +200,58 @@ impl ParticlePipeline {
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("Particle pipeline"), label: Some("Particle pipeline"),
layout: Some(&render_pipeline_layout), layout: Some(&render_pipeline_layout),
vertex_stage: wgpu::ProgrammableStageDescriptor { vertex: wgpu::VertexState {
module: vs_module, module: vs_module,
entry_point: "main", entry_point: "main",
buffers: &[Vertex::desc(), Instance::desc()],
}, },
fragment_stage: Some(wgpu::ProgrammableStageDescriptor { primitive: wgpu::PrimitiveState {
module: fs_module, topology: wgpu::PrimitiveTopology::TriangleList,
entry_point: "main", strip_index_format: None,
}),
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
front_face: wgpu::FrontFace::Ccw, front_face: wgpu::FrontFace::Ccw,
cull_mode: wgpu::CullMode::Back, cull_mode: wgpu::CullMode::Back,
polygon_mode: wgpu::PolygonMode::Fill, polygon_mode: wgpu::PolygonMode::Fill,
},
depth_stencil: Some(wgpu::DepthStencilState {
format: wgpu::TextureFormat::Depth32Float,
depth_write_enabled: true,
depth_compare: wgpu::CompareFunction::GreaterEqual,
stencil: wgpu::StencilState {
front: wgpu::StencilFaceState::IGNORE,
back: wgpu::StencilFaceState::IGNORE,
read_mask: !0,
write_mask: !0,
},
bias: wgpu::DepthBiasState {
constant: 0,
slope_scale: 0.0,
clamp: 0.0,
},
clamp_depth: false, clamp_depth: false,
depth_bias: 0,
depth_bias_slope_scale: 0.0,
depth_bias_clamp: 0.0,
}), }),
primitive_topology: wgpu::PrimitiveTopology::TriangleList, multisample: wgpu::MultisampleState {
color_states: &[wgpu::ColorStateDescriptor { count: samples,
mask: !0,
alpha_to_coverage_enabled: false,
},
fragment: Some(wgpu::FragmentState {
module: fs_module,
entry_point: "main",
targets: &[wgpu::ColorTargetState {
format: sc_desc.format, format: sc_desc.format,
color_blend: wgpu::BlendDescriptor { color_blend: wgpu::BlendState {
src_factor: wgpu::BlendFactor::SrcAlpha, src_factor: wgpu::BlendFactor::SrcAlpha,
dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha, dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,
operation: wgpu::BlendOperation::Add, operation: wgpu::BlendOperation::Add,
}, },
alpha_blend: wgpu::BlendDescriptor { alpha_blend: wgpu::BlendState {
src_factor: wgpu::BlendFactor::One, src_factor: wgpu::BlendFactor::One,
dst_factor: wgpu::BlendFactor::One, dst_factor: wgpu::BlendFactor::One,
operation: wgpu::BlendOperation::Add, operation: wgpu::BlendOperation::Add,
}, },
write_mask: wgpu::ColorWrite::ALL, write_mask: wgpu::ColorWrite::ALL,
}], }],
depth_stencil_state: Some(wgpu::DepthStencilStateDescriptor {
format: wgpu::TextureFormat::Depth32Float,
depth_write_enabled: true,
depth_compare: wgpu::CompareFunction::GreaterEqual,
stencil: wgpu::StencilStateDescriptor {
front: wgpu::StencilStateFaceDescriptor::IGNORE,
back: wgpu::StencilStateFaceDescriptor::IGNORE,
read_mask: !0,
write_mask: !0,
},
}), }),
vertex_state: wgpu::VertexStateDescriptor {
index_format: None,
vertex_buffers: &[Vertex::desc(), Instance::desc()],
},
sample_count: samples,
sample_mask: !0,
alpha_to_coverage_enabled: false,
}); });
Self { Self {

View File

@ -114,7 +114,6 @@ impl PostProcessPipeline {
sc_desc: &wgpu::SwapChainDescriptor, sc_desc: &wgpu::SwapChainDescriptor,
global_layout: &GlobalsLayouts, global_layout: &GlobalsLayouts,
layout: &PostProcessLayout, layout: &PostProcessLayout,
aa_mode: AaMode,
) -> Self { ) -> Self {
common_base::span!(_guard, "PostProcessPipeline::new"); common_base::span!(_guard, "PostProcessPipeline::new");
let render_pipeline_layout = let render_pipeline_layout =
@ -124,41 +123,37 @@ impl PostProcessPipeline {
bind_group_layouts: &[&global_layout.globals, &layout.layout], bind_group_layouts: &[&global_layout.globals, &layout.layout],
}); });
let samples = match aa_mode {
AaMode::None | AaMode::Fxaa => 1,
// TODO: Ensure sampling in the shader is exactly between the 4 texels
AaMode::MsaaX4 => 4,
AaMode::MsaaX8 => 8,
AaMode::MsaaX16 => 16,
};
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("Post process pipeline"), label: Some("Post process pipeline"),
layout: Some(&render_pipeline_layout), layout: Some(&render_pipeline_layout),
vertex_stage: wgpu::ProgrammableStageDescriptor { vertex: wgpu::VertexState {
module: vs_module, module: vs_module,
entry_point: "main", entry_point: "main",
buffers: &[],
}, },
fragment_stage: Some(wgpu::ProgrammableStageDescriptor { primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
strip_index_format: None,
front_face: wgpu::FrontFace::Ccw,
cull_mode: wgpu::CullMode::None,
polygon_mode: wgpu::PolygonMode::Fill,
},
depth_stencil: None,
multisample: wgpu::MultisampleState {
count: 1,
mask: !0,
alpha_to_coverage_enabled: false,
},
fragment: Some(wgpu::FragmentState {
module: fs_module, module: fs_module,
entry_point: "main", entry_point: "main",
}), targets: &[wgpu::ColorTargetState {
rasterization_state: None,
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
color_states: &[wgpu::ColorStateDescriptor {
format: sc_desc.format, format: sc_desc.format,
color_blend: wgpu::BlendDescriptor::REPLACE, color_blend: wgpu::BlendState::REPLACE,
alpha_blend: wgpu::BlendDescriptor::REPLACE, alpha_blend: wgpu::BlendState::REPLACE,
write_mask: wgpu::ColorWrite::ALL, write_mask: wgpu::ColorWrite::ALL,
}], }],
depth_stencil_state: None, }),
vertex_state: wgpu::VertexStateDescriptor {
index_format: None,
vertex_buffers: &[],
},
sample_count: samples,
sample_mask: !0,
alpha_to_coverage_enabled: false,
}); });
Self { Self {

View File

@ -157,43 +157,41 @@ impl ShadowFigurePipeline {
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("Directed shadow figure pipeline"), label: Some("Directed shadow figure pipeline"),
layout: Some(&render_pipeline_layout), layout: Some(&render_pipeline_layout),
vertex_stage: wgpu::ProgrammableStageDescriptor { vertex: wgpu::VertexState {
module: vs_module, module: vs_module,
entry_point: "main", entry_point: "main",
buffers: &[TerrainVertex::desc()],
}, },
fragment_stage: /*Some(wgpu::ProgrammableStageDescriptor { primitive: wgpu::PrimitiveState {
module: fs_module, topology: wgpu::PrimitiveTopology::TriangleList,
entry_point: "main", strip_index_format: None,
})*/None,
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
front_face: wgpu::FrontFace::Ccw, front_face: wgpu::FrontFace::Ccw,
cull_mode: wgpu::CullMode::Front, cull_mode: wgpu::CullMode::Back,
polygon_mode: wgpu::PolygonMode::Fill, polygon_mode: wgpu::PolygonMode::Fill,
clamp_depth: true, },
depth_bias: 0, depth_stencil: Some(wgpu::DepthStencilState {
depth_bias_slope_scale: 0.0,
depth_bias_clamp: 0.0,
}),
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
color_states: &[],
depth_stencil_state: Some(wgpu::DepthStencilStateDescriptor {
format: wgpu::TextureFormat::Depth24Plus, format: wgpu::TextureFormat::Depth24Plus,
depth_write_enabled: true, depth_write_enabled: true,
depth_compare: wgpu::CompareFunction::Less, depth_compare: wgpu::CompareFunction::Less,
stencil: wgpu::StencilStateDescriptor { stencil: wgpu::StencilState {
front: wgpu::StencilStateFaceDescriptor::IGNORE, front: wgpu::StencilFaceState::IGNORE,
back: wgpu::StencilStateFaceDescriptor::IGNORE, back: wgpu::StencilFaceState::IGNORE,
read_mask: !0, read_mask: !0,
write_mask: !0, write_mask: !0,
}, },
}), bias: wgpu::DepthBiasState {
vertex_state: wgpu::VertexStateDescriptor { constant: 0,
index_format: None, slope_scale: 0.0,
vertex_buffers: &[TerrainVertex::desc()], clamp: 0.0,
}, },
sample_count: samples, clamp_depth: true,
sample_mask: !0, }),
multisample: wgpu::MultisampleState {
count: samples,
mask: !0,
alpha_to_coverage_enabled: false, alpha_to_coverage_enabled: false,
},
fragment: None,
}); });
Self { Self {
@ -233,43 +231,41 @@ impl ShadowPipeline {
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("Directed shadow pipeline"), label: Some("Directed shadow pipeline"),
layout: Some(&render_pipeline_layout), layout: Some(&render_pipeline_layout),
vertex_stage: wgpu::ProgrammableStageDescriptor { vertex: wgpu::VertexState {
module: vs_module, module: vs_module,
entry_point: "main", entry_point: "main",
buffers: &[TerrainVertex::desc()],
}, },
fragment_stage: /*Some(wgpu::ProgrammableStageDescriptor { primitive: wgpu::PrimitiveState {
module: fs_module, topology: wgpu::PrimitiveTopology::TriangleList,
entry_point: "main", strip_index_format: None,
})*/None,
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
front_face: wgpu::FrontFace::Ccw, front_face: wgpu::FrontFace::Ccw,
cull_mode: wgpu::CullMode::Front, cull_mode: wgpu::CullMode::Back,
polygon_mode: wgpu::PolygonMode::Fill, polygon_mode: wgpu::PolygonMode::Fill,
clamp_depth: true, },
depth_bias: 0, depth_stencil: Some(wgpu::DepthStencilState {
depth_bias_slope_scale: 0.0,
depth_bias_clamp: 0.0,
}),
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
color_states: &[],
depth_stencil_state: Some(wgpu::DepthStencilStateDescriptor {
format: wgpu::TextureFormat::Depth24Plus, format: wgpu::TextureFormat::Depth24Plus,
depth_write_enabled: true, depth_write_enabled: true,
depth_compare: wgpu::CompareFunction::Less, depth_compare: wgpu::CompareFunction::Less,
stencil: wgpu::StencilStateDescriptor { stencil: wgpu::StencilState {
front: wgpu::StencilStateFaceDescriptor::IGNORE, front: wgpu::StencilFaceState::IGNORE,
back: wgpu::StencilStateFaceDescriptor::IGNORE, back: wgpu::StencilFaceState::IGNORE,
read_mask: !0, read_mask: !0,
write_mask: !0, write_mask: !0,
}, },
}), bias: wgpu::DepthBiasState {
vertex_state: wgpu::VertexStateDescriptor { constant: 0,
index_format: None, slope_scale: 0.0,
vertex_buffers: &[TerrainVertex::desc()], clamp: 0.0,
}, },
sample_count: samples, clamp_depth: true,
sample_mask: !0, }),
multisample: wgpu::MultisampleState {
count: samples,
mask: !0,
alpha_to_coverage_enabled: false, alpha_to_coverage_enabled: false,
},
fragment: None,
}); });
Self { Self {
@ -311,43 +307,41 @@ impl PointShadowPipeline {
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("Point shadow pipeline"), label: Some("Point shadow pipeline"),
layout: Some(&render_pipeline_layout), layout: Some(&render_pipeline_layout),
vertex_stage: wgpu::ProgrammableStageDescriptor { vertex: wgpu::VertexState {
module: vs_module, module: vs_module,
entry_point: "main", entry_point: "main",
buffers: &[TerrainVertex::desc()],
}, },
fragment_stage: /*Some(wgpu::ProgrammableStageDescriptor { primitive: wgpu::PrimitiveState {
module: fs_module, topology: wgpu::PrimitiveTopology::TriangleList,
entry_point: "main", strip_index_format: None,
})*/None,
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
front_face: wgpu::FrontFace::Ccw, front_face: wgpu::FrontFace::Ccw,
cull_mode: wgpu::CullMode::Back, cull_mode: wgpu::CullMode::Back,
polygon_mode: wgpu::PolygonMode::Fill, polygon_mode: wgpu::PolygonMode::Fill,
clamp_depth: false, },
depth_bias: 0, depth_stencil: Some(wgpu::DepthStencilState {
depth_bias_slope_scale: 0.0,
depth_bias_clamp: 0.0,
}),
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
color_states: &[],
depth_stencil_state: Some(wgpu::DepthStencilStateDescriptor {
format: wgpu::TextureFormat::Depth24Plus, format: wgpu::TextureFormat::Depth24Plus,
depth_write_enabled: true, depth_write_enabled: true,
depth_compare: wgpu::CompareFunction::Less, depth_compare: wgpu::CompareFunction::Less,
stencil: wgpu::StencilStateDescriptor { stencil: wgpu::StencilState {
front: wgpu::StencilStateFaceDescriptor::IGNORE, front: wgpu::StencilFaceState::IGNORE,
back: wgpu::StencilStateFaceDescriptor::IGNORE, back: wgpu::StencilFaceState::IGNORE,
read_mask: !0, read_mask: !0,
write_mask: !0, write_mask: !0,
}, },
}), bias: wgpu::DepthBiasState {
vertex_state: wgpu::VertexStateDescriptor { constant: 0,
index_format: None, slope_scale: 0.0,
vertex_buffers: &[TerrainVertex::desc()], clamp: 0.0,
}, },
sample_count: samples, clamp_depth: false,
sample_mask: !0, }),
multisample: wgpu::MultisampleState {
count: samples,
mask: !0,
alpha_to_coverage_enabled: false, alpha_to_coverage_enabled: false,
},
fragment: None,
}); });
Self { Self {

View File

@ -9,11 +9,11 @@ pub struct Vertex {
} }
impl Vertex { impl Vertex {
fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> { fn desc<'a>() -> wgpu::VertexBufferLayout<'a> {
wgpu::VertexBufferDescriptor { wgpu::VertexBufferLayout {
stride: Self::STRIDE, array_stride: Self::STRIDE,
step_mode: wgpu::InputStepMode::Vertex, step_mode: wgpu::InputStepMode::Vertex,
attributes: &[wgpu::VertexAttributeDescriptor { attributes: &[wgpu::VertexAttribute {
offset: 0, offset: 0,
shader_location: 0, shader_location: 0,
format: wgpu::VertexFormat::Float3, format: wgpu::VertexFormat::Float3,
@ -58,48 +58,50 @@ impl SkyboxPipeline {
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("Skybox pipeline"), label: Some("Skybox pipeline"),
layout: Some(&render_pipeline_layout), layout: Some(&render_pipeline_layout),
vertex_stage: wgpu::ProgrammableStageDescriptor { vertex: wgpu::VertexState {
module: vs_module, module: vs_module,
entry_point: "main", entry_point: "main",
buffers: &[Vertex::desc()],
}, },
fragment_stage: Some(wgpu::ProgrammableStageDescriptor { primitive: wgpu::PrimitiveState {
module: fs_module, topology: wgpu::PrimitiveTopology::TriangleList,
entry_point: "main", strip_index_format: None,
}),
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
front_face: wgpu::FrontFace::Ccw, front_face: wgpu::FrontFace::Ccw,
cull_mode: wgpu::CullMode::Back, cull_mode: wgpu::CullMode::Back,
polygon_mode: wgpu::PolygonMode::Fill, polygon_mode: wgpu::PolygonMode::Fill,
clamp_depth: false, },
depth_bias: 0, depth_stencil: Some(wgpu::DepthStencilState {
depth_bias_slope_scale: 0.0,
depth_bias_clamp: 0.0,
}),
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
color_states: &[wgpu::ColorStateDescriptor {
format: sc_desc.format,
color_blend: wgpu::BlendDescriptor::REPLACE,
alpha_blend: wgpu::BlendDescriptor::REPLACE,
write_mask: wgpu::ColorWrite::ALL,
}],
depth_stencil_state: Some(wgpu::DepthStencilStateDescriptor {
format: wgpu::TextureFormat::Depth32Float, format: wgpu::TextureFormat::Depth32Float,
depth_write_enabled: true, depth_write_enabled: true,
depth_compare: wgpu::CompareFunction::GreaterEqual, depth_compare: wgpu::CompareFunction::GreaterEqual,
stencil: wgpu::StencilStateDescriptor { stencil: wgpu::StencilState {
front: wgpu::StencilStateFaceDescriptor::IGNORE, front: wgpu::StencilFaceState::IGNORE,
back: wgpu::StencilStateFaceDescriptor::IGNORE, back: wgpu::StencilFaceState::IGNORE,
read_mask: !0, read_mask: !0,
write_mask: !0, write_mask: !0,
}, },
}), bias: wgpu::DepthBiasState {
vertex_state: wgpu::VertexStateDescriptor { constant: 0,
index_format: None, slope_scale: 0.0,
vertex_buffers: &[Vertex::desc()], clamp: 0.0,
}, },
sample_count: samples, clamp_depth: false,
sample_mask: !0, }),
multisample: wgpu::MultisampleState {
count: samples,
mask: !0,
alpha_to_coverage_enabled: false, alpha_to_coverage_enabled: false,
},
fragment: Some(wgpu::FragmentState {
module: fs_module,
entry_point: "main",
targets: &[wgpu::ColorTargetState {
format: sc_desc.format,
color_blend: wgpu::BlendState::REPLACE,
alpha_blend: wgpu::BlendState::REPLACE,
write_mask: wgpu::ColorWrite::ALL,
}],
}),
}); });
Self { Self {

View File

@ -60,11 +60,11 @@ impl Vertex {
} }
} }
fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> { fn desc<'a>() -> wgpu::VertexBufferLayout<'a> {
const ATTRIBUTES: [wgpu::VertexAttributeDescriptor; 3] = const ATTRIBUTES: [wgpu::VertexAttribute; 3] =
wgpu::vertex_attr_array![0 => Float3, 1 => Uint, 2 => Uint]; wgpu::vertex_attr_array![0 => Float3, 1 => Uint, 2 => Uint];
wgpu::VertexBufferDescriptor { wgpu::VertexBufferLayout {
stride: Self::STRIDE, array_stride: Self::STRIDE,
step_mode: wgpu::InputStepMode::Vertex, step_mode: wgpu::InputStepMode::Vertex,
attributes: &ATTRIBUTES, attributes: &ATTRIBUTES,
} }
@ -113,10 +113,10 @@ impl Instance {
} }
} }
fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> { fn desc<'a>() -> wgpu::VertexBufferLayout<'a> {
const ATTRIBUTES: [wgpu::VertexAttributeDescriptor; 7] = wgpu::vertex_attr_array![3 => Uint, 4 => Float4, 5 => Float4, 6 => Float4,7 => Float4, 8 => Float4, 9 => Float]; const ATTRIBUTES: [wgpu::VertexAttribute; 7] = wgpu::vertex_attr_array![3 => Uint, 4 => Float4, 5 => Float4, 6 => Float4,7 => Float4, 8 => Float4, 9 => Float];
wgpu::VertexBufferDescriptor { wgpu::VertexBufferLayout {
stride: mem::size_of::<Self>() as wgpu::BufferAddress, array_stride: mem::size_of::<Self>() as wgpu::BufferAddress,
step_mode: wgpu::InputStepMode::Instance, step_mode: wgpu::InputStepMode::Instance,
attributes: &ATTRIBUTES, attributes: &ATTRIBUTES,
} }
@ -237,56 +237,58 @@ impl SpritePipeline {
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("Sprite pipeline"), label: Some("Sprite pipeline"),
layout: Some(&render_pipeline_layout), layout: Some(&render_pipeline_layout),
vertex_stage: wgpu::ProgrammableStageDescriptor { vertex: wgpu::VertexState {
module: vs_module, module: vs_module,
entry_point: "main", entry_point: "main",
buffers: &[Vertex::desc(), Instance::desc()],
}, },
fragment_stage: Some(wgpu::ProgrammableStageDescriptor { primitive: wgpu::PrimitiveState {
module: fs_module, topology: wgpu::PrimitiveTopology::TriangleList,
entry_point: "main", strip_index_format: None,
}),
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
front_face: wgpu::FrontFace::Ccw, front_face: wgpu::FrontFace::Ccw,
cull_mode: wgpu::CullMode::Back, cull_mode: wgpu::CullMode::Back,
polygon_mode: wgpu::PolygonMode::Fill, polygon_mode: wgpu::PolygonMode::Fill,
},
depth_stencil: Some(wgpu::DepthStencilState {
format: wgpu::TextureFormat::Depth32Float,
depth_write_enabled: true,
depth_compare: wgpu::CompareFunction::GreaterEqual,
stencil: wgpu::StencilState {
front: wgpu::StencilFaceState::IGNORE,
back: wgpu::StencilFaceState::IGNORE,
read_mask: !0,
write_mask: !0,
},
bias: wgpu::DepthBiasState {
constant: 0,
slope_scale: 0.0,
clamp: 0.0,
},
clamp_depth: false, clamp_depth: false,
depth_bias: 0,
depth_bias_slope_scale: 0.0,
depth_bias_clamp: 0.0,
}), }),
primitive_topology: wgpu::PrimitiveTopology::TriangleList, multisample: wgpu::MultisampleState {
color_states: &[wgpu::ColorStateDescriptor { count: samples,
mask: !0,
alpha_to_coverage_enabled: false,
},
fragment: Some(wgpu::FragmentState {
module: fs_module,
entry_point: "main",
targets: &[wgpu::ColorTargetState {
format: sc_desc.format, format: sc_desc.format,
color_blend: wgpu::BlendDescriptor { color_blend: wgpu::BlendState {
src_factor: wgpu::BlendFactor::SrcAlpha, src_factor: wgpu::BlendFactor::SrcAlpha,
dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha, dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,
operation: wgpu::BlendOperation::Add, operation: wgpu::BlendOperation::Add,
}, },
alpha_blend: wgpu::BlendDescriptor { alpha_blend: wgpu::BlendState {
src_factor: wgpu::BlendFactor::One, src_factor: wgpu::BlendFactor::One,
dst_factor: wgpu::BlendFactor::One, dst_factor: wgpu::BlendFactor::One,
operation: wgpu::BlendOperation::Add, operation: wgpu::BlendOperation::Add,
}, },
write_mask: wgpu::ColorWrite::ALL, write_mask: wgpu::ColorWrite::ALL,
}], }],
depth_stencil_state: Some(wgpu::DepthStencilStateDescriptor {
format: wgpu::TextureFormat::Depth32Float,
depth_write_enabled: true,
depth_compare: wgpu::CompareFunction::GreaterEqual,
stencil: wgpu::StencilStateDescriptor {
front: wgpu::StencilStateFaceDescriptor::IGNORE,
back: wgpu::StencilStateFaceDescriptor::IGNORE,
read_mask: !0,
write_mask: !0,
},
}), }),
vertex_state: wgpu::VertexStateDescriptor {
index_format: None,
vertex_buffers: &[Vertex::desc(), Instance::desc()],
},
sample_count: samples,
sample_mask: !0,
alpha_to_coverage_enabled: false,
}); });
Self { Self {

View File

@ -119,11 +119,11 @@ impl Vertex {
self.pos_norm = (self.pos_norm & !(0xF << 27)) | ((bone_idx as u32 & 0xF) << 27); self.pos_norm = (self.pos_norm & !(0xF << 27)) | ((bone_idx as u32 & 0xF) << 27);
} }
pub fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> { pub fn desc<'a>() -> wgpu::VertexBufferLayout<'a> {
const ATTRIBUTES: [wgpu::VertexAttributeDescriptor; 2] = const ATTRIBUTES: [wgpu::VertexAttribute; 2] =
wgpu::vertex_attr_array![0 => Uint,1 => Uint]; wgpu::vertex_attr_array![0 => Uint,1 => Uint];
wgpu::VertexBufferDescriptor { wgpu::VertexBufferLayout {
stride: Self::STRIDE, array_stride: Self::STRIDE,
step_mode: wgpu::InputStepMode::Vertex, step_mode: wgpu::InputStepMode::Vertex,
attributes: &ATTRIBUTES, attributes: &ATTRIBUTES,
} }
@ -236,48 +236,50 @@ impl TerrainPipeline {
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("Terrain pipeline"), label: Some("Terrain pipeline"),
layout: Some(&render_pipeline_layout), layout: Some(&render_pipeline_layout),
vertex_stage: wgpu::ProgrammableStageDescriptor { vertex: wgpu::VertexState {
module: vs_module, module: vs_module,
entry_point: "main", entry_point: "main",
buffers: &[Vertex::desc()],
}, },
fragment_stage: Some(wgpu::ProgrammableStageDescriptor { primitive: wgpu::PrimitiveState {
module: fs_module, topology: wgpu::PrimitiveTopology::TriangleList,
entry_point: "main", strip_index_format: None,
}),
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
front_face: wgpu::FrontFace::Ccw, front_face: wgpu::FrontFace::Ccw,
cull_mode: wgpu::CullMode::Back, cull_mode: wgpu::CullMode::Back,
polygon_mode: wgpu::PolygonMode::Fill, polygon_mode: wgpu::PolygonMode::Fill,
clamp_depth: false, },
depth_bias: 0, depth_stencil: Some(wgpu::DepthStencilState {
depth_bias_slope_scale: 0.0,
depth_bias_clamp: 0.0,
}),
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
color_states: &[wgpu::ColorStateDescriptor {
format: sc_desc.format,
color_blend: wgpu::BlendDescriptor::REPLACE,
alpha_blend: wgpu::BlendDescriptor::REPLACE,
write_mask: wgpu::ColorWrite::ALL,
}],
depth_stencil_state: Some(wgpu::DepthStencilStateDescriptor {
format: wgpu::TextureFormat::Depth32Float, format: wgpu::TextureFormat::Depth32Float,
depth_write_enabled: true, depth_write_enabled: true,
depth_compare: wgpu::CompareFunction::GreaterEqual, depth_compare: wgpu::CompareFunction::GreaterEqual,
stencil: wgpu::StencilStateDescriptor { stencil: wgpu::StencilState {
front: wgpu::StencilStateFaceDescriptor::IGNORE, front: wgpu::StencilFaceState::IGNORE,
back: wgpu::StencilStateFaceDescriptor::IGNORE, back: wgpu::StencilFaceState::IGNORE,
read_mask: !0, read_mask: !0,
write_mask: !0, write_mask: !0,
}, },
}), bias: wgpu::DepthBiasState {
vertex_state: wgpu::VertexStateDescriptor { constant: 0,
index_format: None, slope_scale: 0.0,
vertex_buffers: &[Vertex::desc()], clamp: 0.0,
}, },
sample_count: samples, clamp_depth: false,
sample_mask: !0, }),
multisample: wgpu::MultisampleState {
count: samples,
mask: !0,
alpha_to_coverage_enabled: false, alpha_to_coverage_enabled: false,
},
fragment: Some(wgpu::FragmentState {
module: fs_module,
entry_point: "main",
targets: &[wgpu::ColorTargetState {
format: sc_desc.format,
color_blend: wgpu::BlendState::REPLACE,
alpha_blend: wgpu::BlendState::REPLACE,
write_mask: wgpu::ColorWrite::ALL,
}],
}),
}); });
Self { Self {

View File

@ -16,11 +16,11 @@ pub struct Vertex {
} }
impl Vertex { impl Vertex {
fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> { fn desc<'a>() -> wgpu::VertexBufferLayout<'a> {
const ATTRIBUTES: [wgpu::VertexAttributeDescriptor; 5] = const ATTRIBUTES: [wgpu::VertexAttribute; 5] =
wgpu::vertex_attr_array![0 => Float2, 1 => Float2, 2 => Float4, 3 => Float2, 4 => Uint]; wgpu::vertex_attr_array![0 => Float2, 1 => Float2, 2 => Float4, 3 => Float2, 4 => Uint];
wgpu::VertexBufferDescriptor { wgpu::VertexBufferLayout {
stride: Self::STRIDE, array_stride: Self::STRIDE,
step_mode: wgpu::InputStepMode::Vertex, step_mode: wgpu::InputStepMode::Vertex,
attributes: &ATTRIBUTES, attributes: &ATTRIBUTES,
} }
@ -192,7 +192,6 @@ impl UiPipeline {
sc_desc: &wgpu::SwapChainDescriptor, sc_desc: &wgpu::SwapChainDescriptor,
global_layout: &GlobalsLayouts, global_layout: &GlobalsLayouts,
layout: &UiLayout, layout: &UiLayout,
aa_mode: AaMode,
) -> Self { ) -> Self {
let render_pipeline_layout = let render_pipeline_layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
@ -201,57 +200,45 @@ impl UiPipeline {
bind_group_layouts: &[&global_layout.globals, &layout.locals, &layout.texture], bind_group_layouts: &[&global_layout.globals, &layout.locals, &layout.texture],
}); });
let samples = match aa_mode {
AaMode::None | AaMode::Fxaa => 1,
// TODO: Ensure sampling in the shader is exactly between the 4 texels
AaMode::MsaaX4 => 4,
AaMode::MsaaX8 => 8,
AaMode::MsaaX16 => 16,
};
let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("UI pipeline"), label: Some("UI pipeline"),
layout: Some(&render_pipeline_layout), layout: Some(&render_pipeline_layout),
vertex_stage: wgpu::ProgrammableStageDescriptor { vertex: wgpu::VertexState {
module: vs_module, module: vs_module,
entry_point: "main", entry_point: "main",
buffers: &[Vertex::desc()],
}, },
fragment_stage: Some(wgpu::ProgrammableStageDescriptor { primitive: wgpu::PrimitiveState {
module: fs_module, topology: wgpu::PrimitiveTopology::TriangleList,
entry_point: "main", strip_index_format: None,
}),
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
front_face: wgpu::FrontFace::Ccw, front_face: wgpu::FrontFace::Ccw,
cull_mode: wgpu::CullMode::Back, cull_mode: wgpu::CullMode::Back,
polygon_mode: wgpu::PolygonMode::Fill, polygon_mode: wgpu::PolygonMode::Fill,
clamp_depth: false, },
depth_bias: 0, depth_stencil: None,
depth_bias_slope_scale: 0.0, multisample: wgpu::MultisampleState {
depth_bias_clamp: 0.0, count: 1,
}), mask: !0,
primitive_topology: wgpu::PrimitiveTopology::TriangleList, alpha_to_coverage_enabled: false,
color_states: &[wgpu::ColorStateDescriptor { },
fragment: Some(wgpu::FragmentState {
module: fs_module,
entry_point: "main",
targets: &[wgpu::ColorTargetState {
format: sc_desc.format, format: sc_desc.format,
color_blend: wgpu::BlendDescriptor { color_blend: wgpu::BlendState {
src_factor: wgpu::BlendFactor::SrcAlpha, src_factor: wgpu::BlendFactor::SrcAlpha,
dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha, dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,
operation: wgpu::BlendOperation::Add, operation: wgpu::BlendOperation::Add,
}, },
alpha_blend: wgpu::BlendDescriptor { alpha_blend: wgpu::BlendState {
src_factor: wgpu::BlendFactor::One, src_factor: wgpu::BlendFactor::One,
dst_factor: wgpu::BlendFactor::One, dst_factor: wgpu::BlendFactor::One,
operation: wgpu::BlendOperation::Add, operation: wgpu::BlendOperation::Add,
}, },
write_mask: wgpu::ColorWrite::ALL, write_mask: wgpu::ColorWrite::ALL,
}], }],
depth_stencil_state: None, }),
vertex_state: wgpu::VertexStateDescriptor {
index_format: None,
vertex_buffers: &[Vertex::desc()],
},
sample_count: samples,
sample_mask: !0,
alpha_to_coverage_enabled: false,
}); });
Self { Self {

View File

@ -2237,7 +2237,6 @@ fn create_pipelines(
sc_desc, sc_desc,
&layouts.global, &layouts.global,
&layouts.ui, &layouts.ui,
mode.aa,
); );
// Construct a pipeline for rendering terrain // Construct a pipeline for rendering terrain
@ -2270,7 +2269,6 @@ fn create_pipelines(
sc_desc, sc_desc,
&layouts.global, &layouts.global,
&layouts.postprocess, &layouts.postprocess,
mode.aa,
); );
// Consider reenabling at some time in the future // Consider reenabling at some time in the future
@ -2362,6 +2360,6 @@ fn create_shader_module(
Ok(device.create_shader_module(&wgpu::ShaderModuleDescriptor { Ok(device.create_shader_module(&wgpu::ShaderModuleDescriptor {
label: Some(source), label: Some(source),
source: wgpu::ShaderSource::SpirV(Cow::Borrowed(spv.as_binary())), source: wgpu::ShaderSource::SpirV(Cow::Borrowed(spv.as_binary())),
flags: wgpu::ShaderFlags::VALIDATION, flags: wgpu::ShaderFlags::empty(), // TODO: renable wgpu::ShaderFlags::VALIDATION,
})) }))
} }

View File

@ -12,6 +12,7 @@ use super::{
Renderer, ShadowMap, ShadowMapRenderer, Renderer, ShadowMap, ShadowMapRenderer,
}; };
use core::{num::NonZeroU32, ops::Range}; use core::{num::NonZeroU32, ops::Range};
use std::sync::Arc;
use vek::Aabr; use vek::Aabr;
pub struct Drawer<'a> { pub struct Drawer<'a> {
@ -324,17 +325,13 @@ impl<'pass> FirstPassDrawer<'pass> {
} }
} }
pub fn draw_terrain<'data: 'pass>( pub fn draw_terrain<'data: 'pass>(&mut self) -> TerrainDrawer<'_, 'pass> {
&mut self,
col_lights: &'data ColLights<terrain::Locals>,
) -> TerrainDrawer<'_, 'pass> {
self.render_pass self.render_pass
.set_pipeline(&self.renderer.terrain_pipeline.pipeline); .set_pipeline(&self.renderer.terrain_pipeline.pipeline);
self.render_pass
.set_bind_group(3, &col_lights.bind_group, &[]);
TerrainDrawer { TerrainDrawer {
render_pass: &mut self.render_pass, render_pass: &mut self.render_pass,
col_lights: None,
} }
} }
@ -397,15 +394,31 @@ impl<'pass_ref, 'pass: 'pass_ref> FigureDrawer<'pass_ref, 'pass> {
pub struct TerrainDrawer<'pass_ref, 'pass: 'pass_ref> { pub struct TerrainDrawer<'pass_ref, 'pass: 'pass_ref> {
render_pass: &'pass_ref mut wgpu::RenderPass<'pass>, render_pass: &'pass_ref mut wgpu::RenderPass<'pass>,
col_lights: Option<&'pass_ref Arc<ColLights<terrain::Locals>>>,
} }
impl<'pass_ref, 'pass: 'pass_ref> TerrainDrawer<'pass_ref, 'pass> { impl<'pass_ref, 'pass: 'pass_ref> TerrainDrawer<'pass_ref, 'pass> {
pub fn draw<'data: 'pass>( pub fn draw<'data: 'pass>(
&mut self, &mut self,
model: &'data Model<terrain::Vertex>, model: &'data Model<terrain::Vertex>,
col_lights: &'data Arc<ColLights<terrain::Locals>>,
locals: &'data terrain::BoundLocals, locals: &'data terrain::BoundLocals,
) { ) {
self.render_pass.set_bind_group(2, &locals.bind_group, &[]); let col_lights = if let Some(col_lights) = self
.col_lights
// Check if we are still using the same atlas texture as the previous drawn
// chunk
.filter(|current_col_lights| Arc::ptr_eq(current_col_lights, col_lights))
{
col_lights
} else {
self.render_pass
.set_bind_group(3, &col_lights.bind_group, &[]); // TODO: put this in slot 2
self.col_lights = Some(col_lights);
col_lights
};
self.render_pass.set_bind_group(2, &locals.bind_group, &[]); // TODO: put this in slot 3
self.render_pass.set_vertex_buffer(0, model.buf().slice(..)); self.render_pass.set_vertex_buffer(0, model.buf().slice(..));
self.render_pass.draw(0..model.len() as u32, 0..1) self.render_pass.draw(0..model.len() as u32, 0..1)
} }

View File

@ -72,7 +72,7 @@ pub struct TerrainChunkData {
fluid_model: Option<Model<FluidVertex>>, fluid_model: Option<Model<FluidVertex>>,
/// If this is `None`, this texture is not allocated in the current atlas, /// If this is `None`, this texture is not allocated in the current atlas,
/// and therefore there is no need to free its allocation. /// and therefore there is no need to free its allocation.
col_lights: Option<guillotiere::AllocId>, col_lights_alloc: Option<guillotiere::AllocId>,
/// The actual backing texture for this chunk. Use this for rendering /// The actual backing texture for this chunk. Use this for rendering
/// purposes. The texture is reference-counted, so it will be /// purposes. The texture is reference-counted, so it will be
/// automatically freed when no chunks are left that need it (though /// automatically freed when no chunks are left that need it (though
@ -334,7 +334,7 @@ pub struct Terrain<V: RectRasterableVol = TerrainChunk> {
/// we allocate. Code cannot assume that this is the assigned texture /// we allocate. Code cannot assume that this is the assigned texture
/// for any particular chunk; look at the `texture` field in /// for any particular chunk; look at the `texture` field in
/// `TerrainChunkData` for that. /// `TerrainChunkData` for that.
col_lights: ColLights<pipelines::terrain::Locals>, col_lights: Arc<ColLights<pipelines::terrain::Locals>>,
waves: FluidWaves, waves: FluidWaves,
phantom: PhantomData<V>, phantom: PhantomData<V>,
@ -579,7 +579,7 @@ impl<V: RectRasterableVol> Terrain<V> {
renderer.fluid_bind_waves(waves_tex) renderer.fluid_bind_waves(waves_tex)
}, },
col_lights, col_lights: Arc::new(col_lights),
phantom: PhantomData, phantom: PhantomData,
} }
} }
@ -638,7 +638,7 @@ impl<V: RectRasterableVol> Terrain<V> {
fn remove_chunk_meta(&mut self, _pos: Vec2<i32>, chunk: &TerrainChunkData) { fn remove_chunk_meta(&mut self, _pos: Vec2<i32>, chunk: &TerrainChunkData) {
// No need to free the allocation if the chunk is not allocated in the current // No need to free the allocation if the chunk is not allocated in the current
// atlas, since we don't bother tracking it at that point. // atlas, since we don't bother tracking it at that point.
if let Some(col_lights) = chunk.col_lights { if let Some(col_lights) = chunk.col_lights_alloc {
self.atlas.deallocate(col_lights); self.atlas.deallocate(col_lights);
} }
/* let (zmin, zmax) = chunk.z_bounds; /* let (zmin, zmax) = chunk.z_bounds;
@ -1128,10 +1128,10 @@ impl<V: RectRasterableVol> Terrain<V> {
// TODO: Consider attempting defragmentation first rather than just // TODO: Consider attempting defragmentation first rather than just
// always moving everything into the new chunk. // always moving everything into the new chunk.
chunks.iter_mut().for_each(|(_, chunk)| { chunks.iter_mut().for_each(|(_, chunk)| {
chunk.col_lights = None; chunk.col_lights_alloc = None;
}); });
*atlas = new_atlas; *atlas = new_atlas;
*col_lights = new_col_lights; *col_lights = Arc::new(new_col_lights);
atlas atlas
.allocate(guillotiere::Size::new( .allocate(guillotiere::Size::new(
@ -1149,7 +1149,7 @@ impl<V: RectRasterableVol> Terrain<V> {
allocation.rectangle.min.y as u32, allocation.rectangle.min.y as u32,
); );
renderer.update_texture( renderer.update_texture(
&col_lights, &col_lights.texture,
atlas_offs.into_array(), atlas_offs.into_array(),
tex_size.into_array(), tex_size.into_array(),
&tex, &tex,
@ -1169,8 +1169,8 @@ impl<V: RectRasterableVol> Terrain<V> {
} else { } else {
None None
}, },
col_lights: Some(allocation.id), col_lights_alloc: Some(allocation.id),
texture: self.col_lights.clone(), col_lights: Arc::clone(&self.col_lights),
light_map: mesh.light_map, light_map: mesh.light_map,
glow_map: mesh.glow_map, glow_map: mesh.glow_map,
sprite_instances, sprite_instances,
@ -1468,7 +1468,7 @@ impl<V: RectRasterableVol> Terrain<V> {
pub fn render<'a>(&'a self, drawer: &mut FirstPassDrawer<'a>, focus_pos: Vec3<f32>) { pub fn render<'a>(&'a self, drawer: &mut FirstPassDrawer<'a>, focus_pos: Vec3<f32>) {
span!(_guard, "render", "Terrain::render"); span!(_guard, "render", "Terrain::render");
let mut drawer = drawer.draw_terrain(&self.col_lights); let mut drawer = drawer.draw_terrain();
let focus_chunk = Vec2::from(focus_pos).map2(TerrainChunk::RECT_SIZE, |e: f32, sz| { let focus_chunk = Vec2::from(focus_pos).map2(TerrainChunk::RECT_SIZE, |e: f32, sz| {
(e as i32).div_euclid(sz as i32) (e as i32).div_euclid(sz as i32)
@ -1481,7 +1481,7 @@ impl<V: RectRasterableVol> Terrain<V> {
}) })
.take(self.chunks.len()) .take(self.chunks.len())
.filter(|chunk| chunk.visible.is_visible()) .filter(|chunk| chunk.visible.is_visible())
.for_each(|chunk| drawer.draw(&chunk.opaque_model, &chunk.locals)); .for_each(|chunk| drawer.draw(&chunk.opaque_model, &chunk.col_lights, &chunk.locals));
} }
pub fn render_translucent<'a>( pub fn render_translucent<'a>(

View File

@ -1105,9 +1105,8 @@ impl Window {
pub fn center_cursor(&self) { pub fn center_cursor(&self) {
let dimensions: Vec2<f64> = self.logical_size(); let dimensions: Vec2<f64> = self.logical_size();
if let Err(err) = if let Err(err) = self
self.window .window
.window()
.set_cursor_position(winit::dpi::PhysicalPosition::new( .set_cursor_position(winit::dpi::PhysicalPosition::new(
dimensions[0] / (2_f64), dimensions[0] / (2_f64),
dimensions[1] / (2_f64), dimensions[1] / (2_f64),