From 31880de8ab1d00e6097bdae8d394eab8a4c59812 Mon Sep 17 00:00:00 2001 From: colin Date: Fri, 7 Dec 2018 13:00:27 -0600 Subject: [PATCH] refactored examples --- examples/src/bin/texture.rs | 9 ++------- examples/src/lib.rs | 29 +---------------------------- 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/examples/src/bin/texture.rs b/examples/src/bin/texture.rs index e3cdfd9..89df311 100644 --- a/examples/src/bin/texture.rs +++ b/examples/src/bin/texture.rs @@ -396,9 +396,8 @@ fn main() { width: image_dimensions.0, height: image_dimensions.1, depth: 1, - }, - ..Default::default() - }]; + }).build()]; + device.cmd_copy_buffer_to_image( texture_command_buffer, image_buffer, @@ -647,10 +646,6 @@ fn main() { polygon_mode: vk::PolygonMode::FILL, ..Default::default() }; - let multisample_state_info = vk::PipelineMultisampleStateCreateInfo { - rasterization_samples: vk::SampleCountFlags::TYPE_1, - ..Default::default() - }; let multisample_state_info = vk::PipelineMultisampleStateCreateInfo::builder() .rasterization_samples(vk::SampleCountFlags::TYPE_1) diff --git a/examples/src/lib.rs b/examples/src/lib.rs index 7a96d3e..7431fc3 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -45,6 +45,7 @@ use std::ops::Drop; use std::os::raw::{c_char, c_void}; use std::ptr; + const MAGIC_NUMBER: u32 = 0x07230203; fn spirv_is_little_endian(bytes: &[u8]) -> bool { @@ -88,34 +89,6 @@ macro_rules! offset_of { }}; } -fn u32_from_bytes(bytes: &[u8; 4]) -> u32 { - unsafe { std::mem::transmute(*bytes) } -} - -pub fn bytes_to_u32_vec(bytes: B) -> Vec -where - B: Iterator, -{ - let mut output = vec![]; - let mut buffer: [u8; 4] = [0, 0, 0, 0]; - let mut byte_len: usize = 0; - for (i, b) in bytes.enumerate() { - byte_len = i; - match i % 4 { - 3 => { - buffer[3] = b; - output.push(u32_from_bytes(&buffer)); - buffer = [0, 0, 0, 0]; - } - idx => buffer[idx] = b, - } - } - if (byte_len + 1) % 4 != 0 { - output.push(u32_from_bytes(&buffer)); - } - output -} - pub fn record_submit_commandbuffer( device: &D, command_buffer: vk::CommandBuffer,