whatever
This commit is contained in:
@@ -75,8 +75,9 @@ pub struct GameObject {
|
||||
pub(crate) type GameObjectHandle = usize;
|
||||
pub(crate) type MeshHandle = usize;
|
||||
|
||||
type FixedGraphicsDescriptorSet = Arc<FixedSizeDescriptorSet<Arc<dyn GraphicsPipelineAbstract + Send + Sync>, ((), PersistentDescriptorSetBuf<Arc<vulkano::buffer::cpu_access::CpuAccessibleBuffer<vs::ty::UniformBufferObject>>>)>>;
|
||||
//type FixedGraphicsDescriptorSet = Arc<FixedSizeDescriptorSet<Arc<dyn GraphicsPipelineAbstract + Send + Sync>, ((((), PersistentDescriptorSetBuf<Arc<CpuAccessibleBuffer<vs::ty::UniformBufferObject>>>), PersistentDescriptorSetImg<Arc<ImmutableImage<Format>>>), PersistentDescriptorSetSampler)>>;
|
||||
//type FixedGraphicsDescriptorSet = Arc<FixedSizeDescriptorSet<Arc<dyn GraphicsPipelineAbstract + Send + Sync>, ((), PersistentDescriptorSetBuf<Arc<vulkano::buffer::cpu_access::CpuAccessibleBuffer<vs::ty::UniformBufferObject>>>)>>;
|
||||
//type FixedGraphicsDescriptorSet = Arc<FixedSizeDescriptorSet<Arc<dyn GraphicsPipelineAbstract + Send + Sync>, (((), PersistentDescriptorSetBuf<Arc<CpuAccessibleBuffer<vs::ty::UniformBufferObject>>>), PersistentDescriptorSetImg<Arc<ImmutableImage<Format>>>)>>;
|
||||
type FixedGraphicsDescriptorSet = Arc<FixedSizeDescriptorSet<Arc<dyn GraphicsPipelineAbstract + Send + Sync>, ((((), PersistentDescriptorSetBuf<Arc<CpuAccessibleBuffer<vs::ty::UniformBufferObject>>>), PersistentDescriptorSetImg<Arc<ImmutableImage<Format>>>), PersistentDescriptorSetSampler)>>;
|
||||
|
||||
pub struct GameData {
|
||||
pub start_time: SystemTime,
|
||||
@@ -268,20 +269,22 @@ 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 default_tex = {
|
||||
let image = image::load_from_memory_with_format(include_bytes!("../models/missing-texture.jpg"),
|
||||
ImageFormat::JPEG).unwrap().to_rgba();
|
||||
let image_data = image.into_raw().clone();
|
||||
|
||||
ImmutableImage::from_iter(
|
||||
let (image_view, future) = ImmutableImage::from_iter(
|
||||
image_data.iter().cloned(),
|
||||
Dimensions::Dim2d { width: 128, height: 128 },
|
||||
Format::R8G8B8A8Unorm,
|
||||
queue.clone(),
|
||||
).unwrap()
|
||||
};
|
||||
).unwrap();
|
||||
|
||||
default_tex_future.flush().unwrap();
|
||||
future.flush().unwrap();
|
||||
|
||||
image_view
|
||||
};
|
||||
|
||||
// Dynamic viewports allow us to recreate just the viewport when the window is resized
|
||||
// Otherwise we would have to recreate the whole pipeline.
|
||||
@@ -310,7 +313,7 @@ impl VulkanRenderer {
|
||||
descriptor_set_pool
|
||||
.lock().unwrap().next()
|
||||
.add_buffer(uniform_buffer.clone()).unwrap()
|
||||
// .add_sampled_image(default_tex.clone(), sampler.clone()).unwrap()
|
||||
.add_sampled_image(default_tex.clone(), sampler.clone()).unwrap()
|
||||
.build().unwrap())
|
||||
})
|
||||
.collect();
|
||||
@@ -419,13 +422,23 @@ impl VulkanRenderer {
|
||||
|
||||
let command_buffer = self.create_command_buffer(fb_index, new_ubo).clone();
|
||||
|
||||
let future = self.previous_frame_end.take().unwrap().join(acquire_future)
|
||||
let future = self.previous_frame_end.take().unwrap()
|
||||
.join(acquire_future)
|
||||
.then_execute(self.queue.clone(), command_buffer).unwrap()
|
||||
.then_swapchain_present(self.queue.clone(), self.swapchain.clone(), fb_index)
|
||||
.then_signal_fence_and_flush();
|
||||
|
||||
match future {
|
||||
Ok(future) => {
|
||||
// we're joining on the previous future but the CPU is running faster than the GPU so
|
||||
// eventually it stutters, and jumps ahead to the newer frames.
|
||||
//
|
||||
// See vulkano issue 1135: https://github.com/vulkano-rs/vulkano/issues/1135
|
||||
// This makes sure the CPU stays in sync with the GPU in situations when the CPU is
|
||||
// running "too fast"
|
||||
#[cfg(target_os = "macos")]
|
||||
future.wait(None).unwrap();
|
||||
|
||||
self.previous_frame_end = Some(Box::new(future) as Box<_>);
|
||||
},
|
||||
Err(FlushError::OutOfDate) => {
|
||||
@@ -585,8 +598,8 @@ fn create_pipeline<V: vulkano::pipeline::vertex::Vertex>(device: Arc<Device>, re
|
||||
.vertex_shader(vertex_shader_entry.clone(), ())
|
||||
.triangle_list()
|
||||
.viewports_dynamic_scissors_irrelevant(1)
|
||||
.fragment_shader(fragment_shader_entry.clone(), ())
|
||||
.depth_stencil_simple_depth()
|
||||
.fragment_shader(fragment_shader_entry.clone(), ())
|
||||
.blend_alpha_blending()
|
||||
.cull_mode_back()
|
||||
.render_pass(sub_pass.clone())
|
||||
|
||||
Reference in New Issue
Block a user