adding a second image buffer for GPU only access. Immutable buffer is write once for textures only. No sampler for regular image buffer though??

master
mitchellhansen 5 years ago
parent 937b4fc8ca
commit 4d5b09e9ca

@ -31,6 +31,7 @@ use std::alloc::Layout;
use vulkano::pipeline::viewport::Viewport;
use image::ImageFormat;
use vulkano::image::immutable::ImmutableImage;
use vulkano::image::attachment::AttachmentImage;
use vulkano::image::Dimensions;
use vulkano::format::Format;
use vulkano::sampler::{Sampler, Filter, MipmapMode, SamplerAddressMode};
@ -114,6 +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>,
}
@ -157,6 +159,7 @@ impl<'a> VkProcessor<'a> {
render_pass: Option::None,
vertex_buffer: Option::None,
dynamic_state: DynamicState { line_width: None, viewports: None, scissors: None },
graphics_iamge_swap_buffer: None,
}
}
@ -338,6 +341,17 @@ impl<'a> VkProcessor<'a> {
).unwrap()
};
let 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(),
[dimensions.0, dimensions.1],
Format::R8G8B8A8Srgb)
};
let sampler = Sampler::new(self.device.clone(), Filter::Linear, Filter::Linear,
MipmapMode::Nearest, SamplerAddressMode::Repeat, SamplerAddressMode::Repeat,
SamplerAddressMode::Repeat, 0.0, 1.0, 0.0, 0.0).unwrap();
@ -381,9 +395,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()
.build().unwrap()));
self.graphics_image_buffer = Some(texture.clone());
self.graphics_iamge_swap_buffer = Some(image.clone().unwrap());
}

Loading…
Cancel
Save