finished updating dependencies

This commit is contained in:
2020-07-27 23:04:49 -07:00
parent f5f0346d5c
commit 5916b0d947
3 changed files with 92 additions and 98 deletions

View File

@@ -30,9 +30,9 @@ use winit::event_loop::EventLoop;
/// VKProcessor holds the vulkan instance information, the swapchain,
/// and the compute and canvas states
pub struct VkProcessor<'a> {
pub struct VkProcessor {
// Vulkan state fields
pub physical: PhysicalDevice<'a>,
//pub physical: PhysicalDevice<'a>,
pub device: Arc<Device>,
pub queues: QueuesIter,
pub queue: Arc<Queue>,
@@ -52,12 +52,12 @@ pub struct VkProcessor<'a> {
}
impl<'a> VkProcessor<'a> {
impl VkProcessor {
/// Creates a new VkProcessor from an instance and surface
/// This includes the physical device, queues, compute and canvas state
pub fn new(instance: &'a Arc<Instance>, surface: Arc<Surface<Window>>) -> VkProcessor<'a> {
pub fn new(instance: Arc<Instance>, surface: Arc<Surface<Window>>) -> VkProcessor {
let physical = PhysicalDevice::enumerate(instance).next().unwrap();
let physical = PhysicalDevice::enumerate(&instance).next().unwrap();
let queue_family = physical.queue_families().find(|&q| {
// We take the first queue that supports drawing to our window.
@@ -78,7 +78,7 @@ impl<'a> VkProcessor<'a> {
VkProcessor {
physical: physical.clone(),
//physical: physical.clone(),
device: device.clone(),
queue: queue.clone(),
queues: queues,
@@ -98,13 +98,15 @@ impl<'a> VkProcessor<'a> {
}
/// Using the surface, we calculate the surface capabilities and create the swapchain and swapchain images
pub fn create_swapchain(&mut self, surface: Arc<Surface<Window>>) {
pub fn create_swapchain(&mut self, instance: Arc<Instance>, surface: Arc<Surface<Window>>) {
let (mut swapchain, images) = {
let capabilities = surface.capabilities(self.physical).unwrap();
let physical = PhysicalDevice::enumerate(&instance).next().unwrap();
let capabilities = surface.capabilities(physical).unwrap();
let usage = capabilities.supported_usage_flags;
let alpha = capabilities.supported_composite_alpha.iter().next().unwrap();
// Choosing the internal format that the images will have.
let format = capabilities.supported_formats[0].0;
let colorspace = capabilities.supported_formats[0].1;
// Set the swapchains window dimensions
let initial_dimensions = if let dimensions = surface.window().inner_size() {
@@ -122,13 +124,13 @@ impl<'a> VkProcessor<'a> {
format,
initial_dimensions,
1, // Layers
usage,
ImageUsage::color_attachment(),
&self.queue,
SurfaceTransform::Identity,
alpha,
PresentMode::Immediate,
FullscreenExclusive::Default, true,
ColorSpace::PassThrough).unwrap()
colorspace).unwrap()
};
self.swapchain = Some(swapchain);
@@ -136,7 +138,7 @@ impl<'a> VkProcessor<'a> {
}
/// On screen resizes, the swapchain and images must be recreated
pub fn recreate_swapchain(&mut self, surface: &'a Arc<Surface<Window>>) {
pub fn recreate_swapchain(&mut self, surface: &Arc<Surface<Window>>) {
let dimensions = if let dimensions = surface.window().inner_size() {
let dimensions: (u32, u32) = dimensions.to_logical::<u32>(surface.window().scale_factor()).into();
[dimensions.0, dimensions.1]
@@ -174,10 +176,10 @@ impl<'a> VkProcessor<'a> {
/// A hardcoded list of shaders which can be preloaded from this function
pub fn preload_shaders(&mut self) {
self.canvas_state.load_shader::<GenericShader, ColorVertex3D>(String::from("color-passthrough"), self.physical.clone(), self.capabilities.clone());
self.canvas_state.load_shader::<GenericShader, TextureVertex3D>(String::from("simple_texture"), self.physical.clone(), self.capabilities.clone());
self.canvas_state.load_shader::<GenericShader, ImageVertex3D>(String::from("simple_image"), self.physical.clone(), self.capabilities.clone());
self.canvas_state.load_shader::<TextShader, ColorVertex3D>(String::from("simple_text"), self.physical.clone(), self.capabilities.clone());
self.canvas_state.load_shader::<GenericShader, ColorVertex3D>(String::from("color-passthrough"), self.capabilities.clone());
self.canvas_state.load_shader::<GenericShader, TextureVertex3D>(String::from("simple_texture"), self.capabilities.clone());
self.canvas_state.load_shader::<GenericShader, ImageVertex3D>(String::from("simple_image"), self.capabilities.clone());
self.canvas_state.load_shader::<TextShader, ColorVertex3D>(String::from("simple_text"), self.capabilities.clone());
}
/// A hardcoded list of shaders which can be proloaded from this function
@@ -230,7 +232,7 @@ impl<'a> VkProcessor<'a> {
/// Run the VKprocessor for a single frame, consuming the Canvas/Compu Frames
pub fn run(&mut self,
surface: &'a Arc<Surface<Window>>,
surface: &Arc<Surface<Window>>,
canvas_frame: CanvasFrame,
compute_frame: CompuFrame,
) {