|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer, DeviceLocalBuffer, ImmutableBuffer, BufferAccess};
|
|
|
|
|
use vulkano::command_buffer::{AutoCommandBufferBuilder, DynamicState};
|
|
|
|
|
use vulkano::descriptor::descriptor_set::{PersistentDescriptorSet, StdDescriptorPoolAlloc, PersistentDescriptorSetBuilder};
|
|
|
|
|
use vulkano::descriptor::descriptor_set::{PersistentDescriptorSet, StdDescriptorPoolAlloc, PersistentDescriptorSetBuilder, FixedSizeDescriptorSetsPool, StdDescriptorPool};
|
|
|
|
|
use vulkano::descriptor::descriptor_set::collection::DescriptorSetsCollection;
|
|
|
|
|
use vulkano::device::{Device, DeviceExtensions, QueuesIter, Queue};
|
|
|
|
|
use vulkano::instance::{Instance, InstanceExtensions, PhysicalDevice, QueueFamily};
|
|
|
|
|
use vulkano::pipeline::{ComputePipeline, GraphicsPipeline, GraphicsPipelineAbstract};
|
|
|
|
@ -42,6 +43,53 @@ use crate::vkprocessor::compute_kernel::ComputeKernel;
|
|
|
|
|
|
|
|
|
|
mod shader_kernels;
|
|
|
|
|
use crate::vkprocessor::shader_kernels::ShaderKernels;
|
|
|
|
|
use vulkano::descriptor::descriptor::DescriptorDesc;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
//#[derive(Clone)]
|
|
|
|
|
//struct ImageBuffers {
|
|
|
|
|
// pub image_buffers : Vec<Box<ImageAccess + Send + Sync>>,
|
|
|
|
|
//}
|
|
|
|
|
//
|
|
|
|
|
//impl ImageBuffers {
|
|
|
|
|
//
|
|
|
|
|
// pub fn new() -> ImageBuffers {
|
|
|
|
|
// ImageBuffers {
|
|
|
|
|
// image_buffers: vec![]
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// pub fn add_image(self) -> Self {
|
|
|
|
|
//
|
|
|
|
|
// self
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
//
|
|
|
|
|
//unsafe impl DescriptorSetsCollection for ImageBuffers {
|
|
|
|
|
// fn into_vec(self) -> Vec<Box<DescriptorSet>> {
|
|
|
|
|
// unimplemented!()
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// fn num_bindings_in_set(&self, set: usize) -> Option<usize> {
|
|
|
|
|
// unimplemented!()
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// fn descriptor(&self, set: usize, binding: usize) -> Option<DescriptorDesc> {
|
|
|
|
|
// unimplemented!()
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Default, Debug, Clone)]
|
|
|
|
@ -103,7 +151,6 @@ unsafe impl SpecializationConstants for SimpleSpecializationConstants {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub struct VkProcessor<'a> {
|
|
|
|
|
pub shader_kernels: Option<ShaderKernels>,
|
|
|
|
|
pub compute_kernel: Option<ComputeKernel>,
|
|
|
|
@ -133,7 +180,7 @@ pub struct VkProcessor<'a> {
|
|
|
|
|
|
|
|
|
|
pub image_buffer_store : Vec<Box<ImageAccess + Send + Sync>>,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// pub image_buffers_obj : ImageBuffers,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -181,7 +228,8 @@ impl<'a> VkProcessor<'a> {
|
|
|
|
|
dynamic_state: DynamicState { line_width: None, viewports: None, scissors: None },
|
|
|
|
|
graphics_image_swap_buffer: None,
|
|
|
|
|
|
|
|
|
|
image_buffer_store: vec![]
|
|
|
|
|
image_buffer_store: vec![],
|
|
|
|
|
//image_buffers_obj: ImageBuffers::new(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -320,18 +368,7 @@ impl<'a> VkProcessor<'a> {
|
|
|
|
|
usage)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
// img_set is only used in the run()'s command buffer construction
|
|
|
|
|
// So, adding a get image set function, I can just build lazily
|
|
|
|
|
|
|
|
|
|
self.img_set = Some(Arc::new(PersistentDescriptorSet::start(
|
|
|
|
|
self.shader_kernels.clone().unwrap().graphics_pipeline.clone().unwrap().clone(), 0)
|
|
|
|
|
.add_sampled_image(texture.clone(), sampler.clone()).unwrap()
|
|
|
|
|
.add_image(compute_transfer_image.clone().unwrap().clone()).unwrap()
|
|
|
|
|
.build().unwrap()));
|
|
|
|
|
self.image_buffer_store.push(Box::new(texture.clone()));
|
|
|
|
|
|
|
|
|
|
self.graphics_image_buffer = Some(texture.clone());
|
|
|
|
|
self.graphics_image_swap_buffer = Some(compute_transfer_image.clone().unwrap());
|
|
|
|
@ -348,6 +385,12 @@ impl<'a> VkProcessor<'a> {
|
|
|
|
|
MipmapMode::Nearest, SamplerAddressMode::Repeat, SamplerAddressMode::Repeat,
|
|
|
|
|
SamplerAddressMode::Repeat, 0.0, 1.0, 0.0, 0.0).unwrap();
|
|
|
|
|
|
|
|
|
|
let mut descriptor_sets = PersistentDescriptorSet::start(
|
|
|
|
|
self.shader_kernels.clone().unwrap().graphics_pipeline.clone().unwrap().clone(), 0
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let descriptor_sets = descriptor_sets.add_sampled_image(self.graphics_image_buffer.clone().unwrap().clone(), sampler.clone()).unwrap();
|
|
|
|
|
|
|
|
|
|
let o : Box<DescriptorSet + Send + Sync> = Box::new(
|
|
|
|
|
PersistentDescriptorSet::start(
|
|
|
|
|
self.shader_kernels.clone().unwrap().graphics_pipeline.clone().unwrap().clone(), 0
|
|
|
|
@ -355,7 +398,6 @@ impl<'a> VkProcessor<'a> {
|
|
|
|
|
.add_sampled_image(self.graphics_image_buffer.clone().unwrap().clone(), sampler.clone()).unwrap()
|
|
|
|
|
.add_image(self.graphics_image_swap_buffer.clone().unwrap().clone()).unwrap()
|
|
|
|
|
.build().unwrap());
|
|
|
|
|
|
|
|
|
|
o
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -425,8 +467,7 @@ impl<'a> VkProcessor<'a> {
|
|
|
|
|
|
|
|
|
|
.draw(self.shader_kernels.clone().unwrap().graphics_pipeline.clone().unwrap().clone(),
|
|
|
|
|
&self.dynamic_state.clone(), v,
|
|
|
|
|
//self.img_set.clone().unwrap().clone(), ())
|
|
|
|
|
self.get_image_set(), ())
|
|
|
|
|
vec![self.get_image_set()], ())
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
|
|
.end_render_pass()
|
|
|
|
|