This commit is contained in:
2019-08-13 11:36:40 +02:00
parent 35bb18ace9
commit 1a9e37df79
5 changed files with 24 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer};
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer, CpuBufferPool};
use vulkano::command_buffer::{AutoCommandBufferBuilder, DynamicState};
use vulkano::device::{Device, DeviceExtensions, Queue};
use vulkano::framebuffer::{Framebuffer, FramebufferAbstract, Subpass, RenderPassAbstract};
@@ -14,7 +14,7 @@ use vulkano::sync;
use vulkano::format::{Format, ClearValue};
use vulkano::instance::debug::{DebugCallback, MessageTypes};
use vulkano::memory::pool::{PotentialDedicatedAllocation, StdMemoryPoolAlloc};
use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
use vulkano::descriptor::descriptor_set::{PersistentDescriptorSet, FixedSizeDescriptorSetsPool, FixedSizeDescriptorSet, PersistentDescriptorSetBuf, PersistentDescriptorSetSampler};
use vulkano::descriptor::DescriptorSet;
use vulkano::sampler::{Sampler, Filter, MipmapMode, SamplerAddressMode};
@@ -22,7 +22,7 @@ use vulkano_win::VkSurfaceBuild;
use winit::{EventsLoop, Window, WindowBuilder, Event, WindowEvent};
use std::sync::Arc;
use std::sync::{Arc, Mutex};
use std::time::SystemTime;
use std::path::{PathBuf};
use std::ffi::{CStr};
@@ -78,6 +78,8 @@ pub struct GameObject {
pub(crate) type GameObjectHandle = usize;
pub(crate) type MeshHandle = usize;
//type FixedGraphicsDescriptorSet = std::sync::Arc<FixedSizeDescriptorSet<std::sync::Arc<dyn GraphicsPipelineAbstract + std::marker::Send + std::marker::Sync>, (((), PersistentDescriptorSetSampler), PersistentDescriptorSetBuf<std::sync::Arc<vulkano::buffer::cpu_access::CpuAccessibleBuffer<vs::ty::UniformBufferObject>>>)>>;
pub struct GameData {
pub start_time: SystemTime,
pub line_vertices: Vec<LinePoint>,
@@ -109,6 +111,7 @@ pub struct VulkanRenderer {
pub recreate_swapchain: bool,
pub debug_callback: Option<DebugCallback>,
pub previous_frame_end: Option<Box<GpuFuture>>,
// pub uniform_buffers: CpuBufferPool<vs::ty::UniformBufferObject>,
}
pub enum RenderLoopResult {
@@ -122,7 +125,6 @@ impl VulkanRenderer {
let mut data = GameData {
push_constants: PushConstants {
time: 0.0,
_dummy0: [0; 12],
model: Matrix4::identity().into(),
view: Matrix4::identity().into(),
projection: Matrix4::identity().into(),
@@ -287,7 +289,6 @@ impl VulkanRenderer {
let line_pipeline: Arc<GraphicsPipelineAbstract + Send + Sync> =
create_pipeline::<LinePoint>(device.clone(), render_pass.clone(), "shaders/line.vert", "shaders/line.frag", true).unwrap();
let (default_tex, default_tex_future) = {
let image = image::load_from_memory_with_format(include_bytes!("../models/missing-texture.jpg"),
ImageFormat::JPEG).unwrap().to_rgba();
@@ -318,6 +319,8 @@ impl VulkanRenderer {
// can draw we also need to create the actual framebuffers.
let framebuffers = window_size_dependent_setup(device.clone(), &images, render_pass.clone(), &mut dynamic_state);
// let uniform_buffers = CpuBufferPool::<vs::ty::UniformBufferObject>::new(device.clone(), BufferUsage::all());
// In the loop below we are going to submit commands to the GPU. Submitting a command produces
// an object that implements the `GpuFuture` trait, which holds the resources for as long as
// they are in use by the GPU.
@@ -327,8 +330,7 @@ impl VulkanRenderer {
let previous_frame_end = Some(Box::new(sync::now(device.clone())) as Box<dyn GpuFuture>);
VulkanRenderer { game_data: data, device, framebuffers, sampler,
default_descriptor_set: default_descriptor_set,
dynamic_state, pipeline, line_pipeline,
dynamic_state, pipeline, line_pipeline, default_descriptor_set,
surface, swapchain, render_pass, queue, line_vertex_buffer, events_loop,
recreate_swapchain: false, debug_callback, previous_frame_end }
}