Compare commits
2 Commits
56e756d818
...
8fd8731696
Author | SHA1 | Date |
---|---|---|
Jarrod Doyle | 8fd8731696 | |
Jarrod Doyle | 443b18729e |
|
@ -4,7 +4,10 @@ mod renderer;
|
|||
use std::time::Instant;
|
||||
|
||||
use anyhow::Result;
|
||||
use crawl::winit::event::{Event, WindowEvent};
|
||||
use crawl::{
|
||||
wgpu,
|
||||
winit::event::{Event, WindowEvent},
|
||||
};
|
||||
use renderer::VoxelRenderer;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
|
@ -13,6 +16,7 @@ fn main() -> Result<()> {
|
|||
crawl::ContextBuilder::new()
|
||||
.with_title("BEAVER")
|
||||
.with_vsync(false)
|
||||
.with_features(wgpu::Features::default() | wgpu::Features::TIMESTAMP_QUERY)
|
||||
.build(),
|
||||
)?;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use anyhow::Result;
|
||||
use crawl::wgpu;
|
||||
use crawl::{wgpu, wgpu_profiler::GpuProfiler};
|
||||
|
||||
use crate::camera::CameraController;
|
||||
|
||||
|
@ -106,29 +106,41 @@ impl VoxelRenderer {
|
|||
}
|
||||
|
||||
impl crawl::Pass for VoxelRenderer {
|
||||
fn execute(&self, encoder: &mut wgpu::CommandEncoder, view: &wgpu::TextureView) {
|
||||
fn execute(
|
||||
&self,
|
||||
profiler: &GpuProfiler,
|
||||
device: &wgpu::Device,
|
||||
encoder: &mut wgpu::CommandEncoder,
|
||||
view: &wgpu::TextureView,
|
||||
) {
|
||||
let mut scope = profiler.scope("Rendering", encoder, device);
|
||||
|
||||
let size = self.render_texture.attributes.size;
|
||||
let mut compute_pass = encoder.begin_compute_pass(&wgpu::ComputePassDescriptor::default());
|
||||
let mut compute_pass = scope.scoped_compute_pass("Ray gen", device);
|
||||
compute_pass.set_pipeline(&self.raygen_pipeline);
|
||||
compute_pass.set_bind_group(0, &self.raygen_bind_group, &[]);
|
||||
compute_pass.dispatch_workgroups(size.width / 8, size.height / 8, 1);
|
||||
drop(compute_pass);
|
||||
|
||||
let mut compute_pass = encoder.begin_compute_pass(&wgpu::ComputePassDescriptor::default());
|
||||
let mut compute_pass = scope.scoped_compute_pass("Ray cast", device);
|
||||
compute_pass.set_pipeline(&self.raycast_pipeline);
|
||||
compute_pass.set_bind_group(0, &self.raygen_bind_group, &[]);
|
||||
compute_pass.dispatch_workgroups(size.width / 8, size.height / 8, 1);
|
||||
drop(compute_pass);
|
||||
|
||||
let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
label: Some("Render Pass"),
|
||||
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||
view,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations::default(),
|
||||
})],
|
||||
..Default::default()
|
||||
});
|
||||
let mut render_pass = scope.scoped_render_pass(
|
||||
"Quad render",
|
||||
device,
|
||||
wgpu::RenderPassDescriptor {
|
||||
label: Some("Render Pass"),
|
||||
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||
view,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations::default(),
|
||||
})],
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
render_pass.set_pipeline(&self.render_pipeline);
|
||||
render_pass.set_bind_group(0, &self.render_texture.bind_group, &[]);
|
||||
render_pass.draw(0..6, 0..1);
|
||||
|
|
Loading…
Reference in New Issue