Update to wgpu 0.13, some errors are left
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
3e31d79107
commit
bfdd61775f
16 changed files with 1015 additions and 852 deletions
1693
Cargo.lock
generated
1693
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
14
Cargo.toml
14
Cargo.toml
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "minecrab"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
@ -9,21 +9,21 @@ edition = "2018"
|
|||
anyhow = "1.0.40"
|
||||
bytemuck = { version = "1.5.1", features = ["derive"] }
|
||||
cgmath = "0.18.0"
|
||||
env_logger = "0.8.3"
|
||||
env_logger = "0.9"
|
||||
futures = "0.3.15"
|
||||
fxhash = "0.2.1"
|
||||
gltf = "0.16"
|
||||
image = "0.23.14"
|
||||
gltf = "1.0.0"
|
||||
image = "0.24"
|
||||
itertools = "0.10.0"
|
||||
log = "0.4.14"
|
||||
noise = "0.7.0"
|
||||
rayon = "1.5.1"
|
||||
rmp-serde = "0.15.4"
|
||||
rmp-serde = "1.1"
|
||||
serde = { version = "1.0.126", features = ["derive"] }
|
||||
serde_repr = "0.1.7"
|
||||
sled = { version = "0.34.6", features = ["compression"] }
|
||||
wgpu = "0.8.1"
|
||||
winit = { version = "0.25.0" }
|
||||
wgpu = "0.13"
|
||||
winit = { version = "0.27" }
|
||||
|
||||
[profile.release]
|
||||
debug = true
|
||||
|
|
|
@ -9,6 +9,7 @@ pkgs.mkShell {
|
|||
|
||||
# Needed by cargo dependencies.
|
||||
cmake gcc zlib pkgconfig openssl
|
||||
fontconfig
|
||||
|
||||
# wgpu graphics dependencies
|
||||
vulkan-loader vulkan-tools
|
||||
|
|
|
@ -20,14 +20,14 @@ impl<I: bytemuck::Pod> GeometryBuffers<I> {
|
|||
pub fn from_geometry<V: Vertex + bytemuck::Pod>(
|
||||
render_context: &RenderContext,
|
||||
geometry: &Geometry<V, I>,
|
||||
usage: wgpu::BufferUsage,
|
||||
usage: wgpu::BufferUsages,
|
||||
) -> Self {
|
||||
let vertices = render_context
|
||||
.device
|
||||
.create_buffer_init(&BufferInitDescriptor {
|
||||
label: None,
|
||||
contents: bytemuck::cast_slice(&geometry.vertices),
|
||||
usage: wgpu::BufferUsage::VERTEX | usage,
|
||||
usage: wgpu::BufferUsages::VERTEX | usage,
|
||||
});
|
||||
|
||||
let indices = render_context
|
||||
|
@ -35,7 +35,7 @@ impl<I: bytemuck::Pod> GeometryBuffers<I> {
|
|||
.create_buffer_init(&BufferInitDescriptor {
|
||||
label: None,
|
||||
contents: bytemuck::cast_slice(&geometry.indices),
|
||||
usage: wgpu::BufferUsage::INDEX | usage,
|
||||
usage: wgpu::BufferUsages::INDEX | usage,
|
||||
});
|
||||
|
||||
Self {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use cgmath::{ElementWise, Vector4};
|
||||
use wgpu::{BufferUsage, RenderPass};
|
||||
|
||||
use crate::{
|
||||
geometry::Geometry,
|
||||
|
@ -38,7 +37,7 @@ impl HotbarHud {
|
|||
geometry_buffers: GeometryBuffers::from_geometry(
|
||||
render_context,
|
||||
&Geometry::<HudVertex, _>::default(),
|
||||
BufferUsage::empty(),
|
||||
wgpu::BufferUsages::empty(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +47,7 @@ impl HotbarHud {
|
|||
self.geometry_buffers = GeometryBuffers::from_geometry(
|
||||
render_context,
|
||||
&self.block_vertices(),
|
||||
wgpu::BufferUsage::empty(),
|
||||
wgpu::BufferUsages::empty(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +55,7 @@ impl HotbarHud {
|
|||
pub fn render<'a>(
|
||||
&'a self,
|
||||
render_context: &'a RenderContext,
|
||||
render_pass: &mut RenderPass<'a>,
|
||||
render_pass: &mut wgpu::RenderPass<'a>,
|
||||
) -> usize {
|
||||
let texture_manager = render_context.texture_manager.as_ref().unwrap();
|
||||
|
||||
|
@ -76,8 +75,12 @@ impl HotbarHud {
|
|||
let texture_indices = block.texture_indices();
|
||||
let color = block.color();
|
||||
|
||||
let color_left = color.mul_element_wise(Vector4::new(0.5, 0.5, 0.5, 1.0)).into();
|
||||
let color_front = color.mul_element_wise(Vector4::new(0.15, 0.15, 0.15, 1.0)).into();
|
||||
let color_left = color
|
||||
.mul_element_wise(Vector4::new(0.5, 0.5, 0.5, 1.0))
|
||||
.into();
|
||||
let color_front = color
|
||||
.mul_element_wise(Vector4::new(0.15, 0.15, 0.15, 1.0))
|
||||
.into();
|
||||
let color_top = color.into();
|
||||
|
||||
vertices.extend([
|
||||
|
@ -106,7 +109,6 @@ impl HotbarHud {
|
|||
texture_index: texture_indices.0 as i32,
|
||||
color: color_left,
|
||||
},
|
||||
|
||||
// Front face
|
||||
HudVertex {
|
||||
position: [UI_SCALE_X * (x + 19.0), -1.0 + UI_SCALE_Y * 15.5],
|
||||
|
@ -132,7 +134,6 @@ impl HotbarHud {
|
|||
texture_index: texture_indices.3 as i32,
|
||||
color: color_front,
|
||||
},
|
||||
|
||||
// Top face
|
||||
HudVertex {
|
||||
position: [UI_SCALE_X * (x + 19.0), -1.0 + UI_SCALE_Y * 15.5],
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use wgpu::{CommandEncoder, RenderPipeline, SwapChainTexture};
|
||||
use wgpu::{CommandEncoder, RenderPipeline};
|
||||
|
||||
use crate::{
|
||||
render_context::RenderContext,
|
||||
|
@ -44,16 +44,13 @@ impl Hud {
|
|||
entries: &[
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 0,
|
||||
visibility: wgpu::ShaderStage::FRAGMENT,
|
||||
ty: wgpu::BindingType::Sampler {
|
||||
comparison: false,
|
||||
filtering: true,
|
||||
},
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
|
||||
count: None,
|
||||
},
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 1,
|
||||
visibility: wgpu::ShaderStage::FRAGMENT,
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Texture {
|
||||
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
||||
view_dimension: wgpu::TextureViewDimension::D2Array,
|
||||
|
@ -66,9 +63,8 @@ impl Hud {
|
|||
|
||||
let module = &render_context
|
||||
.device
|
||||
.create_shader_module(&wgpu::ShaderModuleDescriptor {
|
||||
.create_shader_module(wgpu::ShaderModuleDescriptor {
|
||||
label: Some("UI shader"),
|
||||
flags: wgpu::ShaderFlags::all(),
|
||||
source: wgpu::ShaderSource::Wgsl(include_str!("../shaders/ui.wgsl").into()),
|
||||
});
|
||||
|
||||
|
@ -94,23 +90,24 @@ impl Hud {
|
|||
fragment: Some(wgpu::FragmentState {
|
||||
module,
|
||||
entry_point: "main",
|
||||
targets: &[wgpu::ColorTargetState {
|
||||
targets: &[Some(wgpu::ColorTargetState {
|
||||
format: render_context.swap_chain_descriptor.format,
|
||||
blend: Some(wgpu::BlendState::ALPHA_BLENDING),
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
}],
|
||||
write_mask: wgpu::ColorWrites::ALL,
|
||||
})],
|
||||
}),
|
||||
primitive: wgpu::PrimitiveState {
|
||||
topology: wgpu::PrimitiveTopology::TriangleList,
|
||||
strip_index_format: None,
|
||||
front_face: wgpu::FrontFace::Ccw,
|
||||
cull_mode: None,
|
||||
clamp_depth: false,
|
||||
unclipped_depth: false,
|
||||
polygon_mode: wgpu::PolygonMode::Fill,
|
||||
conservative: false,
|
||||
},
|
||||
depth_stencil: None,
|
||||
multisample: Default::default(),
|
||||
multiview: None,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -130,14 +127,14 @@ impl Hud {
|
|||
frame: &SwapChainTexture,
|
||||
) -> usize {
|
||||
let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
color_attachments: &[wgpu::RenderPassColorAttachment {
|
||||
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||
view: &frame.view,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
load: wgpu::LoadOp::Load,
|
||||
store: true,
|
||||
},
|
||||
}],
|
||||
})],
|
||||
..Default::default()
|
||||
});
|
||||
render_pass.set_pipeline(&self.pipeline);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// TODO Might want to move the hotbar outside
|
||||
use wgpu::{BindGroup, BufferUsage, RenderPass};
|
||||
|
||||
use crate::{
|
||||
geometry::Geometry,
|
||||
|
@ -11,7 +10,7 @@ use crate::{
|
|||
};
|
||||
|
||||
pub struct WidgetsHud {
|
||||
texture_bind_group: BindGroup,
|
||||
texture_bind_group: wgpu::BindGroup,
|
||||
geometry_buffers: GeometryBuffers<u16>,
|
||||
pub hotbar_cursor_position: usize,
|
||||
}
|
||||
|
@ -25,7 +24,7 @@ impl WidgetsHud {
|
|||
indices: INDICES.to_vec(),
|
||||
};
|
||||
let geometry_buffers =
|
||||
GeometryBuffers::from_geometry(render_context, &geometry, BufferUsage::COPY_DST);
|
||||
GeometryBuffers::from_geometry(render_context, &geometry, wgpu::BufferUsages::COPY_DST);
|
||||
|
||||
Self {
|
||||
texture_bind_group,
|
||||
|
@ -58,16 +57,13 @@ impl WidgetsHud {
|
|||
entries: &[
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 0,
|
||||
visibility: wgpu::ShaderStage::FRAGMENT,
|
||||
ty: wgpu::BindingType::Sampler {
|
||||
comparison: false,
|
||||
filtering: true,
|
||||
},
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
|
||||
count: None,
|
||||
},
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 1,
|
||||
visibility: wgpu::ShaderStage::FRAGMENT,
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Texture {
|
||||
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
||||
view_dimension: wgpu::TextureViewDimension::D2Array,
|
||||
|
@ -129,7 +125,7 @@ impl WidgetsHud {
|
|||
);
|
||||
}
|
||||
|
||||
pub fn render<'a>(&'a self, render_pass: &mut RenderPass<'a>) -> usize {
|
||||
pub fn render<'a>(&'a self, render_pass: &mut wgpu::RenderPass<'a>) -> usize {
|
||||
// Render the HUD elements
|
||||
self.geometry_buffers.apply_buffers(render_pass);
|
||||
render_pass.set_bind_group(0, &self.texture_bind_group, &[]);
|
||||
|
|
|
@ -15,12 +15,11 @@ mod view;
|
|||
mod world;
|
||||
|
||||
use std::time::{Duration, Instant};
|
||||
use wgpu::SwapChainError;
|
||||
use winit::{
|
||||
dpi::{PhysicalSize, Size},
|
||||
event::{ElementState, Event, KeyboardInput, MouseButton, VirtualKeyCode, WindowEvent},
|
||||
event_loop::{ControlFlow, EventLoop},
|
||||
window::{Window, WindowBuilder},
|
||||
window::{CursorGrabMode, Window, WindowBuilder},
|
||||
};
|
||||
|
||||
use crate::state::State;
|
||||
|
@ -41,7 +40,7 @@ fn handle_window_event(
|
|||
},
|
||||
..
|
||||
} => {
|
||||
let _ = window.set_cursor_grab(false);
|
||||
let _ = window.set_cursor_grab(CursorGrabMode::None);
|
||||
window.set_cursor_visible(true);
|
||||
state.mouse_grabbed = false;
|
||||
None
|
||||
|
@ -63,7 +62,7 @@ fn handle_window_event(
|
|||
&& *button == MouseButton::Left
|
||||
&& *mouse_state == ElementState::Pressed
|
||||
{
|
||||
let _ = window.set_cursor_grab(true);
|
||||
let _ = window.set_cursor_grab(CursorGrabMode::Locked);
|
||||
window.set_cursor_visible(false);
|
||||
state.mouse_grabbed = true;
|
||||
} else {
|
||||
|
@ -72,7 +71,7 @@ fn handle_window_event(
|
|||
None
|
||||
}
|
||||
WindowEvent::Focused(false) => {
|
||||
let _ = window.set_cursor_grab(false);
|
||||
let _ = window.set_cursor_grab(CursorGrabMode::Locked);
|
||||
window.set_cursor_visible(true);
|
||||
state.mouse_grabbed = false;
|
||||
None
|
||||
|
|
|
@ -30,12 +30,13 @@ impl State {
|
|||
async fn create_render_device(
|
||||
window: &Window,
|
||||
) -> (wgpu::Surface, wgpu::Adapter, wgpu::Device, wgpu::Queue) {
|
||||
let instance = wgpu::Instance::new(wgpu::BackendBit::PRIMARY);
|
||||
let instance = wgpu::Instance::new(wgpu::Backends::PRIMARY);
|
||||
let render_surface = unsafe { instance.create_surface(window) };
|
||||
let adapter = instance
|
||||
.request_adapter(&wgpu::RequestAdapterOptions {
|
||||
power_preference: wgpu::PowerPreference::HighPerformance,
|
||||
compatible_surface: Some(&render_surface),
|
||||
force_fallback_adapter: false,
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -45,7 +46,7 @@ impl State {
|
|||
.request_device(
|
||||
&wgpu::DeviceDescriptor {
|
||||
label: Some("render_device"),
|
||||
features: wgpu::Features::SAMPLED_TEXTURE_BINDING_ARRAY,
|
||||
features: wgpu::Features::TEXTURE_BINDING_ARRAY,
|
||||
limits: wgpu::Limits::default(),
|
||||
},
|
||||
None,
|
||||
|
@ -65,7 +66,7 @@ impl State {
|
|||
let size = window.inner_size();
|
||||
|
||||
let swap_chain_descriptor = wgpu::SwapChainDescriptor {
|
||||
usage: wgpu::TextureUsage::RENDER_ATTACHMENT,
|
||||
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
|
||||
format: adapter
|
||||
.get_swap_chain_preferred_format(render_surface)
|
||||
.unwrap(),
|
||||
|
|
|
@ -50,16 +50,13 @@ impl TextRenderer {
|
|||
entries: &[
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 0,
|
||||
visibility: wgpu::ShaderStage::FRAGMENT,
|
||||
ty: wgpu::BindingType::Sampler {
|
||||
comparison: false,
|
||||
filtering: true,
|
||||
},
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
|
||||
count: None,
|
||||
},
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 1,
|
||||
visibility: wgpu::ShaderStage::FRAGMENT,
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Texture {
|
||||
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
||||
view_dimension: wgpu::TextureViewDimension::D2Array,
|
||||
|
@ -162,6 +159,6 @@ impl TextRenderer {
|
|||
string: &str,
|
||||
) -> GeometryBuffers<u16> {
|
||||
let geometry = self.string_geometry(x, y, string);
|
||||
GeometryBuffers::from_geometry(render_context, &geometry, wgpu::BufferUsage::empty())
|
||||
GeometryBuffers::from_geometry(render_context, &geometry, wgpu::BufferUsages::empty())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ impl Texture {
|
|||
sample_count: 1,
|
||||
dimension: wgpu::TextureDimension::D2,
|
||||
format: Self::DEPTH_FORMAT,
|
||||
usage: wgpu::TextureUsage::RENDER_ATTACHMENT | wgpu::TextureUsage::SAMPLED,
|
||||
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
|
||||
});
|
||||
|
||||
let view = texture.create_view(&wgpu::TextureViewDescriptor::default());
|
||||
|
@ -80,9 +80,7 @@ impl Texture {
|
|||
sample_count: 1,
|
||||
dimension: wgpu::TextureDimension::D2,
|
||||
format: wgpu::TextureFormat::Rgba8UnormSrgb,
|
||||
usage: wgpu::TextureUsage::SAMPLED
|
||||
| wgpu::TextureUsage::COPY_DST
|
||||
| wgpu::TextureUsage::COPY_SRC,
|
||||
usage: wgpu::TextureUsages::COPY_DST | wgpu::TextureUsages::COPY_SRC,
|
||||
});
|
||||
|
||||
let stride = 4 * rgba.width();
|
||||
|
@ -92,6 +90,7 @@ impl Texture {
|
|||
texture: &texture,
|
||||
mip_level: 0,
|
||||
origin: wgpu::Origin3d::ZERO,
|
||||
aspect: wgpu::TextureAspect::All,
|
||||
},
|
||||
&rgba.as_bytes()[offset..offset + (size.y * stride) as usize],
|
||||
wgpu::ImageDataLayout {
|
||||
|
@ -182,16 +181,13 @@ impl TextureManager {
|
|||
entries: &[
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 0,
|
||||
visibility: wgpu::ShaderStage::FRAGMENT,
|
||||
ty: wgpu::BindingType::Sampler {
|
||||
comparison: false,
|
||||
filtering: true,
|
||||
},
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
|
||||
count: None,
|
||||
},
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 1,
|
||||
visibility: wgpu::ShaderStage::FRAGMENT,
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Texture {
|
||||
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
||||
view_dimension: wgpu::TextureViewDimension::D2Array,
|
||||
|
@ -252,7 +248,7 @@ impl TextureManager {
|
|||
sample_count: 1,
|
||||
dimension: wgpu::TextureDimension::D2,
|
||||
format: wgpu::TextureFormat::Rgba8UnormSrgb,
|
||||
usage: wgpu::TextureUsage::SAMPLED | wgpu::TextureUsage::COPY_DST,
|
||||
usage: wgpu::TextureUsages::COPY_DST,
|
||||
});
|
||||
|
||||
let mut encoder =
|
||||
|
@ -268,6 +264,7 @@ impl TextureManager {
|
|||
texture: &texture.texture,
|
||||
mip_level: 0,
|
||||
origin: Origin3d::ZERO,
|
||||
aspect: wgpu::TextureAspect::All,
|
||||
},
|
||||
wgpu::ImageCopyTexture {
|
||||
texture: &texture_array,
|
||||
|
@ -277,6 +274,7 @@ impl TextureManager {
|
|||
y: 0,
|
||||
z: i as u32,
|
||||
},
|
||||
aspect: wgpu::TextureAspect::All,
|
||||
},
|
||||
wgpu::Extent3d {
|
||||
width: 16,
|
||||
|
|
|
@ -31,7 +31,7 @@ impl Vertex for HudVertex {
|
|||
fn descriptor() -> wgpu::VertexBufferLayout<'static> {
|
||||
wgpu::VertexBufferLayout {
|
||||
array_stride: size_of::<Self>() as wgpu::BufferAddress,
|
||||
step_mode: wgpu::InputStepMode::Vertex,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
attributes: HUD_VERTEX_ATTRIBUTES,
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ impl Vertex for BlockVertex {
|
|||
fn descriptor() -> wgpu::VertexBufferLayout<'static> {
|
||||
wgpu::VertexBufferLayout {
|
||||
array_stride: size_of::<Self>() as wgpu::BufferAddress,
|
||||
step_mode: wgpu::InputStepMode::Vertex,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
attributes: BLOCK_VERTEX_ATTRIBUTES,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::mem::size_of;
|
||||
|
||||
use cgmath::{EuclideanSpace, Matrix4, Point3, SquareMatrix, Vector4, Zero};
|
||||
use wgpu::{BindGroup, BindGroupLayout, Buffer, BufferDescriptor, BufferUsage};
|
||||
use wgpu::{BindGroup, BindGroupLayout, Buffer, BufferDescriptor, BufferUsages};
|
||||
|
||||
use crate::{
|
||||
aabb::Aabb,
|
||||
|
@ -48,7 +48,7 @@ impl View {
|
|||
let buffer = render_context.device.create_buffer(&BufferDescriptor {
|
||||
label: Some("view buffer"),
|
||||
size: size_of::<ViewRaw>() as u64,
|
||||
usage: BufferUsage::UNIFORM | BufferUsage::COPY_DST,
|
||||
usage: BufferUsages::UNIFORM | BufferUsages::COPY_DST,
|
||||
mapped_at_creation: false,
|
||||
});
|
||||
|
||||
|
@ -58,7 +58,7 @@ impl View {
|
|||
.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||
entries: &[wgpu::BindGroupLayoutEntry {
|
||||
binding: 0,
|
||||
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
|
||||
visibility: wgpu::ShaderStages::VERTEX | wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Buffer {
|
||||
ty: wgpu::BufferBindingType::Uniform,
|
||||
has_dynamic_offset: false,
|
||||
|
|
|
@ -22,7 +22,6 @@ use serde::{
|
|||
ser::SerializeSeq,
|
||||
Deserialize, Serialize, Serializer,
|
||||
};
|
||||
use wgpu::{BufferUsage, RenderPass};
|
||||
|
||||
pub const CHUNK_SIZE: usize = 32;
|
||||
pub const CHUNK_ISIZE: isize = CHUNK_SIZE as isize;
|
||||
|
@ -98,7 +97,7 @@ impl<'de> Deserialize<'de> for Chunk {
|
|||
impl Chunk {
|
||||
pub fn render<'a>(
|
||||
&'a self,
|
||||
render_pass: &mut RenderPass<'a>,
|
||||
render_pass: &mut wgpu::RenderPass<'a>,
|
||||
position: &Point3<isize>,
|
||||
view: &View,
|
||||
) -> usize {
|
||||
|
@ -418,7 +417,7 @@ impl Chunk {
|
|||
self.buffers = Some(GeometryBuffers::from_geometry(
|
||||
render_context,
|
||||
&Self::quads_to_geometry(quads),
|
||||
BufferUsage::empty(),
|
||||
wgpu::BufferUsages::empty(),
|
||||
));
|
||||
|
||||
self.update_fullness();
|
||||
|
|
|
@ -26,7 +26,7 @@ use cgmath::{EuclideanSpace, InnerSpace, Point3, Vector3};
|
|||
use fxhash::FxHashMap;
|
||||
use wgpu::{
|
||||
util::{BufferInitDescriptor, DeviceExt},
|
||||
BindGroup, Buffer, CommandEncoder, RenderPipeline, SwapChainTexture,
|
||||
BindGroup, Buffer, CommandEncoder, RenderPipeline,
|
||||
};
|
||||
|
||||
pub struct World {
|
||||
|
@ -186,7 +186,7 @@ impl World {
|
|||
|
||||
let mut render_pass = render_encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
label: Some("render_pass"),
|
||||
color_attachments: &[wgpu::RenderPassColorAttachment {
|
||||
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||
view: &frame.view,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
|
@ -198,7 +198,7 @@ impl World {
|
|||
}),
|
||||
store: true,
|
||||
},
|
||||
}],
|
||||
})],
|
||||
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
|
||||
view: &self.depth_texture.view,
|
||||
depth_ops: Some(wgpu::Operations {
|
||||
|
@ -244,7 +244,7 @@ impl World {
|
|||
.create_buffer_init(&BufferInitDescriptor {
|
||||
label: Some("time_buffer"),
|
||||
contents: bytemuck::cast_slice(&[time]),
|
||||
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
|
||||
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
|
||||
});
|
||||
|
||||
let time_bind_group_layout =
|
||||
|
@ -253,7 +253,7 @@ impl World {
|
|||
.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||
entries: &[wgpu::BindGroupLayoutEntry {
|
||||
binding: 0,
|
||||
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
|
||||
visibility: wgpu::ShaderStages::VERTEX | wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Buffer {
|
||||
ty: wgpu::BufferBindingType::Uniform,
|
||||
has_dynamic_offset: false,
|
||||
|
@ -289,13 +289,12 @@ impl World {
|
|||
],
|
||||
});
|
||||
|
||||
let shader = render_context.device.create_shader_module(
|
||||
&(wgpu::ShaderModuleDescriptor {
|
||||
let shader = render_context
|
||||
.device
|
||||
.create_shader_module(wgpu::ShaderModuleDescriptor {
|
||||
label: Some("shader"),
|
||||
flags: wgpu::ShaderFlags::all(),
|
||||
source: wgpu::ShaderSource::Wgsl(include_str!("../shaders/world.wgsl").into()),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
let render_pipeline =
|
||||
render_context
|
||||
|
@ -311,14 +310,14 @@ impl World {
|
|||
fragment: Some(wgpu::FragmentState {
|
||||
module: &shader,
|
||||
entry_point: "main",
|
||||
targets: &[wgpu::ColorTargetState {
|
||||
targets: &[Some(wgpu::ColorTargetState {
|
||||
format: render_context.swap_chain_descriptor.format,
|
||||
blend: Some(wgpu::BlendState {
|
||||
alpha: wgpu::BlendComponent::REPLACE,
|
||||
color: wgpu::BlendComponent::REPLACE,
|
||||
}),
|
||||
write_mask: wgpu::ColorWrite::ALL,
|
||||
}],
|
||||
write_mask: wgpu::ColorWrites::ALL,
|
||||
})],
|
||||
}),
|
||||
primitive: wgpu::PrimitiveState {
|
||||
cull_mode: Some(wgpu::Face::Back),
|
||||
|
@ -333,6 +332,7 @@ impl World {
|
|||
bias: wgpu::DepthBiasState::default(),
|
||||
}),
|
||||
multisample: wgpu::MultisampleState::default(),
|
||||
multiview: None,
|
||||
});
|
||||
|
||||
let depth_texture = Texture::create_depth_texture(render_context, "depth_texture");
|
||||
|
|
|
@ -2,7 +2,6 @@ extern crate gltf;
|
|||
extern crate wgpu;
|
||||
|
||||
use cgmath::Vector3;
|
||||
use wgpu::{BufferUsage, RenderPass};
|
||||
|
||||
use crate::{
|
||||
geometry::Geometry, geometry_buffers::GeometryBuffers, render_context::RenderContext,
|
||||
|
@ -68,11 +67,11 @@ impl Npc {
|
|||
self.geometry_buffers = Some(GeometryBuffers::from_geometry(
|
||||
render_context,
|
||||
&self.geometry,
|
||||
BufferUsage::empty(),
|
||||
wgpu::BufferUsages::empty(),
|
||||
));
|
||||
}
|
||||
|
||||
pub fn render<'a>(&'a self, render_pass: &mut RenderPass<'a>) -> usize {
|
||||
pub fn render<'a>(&'a self, render_pass: &mut wgpu::RenderPass<'a>) -> usize {
|
||||
let buffers = self.geometry_buffers.as_ref().unwrap();
|
||||
buffers.apply_buffers(render_pass);
|
||||
buffers.draw_indexed(render_pass)
|
||||
|
|
Loading…
Reference in a new issue