Rename render module to gfx

This commit is contained in:
Jarrod Doyle 2023-09-08 14:33:33 +01:00
parent e3a00341bc
commit 1098c418f1
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
10 changed files with 21 additions and 21 deletions

View File

@ -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,

View File

@ -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)]

View File

@ -1,6 +1,6 @@
mod core;
mod gfx;
mod math;
mod render;
mod voxel;
fn main() {

View File

@ -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();

View File

@ -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