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