From 1098c418f1bbebc4c09e51e6dbccf104cdc3c011 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Fri, 8 Sep 2023 14:33:33 +0100 Subject: [PATCH] Rename render module to gfx --- src/core/app.rs | 6 +++--- src/core/camera.rs | 2 +- src/{render.rs => gfx.rs} | 0 src/{render => gfx}/bind_group.rs | 0 src/{render => gfx}/context.rs | 0 src/{render => gfx}/renderer.rs | 0 src/{render => gfx}/texture.rs | 0 src/main.rs | 2 +- src/voxel/brickmap.rs | 8 ++++---- src/voxel/voxel_renderer.rs | 24 ++++++++++++------------ 10 files changed, 21 insertions(+), 21 deletions(-) rename src/{render.rs => gfx.rs} (100%) rename src/{render => gfx}/bind_group.rs (100%) rename src/{render => gfx}/context.rs (100%) rename src/{render => gfx}/renderer.rs (100%) rename src/{render => gfx}/texture.rs (100%) diff --git a/src/core/app.rs b/src/core/app.rs index 35a0e13..2f8b029 100644 --- a/src/core/app.rs +++ b/src/core/app.rs @@ -7,7 +7,7 @@ use winit::{ use super::camera; use crate::{ - render::{self, Renderer}, + gfx::{self, Renderer}, voxel, }; @@ -15,7 +15,7 @@ pub struct App { title: String, window: winit::window::Window, event_loop: EventLoop<()>, - render_ctx: render::Context, + render_ctx: gfx::Context, } impl App { @@ -29,7 +29,7 @@ impl App { .build(&event_loop) .unwrap(); - let render_ctx = render::Context::new( + let render_ctx = gfx::Context::new( &window, wgpu::Limits { max_storage_buffer_binding_size: 1 << 30, diff --git a/src/core/camera.rs b/src/core/camera.rs index 1be8ea5..2c9ccb6 100644 --- a/src/core/camera.rs +++ b/src/core/camera.rs @@ -2,7 +2,7 @@ use std::time::Duration; use wgpu::util::DeviceExt; use winit::event::{ElementState, KeyboardInput, VirtualKeyCode, WindowEvent}; -use crate::render::Context; +use crate::gfx::Context; #[repr(C)] #[derive(Debug, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)] diff --git a/src/render.rs b/src/gfx.rs similarity index 100% rename from src/render.rs rename to src/gfx.rs diff --git a/src/render/bind_group.rs b/src/gfx/bind_group.rs similarity index 100% rename from src/render/bind_group.rs rename to src/gfx/bind_group.rs diff --git a/src/render/context.rs b/src/gfx/context.rs similarity index 100% rename from src/render/context.rs rename to src/gfx/context.rs diff --git a/src/render/renderer.rs b/src/gfx/renderer.rs similarity index 100% rename from src/render/renderer.rs rename to src/gfx/renderer.rs diff --git a/src/render/texture.rs b/src/gfx/texture.rs similarity index 100% rename from src/render/texture.rs rename to src/gfx/texture.rs diff --git a/src/main.rs b/src/main.rs index 9c4810f..5f2fac1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ mod core; +mod gfx; mod math; -mod render; mod voxel; fn main() { diff --git a/src/voxel/brickmap.rs b/src/voxel/brickmap.rs index 9c9d846..36cc2ff 100644 --- a/src/voxel/brickmap.rs +++ b/src/voxel/brickmap.rs @@ -2,7 +2,7 @@ use std::collections::HashSet; use wgpu::util::DeviceExt; -use crate::{math, render}; +use crate::{gfx, math}; #[repr(C)] #[derive(Debug, Default, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)] @@ -65,7 +65,7 @@ pub struct BrickmapManager { // - Brickworld system impl BrickmapManager { pub fn new( - context: &render::Context, + context: &gfx::Context, brickgrid_dims: glam::UVec3, brickmap_cache_size: usize, shading_table_bucket_size: u32, @@ -202,7 +202,7 @@ impl BrickmapManager { pub fn process_feedback_buffer( &mut self, - context: &render::Context, + context: &gfx::Context, world: &mut super::world::WorldManager, ) { // Get request count @@ -331,7 +331,7 @@ impl BrickmapManager { self.brickgrid_staged.insert(index); } - fn upload_unpack_buffers(&mut self, context: &render::Context) { + fn upload_unpack_buffers(&mut self, context: &gfx::Context) { // Brickgrid let mut data = Vec::new(); let mut iter = self.brickgrid_staged.iter(); diff --git a/src/voxel/voxel_renderer.rs b/src/voxel/voxel_renderer.rs index 6680d96..a6f724d 100644 --- a/src/voxel/voxel_renderer.rs +++ b/src/voxel/voxel_renderer.rs @@ -1,11 +1,11 @@ use std::time::Duration; -use crate::{core, render}; +use crate::{core, gfx}; #[derive(Debug)] pub struct VoxelRenderer { clear_color: wgpu::Color, - render_texture: render::Texture, + render_texture: gfx::Texture, render_pipeline: wgpu::RenderPipeline, brickmap_manager: super::brickmap::BrickmapManager, raycast_pipeline: wgpu::ComputePipeline, @@ -15,13 +15,13 @@ pub struct VoxelRenderer { } impl VoxelRenderer { - pub fn new(context: &render::Context, camera_controller: &core::CameraController) -> Self { + pub fn new(context: &gfx::Context, camera_controller: &core::CameraController) -> Self { log::info!("Creating render shader..."); let shader_descriptor = wgpu::include_wgsl!("../../assets/shaders/shader.wgsl"); let shader = context.device.create_shader_module(shader_descriptor); log::info!("Creating render texture..."); - let render_texture = render::TextureBuilder::new() + let render_texture = gfx::TextureBuilder::new() .with_size(context.size.width, context.size.height, 1) .with_format(wgpu::TextureFormat::Rgba8Unorm) .with_usage( @@ -74,7 +74,7 @@ impl VoxelRenderer { log::info!("Creating compute pipelines..."); let cs_descriptor = wgpu::include_wgsl!("../../assets/shaders/brickmap_upload.wgsl"); let cs = context.device.create_shader_module(cs_descriptor); - let unpack_layout = render::BindGroupLayoutBuilder::new() + let unpack_layout = gfx::BindGroupLayoutBuilder::new() .with_label("GPU Unpack BGL") .with_uniform_entry(wgpu::ShaderStages::COMPUTE) .with_rw_storage_entry(wgpu::ShaderStages::COMPUTE) @@ -83,7 +83,7 @@ impl VoxelRenderer { .with_ro_storage_entry(wgpu::ShaderStages::COMPUTE) .with_ro_storage_entry(wgpu::ShaderStages::COMPUTE) .build(context); - let unpack_bind_group = render::BindGroupBuilder::new() + let unpack_bind_group = gfx::BindGroupBuilder::new() .with_label("GPU Unpack BG") .with_layout(&unpack_layout) .with_entry(brickmap_manager.get_worldstate_buffer().as_entire_binding()) @@ -119,7 +119,7 @@ impl VoxelRenderer { let cs_descriptor = wgpu::include_wgsl!("../../assets/shaders/voxel_volume.wgsl"); let cs = context.device.create_shader_module(cs_descriptor); - let raycast_layout = render::BindGroupLayoutBuilder::new() + let raycast_layout = gfx::BindGroupLayoutBuilder::new() .with_label("Voxel Raycast BGL") .with_entry( wgpu::ShaderStages::COMPUTE, @@ -137,7 +137,7 @@ impl VoxelRenderer { .with_rw_storage_entry(wgpu::ShaderStages::COMPUTE) .with_uniform_entry(wgpu::ShaderStages::COMPUTE) .build(context); - let raycast_bind_group = render::BindGroupBuilder::new() + let raycast_bind_group = gfx::BindGroupBuilder::new() .with_label("Voxel Raycast BG") .with_layout(&raycast_layout) .with_entry(wgpu::BindingResource::TextureView(&render_texture.view)) @@ -177,8 +177,8 @@ impl VoxelRenderer { } } -impl render::Renderer for VoxelRenderer { - fn render(&self, context: &render::Context) { +impl gfx::Renderer for VoxelRenderer { + fn render(&self, context: &gfx::Context) { let frame = context.surface.get_current_texture().unwrap(); let view = frame .texture @@ -232,13 +232,13 @@ impl render::Renderer for VoxelRenderer { frame.present(); } - fn update(&mut self, _dt: &Duration, _context: &render::Context) {} + fn update(&mut self, _dt: &Duration, _context: &gfx::Context) {} } impl VoxelRenderer { pub fn update_brickmap( &mut self, - context: &render::Context, + context: &gfx::Context, world: &mut super::world::WorldManager, ) { self.brickmap_manager