removed the extra stuff from the kernels. Having some issues with the layouts not agreeing with the set size...

master
mitchellhansen 5 years ago
parent dfd4cbb6a2
commit 0be20eb959

@ -1,12 +1,8 @@
#version 450
layout(location = 0) in vec2 tex_coords;
layout(location = 1) in vec4 out_color;
layout(location = 0) in vec4 out_color;
layout(location = 0) out vec4 f_color;
layout(set = 0, binding = 0) uniform sampler2D tex;
layout(set = 0, binding = 1, rgba32ui) readonly uniform uimage2D img;
void main() {
f_color = out_color;
}

@ -2,8 +2,7 @@
layout(location = 0) in vec2 position;
layout(location = 1) in vec4 color;
layout(location = 0) out vec2 tex_coords;
layout(location = 1) out vec4 out_color;
layout(location = 0) out vec4 out_color;
void main() {
out_color = color;

@ -1,21 +1,18 @@
#version 450
layout(location = 0) in vec2 tex_coords;
layout(location = 1) in vec4 out_color;
layout(location = 0) out vec4 f_color;
layout(set = 0, binding = 0) uniform sampler2D tex;
layout(set = 0, binding = 1, rgba32ui) readonly uniform uimage2D img;
void main() {
ivec2 pos = ivec2(gl_FragCoord.x, gl_FragCoord.y);
f_color = imageLoad(img, ivec2(pos)) / (255.0);
// f_color = imageLoad(img, ivec2(pos)) / (255.0);
//
// float gamma = 0.5;
// f_color.rgb = pow(f_color.rgb, vec3(1.0/gamma));
float gamma = 0.5;
f_color.rgb = pow(f_color.rgb, vec3(1.0/gamma));
//f_color = out_color;
// f_color = texture(tex, tex_coords);
f_color = texture(tex, tex_coords);
}

@ -1,12 +1,9 @@
#version 450
layout(location = 0) in vec2 position;
layout(location = 1) in vec4 color;
layout(location = 0) out vec2 tex_coords;
layout(location = 1) out vec4 out_color;
void main() {
out_color = color;
gl_Position = vec4(position, 0.0, 1.0);
tex_coords = position;

@ -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>,

@ -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 =

Loading…
Cancel
Save