removed the extra stuff from the kernels. Having some issues with the layouts not agreeing with the set size...
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use crate::vertex_2d::{ColoredVertex2D, Vertex2D};
|
||||
use vulkano::command_buffer::{AutoCommandBufferBuilder, DynamicState};
|
||||
|
||||
use std::collections::HashMap;
|
||||
use vulkano::buffer::{BufferAccess, BufferUsage, ImmutableBuffer};
|
||||
use std::sync::Arc;
|
||||
@@ -19,7 +18,6 @@ use image::GenericImageView;
|
||||
use crate::util::compute_image::ComputeImage;
|
||||
use std::iter::FromIterator;
|
||||
use vulkano::swapchain::Capabilities;
|
||||
|
||||
use winit::Window;
|
||||
use vulkano::pipeline::viewport::Viewport;
|
||||
|
||||
@@ -128,7 +126,7 @@ impl Canvas {
|
||||
|
||||
let shader_kernels = HashMap::from_iter(vec![
|
||||
(ShaderType::SOLID, ShaderKernels::new(solid_color_kernel, capabilities.clone(), queue.clone(), physical.clone(), device.clone())),
|
||||
(ShaderType::TEXTURED, ShaderKernels::new(texture_kernel, capabilities.clone(), queue.clone(), physical.clone(), device.clone()))
|
||||
//(ShaderType::TEXTURED, ShaderKernels::new(texture_kernel, capabilities.clone(), queue.clone(), physical.clone(), device.clone()))
|
||||
]);
|
||||
|
||||
Canvas {
|
||||
@@ -271,6 +269,9 @@ impl Canvas {
|
||||
}
|
||||
|
||||
fn get_solid_color_descriptor_set(&self) -> Box<dyn DescriptorSet + Send + Sync> {
|
||||
|
||||
println!("{}", self.shader_kernels.get(&ShaderType::SOLID).unwrap().clone().get_pipeline().clone().num_sets());
|
||||
|
||||
let o: Box<dyn DescriptorSet + Send + Sync> = Box::new(
|
||||
PersistentDescriptorSet::start(
|
||||
self.shader_kernels.get(&ShaderType::SOLID).unwrap().clone().get_pipeline().clone(), 0
|
||||
@@ -338,11 +339,11 @@ impl Canvas {
|
||||
).unwrap();
|
||||
},
|
||||
ShaderType::TEXTURED => {
|
||||
command_buffer = command_buffer.draw(
|
||||
kernel.clone().get_pipeline().clone(),
|
||||
&dynamic_state.clone(), self.colored_vertex_buffer.clone(),
|
||||
vec![self.get_textured_descriptor_set(String::from("funky-bird"))], ()
|
||||
).unwrap();
|
||||
// command_buffer = command_buffer.draw(
|
||||
// kernel.clone().get_pipeline().clone(),
|
||||
// &dynamic_state.clone(), self.textured_vertex_buffer.clone(),
|
||||
// vec![self.get_textured_descriptor_set(String::from("funky-bird.jpg"))], ()
|
||||
// ).unwrap();
|
||||
},
|
||||
ShaderType::COMPUTE => {},
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use std::collections::HashSet;
|
||||
use sfml::window::{Key, Event, mouse::Button};
|
||||
|
||||
|
||||
pub struct Input {
|
||||
held_keys: HashSet<Key>,
|
||||
held_mouse: HashSet<u8>,
|
||||
|
||||
30
src/main.rs
30
src/main.rs
@@ -10,36 +10,11 @@ extern crate rand;
|
||||
extern crate sfml;
|
||||
extern crate time;
|
||||
|
||||
|
||||
|
||||
use sfml::system::*;
|
||||
|
||||
|
||||
|
||||
|
||||
use vulkano::sync;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
use crate::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;
|
||||
@@ -47,7 +22,6 @@ use sprite::Sprite;
|
||||
|
||||
|
||||
mod util;
|
||||
|
||||
mod slider;
|
||||
mod timer;
|
||||
mod input;
|
||||
@@ -73,7 +47,8 @@ fn main() {
|
||||
|
||||
let mut processor = vkprocessor::VkProcessor::new(&instance, &surface);
|
||||
processor.compile_kernel(String::from("simple-edge.compute"));
|
||||
processor.load_textures(String::from("background.jpg"));
|
||||
processor.load_compute_image(String::from("background.jpg"));
|
||||
processor.load_textures(String::from("funky-bird.jpg"));
|
||||
processor.create_swapchain(&surface);
|
||||
|
||||
let mut timer = Timer::new();
|
||||
@@ -136,6 +111,7 @@ fn main() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
(frame_future) = processor.run(&surface, frame_future);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
use crate::canvas::Drawable;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer};
|
||||
|
||||
use vulkano::descriptor::descriptor_set::{PersistentDescriptorSet};
|
||||
use vulkano::device::{Device};
|
||||
use vulkano::pipeline::{ComputePipeline};
|
||||
|
||||
@@ -1,43 +1,14 @@
|
||||
|
||||
|
||||
|
||||
use vulkano::device::{Device};
|
||||
|
||||
use vulkano::pipeline::{ComputePipeline};
|
||||
|
||||
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::ffi::CStr;
|
||||
use std::path::PathBuf;
|
||||
use shade_runner as sr;
|
||||
|
||||
|
||||
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};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ComputeKernel {
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ use crate::util::compute_image::ComputeImage;
|
||||
use crate::canvas::Canvas;
|
||||
|
||||
pub struct VkProcessor<'a> {
|
||||
|
||||
// Vulkan state fields
|
||||
pub instance: Arc<Instance>,
|
||||
pub physical: PhysicalDevice<'a>,
|
||||
@@ -20,7 +21,6 @@ pub struct VkProcessor<'a> {
|
||||
pub queue: Arc<Queue>,
|
||||
pub dynamic_state: DynamicState,
|
||||
|
||||
// TODO: This will need to handle multiple of each type
|
||||
pub compute_kernel: Option<ComputeKernel>,
|
||||
pub compute_image: Option<ComputeImage>,
|
||||
|
||||
@@ -138,10 +138,7 @@ impl<'a> VkProcessor<'a> {
|
||||
self.compute_image = Some(ComputeImage::new(self.device.clone(), image_filename.clone()));
|
||||
}
|
||||
|
||||
pub fn load_textures(&mut self, image_filename: String)
|
||||
{
|
||||
self.load_compute_image(image_filename.clone());
|
||||
|
||||
pub fn load_textures(&mut self, image_filename: String) {
|
||||
self.canvas.load_texture_from_filename(image_filename.clone());
|
||||
}
|
||||
|
||||
@@ -149,7 +146,6 @@ impl<'a> VkProcessor<'a> {
|
||||
self.compute_image.clone().unwrap().clone().save_image();
|
||||
}
|
||||
|
||||
|
||||
pub fn run(&mut self,
|
||||
surface: &'a Arc<Surface<Window>>,
|
||||
mut frame_future: Box<dyn GpuFuture>,
|
||||
@@ -180,7 +176,6 @@ impl<'a> VkProcessor<'a> {
|
||||
Err(err) => panic!("{:?}", err)
|
||||
};
|
||||
|
||||
|
||||
let xy = self.compute_image.clone().unwrap().get_size();
|
||||
|
||||
let mut command_buffer =
|
||||
|
||||
Reference in New Issue
Block a user