Skip to content

Commit

Permalink
fixes clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Russo committed Feb 10, 2019
1 parent 8a78019 commit 7e41b63
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 21 deletions.
29 changes: 17 additions & 12 deletions src/bin/23_images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ use vulkano::buffer::{
};
use vulkano::descriptor::descriptor_set::{
FixedSizeDescriptorSetsPool,
FixedSizeDescriptorSet
FixedSizeDescriptorSet,
PersistentDescriptorSetBuf
};

use image::GenericImageView;
Expand All @@ -77,7 +78,7 @@ const VALIDATION_LAYERS: &[&str] = &[
"VK_LAYER_LUNARG_standard_validation"
];

const TEXTURE_PATH: &'static str = "src/bin/23_statue.jpg";
const TEXTURE_PATH: &str = "src/bin/23_statue.jpg";

/// Required device extensions
fn device_extensions() -> DeviceExtensions {
Expand Down Expand Up @@ -118,6 +119,7 @@ impl Vertex {
}
impl_vertex!(Vertex, pos, color);

#[allow(dead_code)]
#[derive(Copy, Clone)]
struct UniformBufferObject {
model: glm::Mat4,
Expand All @@ -138,6 +140,8 @@ fn indices() -> [u16; 6] {
[0, 1, 2, 2, 3, 0]
}

type DescriptorSetResources = ((), PersistentDescriptorSetBuf<Arc<CpuAccessibleBuffer<UniformBufferObject>>>);

struct HelloTriangleApplication {
instance: Arc<Instance>,
#[allow(unused)]
Expand All @@ -160,13 +164,14 @@ struct HelloTriangleApplication {

swap_chain_framebuffers: Vec<Arc<FramebufferAbstract + Send + Sync>>,

#[allow(dead_code)]
texture_image: Arc<ImmutableImage<Format>>,

vertex_buffer: Arc<BufferAccess + Send + Sync>,
index_buffer: Arc<TypedBufferAccess<Content=[u16]> + Send + Sync>,
uniform_buffers: Vec<Arc<CpuAccessibleBuffer<UniformBufferObject>>>,

descriptor_sets: Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, ((), vulkano::descriptor::descriptor_set::PersistentDescriptorSetBuf<std::sync::Arc<vulkano::buffer::CpuAccessibleBuffer<UniformBufferObject>>>)>>>,
descriptor_sets: Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, DescriptorSetResources>>>,

command_buffers: Vec<Arc<AutoCommandBuffer>>,

Expand Down Expand Up @@ -268,7 +273,7 @@ impl HelloTriangleApplication {
let required_extensions = Self::get_required_extensions();

if ENABLE_VALIDATION_LAYERS && Self::check_validation_layer_support() {
Instance::new(Some(&app_info), &required_extensions, VALIDATION_LAYERS.iter().map(|s| *s))
Instance::new(Some(&app_info), &required_extensions, VALIDATION_LAYERS.iter().cloned())
.expect("failed to create Vulkan instance")
} else {
Instance::new(Some(&app_info), &required_extensions, None)
Expand Down Expand Up @@ -494,7 +499,7 @@ impl HelloTriangleApplication {
}

fn create_framebuffers(
swap_chain_images: &Vec<Arc<SwapchainImage<Window>>>,
swap_chain_images: &[Arc<SwapchainImage<Window>>],
render_pass: &Arc<RenderPassAbstract + Send + Sync>
) -> Vec<Arc<FramebufferAbstract + Send + Sync>> {
swap_chain_images.iter()
Expand Down Expand Up @@ -524,7 +529,7 @@ impl HelloTriangleApplication {

future.flush().unwrap();

return image_view;
image_view
}

fn create_vertex_buffer(graphics_queue: &Arc<Queue>) -> Arc<BufferAccess + Send + Sync> {
Expand Down Expand Up @@ -580,10 +585,11 @@ impl HelloTriangleApplication {
)
}


fn create_descriptor_sets(
pool: &Arc<Mutex<FixedSizeDescriptorSetsPool<Arc<GraphicsPipelineAbstract + Send + Sync>>>>,
uniform_buffers: &Vec<Arc<CpuAccessibleBuffer<UniformBufferObject>>>,
) -> Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, ((), vulkano::descriptor::descriptor_set::PersistentDescriptorSetBuf<std::sync::Arc<vulkano::buffer::CpuAccessibleBuffer<UniformBufferObject>>>)>>>
uniform_buffers: &[Arc<CpuAccessibleBuffer<UniformBufferObject>>],
) -> Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, DescriptorSetResources>>>
{
uniform_buffers
.iter()
Expand Down Expand Up @@ -705,9 +711,8 @@ impl HelloTriangleApplication {

let mut done = false;
self.events_loop.poll_events(|ev| {
match ev {
Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => done = true,
_ => ()
if let Event::WindowEvent { event: WindowEvent::CloseRequested, .. } = ev {
done = true
}
});
if done {
Expand Down Expand Up @@ -761,7 +766,7 @@ impl HelloTriangleApplication {

fn update_uniform_buffer(start_time: Instant, dimensions: [f32; 2]) -> UniformBufferObject {
let duration = Instant::now().duration_since(start_time);
let elapsed = (duration.as_secs() * 1000) + duration.subsec_millis() as u64;
let elapsed = (duration.as_secs() * 1000) + u64::from(duration.subsec_millis());

let identity_matrix = glm::mat4(
1.0, 0.0, 0.0, 0.0,
Expand Down
52 changes: 43 additions & 9 deletions src/bin/23_images.rs.diff
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,55 @@
use vulkano::sync::{self, SharingMode, GpuFuture};
use vulkano::pipeline::{
GraphicsPipeline,
@@ -62,6 +68,8 @@ use vulkano::descriptor::descriptor_set::{
FixedSizeDescriptorSet
@@ -59,9 +65,12 @@ use vulkano::buffer::{
};
use vulkano::descriptor::descriptor_set::{
FixedSizeDescriptorSetsPool,
- FixedSizeDescriptorSet
+ FixedSizeDescriptorSet,
+ PersistentDescriptorSetBuf
};

+use image::GenericImageView;
+
const WIDTH: u32 = 800;
const HEIGHT: u32 = 600;

@@ -69,6 +77,8 @@ const VALIDATION_LAYERS: &[&str] = &[
@@ -69,6 +78,8 @@ const VALIDATION_LAYERS: &[&str] = &[
"VK_LAYER_LUNARG_standard_validation"
];

+const TEXTURE_PATH: &'static str = "src/bin/23_statue.jpg";
+const TEXTURE_PATH: &str = "src/bin/23_statue.jpg";
+
/// Required device extensions
fn device_extensions() -> DeviceExtensions {
DeviceExtensions {
@@ -150,6 +160,8 @@ struct HelloTriangleApplication {
@@ -129,6 +140,8 @@ fn indices() -> [u16; 6] {
[0, 1, 2, 2, 3, 0]
}

+type DescriptorSetResources = ((), PersistentDescriptorSetBuf<Arc<CpuAccessibleBuffer<UniformBufferObject>>>);
+
struct HelloTriangleApplication {
instance: Arc<Instance>,
#[allow(unused)]
@@ -151,11 +164,14 @@ struct HelloTriangleApplication {

swap_chain_framebuffers: Vec<Arc<FramebufferAbstract + Send + Sync>>,

+ #[allow(dead_code)]
+ texture_image: Arc<ImmutableImage<Format>>,
+
vertex_buffer: Arc<BufferAccess + Send + Sync>,
index_buffer: Arc<TypedBufferAccess<Content=[u16]> + Send + Sync>,
uniform_buffers: Vec<Arc<CpuAccessibleBuffer<UniformBufferObject>>>,
@@ -185,6 +197,8 @@ impl HelloTriangleApplication {

- descriptor_sets: Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, ((), vulkano::descriptor::descriptor_set::PersistentDescriptorSetBuf<std::sync::Arc<vulkano::buffer::CpuAccessibleBuffer<UniformBufferObject>>>)>>>,
+ descriptor_sets: Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, DescriptorSetResources>>>,

command_buffers: Vec<Arc<AutoCommandBuffer>>,

@@ -186,6 +202,8 @@ impl HelloTriangleApplication {

let start_time = Instant::now();

Expand All @@ -58,7 +79,7 @@
let vertex_buffer = Self::create_vertex_buffer(&graphics_queue);
let index_buffer = Self::create_index_buffer(&graphics_queue);
let uniform_buffers = Self::create_uniform_buffers(&device, swap_chain_images.len(), start_time, swap_chain.dimensions());
@@ -215,6 +229,8 @@ impl HelloTriangleApplication {
@@ -216,6 +234,8 @@ impl HelloTriangleApplication {

swap_chain_framebuffers,

Expand All @@ -67,7 +88,7 @@
vertex_buffer,
index_buffer,
uniform_buffers,
@@ -491,6 +507,26 @@ impl HelloTriangleApplication {
@@ -492,6 +512,26 @@ impl HelloTriangleApplication {
).collect::<Vec<_>>()
}

Expand All @@ -88,9 +109,22 @@
+
+ future.flush().unwrap();
+
+ return image_view;
+ image_view
+ }
+
fn create_vertex_buffer(graphics_queue: &Arc<Queue>) -> Arc<BufferAccess + Send + Sync> {
let (buffer, future) = ImmutableBuffer::from_iter(
vertices().iter().cloned(), BufferUsage::vertex_buffer(),
@@ -545,10 +585,11 @@ impl HelloTriangleApplication {
)
}

+
fn create_descriptor_sets(
pool: &Arc<Mutex<FixedSizeDescriptorSetsPool<Arc<GraphicsPipelineAbstract + Send + Sync>>>>,
uniform_buffers: &[Arc<CpuAccessibleBuffer<UniformBufferObject>>],
- ) -> Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, ((), vulkano::descriptor::descriptor_set::PersistentDescriptorSetBuf<std::sync::Arc<vulkano::buffer::CpuAccessibleBuffer<UniformBufferObject>>>)>>>
+ ) -> Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, DescriptorSetResources>>>
{
uniform_buffers
.iter()

0 comments on commit 7e41b63

Please sign in to comment.