diff --git a/src/graphics.rs b/src/graphics.rs index 8cc0521..4142ac7 100644 --- a/src/graphics.rs +++ b/src/graphics.rs @@ -15,6 +15,15 @@ use vulkano::{device::physical::PhysicalDeviceType, instance::InstanceCreateFlag #[cfg(feature = "openxr")] use {ash::vk, std::os::raw::c_void}; +pub type Vert2Buf = Subbuffer<[Vert2Uv]>; +pub type IndexBuf = Subbuffer<[u16]>; + +pub type LegacyPipeline = WlxPipeline; +pub type DynamicPipeline = WlxPipeline; + +pub type LegacyPass = WlxPass; +pub type DynamicPass = WlxPass; + use vulkano::{ buffer::{ allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo}, @@ -118,8 +127,8 @@ pub struct WlxGraphics { pub command_buffer_allocator: Arc, pub descriptor_set_allocator: Arc, - pub quad_verts: Subbuffer<[Vert2Uv]>, - pub quad_indices: Subbuffer<[u16]>, + pub quad_verts: Vert2Buf, + pub quad_indices: IndexBuf, pub shared_shaders: RwLock>>, } @@ -474,7 +483,7 @@ impl WlxGraphics { fn default_quad( memory_allocator: Arc, - ) -> anyhow::Result<(Subbuffer<[Vert2Uv]>, Subbuffer<[u16]>)> { + ) -> anyhow::Result<(Vert2Buf, IndexBuf)> { let vertices = [ Vert2Uv { in_pos: [0., 0.], @@ -532,7 +541,7 @@ impl WlxGraphics { y: f32, w: f32, h: f32, - ) -> anyhow::Result> { + ) -> anyhow::Result { let rw = width; let rh = height; @@ -704,8 +713,8 @@ impl WlxGraphics { frag: Arc, format: Format, blend: Option, - ) -> anyhow::Result>> { - Ok(Arc::new(WlxPipeline::::new( + ) -> anyhow::Result> { + Ok(Arc::new(LegacyPipeline::new( render_target, self.clone(), vert, @@ -724,8 +733,8 @@ impl WlxGraphics { blend: Option, initial_layout: ImageLayout, final_layout: ImageLayout, - ) -> anyhow::Result>> { - Ok(Arc::new(WlxPipeline::::new_with_layout( + ) -> anyhow::Result> { + Ok(Arc::new(LegacyPipeline::new_with_layout( render_target, self.clone(), vert, @@ -744,8 +753,8 @@ impl WlxGraphics { frag: Arc, format: Format, blend: Option, - ) -> anyhow::Result>> { - Ok(Arc::new(WlxPipeline::::new( + ) -> anyhow::Result> { + Ok(Arc::new(DynamicPipeline::new( self.clone(), vert, frag, @@ -841,10 +850,7 @@ pub struct WlxCommandBuffer { #[allow(dead_code)] impl WlxCommandBuffer { - pub fn begin_render_pass( - &mut self, - pipeline: &WlxPipeline, - ) -> anyhow::Result<()> { + pub fn begin_render_pass(&mut self, pipeline: &LegacyPipeline) -> anyhow::Result<()> { self.command_buffer.begin_render_pass( RenderPassBeginInfo { clear_values: vec![Some([0.0, 0.0, 0.0, 0.0].into())], @@ -1031,11 +1037,11 @@ impl WlxPipeline { pub fn create_pass( self: &Arc, dimensions: [f32; 2], - vertex_buffer: Subbuffer<[Vert2Uv]>, - index_buffer: Subbuffer<[u16]>, + vertex_buffer: Vert2Buf, + index_buffer: IndexBuf, descriptor_sets: Vec>, - ) -> anyhow::Result> { - WlxPass::::new( + ) -> anyhow::Result { + DynamicPass::new( self.clone(), dimensions, vertex_buffer, @@ -1200,11 +1206,11 @@ impl WlxPipeline { pub fn create_pass( self: &Arc, dimensions: [f32; 2], - vertex_buffer: Subbuffer<[Vert2Uv]>, - index_buffer: Subbuffer<[u16]>, + vertex_buffer: Vert2Buf, + index_buffer: IndexBuf, descriptor_sets: Vec>, - ) -> anyhow::Result> { - WlxPass::::new( + ) -> anyhow::Result { + LegacyPass::new( self.clone(), dimensions, vertex_buffer, @@ -1278,18 +1284,18 @@ impl WlxPipeline { #[allow(dead_code)] pub struct WlxPass { pipeline: Arc>, - vertex_buffer: Subbuffer<[Vert2Uv]>, - index_buffer: Subbuffer<[u16]>, + vertex_buffer: Vert2Buf, + index_buffer: IndexBuf, descriptor_sets: Vec>, pub command_buffer: Arc, } impl WlxPass { fn new( - pipeline: Arc>, + pipeline: Arc, dimensions: [f32; 2], - vertex_buffer: Subbuffer<[Vert2Uv]>, - index_buffer: Subbuffer<[u16]>, + vertex_buffer: Vert2Buf, + index_buffer: IndexBuf, descriptor_sets: Vec>, ) -> anyhow::Result { let viewport = Viewport { @@ -1346,10 +1352,10 @@ impl WlxPass { impl WlxPass { fn new( - pipeline: Arc>, + pipeline: Arc, dimensions: [f32; 2], - vertex_buffer: Subbuffer<[Vert2Uv]>, - index_buffer: Subbuffer<[u16]>, + vertex_buffer: Vert2Buf, + index_buffer: IndexBuf, descriptor_sets: Vec>, ) -> anyhow::Result { let viewport = Viewport {