Compare commits
No commits in common. "8fd8731696ac4c6953b8c31697725882841b2ac6" and "56e756d81886d557c161b01c8554b51e6bedc0fe" have entirely different histories.
8fd8731696
...
56e756d818
|
@ -4,10 +4,7 @@ mod renderer;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use crawl::{
|
use crawl::winit::event::{Event, WindowEvent};
|
||||||
wgpu,
|
|
||||||
winit::event::{Event, WindowEvent},
|
|
||||||
};
|
|
||||||
use renderer::VoxelRenderer;
|
use renderer::VoxelRenderer;
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
|
@ -16,7 +13,6 @@ fn main() -> Result<()> {
|
||||||
crawl::ContextBuilder::new()
|
crawl::ContextBuilder::new()
|
||||||
.with_title("BEAVER")
|
.with_title("BEAVER")
|
||||||
.with_vsync(false)
|
.with_vsync(false)
|
||||||
.with_features(wgpu::Features::default() | wgpu::Features::TIMESTAMP_QUERY)
|
|
||||||
.build(),
|
.build(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use crawl::{wgpu, wgpu_profiler::GpuProfiler};
|
use crawl::wgpu;
|
||||||
|
|
||||||
use crate::camera::CameraController;
|
use crate::camera::CameraController;
|
||||||
|
|
||||||
|
@ -106,32 +106,21 @@ impl VoxelRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crawl::Pass for VoxelRenderer {
|
impl crawl::Pass for VoxelRenderer {
|
||||||
fn execute(
|
fn execute(&self, encoder: &mut wgpu::CommandEncoder, view: &wgpu::TextureView) {
|
||||||
&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 size = self.render_texture.attributes.size;
|
||||||
let mut compute_pass = scope.scoped_compute_pass("Ray gen", device);
|
let mut compute_pass = encoder.begin_compute_pass(&wgpu::ComputePassDescriptor::default());
|
||||||
compute_pass.set_pipeline(&self.raygen_pipeline);
|
compute_pass.set_pipeline(&self.raygen_pipeline);
|
||||||
compute_pass.set_bind_group(0, &self.raygen_bind_group, &[]);
|
compute_pass.set_bind_group(0, &self.raygen_bind_group, &[]);
|
||||||
compute_pass.dispatch_workgroups(size.width / 8, size.height / 8, 1);
|
compute_pass.dispatch_workgroups(size.width / 8, size.height / 8, 1);
|
||||||
drop(compute_pass);
|
drop(compute_pass);
|
||||||
|
|
||||||
let mut compute_pass = scope.scoped_compute_pass("Ray cast", device);
|
let mut compute_pass = encoder.begin_compute_pass(&wgpu::ComputePassDescriptor::default());
|
||||||
compute_pass.set_pipeline(&self.raycast_pipeline);
|
compute_pass.set_pipeline(&self.raycast_pipeline);
|
||||||
compute_pass.set_bind_group(0, &self.raygen_bind_group, &[]);
|
compute_pass.set_bind_group(0, &self.raygen_bind_group, &[]);
|
||||||
compute_pass.dispatch_workgroups(size.width / 8, size.height / 8, 1);
|
compute_pass.dispatch_workgroups(size.width / 8, size.height / 8, 1);
|
||||||
drop(compute_pass);
|
drop(compute_pass);
|
||||||
|
|
||||||
let mut render_pass = scope.scoped_render_pass(
|
let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||||
"Quad render",
|
|
||||||
device,
|
|
||||||
wgpu::RenderPassDescriptor {
|
|
||||||
label: Some("Render Pass"),
|
label: Some("Render Pass"),
|
||||||
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||||
view,
|
view,
|
||||||
|
@ -139,8 +128,7 @@ impl crawl::Pass for VoxelRenderer {
|
||||||
ops: wgpu::Operations::default(),
|
ops: wgpu::Operations::default(),
|
||||||
})],
|
})],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
});
|
||||||
);
|
|
||||||
render_pass.set_pipeline(&self.render_pipeline);
|
render_pass.set_pipeline(&self.render_pipeline);
|
||||||
render_pass.set_bind_group(0, &self.render_texture.bind_group, &[]);
|
render_pass.set_bind_group(0, &self.render_texture.bind_group, &[]);
|
||||||
render_pass.draw(0..6, 0..1);
|
render_pass.draw(0..6, 0..1);
|
||||||
|
|
Loading…
Reference in New Issue