From e13aab18088569f436e4109dca169f83c0e8dce4 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Sat, 8 Apr 2023 21:52:52 +0100 Subject: [PATCH] Use the voxel raycast shader --- src/renderer.rs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/renderer.rs b/src/renderer.rs index 271c467..82f5d46 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -138,7 +138,7 @@ impl Renderer { }); log::info!("Creating compute pipeline..."); - let cs_descriptor = wgpu::include_wgsl!("../assets/shaders/image_recolor.wgsl"); + let cs_descriptor = wgpu::include_wgsl!("../assets/shaders/branchless_dda.wgsl"); let cs = context.device.create_shader_module(cs_descriptor); let compute_layout = context @@ -182,19 +182,6 @@ impl Renderer { entry_point: "compute", }); - let mut encoder = context - .device - .create_command_encoder(&wgpu::CommandEncoderDescriptor::default()); - - let size = render_texture.attributes.size; - let mut compute_pass = encoder.begin_compute_pass(&wgpu::ComputePassDescriptor::default()); - compute_pass.set_pipeline(&compute_pipeline); - compute_pass.set_bind_group(0, &compute_bind_group, &[]); - compute_pass.dispatch_workgroups(size.width / 8, size.height / 8, 1); - drop(compute_pass); - - context.queue.submit(Some(encoder.finish())); - let clear_color = wgpu::Color { r: 255.0 / 255.0, g: 216.0 / 255.0, @@ -221,6 +208,13 @@ impl Renderer { .device .create_command_encoder(&wgpu::CommandEncoderDescriptor::default()); + let size = self.render_texture.attributes.size; + let mut compute_pass = encoder.begin_compute_pass(&wgpu::ComputePassDescriptor::default()); + compute_pass.set_pipeline(&self.compute_pipeline); + compute_pass.set_bind_group(0, &self.compute_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 {