going to save here. re-evaluating drawable now that runtimevertexdef is in
This commit is contained in:
@@ -13,7 +13,6 @@ All buffers will have a coupled handle type stored in the [[/src/canvas/mod.rs|c
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
===== CanvasImage =====
|
===== CanvasImage =====
|
||||||
|
|
||||||
|
|
||||||
@@ -43,7 +42,3 @@ Container class for
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,13 @@ I like this immediate interface for this simple style of UI and drawing.
|
|||||||
|
|
||||||
@todo finish this
|
@todo finish this
|
||||||
|
|
||||||
|
Now. The CanvasFrame is closely coupled with the Drawable trait, the object which allows CanvasFrame to ingest all drawable object on a single interface
|
||||||
|
|
||||||
|
Drawable needs a few things:
|
||||||
|
Handle to the Texture or Image it is using
|
||||||
|
Vertices describing it
|
||||||
|
(vertices will be character data for text)
|
||||||
|
Instances?
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Creation-Date: 2020-02-03T23:30:41-08:00
|
|||||||
|
|
||||||
====== CanvasState ======
|
====== CanvasState ======
|
||||||
|
|
||||||
[[~/source/Trac3r-rust/doc/sfml_rust/canvas/struct.CanvasState.html|Documentation]]
|
[[/doc/sfml_rust/canvas/canvas_state/struct.CanvasState.html|Documentation]]
|
||||||
|
|
||||||
===== Details =====
|
===== Details =====
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ Creation-Date: 2020-02-03T23:30:41-08:00
|
|||||||
|
|
||||||
**window_size_dependent_setup** is currently hosted inside this class. If a second graphics class is added I will add some shared library for this to live.
|
**window_size_dependent_setup** is currently hosted inside this class. If a second graphics class is added I will add some shared library for this to live.
|
||||||
|
|
||||||
**render_pass **the render pass is created with our depth stencil data **D32Sfloat_S8Uint** and the color attachment for the render output. This is highly 2D dependent
|
**render_pass **the render pass is created with our depth stencil/color data **D32Sfloat_S8Uint **attachment for the render output. This is highly shader dependent. Also depends on the DynamicState
|
||||||
|
|
||||||
|
|
||||||
===== Interface =====
|
===== Interface =====
|
||||||
@@ -22,6 +22,8 @@ Creation-Date: 2020-02-03T23:30:41-08:00
|
|||||||
The class then interacts with these stored items by taking and executing a list of operations to perform on them.
|
The class then interacts with these stored items by taking and executing a list of operations to perform on them.
|
||||||
|
|
||||||
CanvasFrame
|
CanvasFrame
|
||||||
|
Going to need some interface for getting vertices.
|
||||||
|
Some interface for getting the texture or image
|
||||||
|
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
|
|||||||
@@ -17,6 +17,49 @@ Main Systems:
|
|||||||
[[CompuState]] [[~/source/Trac3r-rust/doc/sfml_rust/compute/compu_state/struct.CompuState.html|===========]]
|
[[CompuState]] [[~/source/Trac3r-rust/doc/sfml_rust/compute/compu_state/struct.CompuState.html|===========]]
|
||||||
|
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
====== Warming Up ======
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
In Shader lie the shader compilers, pipelines, and supporting data.
|
||||||
|
|
||||||
|
**Current Question:**
|
||||||
|
Where do I put the CompiledShaderHandles?
|
||||||
|
|
||||||
|
I need to put them where I create them. The actual shader doesn't.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
├── canvas
|
├── canvas
|
||||||
│ ├── canvas_frame.rs
|
│ ├── canvas_frame.rs
|
||||||
│ ├── canvas_state.rs
|
│ ├── canvas_state.rs
|
||||||
|
|||||||
@@ -1,13 +1,70 @@
|
|||||||
use crate::util::vertex_3d::{Vertex3D};
|
use crate::util::vertex_3d::{Vertex3D};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use crate::canvas::canvas_state::{Drawable};
|
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use crate::canvas::*;
|
use crate::canvas::*;
|
||||||
use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
|
use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
|
||||||
use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle};
|
use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle, Handle};
|
||||||
use crate::canvas::managed::shader::text_shader::GlyphInstance;
|
use crate::canvas::managed::shader::text_shader::GlyphInstance;
|
||||||
|
|
||||||
|
// I don't think this is going to work without getting into Box'ing
|
||||||
|
pub trait DrawableTest<V, H, In> where H: Handle{
|
||||||
|
fn get_vertices(&self) -> Vec<V>;
|
||||||
|
fn get_instances(&self) -> Vec<In>;
|
||||||
|
fn get_handle(&self) -> H;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub struct DrawableTestee {
|
||||||
|
pub vertices: Vec<u32>,
|
||||||
|
pub instances: Vec<u32>,
|
||||||
|
pub handle: Arc<CanvasTextureHandle>
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<V, H: Handle, In> DrawableTest<V, H, In> for DrawableTestee {
|
||||||
|
fn get_vertices(&self) -> Vec<V> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_instances(&self) -> Vec<In> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_handle(&self) -> H {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pub trait Drawable {
|
||||||
|
|
||||||
|
fn get_vertices(&self) -> Vec<(f32, f32, f32)>;
|
||||||
|
fn get_color(&self) -> (f32, f32, f32, f32);
|
||||||
|
fn get_ti_coords(&self) -> Vec<(f32, f32)>;
|
||||||
|
|
||||||
|
fn get_texture_handle(&self) -> Option<Arc<CanvasTextureHandle>>;
|
||||||
|
fn get_image_handle(&self) -> Option<Arc<CanvasImageHandle>>;
|
||||||
|
// fn get_text_handle(&self) -> Option<Arc<CanvasTextHandle>>;
|
||||||
|
|
||||||
|
// These needs to return a vector of raw-ass data in addition to the definition for this data
|
||||||
|
fn collect(&self) -> Vec<RuntimeVertexDef> {
|
||||||
|
let color = self.get_color();
|
||||||
|
// self.get_vertices().iter().zip(self.get_ti_coords().iter()).map(|(a, b)|
|
||||||
|
// Vertex3D {
|
||||||
|
// v_position: [a.0, a.1, a.2],
|
||||||
|
// color: [color.0, color.1, color.2, color.3],
|
||||||
|
// ti_position: [b.0, b.1],
|
||||||
|
// }).collect()
|
||||||
|
// TODO
|
||||||
|
vec![RuntimeVertexDef::from_primitive(0)]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait VertexDefinitionAndData {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
pub struct CanvasFrame {
|
pub struct CanvasFrame {
|
||||||
pub colored_drawables: Vec<RuntimeVertexDef>,
|
pub colored_drawables: Vec<RuntimeVertexDef>,
|
||||||
@@ -16,70 +73,6 @@ pub struct CanvasFrame {
|
|||||||
pub text_drawables: HashMap<Arc<CanvasFontHandle>, Vec<GlyphInstance>>
|
pub text_drawables: HashMap<Arc<CanvasFontHandle>, Vec<GlyphInstance>>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
This is sort of the beginning of our interface with the user definable sprites.
|
|
||||||
Will be taking in multiple type of items
|
|
||||||
|
|
||||||
TEXT
|
|
||||||
FontHandle
|
|
||||||
VertexDefintion
|
|
||||||
color
|
|
||||||
position
|
|
||||||
instances (string)
|
|
||||||
Textured
|
|
||||||
TextureHandle
|
|
||||||
VertexDefintion
|
|
||||||
position
|
|
||||||
coords
|
|
||||||
size
|
|
||||||
|
|
||||||
Vertex definition is directly correlated to the compiled code. How do I bucket these
|
|
||||||
|
|
||||||
I guess I could store them and set handles like I do textures
|
|
||||||
|
|
||||||
The only ent that can create these vertex handles is the vkprocessor.
|
|
||||||
So Text can only get a vertex definition by going like shader.get_definition()
|
|
||||||
|
|
||||||
|
|
||||||
Text
|
|
||||||
FontHandle
|
|
||||||
VertexHandle
|
|
||||||
|
|
||||||
|
|
||||||
Drawable must include
|
|
||||||
shader_handle (but how to I get this to the text? this is runtime)
|
|
||||||
|
|
||||||
Okay, no. Maybe a default shader type of setup. With a shader handle override????
|
|
||||||
|
|
||||||
Type: Text
|
|
||||||
Textured
|
|
||||||
Img
|
|
||||||
Color
|
|
||||||
|
|
||||||
frame.draw(text) {
|
|
||||||
|
|
||||||
text.type == TEXT { // When it matches to default text shader
|
|
||||||
text_shader.get_definition()
|
|
||||||
text_shader.get_pipeline()
|
|
||||||
}
|
|
||||||
...
|
|
||||||
else { // When the user passes in a shader
|
|
||||||
text.shader_handle.get_definition()
|
|
||||||
text.shader_handle.get_pipeline()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Has default shader
|
|
||||||
let text = Text::new("asdoif");
|
|
||||||
|
|
||||||
let frame = CanvasFrame::new();
|
|
||||||
frame.draw(text);
|
|
||||||
|
|
||||||
vkprocessor.run(frame);
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
impl CanvasFrame {
|
impl CanvasFrame {
|
||||||
|
|
||||||
/// Creates a bare canvas frame with empty accumulators a
|
/// Creates a bare canvas frame with empty accumulators a
|
||||||
@@ -92,6 +85,19 @@ impl CanvasFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// pub fn draw_test<V : VertexDefinitionAndData, H: Handle, In>(&mut self, drawable: &dyn DrawableTest<V, H, In>) {
|
||||||
|
// let h = drawable.get_handle();
|
||||||
|
//
|
||||||
|
// let v = drawable.get_vertices();
|
||||||
|
//
|
||||||
|
// let v = v.get(0).unwrap();
|
||||||
|
//
|
||||||
|
// // need to fill up the drawables....
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
// TODO: Fix this for text and fonts
|
// TODO: Fix this for text and fonts
|
||||||
/// Accumulates the drawables collected Vertex2D's
|
/// Accumulates the drawables collected Vertex2D's
|
||||||
@@ -119,24 +125,3 @@ impl CanvasFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct GenericCanvasFrame<H, V, In> {
|
|
||||||
frame_data: HashMap<H, Vec<(Vec<V>, Vec<In>)>>
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//impl<V, In> GenericCanvasFrame<Vertex3D, V, In> {
|
|
||||||
//
|
|
||||||
// /// Creates a bare canvas frame with empty accumulators
|
|
||||||
// pub fn new() -> GenericCanvasFrame<Vertex3D, V, In> {
|
|
||||||
// GenericCanvasFrame {
|
|
||||||
// frame_data: Default::default()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// pub fn draw(&mut self, drawable: &dyn DrawableTest<V, Vertex3D, In>) {
|
|
||||||
// self.frame_data
|
|
||||||
// .entry(drawable.get_handle().clone())
|
|
||||||
// .or_insert(Vec::new())
|
|
||||||
// .push((drawable.get_vertices(), drawable.get_instances()));
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -29,48 +29,14 @@ use std::io::Read;
|
|||||||
use rusttype::{Font, PositionedGlyph, Scale, Rect, point, GlyphId, Line, Curve, Segment};
|
use rusttype::{Font, PositionedGlyph, Scale, Rect, point, GlyphId, Line, Curve, Segment};
|
||||||
use vulkano::pipeline::vertex::VertexDefinition;
|
use vulkano::pipeline::vertex::VertexDefinition;
|
||||||
use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
|
use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
|
||||||
use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle, CompiledGraphicsPipelineHandle, Handle};
|
use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle, CompiledShaderHandle, Handle};
|
||||||
use crate::canvas::managed::gpu_buffers::{CanvasImage, CanvasTexture, CanvasFont};
|
use crate::canvas::managed::gpu_buffers::{CanvasImage, CanvasTexture, CanvasFont};
|
||||||
use crate::canvas::managed::shader::shader_common::CompiledGraphicsPipeline;
|
use crate::canvas::managed::shader::shader_common::CompiledGraphicsPipeline;
|
||||||
use crate::canvas::managed::shader::generic_shader::GenericShader;
|
use crate::canvas::managed::shader::generic_shader::GenericShader;
|
||||||
|
|
||||||
|
|
||||||
// I don't think this is going to work without getting into Box'ing
|
|
||||||
pub trait DrawableTest<V, H, In> {
|
|
||||||
fn get_vertices(&self) -> Vec<V>;
|
|
||||||
fn get_instances(&self) -> Vec<In>;
|
|
||||||
fn get_handle(&self) -> H;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// A drawable object can be passed into a CanvasFrame to be rendered
|
|
||||||
/// Very generic implementation. (N % 2 == 0) vertices, ditto for texture coords, and rgba color
|
|
||||||
/// Provides Image and Texture handles for drawing
|
|
||||||
|
|
||||||
pub trait Drawable {
|
|
||||||
|
|
||||||
fn get_vertices(&self) -> Vec<(f32, f32, f32)>;
|
|
||||||
fn get_color(&self) -> (f32, f32, f32, f32);
|
|
||||||
fn get_ti_coords(&self) -> Vec<(f32, f32)>;
|
|
||||||
|
|
||||||
fn get_texture_handle(&self) -> Option<Arc<CanvasTextureHandle>>;
|
|
||||||
fn get_image_handle(&self) -> Option<Arc<CanvasImageHandle>>;
|
|
||||||
// fn get_text_handle(&self) -> Option<Arc<CanvasTextHandle>>;
|
|
||||||
|
|
||||||
fn collect(&self) -> Vec<RuntimeVertexDef> {
|
|
||||||
let color = self.get_color();
|
|
||||||
// self.get_vertices().iter().zip(self.get_ti_coords().iter()).map(|(a, b)|
|
|
||||||
// Vertex3D {
|
|
||||||
// v_position: [a.0, a.1, a.2],
|
|
||||||
// color: [color.0, color.1, color.2, color.3],
|
|
||||||
// ti_position: [b.0, b.1],
|
|
||||||
// }).collect()
|
|
||||||
// TODO
|
|
||||||
vec![RuntimeVertexDef::from_primitive(0)]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Canvas state is used for storage of texture and image buffers in addition to vertex buffers
|
/// Canvas state is used for storage of texture and image buffers in addition to vertex buffers
|
||||||
/// Canvas state also contains logic for writing the stored buffers to the command_buffer
|
/// Canvas state also contains logic for writing the stored buffers to the command_buffer
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@@ -308,10 +274,10 @@ impl CanvasState {
|
|||||||
pub fn load_shader<T: 'static>(&mut self,
|
pub fn load_shader<T: 'static>(&mut self,
|
||||||
filename: String,
|
filename: String,
|
||||||
physical: PhysicalDevice,
|
physical: PhysicalDevice,
|
||||||
capabilities: Capabilities) -> Option<Arc<CompiledGraphicsPipelineHandle>>
|
capabilities: Capabilities) -> Option<Arc<CompiledShaderHandle>>
|
||||||
where T: CompiledGraphicsPipeline {
|
where T: CompiledGraphicsPipeline {
|
||||||
|
|
||||||
let handle = Arc::new(CompiledGraphicsPipelineHandle {
|
let handle = Arc::new(CompiledShaderHandle {
|
||||||
handle: self.shader_buffers.len() as u32
|
handle: self.shader_buffers.len() as u32
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -396,7 +362,7 @@ impl CanvasState {
|
|||||||
|
|
||||||
/// Using the shader name, iterates through the stored shaders and matches by the name
|
/// Using the shader name, iterates through the stored shaders and matches by the name
|
||||||
pub fn get_shader_handle(&self, shader_name: String)
|
pub fn get_shader_handle(&self, shader_name: String)
|
||||||
-> Option<Arc<CompiledGraphicsPipelineHandle>> {
|
-> Option<Arc<CompiledShaderHandle>> {
|
||||||
for shader in self.shader_buffers.clone() {
|
for shader in self.shader_buffers.clone() {
|
||||||
if shader.get_name() == shader_name {
|
if shader.get_name() == shader_name {
|
||||||
return Some(shader.get_handle().clone());
|
return Some(shader.get_handle().clone());
|
||||||
|
|||||||
@@ -41,23 +41,11 @@ impl Handle for CanvasImageHandle {
|
|||||||
|
|
||||||
/// Typed wrapper for a u32 handle
|
/// Typed wrapper for a u32 handle
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
|
||||||
pub struct CanvasShaderHandle {
|
pub struct CompiledShaderHandle {
|
||||||
pub(in crate::canvas) handle: u32
|
pub(in crate::canvas) handle: u32
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Handle for CanvasShaderHandle {
|
impl Handle for CompiledShaderHandle {
|
||||||
fn get_handle(&self) -> u32 {
|
|
||||||
self.handle
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Typed wrapper for a u32 handle
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
|
|
||||||
pub struct CompiledGraphicsPipelineHandle {
|
|
||||||
pub(in crate::canvas) handle: u32
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Handle for CompiledGraphicsPipelineHandle {
|
|
||||||
fn get_handle(&self) -> u32 {
|
fn get_handle(&self) -> u32 {
|
||||||
self.handle
|
self.handle
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use shade_runner as sr;
|
|||||||
use vulkano::memory::pool::PotentialDedicatedAllocation::Generic;
|
use vulkano::memory::pool::PotentialDedicatedAllocation::Generic;
|
||||||
use vulkano::SafeDeref;
|
use vulkano::SafeDeref;
|
||||||
use crate::canvas::managed::shader::shader_common::{ShaderType, CompiledGraphicsPipelineResources, CompiledGraphicsPipeline};
|
use crate::canvas::managed::shader::shader_common::{ShaderType, CompiledGraphicsPipelineResources, CompiledGraphicsPipeline};
|
||||||
use crate::canvas::managed::handles::CompiledGraphicsPipelineHandle;
|
use crate::canvas::managed::handles::CompiledShaderHandle;
|
||||||
use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
|
use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
|
||||||
use crate::canvas::managed::ShaderSpecializationConstants;
|
use crate::canvas::managed::ShaderSpecializationConstants;
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ use crate::canvas::managed::ShaderSpecializationConstants;
|
|||||||
pub struct GenericShader {
|
pub struct GenericShader {
|
||||||
graphics_pipeline: Option<Arc<dyn GraphicsPipelineAbstract + Sync + Send>>,
|
graphics_pipeline: Option<Arc<dyn GraphicsPipelineAbstract + Sync + Send>>,
|
||||||
|
|
||||||
handle: Arc<CompiledGraphicsPipelineHandle>,
|
handle: Arc<CompiledShaderHandle>,
|
||||||
name: String,
|
name: String,
|
||||||
|
|
||||||
device: Arc<Device>,
|
device: Arc<Device>,
|
||||||
@@ -44,7 +44,7 @@ impl CompiledGraphicsPipeline for GenericShader {
|
|||||||
/// This will explode when the shader does not want to compile
|
/// This will explode when the shader does not want to compile
|
||||||
fn new(filename: String,
|
fn new(filename: String,
|
||||||
device: Arc<Device>,
|
device: Arc<Device>,
|
||||||
handle: Arc<CompiledGraphicsPipelineHandle>,
|
handle: Arc<CompiledShaderHandle>,
|
||||||
render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> GenericShader {
|
render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> GenericShader {
|
||||||
|
|
||||||
let compiled_vertex = GenericShader::compile(
|
let compiled_vertex = GenericShader::compile(
|
||||||
@@ -122,7 +122,7 @@ impl CompiledGraphicsPipeline for GenericShader {
|
|||||||
self.name.clone()
|
self.name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_handle(&self) -> Arc<CompiledGraphicsPipelineHandle> {
|
fn get_handle(&self) -> Arc<CompiledShaderHandle> {
|
||||||
self.handle.clone()
|
self.handle.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use vulkano::pipeline::shader::{ShaderModule, GraphicsShaderType, GeometryShader
|
|||||||
use vulkano::device::Device;
|
use vulkano::device::Device;
|
||||||
use shade_runner::Entry;
|
use shade_runner::Entry;
|
||||||
use shaderc::ShaderKind;
|
use shaderc::ShaderKind;
|
||||||
use crate::canvas::managed::handles::CompiledGraphicsPipelineHandle;
|
use crate::canvas::managed::handles::CompiledShaderHandle;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@@ -102,10 +102,10 @@ pub trait CompiledGraphicsPipelineResources {
|
|||||||
pub trait CompiledGraphicsPipeline {
|
pub trait CompiledGraphicsPipeline {
|
||||||
fn new(filename: String,
|
fn new(filename: String,
|
||||||
device: Arc<Device>,
|
device: Arc<Device>,
|
||||||
handle: Arc<CompiledGraphicsPipelineHandle>,
|
handle: Arc<CompiledShaderHandle>,
|
||||||
render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> Self where Self: Sized;
|
render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> Self where Self: Sized;
|
||||||
fn get_name(&self) -> String;
|
fn get_name(&self) -> String;
|
||||||
fn get_handle(&self) -> Arc<CompiledGraphicsPipelineHandle>;
|
fn get_handle(&self) -> Arc<CompiledShaderHandle>;
|
||||||
fn get_pipeline(&self) -> Arc<dyn GraphicsPipelineAbstract + Sync + Send>;
|
fn get_pipeline(&self) -> Arc<dyn GraphicsPipelineAbstract + Sync + Send>;
|
||||||
fn get_renderpass(&self) -> Arc<dyn RenderPassAbstract + Send + Sync>;
|
fn get_renderpass(&self) -> Arc<dyn RenderPassAbstract + Send + Sync>;
|
||||||
fn recompile(self, render_pass: Arc<dyn RenderPassAbstract + Send + Sync>)
|
fn recompile(self, render_pass: Arc<dyn RenderPassAbstract + Send + Sync>)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use vulkano::pipeline::vertex::{SingleBufferDefinition, OneVertexOneInstanceDefi
|
|||||||
use crate::util::vertex_3d::Vertex3D;
|
use crate::util::vertex_3d::Vertex3D;
|
||||||
use shade_runner as sr;
|
use shade_runner as sr;
|
||||||
use crate::canvas::managed::shader::shader_common::{ShaderType, CompiledGraphicsPipelineResources, CompiledGraphicsPipeline};
|
use crate::canvas::managed::shader::shader_common::{ShaderType, CompiledGraphicsPipelineResources, CompiledGraphicsPipeline};
|
||||||
use crate::canvas::managed::handles::CompiledGraphicsPipelineHandle;
|
use crate::canvas::managed::handles::CompiledShaderHandle;
|
||||||
use crate::canvas::managed::shader::generic_shader::GenericShader;
|
use crate::canvas::managed::shader::generic_shader::GenericShader;
|
||||||
use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
|
use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
|
||||||
use crate::canvas::managed::ShaderSpecializationConstants;
|
use crate::canvas::managed::ShaderSpecializationConstants;
|
||||||
@@ -32,7 +32,7 @@ vulkano::impl_vertex!(GlyphInstance, screen_position, atlas_position, atlas_size
|
|||||||
pub struct TextShader {
|
pub struct TextShader {
|
||||||
graphics_pipeline: Option<Arc<dyn GraphicsPipelineAbstract + Sync + Send>>,
|
graphics_pipeline: Option<Arc<dyn GraphicsPipelineAbstract + Sync + Send>>,
|
||||||
|
|
||||||
handle: Arc<CompiledGraphicsPipelineHandle>,
|
handle: Arc<CompiledShaderHandle>,
|
||||||
name: String,
|
name: String,
|
||||||
|
|
||||||
device: Arc<Device>,
|
device: Arc<Device>,
|
||||||
@@ -50,7 +50,7 @@ impl CompiledGraphicsPipeline for TextShader {
|
|||||||
/// This will explode when the shader does not want to compile
|
/// This will explode when the shader does not want to compile
|
||||||
fn new(filename: String,
|
fn new(filename: String,
|
||||||
device: Arc<Device>,
|
device: Arc<Device>,
|
||||||
handle: Arc<CompiledGraphicsPipelineHandle>,
|
handle: Arc<CompiledShaderHandle>,
|
||||||
render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> TextShader {
|
render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> TextShader {
|
||||||
|
|
||||||
let compiled_vertex = GenericShader::compile(
|
let compiled_vertex = GenericShader::compile(
|
||||||
@@ -151,7 +151,7 @@ impl CompiledGraphicsPipeline for TextShader {
|
|||||||
self.name.clone()
|
self.name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_handle(&self) -> Arc<CompiledGraphicsPipelineHandle> {
|
fn get_handle(&self) -> Arc<CompiledShaderHandle> {
|
||||||
self.handle.clone()
|
self.handle.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use crate::canvas::canvas_state::{Drawable};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use crate::canvas::managed::handles::{CanvasImageHandle};
|
use crate::canvas::managed::handles::{CanvasImageHandle};
|
||||||
use crate::compute::managed::handles::{CompuKernelHandle, CompuBufferHandle};
|
use crate::compute::managed::handles::{CompuKernelHandle, CompuBufferHandle};
|
||||||
use crate::compute::managed::compu_sprite::CompuSprite;
|
use crate::compute::managed::compu_sprite::CompuSprite;
|
||||||
|
use crate::canvas::canvas_frame::Drawable;
|
||||||
|
|
||||||
pub struct CompuFrame {
|
pub struct CompuFrame {
|
||||||
// Vec<(Buffer, Kernel)>
|
// Vec<(Buffer, Kernel)>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use vulkano::buffer::{CpuAccessibleBuffer, BufferUsage};
|
use vulkano::buffer::{CpuAccessibleBuffer, BufferUsage};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use crate::canvas::canvas_state::{Drawable, CanvasState};
|
|
||||||
use vulkano::framebuffer::RenderPassAbstract;
|
use vulkano::framebuffer::RenderPassAbstract;
|
||||||
use vulkano::pipeline::{GraphicsPipelineAbstract, ComputePipeline};
|
use vulkano::pipeline::{GraphicsPipelineAbstract, ComputePipeline};
|
||||||
use vulkano::device::Device;
|
use vulkano::device::Device;
|
||||||
@@ -23,6 +22,7 @@ use crate::canvas::managed::handles::Handle;
|
|||||||
use crate::compute::managed::compu_buffer::CompuBuffers;
|
use crate::compute::managed::compu_buffer::CompuBuffers;
|
||||||
use crate::compute::managed::handles::{CompuKernelHandle, CompuBufferHandle};
|
use crate::compute::managed::handles::{CompuKernelHandle, CompuBufferHandle};
|
||||||
use crate::compute::managed::compu_kernel::CompuKernel;
|
use crate::compute::managed::compu_kernel::CompuKernel;
|
||||||
|
use crate::canvas::canvas_state::CanvasState;
|
||||||
|
|
||||||
|
|
||||||
/// State holding the compute buffers for computation and the kernels which will compute them
|
/// State holding the compute buffers for computation and the kernels which will compute them
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::canvas::canvas_state::{Drawable};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use crate::canvas::managed::handles::{CanvasImageHandle, CanvasTextureHandle};
|
use crate::canvas::managed::handles::{CanvasImageHandle, CanvasTextureHandle};
|
||||||
|
use crate::canvas::canvas_frame::Drawable;
|
||||||
|
|
||||||
pub struct CompuSprite {
|
pub struct CompuSprite {
|
||||||
pub vertices: [(f32, f32, f32); 6],
|
pub vertices: [(f32, f32, f32); 6],
|
||||||
|
|||||||
14
src/main.rs
14
src/main.rs
@@ -25,8 +25,9 @@ use crate::util::load_raw;
|
|||||||
use crate::sprite::{Poly, Text, TextHandle, TextVertex, TextInstance};
|
use crate::sprite::{Poly, Text, TextHandle, TextVertex, TextInstance};
|
||||||
use vulkano::instance::debug::DebugCallback;
|
use vulkano::instance::debug::DebugCallback;
|
||||||
use crate::compute::compu_frame::CompuFrame;
|
use crate::compute::compu_frame::CompuFrame;
|
||||||
use crate::canvas::canvas_frame::{CanvasFrame, GenericCanvasFrame};
|
use crate::canvas::canvas_frame::{CanvasFrame, DrawableTestee};
|
||||||
use crate::compute::managed::compu_sprite::CompuSprite;
|
use crate::compute::managed::compu_sprite::CompuSprite;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|
||||||
pub mod util;
|
pub mod util;
|
||||||
@@ -86,6 +87,17 @@ pub fn main() {
|
|||||||
processor.preload_fonts();
|
processor.preload_fonts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut v = vec![];
|
||||||
|
|
||||||
|
let d = DrawableTestee {
|
||||||
|
vertices: vec![],
|
||||||
|
instances: vec![],
|
||||||
|
handle: Arc::new(Default::default())
|
||||||
|
};
|
||||||
|
|
||||||
|
v.push(d);
|
||||||
|
|
||||||
|
|
||||||
let q2 = hprof::enter("Game Objects");
|
let q2 = hprof::enter("Game Objects");
|
||||||
|
|
||||||
let mut timer = Timer::new();
|
let mut timer = Timer::new();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use crate::util::vertex_3d::Vertex3D;
|
|||||||
use crate::canvas::*;
|
use crate::canvas::*;
|
||||||
use crate::canvas::managed::handles::{CanvasFontHandle, CanvasImageHandle, CanvasTextureHandle};
|
use crate::canvas::managed::handles::{CanvasFontHandle, CanvasImageHandle, CanvasTextureHandle};
|
||||||
use crate::canvas::managed::shader::text_shader::GlyphInstance;
|
use crate::canvas::managed::shader::text_shader::GlyphInstance;
|
||||||
use crate::canvas::canvas_state::{DrawableTest, Drawable};
|
use crate::canvas::canvas_frame::{DrawableTest, Drawable};
|
||||||
|
|
||||||
///
|
///
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@@ -98,21 +98,6 @@ impl Sprite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<H, In> DrawableTest<Vertex3D, H, In> for Sprite {
|
|
||||||
fn get_vertices(&self) -> Vec<Vertex3D> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_instances(&self) -> Vec<In> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_handle(&self) -> H {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Drawable for Sprite {
|
impl Drawable for Sprite {
|
||||||
fn get_vertices(&self) -> Vec<(f32, f32, f32)> {
|
fn get_vertices(&self) -> Vec<(f32, f32, f32)> {
|
||||||
self.vertices.to_vec()
|
self.vertices.to_vec()
|
||||||
@@ -302,17 +287,3 @@ pub trait TextInstance {
|
|||||||
pub trait TextVertex {
|
pub trait TextVertex {
|
||||||
fn get_vertices() -> Vec<(u32, u32, u32)>;
|
fn get_vertices() -> Vec<(u32, u32, u32)>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V: TextVertex, H, In: TextInstance> DrawableTest<V, H, In> for Text {
|
|
||||||
fn get_vertices(&self) -> Vec<V> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_instances(&self) -> Vec<In> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_handle(&self) -> H {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -19,7 +19,7 @@ use crate::util::vertex_3d::Vertex3D;
|
|||||||
use crate::canvas::canvas_state::CanvasState;
|
use crate::canvas::canvas_state::CanvasState;
|
||||||
use crate::canvas::managed::shader::generic_shader::GenericShader;
|
use crate::canvas::managed::shader::generic_shader::GenericShader;
|
||||||
use crate::canvas::managed::shader::text_shader::TextShader;
|
use crate::canvas::managed::shader::text_shader::TextShader;
|
||||||
use crate::canvas::managed::handles::{CanvasTextureHandle, CompiledGraphicsPipelineHandle, CanvasFontHandle, CanvasImageHandle};
|
use crate::canvas::managed::handles::{CanvasTextureHandle, CompiledShaderHandle, CanvasFontHandle, CanvasImageHandle};
|
||||||
use crate::compute::managed::handles::{CompuKernelHandle, CompuBufferHandle};
|
use crate::compute::managed::handles::{CompuKernelHandle, CompuBufferHandle};
|
||||||
|
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ impl<'a> VkProcessor<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// O(n) Lookup for the matching shader string
|
/// O(n) Lookup for the matching shader string
|
||||||
pub fn get_shader_handle(&self, shader_name: String) -> Option<Arc<CompiledGraphicsPipelineHandle>> {
|
pub fn get_shader_handle(&self, shader_name: String) -> Option<Arc<CompiledShaderHandle>> {
|
||||||
self.canvas_state.get_shader_handle(shader_name)
|
self.canvas_state.get_shader_handle(shader_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user