feat: implement a more modular graphics pipeline

This commit is contained in:
alphafetus committed 2026-05-10 01:04:42 -04:00
1 parent 6fe8ff2af0
commit 8b76fdb6ae
15 files changed
+498 -85

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
use std::sync::Arc;
use vulkano::buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer};
use vulkano::memory::allocator::{AllocationCreateInfo, MemoryAllocator, MemoryTypeFilter};
use crate::common::camera::Camera;
#[derive(BufferContents)]
#[repr(C)]
pub struct CameraUniform {
pub view: [[f32; 4]; 4],
pub proj: [[f32; 4]; 4],
}
impl From<Camera> for CameraUniform {
fn from(camera: Camera) -> Self {
Self::from(&camera)
}
}
impl From<&Camera> for CameraUniform {
fn from(camera: &Camera) -> Self {
let view = camera.get_view();
let proj = camera.get_projection();
Self {
view: view.into(),
proj: proj.into(),
}
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ use vulkano::buffer::BufferContents;
use vulkano::pipeline::graphics::vertex_input::Vertex;
/// A transformation matrix for a mesh that can be passed into the shaders.
#[derive(BufferContents, Vertex)]
#[derive(Debug, Clone, BufferContents, Vertex)]
#[repr(C)]
pub struct GpuInstance {
#[format(R32G32B32A32_SFLOAT)]
+1
View File
@@ -1,2 +1,3 @@
pub mod instance;
pub mod vertex3;
pub mod camera;
+9 -3
View File
@@ -6,12 +6,18 @@ use vulkano::pipeline::graphics::vertex_input::Vertex;
pub struct Vertex3 {
#[format(R32G32B32_SFLOAT)]
pub(crate) position: [f32; 3],
#[format(R32G32B32_SFLOAT)]
pub(crate) normal: [f32; 3],
}
impl From<[f32; 3]> for Vertex3 {
fn from(v: [f32; 3]) -> Self {
impl Vertex3 {
pub fn new(
position: [f32; 3],
normal: [f32; 3],
) -> Self {
Self {
position: v.clone(),
position,
normal,
}
}
}