List of evicted pages
This commit is contained in:
+56
-70
@@ -52,6 +52,7 @@ use winit::window::WindowId;
|
||||
|
||||
use crate::camera::Camera;
|
||||
use crate::egui_renderer::EguiRenderer;
|
||||
use crate::gpu_profiler::Frame;
|
||||
use crate::gpu_profiler::Profile;
|
||||
use crate::gpu_profiler::ProfilingEncoder;
|
||||
use crate::producers::ChunkedProducer;
|
||||
@@ -68,6 +69,7 @@ use crate::voxel_cache::producer_interface::CacheRequest;
|
||||
|
||||
mod camera;
|
||||
mod egui_renderer;
|
||||
mod gi_pipeline;
|
||||
mod gpu;
|
||||
pub mod gpu_profiler;
|
||||
mod producers;
|
||||
@@ -108,8 +110,8 @@ struct State
|
||||
gi_bg_layout: BindGroupLayout,
|
||||
voxel_cache: Arc<Mutex<VoxelCache<4>>>,
|
||||
cache_interface: Arc<CacheProducerInterface<4>>,
|
||||
terrain_generator: Arc<SdfGenerator<4>>,
|
||||
//terrain_generator: Arc<TerrainGenerator<4>>,
|
||||
//terrain_generator: Arc<SdfGenerator<4>>,
|
||||
terrain_generator: Arc<TerrainGenerator<4>>,
|
||||
chunk_pos_map: Arc<HashMap<u32, (usize, usize, usize)>>,
|
||||
instance_buffer: Buffer,
|
||||
instance_count: usize,
|
||||
@@ -123,6 +125,7 @@ struct State
|
||||
terrain_alt: usize,
|
||||
|
||||
profile: Arc<Mutex<Profile>>,
|
||||
insert_profile: Arc<Mutex<Profile>>,
|
||||
|
||||
camera: Camera,
|
||||
cursor_grabed: bool,
|
||||
@@ -183,6 +186,7 @@ impl State
|
||||
| Features::SHADER_I16
|
||||
| Features::SHADER_F16
|
||||
| Features::TIMESTAMP_QUERY_INSIDE_ENCODERS
|
||||
| Features::TIMESTAMP_QUERY_INSIDE_PASSES
|
||||
| Features::STORAGE_RESOURCE_BINDING_ARRAY
|
||||
| Features::BUFFER_BINDING_ARRAY
|
||||
| Features::PASSTHROUGH_SHADERS
|
||||
@@ -334,16 +338,24 @@ impl State
|
||||
|
||||
let egui_renderer = EguiRenderer::new(&device, surface_format, &window);
|
||||
|
||||
let attributes = VoxelCacheLayout::default()
|
||||
.add_attribute(voxel_cache::layout::VoxelCacheAttribute { word_count: 1 })
|
||||
.add_attribute(voxel_cache::layout::VoxelCacheAttribute { word_count: 3 });
|
||||
let mut attributes = VoxelCacheLayout::default();
|
||||
attributes.add_attribute(voxel_cache::layout::VoxelCacheAttribute {
|
||||
word_count: 1,
|
||||
rate: voxel_cache::layout::VoxelCacheAttributeRate::Pointer,
|
||||
init: voxel_cache::layout::VoxelCacheAttributeInit::Copy,
|
||||
});
|
||||
attributes.add_attribute(voxel_cache::layout::VoxelCacheAttribute {
|
||||
word_count: 3,
|
||||
rate: voxel_cache::layout::VoxelCacheAttributeRate::Pointer,
|
||||
init: voxel_cache::layout::VoxelCacheAttributeInit::Copy,
|
||||
});
|
||||
|
||||
let mut voxel_cache =
|
||||
VoxelCache::<4>::new(150_000, device.clone(), queue.clone(), &attributes);
|
||||
let cache_interface = CacheProducerInterface::new(1024, &device, &attributes);
|
||||
|
||||
//let terrain_generator = TerrainGenerator::<4>::new(5, "vxls_height.tif", 0.2, "img.jpg");
|
||||
let terrain_generator = SdfGenerator::<4>::new(5);
|
||||
let terrain_generator = TerrainGenerator::<4>::new(5, "vxls_height.tif", 0.2, "img.jpg");
|
||||
//let terrain_generator = SdfGenerator::<4>::new(5);
|
||||
// let terrain_generator = TerrainGenerator::<4>::new(
|
||||
// 5,
|
||||
// "./pointe_percee/height.tif",
|
||||
@@ -358,12 +370,12 @@ impl State
|
||||
// );
|
||||
//
|
||||
|
||||
// let terrain_width = terrain_generator.chunk_width;
|
||||
// let terrain_height = terrain_generator.chunk_height;
|
||||
// let terrain_alt = terrain_generator.chunk_alt;
|
||||
let terrain_width = 10;
|
||||
let terrain_height = 10;
|
||||
let terrain_alt = 10;
|
||||
let terrain_width = terrain_generator.chunk_width;
|
||||
let terrain_height = terrain_generator.chunk_height;
|
||||
let terrain_alt = terrain_generator.chunk_alt;
|
||||
// let terrain_width = 10;
|
||||
// let terrain_height = 10;
|
||||
// let terrain_alt = 10;
|
||||
println!(
|
||||
"Chunk count : {}",
|
||||
terrain_width * terrain_height * terrain_width
|
||||
@@ -667,6 +679,7 @@ impl State
|
||||
terrain_height,
|
||||
terrain_alt,
|
||||
profile: Arc::new(Mutex::new(Profile::default())),
|
||||
insert_profile: Arc::new(Mutex::new(Profile::default())),
|
||||
cursor_grabed: true,
|
||||
};
|
||||
|
||||
@@ -1029,58 +1042,6 @@ impl State
|
||||
};
|
||||
self.target_blitter
|
||||
.copy(&self.device, &mut encoder, target_view, &texture_view);
|
||||
/*
|
||||
{
|
||||
let mut renderpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
label: None,
|
||||
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||
view: &texture_view,
|
||||
depth_slice: None,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
load: wgpu::LoadOp::Clear(wgpu::Color {
|
||||
r: 0.,
|
||||
g: 2. / 255.,
|
||||
b: 15. / 255.,
|
||||
a: 1.,
|
||||
}),
|
||||
store: wgpu::StoreOp::Store,
|
||||
},
|
||||
})],
|
||||
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
|
||||
view: &self.depth_buffer.1,
|
||||
depth_ops: Some(Operations {
|
||||
load: wgpu::LoadOp::Clear(1.),
|
||||
store: wgpu::StoreOp::Discard,
|
||||
}),
|
||||
stencil_ops: None,
|
||||
}),
|
||||
timestamp_writes: Some(wgpu::RenderPassTimestampWrites {
|
||||
query_set: ×tamp_query,
|
||||
beginning_of_pass_write_index: Some(0),
|
||||
end_of_pass_write_index: Some(1),
|
||||
}),
|
||||
occlusion_query_set: None,
|
||||
multiview_mask: None,
|
||||
});
|
||||
|
||||
renderpass.set_pipeline(&self.pipeline);
|
||||
renderpass.set_vertex_buffer(0, self.instance_buffer.slice(..));
|
||||
renderpass.set_bind_group(0, Some(&self.voxel_cache.lock().bind_group()), &[]);
|
||||
let imm = [Immediates {
|
||||
view_proj: self.camera.view_proj(),
|
||||
cam_pos: self.camera.position,
|
||||
frame_timestamp: self.voxel_cache.lock().current_timestamp(),
|
||||
}];
|
||||
renderpass.set_immediates(0, unsafe { as_raw_bytes(&imm) });
|
||||
renderpass.draw(0..36, 0..(self.instance_count as u32));
|
||||
|
||||
// End the renderpass.
|
||||
drop(renderpass);
|
||||
|
||||
encoder.resolve_query_set(×tamp_query, 0..2, ×tamp_buffer, 0);
|
||||
}
|
||||
*/
|
||||
|
||||
// ~~ EGUI Render pass ~~
|
||||
{
|
||||
@@ -1121,7 +1082,7 @@ impl State
|
||||
// [512., 512.],
|
||||
// )));
|
||||
egui_plot::Plot::new("Plot")
|
||||
.height(512.)
|
||||
.height(256.)
|
||||
.show(ui, |plot_ui| {
|
||||
plot_ui.bar_chart(BarChart::new(
|
||||
"histo",
|
||||
@@ -1135,7 +1096,20 @@ impl State
|
||||
});
|
||||
|
||||
let q = self.queue.get_timestamp_period() / 1_000_000.;
|
||||
self.profile.lock().show(ui, q);
|
||||
let f = Frame {
|
||||
name: "skibidi",
|
||||
children: vec![],
|
||||
start_timestamp: 0,
|
||||
end_timestamp: 1_000_000,
|
||||
};
|
||||
let p = Profile { frames: vec![f] };
|
||||
// self.profile.lock().show(ui, q);
|
||||
self.profile
|
||||
.lock()
|
||||
.show_flamegraph("first_profile".into(), q, ui);
|
||||
self.insert_profile
|
||||
.lock()
|
||||
.show_flamegraph("second_profile".into(), q, ui);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1255,6 +1229,7 @@ impl State
|
||||
let cloned_generator = self.terrain_generator.clone();
|
||||
let cloned_map = self.chunk_pos_map.clone();
|
||||
let cloned_cache_interface = self.cache_interface.clone();
|
||||
let cloned_insert_profile = self.insert_profile.clone();
|
||||
let (tx, rx) = sync_channel(1);
|
||||
|
||||
// ~~ Download request buffer, fullfill requests, writeback to cache ~~
|
||||
@@ -1378,10 +1353,21 @@ impl State
|
||||
);
|
||||
|
||||
let mut encoder = cloned_device.create_command_encoder(&Default::default());
|
||||
cloned_cache
|
||||
.lock()
|
||||
.cache_insert(&mut encoder, &cloned_cache_interface);
|
||||
let mut profiled_encoder =
|
||||
ProfilingEncoder::new(&cloned_device, &mut encoder);
|
||||
{
|
||||
gpu_profiler::begin_frame!(profiled_encoder, "Cache insertion");
|
||||
{
|
||||
cloned_cache
|
||||
.lock()
|
||||
.cache_insert(&mut profiled_encoder, &cloned_cache_interface);
|
||||
}
|
||||
}
|
||||
let profile = profiled_encoder.finish_profiler();
|
||||
cloned_queue.submit([encoder.finish()]);
|
||||
profile.read_back(&cloned_device, &cloned_queue, move |mut profile| {
|
||||
*cloned_insert_profile.lock() = profile;
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user