|
|
|
@ -20,20 +20,19 @@ use vulkano::pipeline::viewport::Viewport;
|
|
|
|
|
use vulkano::descriptor::descriptor::DescriptorDescTy::TexelBuffer;
|
|
|
|
|
use crate::canvas::canvas_frame::CanvasFrame;
|
|
|
|
|
use std::hash::Hash;
|
|
|
|
|
use crate::canvas::canvas_buffer::{CanvasImage, CanvasTexture, CanvasFont};
|
|
|
|
|
use crate::util::vertex_3d::{Vertex3D, TextVertex3D};
|
|
|
|
|
use vulkano::pipeline::depth_stencil::{StencilFaceFlags, DynamicStencilValue};
|
|
|
|
|
use crate::canvas::shader::common::{CompiledGraphicsPipeline};
|
|
|
|
|
use crate::canvas::shader::generic_shader::GenericShader;
|
|
|
|
|
use vulkano::memory::pool::PotentialDedicatedAllocation::Generic;
|
|
|
|
|
use std::borrow::Borrow;
|
|
|
|
|
use crate::canvas::shader::text_shader::GlyphInstance;
|
|
|
|
|
use std::fs::File;
|
|
|
|
|
use std::io::Read;
|
|
|
|
|
use rusttype::{Font, PositionedGlyph, Scale, Rect, point, GlyphId};
|
|
|
|
|
use vulkano::pipeline::vertex::VertexDefinition;
|
|
|
|
|
use crate::canvas::{CanvasTextureHandle, CanvasImageHandle, CompiledGraphicsPipelineHandle, Handle};
|
|
|
|
|
use crate::canvas::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::gpu_buffers::{CanvasImage, CanvasTexture, CanvasFont};
|
|
|
|
|
use crate::canvas::managed::shader::shader_common::CompiledGraphicsPipeline;
|
|
|
|
|
use crate::canvas::managed::shader::generic_shader::GenericShader;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// I don't think this is going to work without getting into Box'ing
|
|
|
|
@ -72,19 +71,6 @@ pub trait Drawable {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Typed wrapper for a u32 font handle (index id)
|
|
|
|
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
|
|
|
|
|
pub struct CanvasFontHandle {
|
|
|
|
|
handle: u32
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Handle for CanvasFontHandle {
|
|
|
|
|
fn get_handle(&self) -> u32 {
|
|
|
|
|
self.handle
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// 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
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
@ -251,7 +237,7 @@ impl CanvasState {
|
|
|
|
|
|
|
|
|
|
/// Return the image buffer from an input image handle
|
|
|
|
|
pub fn get_image(&self, image_handle: Arc<CanvasImageHandle>) -> Arc<AttachmentImage> {
|
|
|
|
|
self.image_buffers.get((*image_handle).clone().handle as usize).unwrap()
|
|
|
|
|
self.image_buffers.get((*image_handle).clone().get_handle() as usize).unwrap()
|
|
|
|
|
.clone().buffer.clone()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -418,7 +404,7 @@ impl CanvasState {
|
|
|
|
|
/// Using the texture handle, grab the stored texture and return the buffer
|
|
|
|
|
pub fn get_texture(&self, texture_handle: Arc<CanvasTextureHandle>)
|
|
|
|
|
-> Arc<ImmutableImage<Format>> {
|
|
|
|
|
let handle = texture_handle.handle as usize;
|
|
|
|
|
let handle = texture_handle.get_handle() as usize;
|
|
|
|
|
|
|
|
|
|
if let Some(i) = self.texture_buffers.get(handle) {
|
|
|
|
|
return i.clone().buffer.clone();
|
|
|
|
@ -550,7 +536,7 @@ impl CanvasState {
|
|
|
|
|
// Solid colors
|
|
|
|
|
let mut shader = self.shader_buffers.get(
|
|
|
|
|
self.get_shader_handle(String::from("color-passthrough"))
|
|
|
|
|
.unwrap().clone().handle as usize
|
|
|
|
|
.unwrap().clone().get_handle() as usize
|
|
|
|
|
).unwrap();
|
|
|
|
|
|
|
|
|
|
// This looks a little weird as colored_vertex_buffer is a vec of GPU allocated vecs.
|
|
|
|
@ -568,12 +554,12 @@ impl CanvasState {
|
|
|
|
|
// Images
|
|
|
|
|
let mut shader = self.shader_buffers.get(
|
|
|
|
|
self.get_shader_handle(String::from("simple_image"))
|
|
|
|
|
.unwrap().clone().handle as usize
|
|
|
|
|
.unwrap().clone().get_handle() as usize
|
|
|
|
|
).unwrap();
|
|
|
|
|
|
|
|
|
|
if !self.image_vertex_buffer.is_empty() {
|
|
|
|
|
for (image_handle, vertex_buffer) in self.image_vertex_buffer.clone() {
|
|
|
|
|
let handle = image_handle.clone().handle as usize;
|
|
|
|
|
let handle = image_handle.clone().get_handle() as usize;
|
|
|
|
|
let descriptor_set = self.image_buffers.get(handle).clone().unwrap().clone()
|
|
|
|
|
.get_descriptor_set(shader.get_pipeline().clone());
|
|
|
|
|
|
|
|
|
@ -589,12 +575,12 @@ impl CanvasState {
|
|
|
|
|
// Textures
|
|
|
|
|
let mut shader = self.shader_buffers.get(
|
|
|
|
|
self.get_shader_handle(String::from("simple_texture"))
|
|
|
|
|
.unwrap().clone().handle as usize
|
|
|
|
|
.unwrap().clone().get_handle() as usize
|
|
|
|
|
).unwrap();
|
|
|
|
|
|
|
|
|
|
if !self.textured_vertex_buffer.is_empty() {
|
|
|
|
|
for (texture_handle, vertex_buffer) in self.textured_vertex_buffer.clone() {
|
|
|
|
|
let handle = texture_handle.clone().handle as usize;
|
|
|
|
|
let handle = texture_handle.clone().get_handle() as usize;
|
|
|
|
|
let descriptor_set = self.texture_buffers.get(handle).clone().unwrap().clone()
|
|
|
|
|
.get_descriptor_set(shader.get_pipeline(), self.sampler.clone());
|
|
|
|
|
|
|
|
|
@ -610,7 +596,7 @@ impl CanvasState {
|
|
|
|
|
// Text
|
|
|
|
|
let mut shader = self.shader_buffers.get(
|
|
|
|
|
self.get_shader_handle(String::from("simple_text"))
|
|
|
|
|
.unwrap().clone().handle as usize
|
|
|
|
|
.unwrap().clone().get_handle() as usize
|
|
|
|
|
).unwrap();
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|