From 438f96eb323b982b42cb3142d0a2755f1c9d9363 Mon Sep 17 00:00:00 2001 From: mitchellhansen Date: Thu, 20 Feb 2020 23:55:36 -0800 Subject: [PATCH] compiles and renders textures again --- notes/Home.txt | 32 +++++++------- notes/VKProcessor.txt | 6 +++ notes/VKProcessor/CanvasContainerClasses.txt | 2 +- notes/VKProcessor/vkprocessor.drawio | 2 +- resources/shaders/color-passthrough.vert | 1 - resources/shaders/simple_image.vert | 3 +- resources/shaders/simple_texture.vert | 3 +- src/canvas/canvas_state.rs | 26 ++++++------ src/canvas/managed/handles.rs | 3 -- src/canvas/managed/shader/generic_shader.rs | 8 ++-- src/canvas/managed/shader/shader_common.rs | 4 +- src/canvas/managed/shader/text_shader.rs | 8 ++-- src/main.rs | 44 +++++++++++--------- src/sprite.rs | 25 ++++++++++- src/util/vertex.rs | 26 ++++++------ src/vkprocessor.rs | 10 ++--- 16 files changed, 112 insertions(+), 91 deletions(-) diff --git a/notes/Home.txt b/notes/Home.txt index 77c3d1c0..3afcc167 100644 --- a/notes/Home.txt +++ b/notes/Home.txt @@ -16,7 +16,6 @@ Main Systems: [[VKProcessor:DynamicVertex|DynamicVertex]] =========== [[VKProcessor:CompuState|CompuState]] [[~/source/Trac3r-rust/doc/sfml_rust/compute/compu_state/struct.CompuState.html|===========]] - -------------------- ====== Warming Up ====== @@ -26,31 +25,27 @@ Currently I'm getting my bearings again on this project. === canvas === I made a maybe(?) good change to the heirarchy of the canvas. Hiding the construction of handles from anything outside. -Currently, canvas is separated out to the state container itself and one API class for users to interact with, in addition to a set of 'managed' objects - -Buffers and Handles are at one level, shared with text which is unrelated. - Why do I hold the shader handles (CompiledShaderHandle) +Currently, canvas is separated out to + * A state container: CanvasState + * An Interface class CanvasFrame + * `Managed` objects. Aka, everything that CanvasState holds -In Shader lie the shader compilers, pipelines, and supporting data. +CanvasText is just laying around until I use it... +Shader pipeline objects exists in one level of managed +Handle and Buffer objects exists in the base managed level -**Current Question:** - Where do I put the CompiledShaderHandles? - - I need to put them where I create them. The actual shader doesn't. +== Do I commit to the all handles in handles.rs? == +FYI The shader API is actually pretty badass -=== canvas frame === -The current workflow: +load_shader::("shadername", a, b); -enum of vertex types - sprite holds vertex::type1 - poly holds vertex::type2 +-------------------- -canvasframe holds +So right now it looks like I am having some trouble in the drawing of the CanvasFrame I've crafted. -canvasState.run takes canvasFrame +It is seriously just a Vector of VertexTypes. Which should be fine -canvasState.draw_commands_test(command_buffer, framebuffers, image_num, canvas_frame); @@ -128,3 +123,4 @@ fn any_content(value : T) where T : IntoContent { +null) diff --git a/notes/VKProcessor.txt b/notes/VKProcessor.txt index 04221dac..b2ded561 100644 --- a/notes/VKProcessor.txt +++ b/notes/VKProcessor.txt @@ -16,6 +16,12 @@ Vk Processors is a do_all class for interaction with the render window, vulkan s [[./vkprocessor.drawio]] + + + + + + -------------------- ===== Data ===== diff --git a/notes/VKProcessor/CanvasContainerClasses.txt b/notes/VKProcessor/CanvasContainerClasses.txt index 134e59ce..11613aaf 100644 --- a/notes/VKProcessor/CanvasContainerClasses.txt +++ b/notes/VKProcessor/CanvasContainerClasses.txt @@ -9,7 +9,7 @@ Creation-Date: 2020-02-04T19:34:27-08:00 ===== Details ===== The Canvas needs to package certain buffers along with their metadata. These take the form of **Canvas Buffers**. -All buffers will have a coupled handle type stored in the [[/src/canvas/mod.rs|canvas/mod.rs]] and a reference to that handle +All buffers will have a coupled handle type stored in [[/src/canvas/managed/handles.rs|handles.rs]] and a reference to that handle ===== CanvasImage ===== diff --git a/notes/VKProcessor/vkprocessor.drawio b/notes/VKProcessor/vkprocessor.drawio index 31bf96a4..e37b293a 100644 --- a/notes/VKProcessor/vkprocessor.drawio +++ b/notes/VKProcessor/vkprocessor.drawio @@ -1 +1 @@ -7V1Zd5s4FP41Oafz4ByEWB8TZ2k6aScnzum0jxjLNlMMHpYs/fUjGYRBkjG2wciT5KEFIbC597uf7iLJZ3C4eL2NnOX8azhB/pmqTF7P4NWZqgJgQPwfaXnLWkxoZQ2zyJ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mF5/GcI3fwE= \ No newline at end of file diff --git a/resources/shaders/color-passthrough.vert b/resources/shaders/color-passthrough.vert index 0530d5e4..12ee3717 100644 --- a/resources/shaders/color-passthrough.vert +++ b/resources/shaders/color-passthrough.vert @@ -3,7 +3,6 @@ // These come in from the vertex definition layout(location = 0) in vec3 v_position; layout(location = 1) in vec4 color; -layout(location = 2) in vec2 ti_position; // These are made up in the shader themselves layout(location = 0) out vec4 out_color; diff --git a/resources/shaders/simple_image.vert b/resources/shaders/simple_image.vert index e2b62f18..7af70ad2 100644 --- a/resources/shaders/simple_image.vert +++ b/resources/shaders/simple_image.vert @@ -3,8 +3,7 @@ // These come in from the vertex definition layout(location = 0) in vec3 v_position; -layout(location = 1) in vec4 color; -layout(location = 2) in vec2 ti_position; +layout(location = 1) in vec2 ti_position; // These are made up in the shader themselves layout(location = 0) out vec2 img_coords; diff --git a/resources/shaders/simple_texture.vert b/resources/shaders/simple_texture.vert index 83a06f4e..a839e32a 100644 --- a/resources/shaders/simple_texture.vert +++ b/resources/shaders/simple_texture.vert @@ -4,8 +4,7 @@ // These come in from the vertex definition // TODO : Need to add texture coordinate attribute so I can single VBO all these sumbitches layout(location = 0) in vec3 v_position; -layout(location = 1) in vec4 color; -layout(location = 2) in vec2 ti_position; +layout(location = 1) in vec2 ti_position; // These are made up in the shader themselves layout(location = 0) out vec2 tex_coords; diff --git a/src/canvas/canvas_state.rs b/src/canvas/canvas_state.rs index 41b6096a..01b43b7d 100644 --- a/src/canvas/canvas_state.rs +++ b/src/canvas/canvas_state.rs @@ -30,10 +30,10 @@ use vulkano::pipeline::vertex::{VertexDefinition, Vertex}; use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef; use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle, CompiledShaderHandle, Handle, DrawableHandle}; use crate::canvas::managed::gpu_buffers::{CanvasImage, CanvasTexture, CanvasFont}; -use crate::canvas::managed::shader::shader_common::CompiledGraphicsPipeline; +use crate::canvas::managed::shader::shader_common::CompiledShader; use crate::canvas::managed::shader::generic_shader::GenericShader; use crate::VertexTypes; -use crate::util::vertex::{TextVertex3D, TextureVertex2D, ImageVertex2D, ColorVertex2D, CanvasFrameAllocation}; +use crate::util::vertex::{TextVertex3D, TextureVertex3D, ImageVertex3D, ColorVertex3D, CanvasFrameAllocation}; use shade_runner::Input; @@ -52,7 +52,7 @@ pub struct CanvasState { font_buffers: Vec>, /// Compiled Graphics pipelines have a handle which self describe their position in this vector - shader_buffers: Vec>>, + shader_buffers: Vec>>, /// Looks like we gotta hold onto the queue for managing textures queue: Arc, @@ -260,13 +260,13 @@ impl CanvasState { filename: String, physical: PhysicalDevice, capabilities: Capabilities) -> Option> - where T: CompiledGraphicsPipeline, V: Vertex { + where T: CompiledShader, V: Vertex { let handle = Arc::new(CompiledShaderHandle { handle: self.shader_buffers.len() as u32 }); - let shader: Box = Box::new(T::new::( + let shader: Box = Box::new(T::new::( filename.clone(), self.device.clone(), handle.clone(), @@ -390,9 +390,9 @@ impl CanvasState { /// Consume and allocate the canvas frame data to the GPU pub fn allocate(&mut self, canvas_frame: CanvasFrame) -> CanvasFrameAllocation { - let mut colored_vertex_buffer: Vec = Vec::default(); - let mut textured_vertex_buffer: HashMap, Vec> = HashMap::new(); - let mut image_vertex_buffer: HashMap, Vec> = HashMap::new(); + let mut colored_vertex_buffer: Vec = Vec::default(); + let mut textured_vertex_buffer: HashMap, Vec> = HashMap::new(); + let mut image_vertex_buffer: HashMap, Vec> = HashMap::new(); let mut text_instances: HashMap, Vec> = HashMap::new(); for value in canvas_frame.map { @@ -477,7 +477,7 @@ impl CanvasState { // This looks a little weird as colored_vertex_buffer is a vec of GPU allocated vecs. // But we can pass in multiple vertex buffers - if allocated_buffers.colored_vertex_buffer.is_empty() { + if !allocated_buffers.colored_vertex_buffer.is_empty() { command_buffer = command_buffer.draw( shader.get_pipeline().clone(), &self.dynamic_state.clone(), @@ -529,10 +529,10 @@ impl CanvasState { } // Text - let mut shader = self.shader_buffers.get( - self.get_shader_handle(String::from("simple_text")) - .unwrap().clone().get_handle() as usize - ).unwrap(); +// let mut shader = self.shader_buffers.get( +// self.get_shader_handle(String::from("simple_text")) +// .unwrap().clone().get_handle() as usize +// ).unwrap(); // // if !self.text_instances.is_empty() { diff --git a/src/canvas/managed/handles.rs b/src/canvas/managed/handles.rs index 6f6f8f24..a1463830 100644 --- a/src/canvas/managed/handles.rs +++ b/src/canvas/managed/handles.rs @@ -3,15 +3,12 @@ pub trait Handle { fn get_handle(&self) -> u32; } - pub enum DrawableHandle { Texture(CanvasTextureHandle), Image(CanvasImageHandle), Font(CanvasFontHandle), } - - /// Typed wrapper for a u32 handle #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] pub struct CanvasFontHandle { diff --git a/src/canvas/managed/shader/generic_shader.rs b/src/canvas/managed/shader/generic_shader.rs index 713e230f..0d8de92b 100644 --- a/src/canvas/managed/shader/generic_shader.rs +++ b/src/canvas/managed/shader/generic_shader.rs @@ -14,11 +14,11 @@ use vulkano::pipeline::vertex::{SingleBufferDefinition, VertexDefinition, Vertex use shade_runner as sr; use vulkano::memory::pool::PotentialDedicatedAllocation::Generic; use vulkano::SafeDeref; -use crate::canvas::managed::shader::shader_common::{ShaderType, CompiledGraphicsPipelineResources, CompiledGraphicsPipeline}; +use crate::canvas::managed::shader::shader_common::{ShaderType, CompiledShaderResources, CompiledShader}; use crate::canvas::managed::handles::CompiledShaderHandle; use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef; use crate::canvas::managed::ShaderSpecializationConstants; -use crate::util::vertex::{VertexTypes, ColorVertex2D}; +use crate::util::vertex::{VertexTypes, ColorVertex3D}; /// CanvasShader holds the pipeline and render pass for the input shader source #[derive(Clone)] @@ -37,10 +37,10 @@ impl GenericShader { } /// Gives CanvasShader the resource functions -impl CompiledGraphicsPipelineResources for GenericShader {} +impl CompiledShaderResources for GenericShader {} /// Convenience interface so we don't have to juggle shader types -impl CompiledGraphicsPipeline for GenericShader { +impl CompiledShader for GenericShader { /// This will explode when the shader does not want to compile fn new(filename: String, diff --git a/src/canvas/managed/shader/shader_common.rs b/src/canvas/managed/shader/shader_common.rs index 366b8368..3133160f 100644 --- a/src/canvas/managed/shader/shader_common.rs +++ b/src/canvas/managed/shader/shader_common.rs @@ -29,7 +29,7 @@ This best works I think if I allow users to /// Inheriting this gives private functions to grab resources -pub trait CompiledGraphicsPipelineResources { +pub trait CompiledShaderResources { fn get_path(filename: String, shader_type: ShaderType) -> PathBuf { let project_root = @@ -100,7 +100,7 @@ pub trait CompiledGraphicsPipelineResources { -pub trait CompiledGraphicsPipeline { +pub trait CompiledShader { fn new(filename: String, device: Arc, handle: Arc, diff --git a/src/canvas/managed/shader/text_shader.rs b/src/canvas/managed/shader/text_shader.rs index bb9e506a..15b3231a 100644 --- a/src/canvas/managed/shader/text_shader.rs +++ b/src/canvas/managed/shader/text_shader.rs @@ -11,12 +11,12 @@ use std::marker::PhantomData; use vulkano::pipeline::depth_stencil::{DepthStencil, Compare, DepthBounds, Stencil, StencilOp}; use vulkano::pipeline::vertex::{SingleBufferDefinition, OneVertexOneInstanceDefinition, Vertex}; use shade_runner as sr; -use crate::canvas::managed::shader::shader_common::{ShaderType, CompiledGraphicsPipelineResources, CompiledGraphicsPipeline}; +use crate::canvas::managed::shader::shader_common::{ShaderType, CompiledShaderResources, CompiledShader}; use crate::canvas::managed::handles::CompiledShaderHandle; use crate::canvas::managed::shader::generic_shader::GenericShader; use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef; use crate::canvas::managed::ShaderSpecializationConstants; -use crate::util::vertex::ColorVertex2D; +use crate::util::vertex::ColorVertex3D; /// CanvasShader holds the pipeline and render pass for the input shader source @@ -34,10 +34,10 @@ pub struct TextShader { impl TextShader {} /// Gives CanvasShader the resource functions -impl CompiledGraphicsPipelineResources for TextShader {} +impl CompiledShaderResources for TextShader {} /// Convenience interface so we don't have to juggle shader types -impl CompiledGraphicsPipeline for TextShader { +impl CompiledShader for TextShader { /// This will explode when the shader does not want to compile fn new(filename: String, diff --git a/src/main.rs b/src/main.rs index 82c78f9d..12e373a1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,8 +27,9 @@ use crate::compute::compu_frame::CompuFrame; use crate::canvas::canvas_frame::{CanvasFrame, Drawable}; use crate::compute::managed::compu_sprite::CompuSprite; use std::sync::Arc; -use crate::canvas::managed::handles::{CanvasTextureHandle, Handle}; -use crate::util::vertex::{VertexTypes, TextureVertex2D}; +use crate::canvas::managed::handles::{CanvasTextureHandle, Handle, CanvasFontHandle}; +use crate::util::vertex::{VertexTypes, TextureVertex3D}; +use crate::compute::managed::handles::{CompuBufferHandle, CompuKernelHandle}; pub mod util; @@ -89,13 +90,11 @@ pub fn main() { processor.preload_fonts(); } - - - let q2 = hprof::enter("Game Objects"); let mut timer = Timer::new(); - let mut frame_future = Box::new(sync::now(processor.device.clone())) as Box; + let mut frame_future : Box = + Box::new(sync::now(processor.device.clone())) as Box; let step_size: f32 = 0.005; let mut elapsed_time: f32; @@ -104,26 +103,31 @@ pub fn main() { let mut current_time: f32 = timer.elap_time(); let image_data = load_raw(String::from("funky-bird.jpg")); - let image_dimensions_f = ((image_data.1).0 as f32, (image_data.1).1 as f32); - let image_dimensions_u = image_data.1; - let compu_sprite1 = CompuSprite::new((0.0, -0.5), (0.4, 0.4), 0, image_dimensions_f, - // This swap image needs to match the size of the compute - processor.new_swap_image(image_dimensions_u)); - - let compute_buffer = processor.new_compute_buffer(image_data.0, image_data.1, 4); - - let compute_kernel = processor.get_kernel_handle(String::from("simple-edge.compute")) + let image_dimensions_f : (f32, f32) = ((image_data.1).0 as f32, (image_data.1).1 as f32); + let image_dimensions_u : (u32, u32) = image_data.1; + let compu_sprite1 : CompuSprite = + CompuSprite::new((0.0, -0.5), (0.4, 0.4), 0, image_dimensions_f, + // Swap image to render the result to. Must match dimensions + processor.new_swap_image(image_dimensions_u)); + + let compute_buffer : Arc = + processor.new_compute_buffer(image_data.0, image_data.1, 4); + + let compute_kernel : Arc = + processor.get_kernel_handle(String::from("simple-edge.compute")) .expect("Can't find that kernel"); - let funky_handle = processor.get_texture_handle(String::from("funky-bird.jpg")).unwrap(); - let sfml_handle = processor.get_texture_handle(String::from("sfml.png")).unwrap(); - let font_handle = processor.get_font_handle(String::from("sansation.ttf")).unwrap(); + // Get the handles for the assets + let funky_handle : Arc = + processor.get_texture_handle(String::from("funky-bird.jpg")).unwrap(); + let sfml_handle : Arc = + processor.get_texture_handle(String::from("sfml.png")).unwrap(); + let font_handle : Arc = + processor.get_font_handle(String::from("sansation.ttf")).unwrap(); let funky_sprite = Sprite::new((0.0, -0.5), (0.5, 0.5), 0, funky_handle.clone()); let sfml_sprite = Sprite::new((0.0, -0.5), (0.5, 0.5), 1, sfml_handle.clone()); //let text_sprite = Text::new((-0.1,-0.1), (10.0, 10.0), font_handle.clone()); - - //let test_polygon = Poly::new_with_color((-0.5, -0.5), (0.5, 0.5), 1, (1.0,0.0,0.0,0.0)); drop(q2); diff --git a/src/sprite.rs b/src/sprite.rs index 75cb01a3..b00f9e12 100644 --- a/src/sprite.rs +++ b/src/sprite.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use crate::canvas::*; use crate::canvas::managed::handles::{CanvasFontHandle, CanvasImageHandle, CanvasTextureHandle, Handle}; use crate::canvas::canvas_frame::{Drawable}; -use crate::util::vertex::{VertexTypes, TextureVertex2D, Vertex3D}; +use crate::util::vertex::{VertexTypes, TextureVertex3D, Vertex3D}; /// #[derive(Debug, Clone)] @@ -25,8 +25,29 @@ impl Sprite { let normalized_depth = (depth as f32 / 255.0); + let verts = vec![ + TextureVertex3D{ + v_position: [position.0, position.1, normalized_depth], // top left + ti_position: [-0.0, -0.0] }, + TextureVertex3D{ + v_position: [position.0, position.1 + size.1, normalized_depth], // bottom left + ti_position: [-0.0, 1.0] }, + TextureVertex3D{ + v_position: [position.0 + size.0, position.1 + size.1, normalized_depth], // bottom right + ti_position: [1.0, 1.0] }, + TextureVertex3D{ + v_position: [position.0, position.1, normalized_depth], // top left + ti_position: [-0.0, -0.0] }, + TextureVertex3D{ + v_position: [position.0 + size.0, position.1 + size.1, normalized_depth], // bottom right + ti_position: [1.0, 1.0] }, + TextureVertex3D{ + v_position: [position.0 + size.0, position.1, normalized_depth], // top right + ti_position: [1.0, -0.0] }, + ]; + Sprite { - verts: VertexTypes::TextureType(Vec::new(), texture_handle), + verts: VertexTypes::TextureType(verts, texture_handle), position: position, size: size, } diff --git a/src/util/vertex.rs b/src/util/vertex.rs index 9dc6f5c6..323fe241 100644 --- a/src/util/vertex.rs +++ b/src/util/vertex.rs @@ -4,25 +4,25 @@ use vulkano::buffer::BufferAccess; use std::collections::HashMap; #[derive(Default, Debug, Clone, Copy)] -pub struct TextureVertex2D { - pub v_position: [f32; 2], +pub struct TextureVertex3D { + pub v_position: [f32; 3], pub ti_position: [f32; 2], } -vulkano::impl_vertex!(TextureVertex2D, v_position, ti_position); +vulkano::impl_vertex!(TextureVertex3D, v_position, ti_position); #[derive(Default, Debug, Clone, Copy)] -pub struct ColorVertex2D { - pub v_position: [f32; 2], +pub struct ColorVertex3D { + pub v_position: [f32; 3], pub color: [f32; 4], } -vulkano::impl_vertex!(ColorVertex2D, v_position, color); +vulkano::impl_vertex!(ColorVertex3D, v_position, color); #[derive(Default, Debug, Clone, Copy)] -pub struct ImageVertex2D { - pub v_position: [f32; 2], - pub color: [f32; 4], +pub struct ImageVertex3D { + pub v_position: [f32; 3], + pub ti_position: [f32; 2], } -vulkano::impl_vertex!(ImageVertex2D, v_position, color); +vulkano::impl_vertex!(ImageVertex3D, v_position, ti_position); #[derive(Default, Debug, Clone, Copy)] pub struct Vertex3D { @@ -52,9 +52,9 @@ vulkano::impl_vertex!(GlyphInstance, screen_position, atlas_position, atlas_size #[derive(Debug, Clone)] pub enum VertexTypes { - TextureType(Vec, Arc), - ImageType(Vec, Arc), - ColorType(Vec), + TextureType(Vec, Arc), + ImageType(Vec, Arc), + ColorType(Vec), ThreeDType(Vec), } diff --git a/src/vkprocessor.rs b/src/vkprocessor.rs index 1ac7cc23..7ffb54da 100644 --- a/src/vkprocessor.rs +++ b/src/vkprocessor.rs @@ -20,7 +20,7 @@ use crate::canvas::managed::shader::generic_shader::GenericShader; use crate::canvas::managed::shader::text_shader::TextShader; use crate::canvas::managed::handles::{CanvasTextureHandle, CompiledShaderHandle, CanvasFontHandle, CanvasImageHandle}; use crate::compute::managed::handles::{CompuKernelHandle, CompuBufferHandle}; -use crate::util::vertex::{VertexTypes, ColorVertex2D, TextVertex3D, TextureVertex2D, ImageVertex2D}; +use crate::util::vertex::{VertexTypes, ColorVertex3D, TextVertex3D, TextureVertex3D, ImageVertex3D}; /// VKProcessor holds the vulkan instance information, the swapchain, @@ -168,10 +168,10 @@ impl<'a> VkProcessor<'a> { /// A hardcoded list of shaders which can be preloaded from this function pub fn preload_shaders(&mut self) { - self.canvas_state.load_shader::(String::from("color-passthrough"), self.physical.clone(), self.capabilities.clone()); - self.canvas_state.load_shader::(String::from("simple_texture"), self.physical.clone(), self.capabilities.clone()); - self.canvas_state.load_shader::(String::from("simple_image"), self.physical.clone(), self.capabilities.clone()); - self.canvas_state.load_shader::(String::from("simple_text"), self.physical.clone(), self.capabilities.clone()); + self.canvas_state.load_shader::(String::from("color-passthrough"), self.physical.clone(), self.capabilities.clone()); + self.canvas_state.load_shader::(String::from("simple_texture"), self.physical.clone(), self.capabilities.clone()); + self.canvas_state.load_shader::(String::from("simple_image"), self.physical.clone(), self.capabilities.clone()); + // self.canvas_state.load_shader::(String::from("simple_text"), self.physical.clone(), self.capabilities.clone()); } /// A hardcoded list of shaders which can be proloaded from this function