From 34c23eebc0d197805c01dd3a7bcbda98b867839f Mon Sep 17 00:00:00 2001 From: mitchellhansen Date: Sat, 21 Sep 2019 23:59:43 -0700 Subject: [PATCH] moved to rust style file tree --- src/{ => canvas}/canvas_buffer.rs | 6 +- src/{ => canvas}/canvas_frame.rs | 4 +- src/{ => canvas}/canvas_shader.rs | 113 +++++++++++++--------- src/{canvas.rs => canvas/canvas_state.rs} | 10 +- src/{ => canvas}/canvas_text.rs | 6 +- src/canvas/mod.rs | 9 ++ src/{ => compute}/compu_buffer.rs | 0 src/{ => compute}/compu_frame.rs | 8 +- src/{ => compute}/compu_kernel.rs | 2 +- src/{ => compute}/compu_sprite.rs | 2 +- src/{ => compute}/compu_state.rs | 21 ++-- src/compute/mod.rs | 11 +++ src/input.rs | 44 --------- src/main.rs | 31 ++---- src/sprite.rs | 2 +- src/util/mod.rs | 4 + src/{ => util}/timer.rs | 0 src/util/vertex_2d.rs | 10 ++ src/{ => util}/vertex_3d.rs | 1 + src/vertex_2d.rs | 33 ------- src/vkprocessor.rs | 14 +-- 21 files changed, 145 insertions(+), 186 deletions(-) rename src/{ => canvas}/canvas_buffer.rs (93%) rename src/{ => canvas}/canvas_frame.rs (92%) rename src/{ => canvas}/canvas_shader.rs (80%) rename src/{canvas.rs => canvas/canvas_state.rs} (98%) rename src/{ => canvas}/canvas_text.rs (98%) create mode 100644 src/canvas/mod.rs rename src/{ => compute}/compu_buffer.rs (100%) rename src/{ => compute}/compu_frame.rs (86%) rename src/{ => compute}/compu_kernel.rs (98%) rename src/{ => compute}/compu_sprite.rs (96%) rename src/{ => compute}/compu_state.rs (89%) create mode 100644 src/compute/mod.rs delete mode 100644 src/input.rs rename src/{ => util}/timer.rs (100%) create mode 100644 src/util/vertex_2d.rs rename src/{ => util}/vertex_3d.rs (73%) delete mode 100644 src/vertex_2d.rs diff --git a/src/canvas_buffer.rs b/src/canvas/canvas_buffer.rs similarity index 93% rename from src/canvas_buffer.rs rename to src/canvas/canvas_buffer.rs index d55b6723..434010b9 100644 --- a/src/canvas_buffer.rs +++ b/src/canvas/canvas_buffer.rs @@ -1,13 +1,13 @@ -use crate::canvas::{CanvasTextureHandle, CanvasImageHandle}; +use crate::canvas::canvas_state::{CanvasTextureHandle, CanvasImageHandle}; use vulkano::image::{ImmutableImage, AttachmentImage}; use std::sync::Arc; use vulkano::format::{Format, R8Unorm}; -use crate::canvas_shader::CanvasShader; +use crate::canvas::canvas_shader::CanvasShader; use vulkano::sampler::Sampler; use vulkano::descriptor::DescriptorSet; use vulkano::descriptor::descriptor_set::PersistentDescriptorSet; use vulkano::buffer::CpuAccessibleBuffer; -use crate::canvas_text::{CanvasTextCacheHandle, CanvasTextHandle}; +use crate::canvas::canvas_text::{CanvasTextCacheHandle, CanvasTextHandle}; #[derive(Clone)] pub struct CanvasTexture { diff --git a/src/canvas_frame.rs b/src/canvas/canvas_frame.rs similarity index 92% rename from src/canvas_frame.rs rename to src/canvas/canvas_frame.rs index c216e09e..adeccd9f 100644 --- a/src/canvas_frame.rs +++ b/src/canvas/canvas_frame.rs @@ -1,7 +1,7 @@ -use crate::vertex_3d::{Vertex3D}; +use crate::util::vertex_3d::{Vertex3D}; use std::sync::Arc; use std::collections::HashMap; -use crate::canvas::{Drawable, CanvasTextureHandle, CanvasImageHandle}; +use crate::canvas::canvas_state::{Drawable, CanvasTextureHandle, CanvasImageHandle}; /// pub struct CanvasFrame { diff --git a/src/canvas_shader.rs b/src/canvas/canvas_shader.rs similarity index 80% rename from src/canvas_shader.rs rename to src/canvas/canvas_shader.rs index 14895488..d4946aef 100644 --- a/src/canvas_shader.rs +++ b/src/canvas/canvas_shader.rs @@ -8,9 +8,8 @@ use shade_runner as sr; use vulkano::framebuffer::{Subpass, RenderPassAbstract, Framebuffer, FramebufferAbstract}; use vulkano::pipeline::shader::{GraphicsShaderType, ShaderModule, SpecializationConstants, SpecializationMapEntry}; use vulkano::swapchain::Capabilities; -use crate::vertex_2d::Vertex2D; use vulkano::pipeline::vertex::SingleBufferDefinition; -use crate::vertex_3d::Vertex3D; +use crate::util::vertex_3d::Vertex3D; use vulkano::pipeline::depth_stencil::{DepthStencil, Stencil, StencilOp, Compare, DepthBounds}; use std::collections::HashSet; @@ -21,30 +20,30 @@ pub struct CompiledGraphicsPipelineHandle { } pub trait CompiledGraphicsPipeline { - fn get_paths(&self, filename: String) -> Vec<(ShaderType, PathBuf)> { - - let project_root = - std::env::current_dir() - .expect("failed to get root directory"); - - let mut shader_path = project_root.clone(); - shader_path.push(PathBuf::from("resources/shaders/")); - - - - let mut vertex_shader_path = shader_path.clone(); - vertex_shader_path.push(PathBuf::from("resources/shaders/")); - vertex_shader_path.push(PathBuf::from(filename.clone() + ".vertex")); - - let mut fragment_shader_path = project_root.clone(); - fragment_shader_path.push(PathBuf::from("resources/shaders/")); - fragment_shader_path.push(PathBuf::from(filename.clone() + ".fragment")); - - (vertex_shader_path, fragment_shader_path) - } - fn new(filename: String, shaders: HashSet) -> Box; +// fn get_paths(&self, filename: String) -> Vec<(ShaderType, PathBuf)> { +// +// let project_root = +// std::env::current_dir() +// .expect("failed to get root directory"); +// +// let mut shader_path = project_root.clone(); +// shader_path.push(PathBuf::from("resources/shaders/")); +// +// +// +// let mut vertex_shader_path = shader_path.clone(); +// vertex_shader_path.push(PathBuf::from("resources/shaders/")); +// vertex_shader_path.push(PathBuf::from(filename.clone() + ".vertex")); +// +// let mut fragment_shader_path = project_root.clone(); +// fragment_shader_path.push(PathBuf::from("resources/shaders/")); +// fragment_shader_path.push(PathBuf::from(filename.clone() + ".fragment")); +// +// (vertex_shader_path, fragment_shader_path) +// } + fn new(filename: String, shaders: HashSet) -> Self; fn get_name() -> String; - fn get_handle() -> Arc; + fn get_handle() -> Arc; fn get_pipeline() -> Arc; fn recompile(); } @@ -78,38 +77,38 @@ pub struct CanvasShader { impl CompiledGraphicsPipeline for CanvasShader { - fn get_path(filename: String) -> (PathBuf, PathBuf) { - let project_root = - std::env::current_dir() - .expect("failed to get root directory"); - - let mut shader_path = project_root.clone(); - shader_path.push(PathBuf::from("resources/shaders/")); - - let mut vertex_shader_path = project_root.clone(); - vertex_shader_path.push(PathBuf::from("resources/shaders/")); - vertex_shader_path.push(PathBuf::from(filename.clone() + ".vertex")); - - let mut fragment_shader_path = project_root.clone(); - fragment_shader_path.push(PathBuf::from("resources/shaders/")); - fragment_shader_path.push(PathBuf::from(filename.clone() + ".fragment")); - - (vertex_shader_path, fragment_shader_path) - } - - fn new(filename: String, shaders: HashSet) -> Box { - +// fn get_path(filename: String) -> (PathBuf, PathBuf) { +// let project_root = +// std::env::current_dir() +// .expect("failed to get root directory"); +// +// let mut shader_path = project_root.clone(); +// shader_path.push(PathBuf::from("resources/shaders/")); +// +// let mut vertex_shader_path = project_root.clone(); +// vertex_shader_path.push(PathBuf::from("resources/shaders/")); +// vertex_shader_path.push(PathBuf::from(filename.clone() + ".vertex")); +// +// let mut fragment_shader_path = project_root.clone(); +// fragment_shader_path.push(PathBuf::from("resources/shaders/")); +// fragment_shader_path.push(PathBuf::from(filename.clone() + ".fragment")); +// +// (vertex_shader_path, fragment_shader_path) +// } + + fn new(filename: String, shaders: HashSet) -> Self { + unimplemented!() } fn get_name() -> String { unimplemented!() } - fn get_handle() -> Arc<_> { + fn get_handle() -> Arc { unimplemented!() } - fn get_pipeline() -> Arc { + fn get_pipeline() -> Arc { unimplemented!() } @@ -120,6 +119,24 @@ impl CompiledGraphicsPipeline for CanvasShader { impl CanvasShader { + fn get_path(filename: String) -> (PathBuf, PathBuf) { + let project_root = + std::env::current_dir() + .expect("failed to get root directory"); + + let mut shader_path = project_root.clone(); + shader_path.push(PathBuf::from("resources/shaders/")); + + let mut vertex_shader_path = project_root.clone(); + vertex_shader_path.push(PathBuf::from("resources/shaders/")); + vertex_shader_path.push(PathBuf::from(filename.clone() + ".vertex")); + + let mut fragment_shader_path = project_root.clone(); + fragment_shader_path.push(PathBuf::from("resources/shaders/")); + fragment_shader_path.push(PathBuf::from(filename.clone() + ".fragment")); + + (vertex_shader_path, fragment_shader_path) + } /// Clone and returns the compiled graphics pipeline pub fn get_pipeline(&self) -> Arc { diff --git a/src/canvas.rs b/src/canvas/canvas_state.rs similarity index 98% rename from src/canvas.rs rename to src/canvas/canvas_state.rs index e3edcb80..5083c942 100644 --- a/src/canvas.rs +++ b/src/canvas/canvas_state.rs @@ -18,12 +18,12 @@ use vulkano::swapchain::Capabilities; use winit::Window; use vulkano::pipeline::viewport::Viewport; use vulkano::descriptor::descriptor::DescriptorDescTy::TexelBuffer; -use crate::canvas_frame::CanvasFrame; +use crate::canvas::canvas_frame::CanvasFrame; use std::hash::Hash; -use crate::canvas_text::{CanvasText, CanvasTextHandle}; -use crate::canvas_shader::{CanvasShader, CanvasShaderHandle}; -use crate::canvas_buffer::{CanvasImage, CanvasTexture, CanvasTextCache}; -use crate::vertex_3d::Vertex3D; +use crate::canvas::canvas_text::{CanvasText, CanvasTextHandle}; +use crate::canvas::canvas_shader::{CanvasShader, CanvasShaderHandle}; +use crate::canvas::canvas_buffer::{CanvasImage, CanvasTexture, CanvasTextCache}; +use crate::util::vertex_3d::Vertex3D; use vulkano::pipeline::depth_stencil::{StencilFaceFlags, DynamicStencilValue}; /// A drawable object can be passed into a CanvasFrame to be rendered diff --git a/src/canvas_text.rs b/src/canvas/canvas_text.rs similarity index 98% rename from src/canvas_text.rs rename to src/canvas/canvas_text.rs index 76518efd..89e6f982 100644 --- a/src/canvas_text.rs +++ b/src/canvas/canvas_text.rs @@ -7,7 +7,6 @@ use std::sync::Arc; use vulkano::command_buffer::{AutoCommandBufferBuilder, DynamicState}; use vulkano::image::{ImmutableImage, ImageUsage, ImageLayout, Dimensions}; use vulkano::format::ClearValue; -use crate::vertex_2d::Vertex2D; use vulkano::format::Format::R8Unorm; const CACHE_WIDTH: usize = 1000; @@ -42,9 +41,8 @@ impl CanvasText { let cache = Cache::builder().dimensions(CACHE_WIDTH as u32, CACHE_HEIGHT as u32).build(); let cache_pixel_buffer = vec!(0; CACHE_WIDTH * CACHE_HEIGHT); - - - let font_data = include_bytes!("../resources/fonts/sansation.ttf"); + + let font_data = include_bytes!("../../resources/fonts/sansation.ttf"); let font = Font::from_bytes(font_data as &[u8]).unwrap(); CanvasText { diff --git a/src/canvas/mod.rs b/src/canvas/mod.rs new file mode 100644 index 00000000..71465234 --- /dev/null +++ b/src/canvas/mod.rs @@ -0,0 +1,9 @@ + +pub mod canvas_state; +pub mod canvas_frame; +pub mod canvas_shader; +pub mod canvas_text; +pub mod canvas_buffer; + + +use crate::canvas::canvas_frame::CanvasFrame; \ No newline at end of file diff --git a/src/compu_buffer.rs b/src/compute/compu_buffer.rs similarity index 100% rename from src/compu_buffer.rs rename to src/compute/compu_buffer.rs diff --git a/src/compu_frame.rs b/src/compute/compu_frame.rs similarity index 86% rename from src/compu_frame.rs rename to src/compute/compu_frame.rs index c95c55ba..07beaba6 100644 --- a/src/compu_frame.rs +++ b/src/compute/compu_frame.rs @@ -1,8 +1,8 @@ -use crate::canvas::{CanvasImageHandle, Drawable}; +use crate::canvas::canvas_state::{CanvasImageHandle, Drawable}; use std::sync::Arc; -use crate::compu_sprite::CompuSprite; -use crate::compu_kernel::{CompuKernel, CompuKernelHandle}; -use crate::compu_buffer::{CompuBuffers, CompuBufferHandle}; +use crate::compute::compu_sprite::CompuSprite; +use crate::compute::compu_kernel::{CompuKernel, CompuKernelHandle}; +use crate::compute::compu_buffer::{CompuBuffers, CompuBufferHandle}; pub struct CompuFrame { // Vec<(Buffer, Kernel)> diff --git a/src/compu_kernel.rs b/src/compute/compu_kernel.rs similarity index 98% rename from src/compu_kernel.rs rename to src/compute/compu_kernel.rs index dccef7d2..e6789475 100644 --- a/src/compu_kernel.rs +++ b/src/compute/compu_kernel.rs @@ -8,7 +8,7 @@ use vulkano::descriptor::pipeline_layout::PipelineLayout; use shade_runner::{CompileError, FragLayout, FragInput, FragOutput, VertInput, VertOutput, VertLayout, CompiledShaders, Entry}; use shaderc::CompileOptions; use vulkano::pipeline::shader::{ShaderModule, GraphicsEntryPoint, SpecializationConstants, SpecializationMapEntry}; -use crate::compu_buffer::{CompuBuffers, CompuBufferHandle}; +use crate::compute::compu_buffer::{CompuBuffers, CompuBufferHandle}; #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] pub struct CompuKernelHandle { diff --git a/src/compu_sprite.rs b/src/compute/compu_sprite.rs similarity index 96% rename from src/compu_sprite.rs rename to src/compute/compu_sprite.rs index e662a6a1..a57e04ca 100644 --- a/src/compu_sprite.rs +++ b/src/compute/compu_sprite.rs @@ -1,4 +1,4 @@ -use crate::canvas::{CanvasImageHandle, Drawable, CanvasTextureHandle}; +use crate::canvas::canvas_state::{CanvasImageHandle, Drawable, CanvasTextureHandle}; use std::sync::Arc; pub struct CompuSprite { diff --git a/src/compu_state.rs b/src/compute/compu_state.rs similarity index 89% rename from src/compu_state.rs rename to src/compute/compu_state.rs index d4c9d841..fcf9c573 100644 --- a/src/compu_state.rs +++ b/src/compute/compu_state.rs @@ -1,7 +1,7 @@ use std::ffi::CStr; use vulkano::buffer::{CpuAccessibleBuffer, BufferUsage}; use std::sync::Arc; -use crate::canvas::{Drawable, CanvasState, CanvasImageHandle, CanvasTextureHandle}; +use crate::canvas::canvas_state::{Drawable, CanvasState, CanvasImageHandle, CanvasTextureHandle}; use vulkano::framebuffer::RenderPassAbstract; use vulkano::pipeline::{GraphicsPipelineAbstract, ComputePipeline}; use vulkano::device::Device; @@ -18,9 +18,9 @@ use std::path::PathBuf; use shade_runner::{CompiledShaders, Entry, CompileError}; use vulkano::pipeline::shader::ShaderModule; use shaderc::CompileOptions; -use crate::compu_kernel::{CompuKernel, CompuKernelHandle}; -use crate::compu_buffer::{CompuBuffers, CompuBufferHandle}; -use crate::compu_frame::CompuFrame; +use crate::compute::compu_kernel::{CompuKernel, CompuKernelHandle}; +use crate::compute::compu_buffer::{CompuBuffers, CompuBufferHandle}; +use crate::compute::compu_frame::CompuFrame; // Canvas analog @@ -30,7 +30,6 @@ pub struct CompuState { } impl CompuState { - pub fn new() -> CompuState { CompuState { compute_buffers: vec![], @@ -43,7 +42,6 @@ impl CompuState { dimensions: (u32, u32), stride: u32, device: Arc) -> Arc { - let handle = Arc::new(CompuBufferHandle { handle: self.compute_buffers.len() as u32 }); @@ -65,7 +63,6 @@ impl CompuState { pub fn new_kernel(&mut self, filename: String, device: Arc) -> Arc { - let handle = Arc::new(CompuKernelHandle { handle: self.kernels.len() as u32 }); @@ -104,13 +101,13 @@ impl CompuState { let size = buffer.get_size(); command_buffer = command_buffer - .dispatch([size.0/8,size.1/8,1], p, d, ()).unwrap() + .dispatch([size.0 / 8, size.1 / 8, 1], p, d, ()).unwrap() } // i = (Buffer, Image, Kernel) for i in compute_frame.swapped_to_image { let buffer_id = (*i.0).clone().handle as usize; - let image_id = i.1.clone(); + let image_id = i.1.clone(); let kernel_id = (*i.2).clone().handle as usize; let buffer = self.compute_buffers.get(buffer_id).unwrap(); @@ -129,7 +126,7 @@ impl CompuState { let size = buffer.get_size(); command_buffer = command_buffer - .dispatch([size.0/8,size.1/8,1], p, d, ()).unwrap() + .dispatch([size.0 / 8, size.1 / 8, 1], p, d, ()).unwrap() .copy_buffer_to_image(buffer.get_input_buffer(), image).unwrap(); } @@ -137,7 +134,7 @@ impl CompuState { // i = (Input Buffer, Output Buffer, Kernel) // Input buffer -> Kernel -> Output buffer for i in compute_frame.swapped_to_buffer { - let input_buffer_id = (*i.0).clone().handle as usize; + let input_buffer_id = (*i.0).clone().handle as usize; let output_buffer_id = (*i.1).clone().handle as usize; let kernel_id = (*i.2).clone().handle as usize; @@ -154,7 +151,7 @@ impl CompuState { let size = input_buffer.get_size(); command_buffer = command_buffer - // .dispatch([size.0/8, size.1/8,1], pipeline, descriptor_set, ()).unwrap() + // .dispatch([size.0/8, size.1/8,1], pipeline, descriptor_set, ()).unwrap() .copy_buffer( input_buffer.get_output_buffer(), output_buffer.get_input_buffer()).unwrap(); diff --git a/src/compute/mod.rs b/src/compute/mod.rs new file mode 100644 index 00000000..b9bd0fe9 --- /dev/null +++ b/src/compute/mod.rs @@ -0,0 +1,11 @@ +pub mod compu_frame; +pub mod compu_kernel; +pub mod compu_sprite; +pub mod compu_state; +pub mod compu_buffer; + +use crate::compute::compu_state::CompuState; +use crate::compute::compu_frame::CompuFrame; +use crate::compute::compu_sprite::CompuSprite; +use crate::compute::compu_kernel::CompuKernel; +use crate::compute::compu_buffer::CompuBuffers; \ No newline at end of file diff --git a/src/input.rs b/src/input.rs deleted file mode 100644 index 5dc764ee..00000000 --- a/src/input.rs +++ /dev/null @@ -1,44 +0,0 @@ -use std::collections::HashSet; - -pub struct Input { - held_keys: HashSet, - held_mouse: HashSet, -} - -impl Input { - pub fn new() -> Input { - - let mut key_container = HashSet::new(); - let mut mouse_container = HashSet::new(); - Input { - held_keys: key_container, - held_mouse: mouse_container, - } - } - - pub fn is_held(&self, key: Key) -> bool { - self.held_keys.contains(&key) - } - - pub fn is_mousebutton_held(&self, button: Button) -> bool { - self.held_mouse.contains(&(button as u8)) - } - - pub fn ingest(&mut self, event: &Event) { - match event { - Event::KeyPressed { code, .. } => { - self.held_keys.insert(code.clone()); - } - Event::KeyReleased { code, .. } => { - self.held_keys.remove(code); - } - Event::MouseButtonPressed { button, x, y } => { - self.held_mouse.insert(button.clone() as u8); - }, - Event::MouseButtonReleased { button, x, y } => { - self.held_mouse.remove(&(button.clone() as u8)); - }, - _ => {} - } - } -} diff --git a/src/main.rs b/src/main.rs index a5782319..e658fbc7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,8 @@ #![allow(unused_variables)] #![allow(unused_mut)] + + extern crate cgmath; extern crate image; extern crate nalgebra as na; @@ -10,43 +12,30 @@ extern crate time; extern crate hprof; use vulkano::sync; -use crate::timer::Timer; +use crate::util::timer::Timer; use vulkano::instance::Instance; use vulkano::sync::GpuFuture; use winit::{EventsLoop, WindowBuilder, WindowEvent, Event, DeviceEvent, VirtualKeyCode, ElementState}; use winit::dpi::LogicalSize; use vulkano_win::VkSurfaceBuild; use sprite::Sprite; -use crate::compu_state::CompuState; -use crate::compu_frame::CompuFrame; -use crate::compu_sprite::CompuSprite; -use crate::compu_kernel::CompuKernel; -use crate::compu_buffer::CompuBuffers; + use crate::util::load_raw; -use crate::canvas_frame::CanvasFrame; + use crate::sprite::Poly; use vulkano::instance::debug::DebugCallback; +use crate::compute::compu_sprite::CompuSprite; +use crate::compute::compu_frame::CompuFrame; +use crate::canvas::canvas_frame::CanvasFrame; pub mod util; -pub mod timer; -//pub mod input; pub mod vkprocessor; -pub mod vertex_2d; -pub mod vertex_3d; pub mod sprite; pub mod canvas; -pub mod canvas_frame; -pub mod canvas_shader; -pub mod canvas_buffer; -pub mod canvas_text; - -pub mod compu_state; -pub mod compu_frame; -pub mod compu_sprite; -pub mod compu_kernel; -pub mod compu_buffer; +pub mod compute; + /// Main Entry pub fn main() { diff --git a/src/sprite.rs b/src/sprite.rs index 908b7ffa..2cc0c1b0 100644 --- a/src/sprite.rs +++ b/src/sprite.rs @@ -1,4 +1,4 @@ -use crate::canvas::{Drawable, CanvasTextureHandle, CanvasImageHandle}; +use crate::canvas::canvas_state::{Drawable, CanvasTextureHandle, CanvasImageHandle}; use std::sync::Arc; #[derive(Debug, Clone)] diff --git a/src/util/mod.rs b/src/util/mod.rs index 38d6575f..ade26498 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -3,6 +3,10 @@ use std::sync::Arc; use std::ffi::CStr; use std::path::PathBuf; +pub mod timer; +pub mod vertex_2d; +pub mod vertex_3d; + pub fn load_raw(filename: String) -> (Vec, (u32,u32)) { let project_root = diff --git a/src/timer.rs b/src/util/timer.rs similarity index 100% rename from src/timer.rs rename to src/util/timer.rs diff --git a/src/util/vertex_2d.rs b/src/util/vertex_2d.rs new file mode 100644 index 00000000..c6ecd0f3 --- /dev/null +++ b/src/util/vertex_2d.rs @@ -0,0 +1,10 @@ + +/// Generic vertex 2d with vertex position, texture position and a 32bit color +#[derive(Default, Debug, Clone, Copy)] +pub struct Vertex2D { + pub v_position: [f32; 2], + pub color : [f32; 4], + pub ti_position: [f32; 2], +} + +vulkano::impl_vertex!(Vertex2D, v_position, color, ti_position); \ No newline at end of file diff --git a/src/vertex_3d.rs b/src/util/vertex_3d.rs similarity index 73% rename from src/vertex_3d.rs rename to src/util/vertex_3d.rs index 76ceb79e..c84f8037 100644 --- a/src/vertex_3d.rs +++ b/src/util/vertex_3d.rs @@ -1,4 +1,5 @@ +/// Generic vertex 3d with vertex position, texture position and a 32bit color #[derive(Default, Debug, Clone, Copy)] pub struct Vertex3D { pub v_position: [f32; 3], diff --git a/src/vertex_2d.rs b/src/vertex_2d.rs deleted file mode 100644 index 507477e9..00000000 --- a/src/vertex_2d.rs +++ /dev/null @@ -1,33 +0,0 @@ - - -/// Generic vertex 2d with vertex position, texture position and a 32bit color -#[derive(Default, Debug, Clone, Copy)] -pub struct Vertex2D { - pub v_position: [f32; 2], - pub color : [f32; 4], - pub ti_position: [f32; 2], -} - -vulkano::impl_vertex!(Vertex2D, v_position, color, ti_position); - - - -//impl From<(f32, f32)> for Vertex2D { -// fn from(item: (f32, f32)) -> Self { -// Vertex2D { -// v_position: [], -// color: [], -// ti_position: [] -// } -// } -//} -// -//impl From<((f32,f32),(f32, f32))> for Vertex2D { -// fn from(item: ((f32,f32),(f32, f32))) -> Self { -// Vertex2D { -// v_position: [], -// color: [], -// ti_position: [] -// } -// } -//} \ No newline at end of file diff --git a/src/vkprocessor.rs b/src/vkprocessor.rs index 4994c1ec..6a16845b 100644 --- a/src/vkprocessor.rs +++ b/src/vkprocessor.rs @@ -8,15 +8,15 @@ use std::sync::Arc; use vulkano::swapchain::{Swapchain, PresentMode, SurfaceTransform, Surface, SwapchainCreationError, AcquireError, Capabilities}; use vulkano::image::swapchain::SwapchainImage; use winit::Window; -use crate::compu_state::CompuState; +use crate::compute::compu_state::CompuState; use vulkano::image::ImageUsage; -use crate::compu_frame::CompuFrame; -use crate::canvas::{CanvasState, CanvasTextureHandle, CanvasImageHandle, ShaderType}; -use crate::canvas_frame::CanvasFrame; -use crate::compu_kernel::{CompuKernel, CompuKernelHandle}; -use crate::compu_buffer::{CompuBuffers, CompuBufferHandle}; +use crate::compute::compu_frame::CompuFrame; +use crate::canvas::canvas_state::{CanvasState, CanvasTextureHandle, CanvasImageHandle, ShaderType}; +use crate::canvas::canvas_frame::CanvasFrame; +use crate::compute::compu_kernel::{CompuKernel, CompuKernelHandle}; +use crate::compute::compu_buffer::{CompuBuffers, CompuBufferHandle}; use std::time::Duration; -use crate::canvas_shader::CanvasShaderHandle; +use crate::canvas::canvas_shader::CanvasShaderHandle; use vulkano::pipeline::depth_stencil::{DynamicStencilValue, StencilFaceFlags}; /// VKProcessor holds the vulkan instance information, the swapchain, and the compute and canvas states