Moved the framebuffer gen to the canvas. Cleaned up a lot of unused imports
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
use crate::vertex_2d::{ColoredVertex2D, Vertex2D};
|
||||
use vulkano::command_buffer::{AutoCommandBufferBuilder, DynamicState};
|
||||
use crate::Sprite;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use vulkano::buffer::{BufferAccess, CpuAccessibleBuffer, BufferUsage, ImmutableBuffer};
|
||||
use vulkano::buffer::{BufferAccess, BufferUsage, ImmutableBuffer};
|
||||
use std::sync::Arc;
|
||||
use vulkano::format::{ClearValue, Format};
|
||||
use vulkano::framebuffer::FramebufferAbstract;
|
||||
use vulkano::framebuffer::{FramebufferAbstract, Framebuffer};
|
||||
use vulkano::device::{Device, Queue};
|
||||
use vulkano::instance::PhysicalDevice;
|
||||
use vulkano::image::immutable::ImmutableImage;
|
||||
use crate::util::shader_kernels::ShaderKernels;
|
||||
use vulkano::image::{Dimensions, ImageUsage, ImageAccess, ImageDimensions};
|
||||
use vulkano::image::{Dimensions, ImageAccess, ImageDimensions, SwapchainImage};
|
||||
use vulkano::sampler::{Sampler, SamplerAddressMode, MipmapMode, Filter};
|
||||
use vulkano::descriptor::DescriptorSet;
|
||||
use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
|
||||
@@ -19,7 +19,10 @@ use image::GenericImageView;
|
||||
use crate::util::compute_image::ComputeImage;
|
||||
use std::iter::FromIterator;
|
||||
use vulkano::swapchain::Capabilities;
|
||||
use shaderc::TargetEnv;
|
||||
|
||||
use winit::Window;
|
||||
use vulkano::pipeline::viewport::Viewport;
|
||||
|
||||
// Canvas is the accumulator of Sprites for drawing
|
||||
|
||||
// Needs to know:
|
||||
@@ -32,8 +35,6 @@ use shaderc::TargetEnv;
|
||||
If it is textured. It needs to be rendered with the texture shader which requires a separate
|
||||
graphics pipeline. Might as well have a new render pass as well.
|
||||
|
||||
I need a second version of shaderkernels
|
||||
|
||||
|
||||
So framebuffer is tied to the swapchains images as well as the renderpass
|
||||
|
||||
@@ -50,28 +51,6 @@ it appears that renderpass is tied to the individual shader
|
||||
// The rest will be grouped by their texture and run individually
|
||||
|
||||
|
||||
/*
|
||||
|
||||
vertex count differing is a big nono
|
||||
|
||||
ColoredVertex2D
|
||||
Non-Textured
|
||||
|
||||
Vertex2D
|
||||
Textured
|
||||
|
||||
Colored, vs non-colored:
|
||||
Calling the color() field or not
|
||||
|
||||
|
||||
|
||||
|
||||
I just wanna
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
pub trait Vertex {
|
||||
fn position(&self) -> (f32, f32) {
|
||||
(0.0,0.0)
|
||||
@@ -215,7 +194,7 @@ impl Canvas {
|
||||
|
||||
pub fn load_texture_from_filename(&mut self, filename: String) -> Arc<ImmutableImage<Format>> {
|
||||
|
||||
if (self.texture_store.contains_key(&filename.clone())) {
|
||||
if self.texture_store.contains_key(&filename.clone()) {
|
||||
println!("{} Already exists, not going to replace it.", filename.clone());
|
||||
self.texture_store.get(&filename.clone()).unwrap().clone()
|
||||
} else {
|
||||
@@ -331,31 +310,9 @@ impl Canvas {
|
||||
o
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
So I need the image set in order to get my texture or compute texture
|
||||
Done
|
||||
|
||||
compute image currently holds the set for compute and its swap buffer
|
||||
but during a descriptor set build, we corrow the compute_image and take
|
||||
it's swap buffer
|
||||
|
||||
vkprocessor creates the image sets for draw calls
|
||||
|
||||
takes the pipeline from the ShaderKernel - Which we own
|
||||
adds vk processor owned texture - Not any more
|
||||
adds compute image taken from the ComputeImage - Still true
|
||||
|
||||
we have shaderkernel in here so thats fine
|
||||
Who should own the texture?
|
||||
I would need to borrow it each time I created an image set...
|
||||
These are tied very closely to the input output of a shader, which we would own
|
||||
|
||||
|
||||
I just need to add a third option on sprite and allow it to have a swap buffer
|
||||
*/
|
||||
|
||||
|
||||
pub fn draw_commands(&self,
|
||||
mut command_buffer: AutoCommandBufferBuilder,
|
||||
framebuffers: Vec<Arc<dyn FramebufferAbstract + Send + Sync>>,
|
||||
@@ -395,6 +352,33 @@ impl Canvas {
|
||||
.end_render_pass()
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
/// This method is called once during initialization, then again whenever the window is resized
|
||||
pub fn window_size_dependent_setup(&self,
|
||||
images: &[Arc<SwapchainImage<Window>>],
|
||||
) -> Vec<Arc<dyn FramebufferAbstract + Send + Sync>> {
|
||||
|
||||
let dimensions = images[0].dimensions();
|
||||
|
||||
let mut dynamic_state = DynamicState {
|
||||
line_width: None,
|
||||
viewports: Some(vec![Viewport {
|
||||
origin: [0.0, 0.0],
|
||||
dimensions: [dimensions.width() as f32, dimensions.height() as f32],
|
||||
depth_range: 0.0..1.0,
|
||||
}]),
|
||||
scissors: None
|
||||
};
|
||||
|
||||
images.iter().map(|image| {
|
||||
Arc::new(
|
||||
Framebuffer::start(self.shader_kernels.get(&ShaderType::SOLID).unwrap().render_pass.clone())
|
||||
.add(image.clone()).unwrap()
|
||||
.build().unwrap()
|
||||
) as Arc<dyn FramebufferAbstract + Send + Sync>
|
||||
}).collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user