update
This commit is contained in:
Generated
+1011
-623
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -5,8 +5,8 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
winit = "0.30.9"
|
winit = "0.30.9"
|
||||||
pollster = "0.3.0"
|
pollster = "0.4.0"
|
||||||
bytemuck = "1.19.0"
|
bytemuck = "1.19.0"
|
||||||
num-traits = "0.2.19"
|
num-traits = "0.2.19"
|
||||||
nalgebra = "0.33.2"
|
nalgebra = "0.34.2"
|
||||||
wgpu = "24.0.1"
|
wgpu = "29.0.3"
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ impl Layout {
|
|||||||
sample_count: 1,
|
sample_count: 1,
|
||||||
dimension: wgpu::TextureDimension::D2,
|
dimension: wgpu::TextureDimension::D2,
|
||||||
format: wgpu::TextureFormat::Rgba8Unorm,
|
format: wgpu::TextureFormat::Rgba8Unorm,
|
||||||
usage: wgpu::TextureUsages::STORAGE_BINDING | wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_SRC,
|
usage: wgpu::TextureUsages::STORAGE_BINDING
|
||||||
|
| wgpu::TextureUsages::TEXTURE_BINDING
|
||||||
|
| wgpu::TextureUsages::COPY_SRC,
|
||||||
view_formats: &[],
|
view_formats: &[],
|
||||||
};
|
};
|
||||||
let output = Texture::init(
|
let output = Texture::init(
|
||||||
@@ -70,8 +72,8 @@ impl Layout {
|
|||||||
|
|
||||||
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
||||||
label: Some("Tile Pipeline Layout"),
|
label: Some("Tile Pipeline Layout"),
|
||||||
bind_group_layouts: &[&bind_layout],
|
bind_group_layouts: &[Some(&bind_layout)],
|
||||||
push_constant_ranges: &[],
|
immediate_size: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
+18
-14
@@ -37,9 +37,12 @@ impl Renderer<'_> {
|
|||||||
pub fn new(window: Arc<Window>) -> Self {
|
pub fn new(window: Arc<Window>) -> Self {
|
||||||
let size = window.inner_size();
|
let size = window.inner_size();
|
||||||
|
|
||||||
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
|
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
|
||||||
backends: wgpu::Backends::PRIMARY,
|
backends: wgpu::Backends::PRIMARY,
|
||||||
..Default::default()
|
flags: Default::default(),
|
||||||
|
memory_budget_thresholds: Default::default(),
|
||||||
|
backend_options: Default::default(),
|
||||||
|
display: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
let surface = instance
|
let surface = instance
|
||||||
@@ -53,24 +56,21 @@ impl Renderer<'_> {
|
|||||||
}))
|
}))
|
||||||
.expect("Could not get adapter!");
|
.expect("Could not get adapter!");
|
||||||
|
|
||||||
let buf_size = (10f32.powi(9) * 1.5) as u32;
|
let buf_size = (10f32.powi(9) * 1.5) as u64;
|
||||||
let (device, queue) = pollster::block_on(adapter.request_device(
|
let (device, queue) = pollster::block_on(adapter.request_device(&wgpu::DeviceDescriptor {
|
||||||
&wgpu::DeviceDescriptor {
|
|
||||||
label: None,
|
label: None,
|
||||||
required_features: wgpu::Features::PUSH_CONSTANTS
|
required_features: wgpu::Features::TIMESTAMP_QUERY
|
||||||
| wgpu::Features::TIMESTAMP_QUERY
|
|
||||||
| wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS
|
| wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS
|
||||||
| wgpu::Features::TIMESTAMP_QUERY_INSIDE_PASSES,
|
| wgpu::Features::TIMESTAMP_QUERY_INSIDE_PASSES,
|
||||||
required_limits: wgpu::Limits {
|
required_limits: wgpu::Limits {
|
||||||
max_storage_buffer_binding_size: buf_size,
|
max_storage_buffer_binding_size: buf_size,
|
||||||
max_buffer_size: buf_size as u64,
|
max_buffer_size: buf_size,
|
||||||
max_push_constant_size: 4,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
memory_hints: wgpu::MemoryHints::default(),
|
memory_hints: wgpu::MemoryHints::default(),
|
||||||
},
|
trace: wgpu::Trace::Off,
|
||||||
None,
|
experimental_features: wgpu::ExperimentalFeatures::disabled(),
|
||||||
))
|
}))
|
||||||
.expect("Could not get device!");
|
.expect("Could not get device!");
|
||||||
|
|
||||||
let info = adapter.get_info();
|
let info = adapter.get_info();
|
||||||
@@ -97,7 +97,7 @@ impl Renderer<'_> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
surface.configure(&device, &config);
|
surface.configure(&device, &config);
|
||||||
let staging_belt = wgpu::util::StagingBelt::new(1024);
|
let staging_belt = wgpu::util::StagingBelt::new(device.clone(), 1024);
|
||||||
let timer = GPUTimer::new(&device, queue.get_timestamp_period(), 1);
|
let timer = GPUTimer::new(&device, queue.get_timestamp_period(), 1);
|
||||||
|
|
||||||
let len = 2;
|
let len = 2;
|
||||||
@@ -143,7 +143,11 @@ impl Renderer<'_> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let mut encoder = std::mem::replace(&mut self.encoder, Self::create_encoder(&self.device));
|
let mut encoder = std::mem::replace(&mut self.encoder, Self::create_encoder(&self.device));
|
||||||
let output = self.surface.get_current_texture().unwrap();
|
let output = match self.surface.get_current_texture() {
|
||||||
|
wgpu::CurrentSurfaceTexture::Success(v) => v,
|
||||||
|
wgpu::CurrentSurfaceTexture::Suboptimal(v) => v,
|
||||||
|
_ => panic!("failed to get current surface texture"),
|
||||||
|
};
|
||||||
|
|
||||||
self.timer.start(&mut encoder, 0);
|
self.timer.start(&mut encoder, 0);
|
||||||
self.compute_pipeline.run(&mut encoder);
|
self.compute_pipeline.run(&mut encoder);
|
||||||
|
|||||||
@@ -17,10 +17,7 @@ pub struct Layout {
|
|||||||
pub const LABEL: &str = file!();
|
pub const LABEL: &str = file!();
|
||||||
|
|
||||||
impl Layout {
|
impl Layout {
|
||||||
pub fn init(
|
pub fn init(device: &wgpu::Device, config: &wgpu::SurfaceConfiguration) -> Self {
|
||||||
device: &wgpu::Device,
|
|
||||||
config: &wgpu::SurfaceConfiguration,
|
|
||||||
) -> Self {
|
|
||||||
let view = Storage::init_with(device, "view", bytemuck::bytes_of(&WindowView::default()));
|
let view = Storage::init_with(device, "view", bytemuck::bytes_of(&WindowView::default()));
|
||||||
|
|
||||||
let texture_desc = wgpu::TextureDescriptor {
|
let texture_desc = wgpu::TextureDescriptor {
|
||||||
@@ -124,8 +121,8 @@ impl Layout {
|
|||||||
let render_pipeline_layout =
|
let render_pipeline_layout =
|
||||||
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
||||||
label: Some(LABEL),
|
label: Some(LABEL),
|
||||||
bind_group_layouts: &[&render_bind_layout],
|
bind_group_layouts: &[Some(&render_bind_layout)],
|
||||||
push_constant_ranges: &[],
|
immediate_size: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
@@ -192,7 +189,7 @@ impl Layout {
|
|||||||
mask: !0,
|
mask: !0,
|
||||||
alpha_to_coverage_enabled: true,
|
alpha_to_coverage_enabled: true,
|
||||||
},
|
},
|
||||||
multiview: None,
|
multiview_mask: None,
|
||||||
cache: None,
|
cache: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,10 +80,12 @@ impl RenderPipeline {
|
|||||||
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
|
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
|
||||||
store: wgpu::StoreOp::Store,
|
store: wgpu::StoreOp::Store,
|
||||||
},
|
},
|
||||||
|
depth_slice: None,
|
||||||
})],
|
})],
|
||||||
depth_stencil_attachment: None,
|
depth_stencil_attachment: None,
|
||||||
timestamp_writes: None,
|
timestamp_writes: None,
|
||||||
occlusion_query_set: None,
|
occlusion_query_set: None,
|
||||||
|
multiview_mask: None,
|
||||||
});
|
});
|
||||||
render_pass.set_pipeline(&self.pipeline);
|
render_pass.set_pipeline(&self.pipeline);
|
||||||
render_pass.set_bind_group(0, &self.bind_group, &[]);
|
render_pass.set_bind_group(0, &self.bind_group, &[]);
|
||||||
|
|||||||
@@ -37,15 +37,9 @@ impl<T: bytemuck::Pod> ArrayBuffer<T> {
|
|||||||
return resized;
|
return resized;
|
||||||
}
|
}
|
||||||
if let Some(update) = self.update.take() {
|
if let Some(update) = self.update.take() {
|
||||||
let mut view = belt.write_buffer(
|
let mut view = belt.write_buffer(encoder, &self.buffer, 0, unsafe {
|
||||||
encoder,
|
|
||||||
&self.buffer,
|
|
||||||
0,
|
|
||||||
unsafe {
|
|
||||||
std::num::NonZeroU64::new_unchecked(std::mem::size_of_val(&update[..]) as u64)
|
std::num::NonZeroU64::new_unchecked(std::mem::size_of_val(&update[..]) as u64)
|
||||||
},
|
});
|
||||||
device,
|
|
||||||
);
|
|
||||||
view.copy_from_slice(bytemuck::cast_slice(&update));
|
view.copy_from_slice(bytemuck::cast_slice(&update));
|
||||||
}
|
}
|
||||||
resized
|
resized
|
||||||
@@ -122,7 +116,7 @@ impl<T: bytemuck::Pod> ArrayBuffer<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bind_group_entry(&self, binding: u32) -> wgpu::BindGroupEntry {
|
pub fn bind_group_entry(&self, binding: u32) -> wgpu::BindGroupEntry<'_> {
|
||||||
wgpu::BindGroupEntry {
|
wgpu::BindGroupEntry {
|
||||||
binding,
|
binding,
|
||||||
resource: self.buffer.as_entire_binding(),
|
resource: self.buffer.as_entire_binding(),
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
mod array;
|
||||||
|
mod storage;
|
||||||
mod texture;
|
mod texture;
|
||||||
mod timer;
|
mod timer;
|
||||||
mod uniform;
|
mod uniform;
|
||||||
mod array;
|
|
||||||
mod storage;
|
|
||||||
|
|
||||||
|
pub use array::*;
|
||||||
|
pub use storage::*;
|
||||||
pub use texture::*;
|
pub use texture::*;
|
||||||
pub use timer::*;
|
pub use timer::*;
|
||||||
pub use uniform::*;
|
pub use uniform::*;
|
||||||
pub use array::*;
|
|
||||||
pub use storage::*;
|
|
||||||
|
|||||||
@@ -45,13 +45,9 @@ impl Storage {
|
|||||||
self.old_len = data.len();
|
self.old_len = data.len();
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
let mut view = belt.write_buffer(
|
let mut view = belt.write_buffer(encoder, &self.buffer, 0, unsafe {
|
||||||
encoder,
|
std::num::NonZeroU64::new_unchecked(std::mem::size_of_val(data) as u64)
|
||||||
&self.buffer,
|
});
|
||||||
0,
|
|
||||||
unsafe { std::num::NonZeroU64::new_unchecked(std::mem::size_of_val(data) as u64) },
|
|
||||||
device,
|
|
||||||
);
|
|
||||||
view.copy_from_slice(data);
|
view.copy_from_slice(data);
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
@@ -74,7 +70,7 @@ impl Storage {
|
|||||||
count: None,
|
count: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn bind_group_entry(&self, binding: u32) -> wgpu::BindGroupEntry {
|
pub fn bind_group_entry(&self, binding: u32) -> wgpu::BindGroupEntry<'_> {
|
||||||
wgpu::BindGroupEntry {
|
wgpu::BindGroupEntry {
|
||||||
binding,
|
binding,
|
||||||
resource: self.buffer.as_entire_binding(),
|
resource: self.buffer.as_entire_binding(),
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ impl Texture {
|
|||||||
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||||
mag_filter: wgpu::FilterMode::Linear,
|
mag_filter: wgpu::FilterMode::Linear,
|
||||||
min_filter: wgpu::FilterMode::Linear,
|
min_filter: wgpu::FilterMode::Linear,
|
||||||
mipmap_filter: wgpu::FilterMode::Nearest,
|
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
|
||||||
compare: Some(wgpu::CompareFunction::LessEqual),
|
compare: Some(wgpu::CompareFunction::LessEqual),
|
||||||
lod_min_clamp: 0.0,
|
lod_min_clamp: 0.0,
|
||||||
lod_max_clamp: 100.0,
|
lod_max_clamp: 100.0,
|
||||||
@@ -73,13 +73,13 @@ impl Texture {
|
|||||||
self.texture = device.create_texture(&self.texture_desc);
|
self.texture = device.create_texture(&self.texture_desc);
|
||||||
self.view = self.texture.create_view(&self.view_desc);
|
self.view = self.texture.create_view(&self.view_desc);
|
||||||
}
|
}
|
||||||
pub fn view_bind_group_entry(&self, binding: u32) -> wgpu::BindGroupEntry {
|
pub fn view_bind_group_entry(&self, binding: u32) -> wgpu::BindGroupEntry<'_> {
|
||||||
wgpu::BindGroupEntry {
|
wgpu::BindGroupEntry {
|
||||||
binding,
|
binding,
|
||||||
resource: wgpu::BindingResource::TextureView(&self.view),
|
resource: wgpu::BindingResource::TextureView(&self.view),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn sampler_bind_group_entry(&self, binding: u32) -> wgpu::BindGroupEntry {
|
pub fn sampler_bind_group_entry(&self, binding: u32) -> wgpu::BindGroupEntry<'_> {
|
||||||
wgpu::BindGroupEntry {
|
wgpu::BindGroupEntry {
|
||||||
binding,
|
binding,
|
||||||
resource: wgpu::BindingResource::Sampler(&self.sampler),
|
resource: wgpu::BindingResource::Sampler(&self.sampler),
|
||||||
@@ -118,7 +118,7 @@ impl ResizableTexture {
|
|||||||
self.view = self.texture.create_view(&self.view_desc)
|
self.view = self.texture.create_view(&self.view_desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view_entry(&self, binding: u32) -> wgpu::BindGroupEntry {
|
pub fn view_entry(&self, binding: u32) -> wgpu::BindGroupEntry<'_> {
|
||||||
wgpu::BindGroupEntry {
|
wgpu::BindGroupEntry {
|
||||||
binding,
|
binding,
|
||||||
resource: wgpu::BindingResource::TextureView(&self.view),
|
resource: wgpu::BindingResource::TextureView(&self.view),
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ impl GPUTimer {
|
|||||||
.map_async(wgpu::MapMode::Read, move |v| {
|
.map_async(wgpu::MapMode::Read, move |v| {
|
||||||
s.send(v).expect("what");
|
s.send(v).expect("what");
|
||||||
});
|
});
|
||||||
device.poll(wgpu::Maintain::wait()).panic_on_timeout();
|
device.poll(wgpu::PollType::wait_indefinitely()).unwrap();
|
||||||
if let Ok(Ok(())) = r.recv() {
|
if let Ok(Ok(())) = r.recv() {
|
||||||
let data = self.map_buf.slice(..).get_mapped_range();
|
let data = self.map_buf.slice(..).get_mapped_range();
|
||||||
self.timestamps.copy_from_slice(bytemuck::cast_slice(&data));
|
self.timestamps.copy_from_slice(bytemuck::cast_slice(&data));
|
||||||
@@ -86,4 +86,3 @@ impl GPUTimer {
|
|||||||
pass.write_timestamp(&self.query_set, i * 2 + 1);
|
pass.write_timestamp(&self.query_set, i * 2 + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,21 +33,14 @@ impl<T: bytemuck::Pod> Uniform<T> {
|
|||||||
}
|
}
|
||||||
pub fn update(
|
pub fn update(
|
||||||
&mut self,
|
&mut self,
|
||||||
device: &wgpu::Device,
|
|
||||||
encoder: &mut wgpu::CommandEncoder,
|
encoder: &mut wgpu::CommandEncoder,
|
||||||
belt: &mut wgpu::util::StagingBelt,
|
belt: &mut wgpu::util::StagingBelt,
|
||||||
data: T,
|
data: T,
|
||||||
) {
|
) {
|
||||||
let slice = &[data];
|
let slice = &[data];
|
||||||
let mut view = belt.write_buffer(
|
let mut view = belt.write_buffer(encoder, &self.buffer, 0, unsafe {
|
||||||
encoder,
|
|
||||||
&self.buffer,
|
|
||||||
0,
|
|
||||||
unsafe {
|
|
||||||
std::num::NonZeroU64::new_unchecked((slice.len() * std::mem::size_of::<T>()) as u64)
|
std::num::NonZeroU64::new_unchecked((slice.len() * std::mem::size_of::<T>()) as u64)
|
||||||
},
|
});
|
||||||
device,
|
|
||||||
);
|
|
||||||
view.copy_from_slice(bytemuck::cast_slice(slice));
|
view.copy_from_slice(bytemuck::cast_slice(slice));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,7 +60,7 @@ impl<T> Uniform<T> {
|
|||||||
count: None,
|
count: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn bind_group_entry(&self, binding: u32) -> wgpu::BindGroupEntry {
|
pub fn bind_group_entry(&self, binding: u32) -> wgpu::BindGroupEntry<'_> {
|
||||||
wgpu::BindGroupEntry {
|
wgpu::BindGroupEntry {
|
||||||
binding,
|
binding,
|
||||||
resource: self.buffer.as_entire_binding(),
|
resource: self.buffer.as_entire_binding(),
|
||||||
|
|||||||
+1
-2
@@ -1,6 +1,5 @@
|
|||||||
#![feature(bigint_helper_methods)]
|
#![feature(widening_mul)]
|
||||||
#![feature(int_roundings)]
|
#![feature(int_roundings)]
|
||||||
#![feature(let_chains)]
|
|
||||||
|
|
||||||
use client::ClientApp;
|
use client::ClientApp;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user