easiest solution there was just to remove the unclonable objects from ShaderKernels

master
mitchellhansen 5 years ago
parent db06459bd6
commit 77ccd415d0

@ -105,7 +105,7 @@ unsafe impl SpecializationConstants for SimpleSpecializationConstants {
pub struct VkProcessor<'a> { pub struct VkProcessor<'a> {
pub shader_kernels: Option<Arc<ShaderKernels<'a>>>, pub shader_kernels: Option<ShaderKernels>,
pub compute_kernel: Option<ComputeKernel>, pub compute_kernel: Option<ComputeKernel>,
pub vertex_shader_path: PathBuf, pub vertex_shader_path: PathBuf,
pub fragment_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>>) { 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(), ShaderKernels::new(filename.clone(),
surface, self.queue.clone(), surface, self.queue.clone(),
self.physical, self.physical,
self.device.clone()) self.device.clone())
)); );
} }
// On resizes we have to recreate the swapchain // 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: &'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) pub fn load_buffers(&mut self, image_filename: String)

@ -50,14 +50,15 @@ struct EntryPoint<'a> {
#[derive(Default, Debug, Clone)] #[derive(Default, Debug, Clone)]
struct tVertex { position: [f32; 2] } struct tVertex { position: [f32; 2] }
pub struct ShaderKernels<'a> { #[derive(Clone)]
pub struct ShaderKernels {
pub swapchain : Arc<Swapchain<Window>>, pub swapchain : Arc<Swapchain<Window>>,
pub swapchain_images: Vec<Arc<SwapchainImage<Window>>>, // Surface which is drawn to pub swapchain_images: Vec<Arc<SwapchainImage<Window>>>, // Surface which is drawn to
pub physical: PhysicalDevice<'a>, //pub physical: PhysicalDevice<'a>,
// shader: CompiledShaders, // shader: CompiledShaders,
options: CompileOptions<'a>, //options: CompileOptions<'a>,
pub render_pass: Arc<RenderPassAbstract + Send + Sync>, pub render_pass: Arc<RenderPassAbstract + Send + Sync>,
pub graphics_pipeline: Option<Arc<GraphicsPipelineAbstract + Sync + Send>>, 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(), self.render_pass.clone().unwrap().clone(),
&mut self.dynamic_state); &mut self.dynamic_state);
*/ */
impl<'a> ShaderKernels<'a> { impl ShaderKernels {
fn get_path(filename: String) -> (PathBuf, PathBuf) { fn get_path(filename: String) -> (PathBuf, PathBuf) {
@ -108,12 +109,12 @@ impl<'a> ShaderKernels<'a> {
} }
// On resizes we have to recreate the swapchain // 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 = if let Some(dimensions) = surface.window().get_inner_size() {
let dimensions: (u32, u32) = dimensions.to_physical(surface.window().get_hidpi_factor()).into(); let dimensions: (u32, u32) = dimensions.to_physical(surface.window().get_hidpi_factor()).into();
[dimensions.0, dimensions.1] [dimensions.0, dimensions.1]
} else { } else {
return; return self;
}; };
let (new_swapchain, new_images) = match self.swapchain.clone().recreate_with_dimension(dimensions) { 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 = new_swapchain;
self.swapchain_images = new_images; self.swapchain_images = new_images;
self
} }
pub fn new(filename: String, pub fn new(filename: String,
surface: &'a Arc<Surface<Window>>, surface: &Arc<Surface<Window>>,
queue: Arc<Queue>, queue: Arc<Queue>,
physical: PhysicalDevice<'a>, physical: PhysicalDevice,
device: Arc<Device>) -> ShaderKernels<'a> { device: Arc<Device>) -> ShaderKernels {
let (mut swapchain, images) = { let (mut swapchain, images) = {
let capabilities = surface.capabilities(physical).unwrap(); let capabilities = surface.capabilities(physical).unwrap();
@ -241,9 +243,8 @@ impl<'a> ShaderKernels<'a> {
ShaderKernels { ShaderKernels {
swapchain: swapchain, swapchain: swapchain,
swapchain_images: images, swapchain_images: images,
physical: physical, //physical: physical,
//options: CompileOptions::new().ok_or(CompileError::CreateCompiler).unwrap(),
options: CompileOptions::new().ok_or(CompileError::CreateCompiler).unwrap(),
graphics_pipeline: Some(Arc::new(GraphicsPipeline::start() graphics_pipeline: Some(Arc::new(GraphicsPipeline::start()
// We need to indicate the layout of the vertices. // We need to indicate the layout of the vertices.

Loading…
Cancel
Save