Compare commits
No commits in common. "9b5a011afce0946c061cca54964125715779ab7d" and "c6ee60de02aa0ef30f24b23b5c8995f0ab6aab78" have entirely different histories.
9b5a011afc
...
c6ee60de02
1 changed files with 15 additions and 32 deletions
47
src/main.rs
47
src/main.rs
|
@ -3,8 +3,6 @@ mod math3d;
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::ffi::{c_void, CStr, CString};
|
use std::ffi::{c_void, CStr, CString};
|
||||||
use std::ops::Deref;
|
|
||||||
use std::pin::Pin;
|
|
||||||
|
|
||||||
use math3d::Vertex;
|
use math3d::Vertex;
|
||||||
|
|
||||||
|
@ -951,8 +949,19 @@ impl VulkanApp {
|
||||||
let shader_stages: [ffi::VkPipelineShaderStageCreateInfo; 2] =
|
let shader_stages: [ffi::VkPipelineShaderStageCreateInfo; 2] =
|
||||||
[vert_shader_stage_info, frag_shader_stage_info];
|
[vert_shader_stage_info, frag_shader_stage_info];
|
||||||
|
|
||||||
let (vertex_input_info, _bind_desc, _attr_descs) =
|
let mut vertex_input_info: ffi::VkPipelineVertexInputStateCreateInfo =
|
||||||
Self::create_vertex_input_state_info_struct()?;
|
unsafe { std::mem::zeroed() };
|
||||||
|
vertex_input_info.sType =
|
||||||
|
ffi::VkStructureType_VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
|
||||||
|
|
||||||
|
let bind_desc = Vertex::get_binding_description();
|
||||||
|
let attr_descs = Vertex::get_attribute_descriptions();
|
||||||
|
|
||||||
|
vertex_input_info.vertexBindingDescriptionCount = 1;
|
||||||
|
vertex_input_info.vertexAttributeDescriptionCount = attr_descs.len() as u32;
|
||||||
|
|
||||||
|
vertex_input_info.pVertexBindingDescriptions = std::ptr::addr_of!(bind_desc);
|
||||||
|
vertex_input_info.pVertexAttributeDescriptions = attr_descs.as_ptr();
|
||||||
|
|
||||||
let mut input_assembly: ffi::VkPipelineInputAssemblyStateCreateInfo =
|
let mut input_assembly: ffi::VkPipelineInputAssemblyStateCreateInfo =
|
||||||
unsafe { std::mem::zeroed() };
|
unsafe { std::mem::zeroed() };
|
||||||
|
@ -1679,8 +1688,8 @@ impl VulkanApp {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
{
|
||||||
let data_ptr_vertices: *mut [Vertex; 3] = std::mem::transmute(data_ptr);
|
let data_ptr_vertices: &mut [Vertex; 3] = unsafe { std::mem::transmute(data_ptr) };
|
||||||
*data_ptr_vertices = VERTICES;
|
*data_ptr_vertices = VERTICES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1720,32 +1729,6 @@ impl VulkanApp {
|
||||||
|
|
||||||
Err(String::from("Failed to find suitable memory type!"))
|
Err(String::from("Failed to find suitable memory type!"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::type_complexity)]
|
|
||||||
fn create_vertex_input_state_info_struct() -> Result<
|
|
||||||
(
|
|
||||||
ffi::VkPipelineVertexInputStateCreateInfo,
|
|
||||||
Pin<Box<ffi::VkVertexInputBindingDescription>>,
|
|
||||||
Pin<Box<[ffi::VkVertexInputAttributeDescription; 2]>>,
|
|
||||||
),
|
|
||||||
String,
|
|
||||||
> {
|
|
||||||
let mut vertex_input_info: ffi::VkPipelineVertexInputStateCreateInfo =
|
|
||||||
unsafe { std::mem::zeroed() };
|
|
||||||
vertex_input_info.sType =
|
|
||||||
ffi::VkStructureType_VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
|
|
||||||
|
|
||||||
let bind_desc = Box::pin(Vertex::get_binding_description());
|
|
||||||
let attr_descs = Box::pin(Vertex::get_attribute_descriptions());
|
|
||||||
|
|
||||||
vertex_input_info.vertexBindingDescriptionCount = 1;
|
|
||||||
vertex_input_info.vertexAttributeDescriptionCount = attr_descs.len() as u32;
|
|
||||||
|
|
||||||
vertex_input_info.pVertexBindingDescriptions = bind_desc.deref();
|
|
||||||
vertex_input_info.pVertexAttributeDescriptions = attr_descs.as_ptr();
|
|
||||||
|
|
||||||
Ok((vertex_input_info, bind_desc, attr_descs))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for VulkanApp {
|
impl Drop for VulkanApp {
|
||||||
|
|
Loading…
Reference in a new issue