|
|
|
@ -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.
|
|
|
|
|