refactored examples

This commit is contained in:
colin 2018-12-07 13:00:27 -06:00
parent 962f1ba830
commit 31880de8ab
2 changed files with 3 additions and 35 deletions

View file

@ -396,9 +396,8 @@ fn main() {
width: image_dimensions.0, width: image_dimensions.0,
height: image_dimensions.1, height: image_dimensions.1,
depth: 1, depth: 1,
}, }).build()];
..Default::default()
}];
device.cmd_copy_buffer_to_image( device.cmd_copy_buffer_to_image(
texture_command_buffer, texture_command_buffer,
image_buffer, image_buffer,
@ -647,10 +646,6 @@ fn main() {
polygon_mode: vk::PolygonMode::FILL, polygon_mode: vk::PolygonMode::FILL,
..Default::default() ..Default::default()
}; };
let multisample_state_info = vk::PipelineMultisampleStateCreateInfo {
rasterization_samples: vk::SampleCountFlags::TYPE_1,
..Default::default()
};
let multisample_state_info = vk::PipelineMultisampleStateCreateInfo::builder() let multisample_state_info = vk::PipelineMultisampleStateCreateInfo::builder()
.rasterization_samples(vk::SampleCountFlags::TYPE_1) .rasterization_samples(vk::SampleCountFlags::TYPE_1)

View file

@ -45,6 +45,7 @@ use std::ops::Drop;
use std::os::raw::{c_char, c_void}; use std::os::raw::{c_char, c_void};
use std::ptr; use std::ptr;
const MAGIC_NUMBER: u32 = 0x07230203; const MAGIC_NUMBER: u32 = 0x07230203;
fn spirv_is_little_endian(bytes: &[u8]) -> bool { 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<B>(bytes: B) -> Vec<u32>
where
B: Iterator<Item = u8>,
{
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<D: DeviceV1_0, F: FnOnce(&D, vk::CommandBuffer)>( pub fn record_submit_commandbuffer<D: DeviceV1_0, F: FnOnce(&D, vk::CommandBuffer)>(
device: &D, device: &D,
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,