|
|
@ -1,6 +1,6 @@
|
|
|
|
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer, DeviceLocalBuffer, ImmutableBuffer, BufferAccess};
|
|
|
|
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer, DeviceLocalBuffer, ImmutableBuffer, BufferAccess};
|
|
|
|
use vulkano::command_buffer::{AutoCommandBufferBuilder, DynamicState};
|
|
|
|
use vulkano::command_buffer::{AutoCommandBufferBuilder, DynamicState};
|
|
|
|
use vulkano::descriptor::descriptor_set::{PersistentDescriptorSet, StdDescriptorPoolAlloc};
|
|
|
|
use vulkano::descriptor::descriptor_set::{PersistentDescriptorSet, StdDescriptorPoolAlloc, DescriptorSetDesc};
|
|
|
|
use vulkano::device::{Device, DeviceExtensions, QueuesIter, Queue};
|
|
|
|
use vulkano::device::{Device, DeviceExtensions, QueuesIter, Queue};
|
|
|
|
use vulkano::instance::{Instance, InstanceExtensions, PhysicalDevice, QueueFamily};
|
|
|
|
use vulkano::instance::{Instance, InstanceExtensions, PhysicalDevice, QueueFamily};
|
|
|
|
use vulkano::pipeline::{ComputePipeline, GraphicsPipeline, GraphicsPipelineAbstract, GraphicsPipelineBuilder};
|
|
|
|
use vulkano::pipeline::{ComputePipeline, GraphicsPipeline, GraphicsPipelineAbstract, GraphicsPipelineBuilder};
|
|
|
@ -18,7 +18,7 @@ use image::GenericImage;
|
|
|
|
use shade_runner::{ComputeLayout, CompileError, FragLayout, FragInput, FragOutput, VertInput, VertOutput, VertLayout, CompiledShaders, Entry};
|
|
|
|
use shade_runner::{ComputeLayout, CompileError, FragLayout, FragInput, FragOutput, VertInput, VertOutput, VertLayout, CompiledShaders, Entry};
|
|
|
|
use vulkano::descriptor::descriptor_set::{PersistentDescriptorSetBuf, PersistentDescriptorSetImg, PersistentDescriptorSetSampler};
|
|
|
|
use vulkano::descriptor::descriptor_set::{PersistentDescriptorSetBuf, PersistentDescriptorSetImg, PersistentDescriptorSetSampler};
|
|
|
|
use shaderc::CompileOptions;
|
|
|
|
use shaderc::CompileOptions;
|
|
|
|
use vulkano::framebuffer::{Subpass, RenderPass, RenderPassAbstract, Framebuffer, FramebufferAbstract};
|
|
|
|
use vulkano::framebuffer::{Subpass, RenderPass, RenderPassAbstract, Framebuffer, FramebufferAbstract, RenderPassDesc};
|
|
|
|
use vulkano::pipeline::shader::{GraphicsShaderType, ShaderModule, GraphicsEntryPoint, SpecializationConstants, SpecializationMapEntry};
|
|
|
|
use vulkano::pipeline::shader::{GraphicsShaderType, ShaderModule, GraphicsEntryPoint, SpecializationConstants, SpecializationMapEntry};
|
|
|
|
use vulkano::swapchain::{Swapchain, PresentMode, SurfaceTransform, Surface, SwapchainCreationError, AcquireError};
|
|
|
|
use vulkano::swapchain::{Swapchain, PresentMode, SurfaceTransform, Surface, SwapchainCreationError, AcquireError};
|
|
|
|
use vulkano::swapchain::acquire_next_image;
|
|
|
|
use vulkano::swapchain::acquire_next_image;
|
|
|
@ -26,7 +26,7 @@ use vulkano::image::swapchain::SwapchainImage;
|
|
|
|
use winit::{EventsLoop, WindowBuilder, Window, Event, WindowEvent};
|
|
|
|
use winit::{EventsLoop, WindowBuilder, Window, Event, WindowEvent};
|
|
|
|
use vulkano_win::VkSurfaceBuild;
|
|
|
|
use vulkano_win::VkSurfaceBuild;
|
|
|
|
use vulkano::pipeline::vertex::{SingleBufferDefinition, Vertex};
|
|
|
|
use vulkano::pipeline::vertex::{SingleBufferDefinition, Vertex};
|
|
|
|
use vulkano::descriptor::PipelineLayoutAbstract;
|
|
|
|
use vulkano::descriptor::{PipelineLayoutAbstract, DescriptorSet};
|
|
|
|
use std::alloc::Layout;
|
|
|
|
use std::alloc::Layout;
|
|
|
|
use vulkano::pipeline::viewport::Viewport;
|
|
|
|
use vulkano::pipeline::viewport::Viewport;
|
|
|
|
use image::ImageFormat;
|
|
|
|
use image::ImageFormat;
|
|
|
@ -37,6 +37,7 @@ use vulkano::format::Format;
|
|
|
|
use vulkano::sampler::{Sampler, Filter, MipmapMode, SamplerAddressMode};
|
|
|
|
use vulkano::sampler::{Sampler, Filter, MipmapMode, SamplerAddressMode};
|
|
|
|
use image::flat::NormalForm::ColumnMajorPacked;
|
|
|
|
use image::flat::NormalForm::ColumnMajorPacked;
|
|
|
|
use crate::vkprocessor::SimpleSpecializationConstants;
|
|
|
|
use crate::vkprocessor::SimpleSpecializationConstants;
|
|
|
|
|
|
|
|
use crate::vertex_2d::ColoredVertex2D;
|
|
|
|
|
|
|
|
|
|
|
|
struct EntryPoint<'a> {
|
|
|
|
struct EntryPoint<'a> {
|
|
|
|
compiled_shaders: CompiledShaders,
|
|
|
|
compiled_shaders: CompiledShaders,
|
|
|
@ -46,35 +47,18 @@ struct EntryPoint<'a> {
|
|
|
|
fragment_shader_module: Arc<ShaderModule>,
|
|
|
|
fragment_shader_module: Arc<ShaderModule>,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Default, Debug, Clone)]
|
|
|
|
|
|
|
|
struct tVertex { position: [f32; 2] }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct ShaderKernels {
|
|
|
|
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>,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//shader: CompiledShaders,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//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>>,
|
|
|
|
|
|
|
|
|
|
|
|
device: Arc<Device>,
|
|
|
|
device: Arc<Device>,
|
|
|
|
|
|
|
|
|
|
|
|
// entry_point: EntryPoint<'a>,
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// return the frame buffers
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
let mut framebuffers =
|
|
|
|
|
|
|
|
window_size_dependent_setup(&self.images.clone().unwrap().clone(),
|
|
|
|
|
|
|
|
self.render_pass.clone().unwrap().clone(),
|
|
|
|
|
|
|
|
&mut self.dynamic_state);
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
impl ShaderKernels {
|
|
|
|
impl ShaderKernels {
|
|
|
|
|
|
|
|
|
|
|
|
fn get_path(filename: String) -> (PathBuf, PathBuf) {
|
|
|
|
fn get_path(filename: String) -> (PathBuf, PathBuf) {
|
|
|
@ -237,7 +221,6 @@ impl ShaderKernels {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
).unwrap());
|
|
|
|
).unwrap());
|
|
|
|
|
|
|
|
|
|
|
|
vulkano::impl_vertex!(tVertex, position);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ShaderKernels {
|
|
|
|
ShaderKernels {
|
|
|
@ -250,7 +233,7 @@ impl ShaderKernels {
|
|
|
|
// We need to indicate the layout of the vertices.
|
|
|
|
// We need to indicate the layout of the vertices.
|
|
|
|
// The type `SingleBufferDefinition` actually contains a template parameter corresponding
|
|
|
|
// The type `SingleBufferDefinition` actually contains a template parameter corresponding
|
|
|
|
// to the type of each vertex. But in this code it is automatically inferred.
|
|
|
|
// to the type of each vertex. But in this code it is automatically inferred.
|
|
|
|
.vertex_input_single_buffer::<tVertex>()
|
|
|
|
.vertex_input_single_buffer::<ColoredVertex2D>()
|
|
|
|
|
|
|
|
|
|
|
|
// A Vulkan shader can in theory contain multiple entry points, so we have to specify
|
|
|
|
// A Vulkan shader can in theory contain multiple entry points, so we have to specify
|
|
|
|
// which one. The `main` word of `main_entry_point` actually corresponds to the name of
|
|
|
|
// which one. The `main` word of `main_entry_point` actually corresponds to the name of
|
|
|
@ -261,7 +244,7 @@ impl ShaderKernels {
|
|
|
|
third_constant: 0.0,
|
|
|
|
third_constant: 0.0,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
// The content of the vertex buffer describes a list of triangles.
|
|
|
|
// The content of the vertex buffer describes a list of triangles.
|
|
|
|
.triangle_fan()
|
|
|
|
.triangle_list_with_adjacency()
|
|
|
|
// Use a resizable viewport set to draw over the entire window
|
|
|
|
// Use a resizable viewport set to draw over the entire window
|
|
|
|
.viewports_dynamic_scissors_irrelevant(1)
|
|
|
|
.viewports_dynamic_scissors_irrelevant(1)
|
|
|
|
// See `vertex_shader`.
|
|
|
|
// See `vertex_shader`.
|
|
|
|