Got something working. Need to test and verify I'm getting the data from the compute kernel

master
mitchellhansen 6 years ago
parent 4d5b09e9ca
commit 26410b78a2

@ -17,7 +17,7 @@ vulkano-shaders = "0.13.0"
vulkano-win = "0.13.0"
time = "0.1.38"
shaderc = "0.5.0"
shade_runner = {version = "0.1.1", git = "https://github.com/MitchellHansen/shade_runner"}
#shade_runner = {path = "../shade_runner"}
#shade_runner = {version = "0.1.1", git = "https://github.com/MitchellHansen/shade_runner"}
shade_runner = {path = "../shade_runner"}
winit = "0.19.1"

@ -0,0 +1,9 @@
StorageImage
General-purpose image in device memory.
AttachmentImage
ImageAccess whose purpose is to be used as a framebuffer attachment

@ -2,6 +2,7 @@
layout(location = 0) in vec2 tex_coords;
layout(location = 0) out vec4 f_color;
layout(set = 0, binding = 0) uniform sampler2D tex;
layout(set = 0, binding = 1, rgba8ui) readonly uniform uimage2D img;
void main() {
f_color = texture(tex, tex_coords);
}

@ -5,3 +5,7 @@ void main() {
gl_Position = vec4(position, 0.0, 1.0);
tex_coords = position;
}

@ -32,7 +32,7 @@ use vulkano::pipeline::viewport::Viewport;
use image::ImageFormat;
use vulkano::image::immutable::ImmutableImage;
use vulkano::image::attachment::AttachmentImage;
use vulkano::image::Dimensions;
use vulkano::image::{Dimensions, ImageUsage};
use vulkano::format::Format;
use vulkano::sampler::{Sampler, Filter, MipmapMode, SamplerAddressMode};
@ -104,7 +104,7 @@ pub struct VkProcessor<'a> {
pub queues: QueuesIter,
pub queue: Arc<Queue>,
pub compute_set: Option<Arc<PersistentDescriptorSet<std::sync::Arc<ComputePipeline<PipelineLayout<shade_runner::layouts::ComputeLayout>>>, ((((), PersistentDescriptorSetBuf<std::sync::Arc<vulkano::buffer::cpu_access::CpuAccessibleBuffer<[u8]>>>), PersistentDescriptorSetBuf<std::sync::Arc<vulkano::buffer::cpu_access::CpuAccessibleBuffer<[u8]>>>), PersistentDescriptorSetBuf<std::sync::Arc<vulkano::buffer::cpu_access::CpuAccessibleBuffer<[u32]>>>)>>>,
pub img_set: Option<Arc<PersistentDescriptorSet<Arc<dyn GraphicsPipelineAbstract + Send + Sync>, (((), PersistentDescriptorSetImg<Arc<ImmutableImage<Format>>>), PersistentDescriptorSetSampler)>>>,
pub img_set: Option<Arc<PersistentDescriptorSet<Arc<dyn GraphicsPipelineAbstract + Send + Sync>, ((((), PersistentDescriptorSetImg<Arc<ImmutableImage<Format>>>), PersistentDescriptorSetSampler), PersistentDescriptorSetImg<Arc<AttachmentImage>>)>>>,
pub graphics_image_buffer: Option<Arc<ImmutableImage<Format>>>,
pub image_buffer: Vec<u8>,
pub img_buffers: Vec<Arc<CpuAccessibleBuffer<[u8]>>>,
@ -115,7 +115,7 @@ pub struct VkProcessor<'a> {
pub render_pass: Option<Arc<RenderPassAbstract + Send + Sync>>,
pub vertex_buffer: Option<Arc<(dyn BufferAccess + std::marker::Send + std::marker::Sync + 'static)>>,
pub dynamic_state: DynamicState,
pub graphics_iamge_swap_buffer: Option<i32>,
pub graphics_iamge_swap_buffer: Option<std::sync::Arc<vulkano::image::attachment::AttachmentImage>>,
}
@ -341,15 +341,21 @@ impl<'a> VkProcessor<'a> {
).unwrap()
};
let image = {
let attachment_image = {
let image = image::load_from_memory_with_format(include_bytes!("../resources/images/funky-bird.jpg"),
ImageFormat::JPEG).unwrap().to_rgba();
let dimensions = image.dimensions();
let image_data = image.into_raw().clone();
AttachmentImage::new(self.device.clone(),
let mut usage = ImageUsage::none();
usage.transfer_destination = true;
usage.storage = true;
AttachmentImage::with_usage(
self.device.clone(),
[dimensions.0, dimensions.1],
Format::R8G8B8A8Srgb)
Format::R8G8B8A8Uint,
usage)
};
let sampler = Sampler::new(self.device.clone(), Filter::Linear, Filter::Linear,
@ -395,11 +401,11 @@ impl<'a> VkProcessor<'a> {
self.img_set = Some(Arc::new(PersistentDescriptorSet::start(self.graphics_pipeline.clone().unwrap().clone(), 0)
.add_sampled_image(texture.clone(), sampler.clone()).unwrap()
.add_image(image.unwrap().clone()).unwrap()
.add_image(attachment_image.clone().unwrap().clone()).unwrap()
.build().unwrap()));
self.graphics_image_buffer = Some(texture.clone());
self.graphics_iamge_swap_buffer = Some(image.clone().unwrap());
self.graphics_iamge_swap_buffer = Some(attachment_image.clone().unwrap());
}

Loading…
Cancel
Save