easiest solution there was just to remove the unclonable objects from ShaderKernels
This commit is contained in:
@@ -105,7 +105,7 @@ unsafe impl SpecializationConstants for SimpleSpecializationConstants {
|
||||
|
||||
|
||||
pub struct VkProcessor<'a> {
|
||||
pub shader_kernels: Option<Arc<ShaderKernels<'a>>>,
|
||||
pub shader_kernels: Option<ShaderKernels>,
|
||||
pub compute_kernel: Option<ComputeKernel>,
|
||||
pub vertex_shader_path: PathBuf,
|
||||
pub fragment_shader_path: PathBuf,
|
||||
@@ -185,17 +185,17 @@ impl<'a> VkProcessor<'a> {
|
||||
}
|
||||
|
||||
pub fn compile_shaders(&mut self, filename: String, surface: &'a Arc<Surface<Window>>) {
|
||||
self.shader_kernels = Some(Arc::new(
|
||||
self.shader_kernels = Some(
|
||||
ShaderKernels::new(filename.clone(),
|
||||
surface, self.queue.clone(),
|
||||
self.physical,
|
||||
self.device.clone())
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
// On resizes we have to recreate the swapchain
|
||||
pub fn recreate_swapchain(&mut self, surface: &'a Arc<Surface<Window>>) {
|
||||
//self.shader_kernels.unwrap().recreate_swapchain(surface);
|
||||
self.shader_kernels = Some(self.shader_kernels.take().unwrap().recreate_swapchain(surface));
|
||||
}
|
||||
|
||||
pub fn load_buffers(&mut self, image_filename: String)
|
||||
|
||||
@@ -50,14 +50,15 @@ struct EntryPoint<'a> {
|
||||
#[derive(Default, Debug, Clone)]
|
||||
struct tVertex { position: [f32; 2] }
|
||||
|
||||
pub struct ShaderKernels<'a> {
|
||||
#[derive(Clone)]
|
||||
pub struct ShaderKernels {
|
||||
pub swapchain : Arc<Swapchain<Window>>,
|
||||
pub swapchain_images: Vec<Arc<SwapchainImage<Window>>>, // Surface which is drawn to
|
||||
pub physical: PhysicalDevice<'a>,
|
||||
//pub physical: PhysicalDevice<'a>,
|
||||
|
||||
// shader: CompiledShaders,
|
||||
|
||||
options: CompileOptions<'a>,
|
||||
//options: CompileOptions<'a>,
|
||||
|
||||
pub render_pass: Arc<RenderPassAbstract + Send + Sync>,
|
||||
pub graphics_pipeline: Option<Arc<GraphicsPipelineAbstract + Sync + Send>>,
|
||||
@@ -74,7 +75,7 @@ window_size_dependent_setup(&self.images.clone().unwrap().clone(),
|
||||
self.render_pass.clone().unwrap().clone(),
|
||||
&mut self.dynamic_state);
|
||||
*/
|
||||
impl<'a> ShaderKernels<'a> {
|
||||
impl ShaderKernels {
|
||||
|
||||
fn get_path(filename: String) -> (PathBuf, PathBuf) {
|
||||
|
||||
@@ -108,12 +109,12 @@ impl<'a> ShaderKernels<'a> {
|
||||
}
|
||||
|
||||
// On resizes we have to recreate the swapchain
|
||||
pub fn recreate_swapchain(&mut self, surface: &'a Arc<Surface<Window>>) {
|
||||
pub fn recreate_swapchain(mut self, surface: &Arc<Surface<Window>>) -> Self {
|
||||
let dimensions = if let Some(dimensions) = surface.window().get_inner_size() {
|
||||
let dimensions: (u32, u32) = dimensions.to_physical(surface.window().get_hidpi_factor()).into();
|
||||
[dimensions.0, dimensions.1]
|
||||
} else {
|
||||
return;
|
||||
return self;
|
||||
};
|
||||
|
||||
let (new_swapchain, new_images) = match self.swapchain.clone().recreate_with_dimension(dimensions) {
|
||||
@@ -126,13 +127,14 @@ impl<'a> ShaderKernels<'a> {
|
||||
|
||||
self.swapchain = new_swapchain;
|
||||
self.swapchain_images = new_images;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn new(filename: String,
|
||||
surface: &'a Arc<Surface<Window>>,
|
||||
surface: &Arc<Surface<Window>>,
|
||||
queue: Arc<Queue>,
|
||||
physical: PhysicalDevice<'a>,
|
||||
device: Arc<Device>) -> ShaderKernels<'a> {
|
||||
physical: PhysicalDevice,
|
||||
device: Arc<Device>) -> ShaderKernels {
|
||||
|
||||
let (mut swapchain, images) = {
|
||||
let capabilities = surface.capabilities(physical).unwrap();
|
||||
@@ -241,9 +243,8 @@ impl<'a> ShaderKernels<'a> {
|
||||
ShaderKernels {
|
||||
swapchain: swapchain,
|
||||
swapchain_images: images,
|
||||
physical: physical,
|
||||
|
||||
options: CompileOptions::new().ok_or(CompileError::CreateCompiler).unwrap(),
|
||||
//physical: physical,
|
||||
//options: CompileOptions::new().ok_or(CompileError::CreateCompiler).unwrap(),
|
||||
|
||||
graphics_pipeline: Some(Arc::new(GraphicsPipeline::start()
|
||||
// We need to indicate the layout of the vertices.
|
||||
|
||||
Reference in New Issue
Block a user