Merge pull request 'Apply repr(C) changes' (#14) from dev into master
Reviewed-on: #14
This commit is contained in:
commit
67fd07fec9
6 changed files with 48 additions and 86 deletions
|
@ -16,7 +16,7 @@ rfactor_sm_reader = { git = "https://gavania.de/hodasemi/rfactor_sm_reader.git"
|
||||||
ui = { git = "https://gavania.de/hodasemi/ui.git" }
|
ui = { git = "https://gavania.de/hodasemi/ui.git" }
|
||||||
|
|
||||||
anyhow = { version = "1.0.68", features = ["backtrace"] }
|
anyhow = { version = "1.0.68", features = ["backtrace"] }
|
||||||
cgmath = { version = "0.18.0", features = ["swizzle", "serde"] }
|
safer-ffi = { version = "0.0.10", features = ["proc_macros"] }
|
||||||
paste = "1.0.11"
|
paste = "1.0.11"
|
||||||
serde = "1.0.152"
|
serde = "1.0.152"
|
||||||
serde_json = "1.0.91"
|
serde_json = "1.0.91"
|
||||||
|
|
|
@ -3,7 +3,6 @@ use cgmath::{ortho, vec2, Deg};
|
||||||
use vulkan_rs::prelude::*;
|
use vulkan_rs::prelude::*;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
mem,
|
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
@ -21,16 +20,10 @@ impl BackgroundGenerator {
|
||||||
) -> Result<[Arc<Image>; N]> {
|
) -> Result<[Arc<Image>; N]> {
|
||||||
let max_supported_sample_count = device.max_supported_sample_count(VK_SAMPLE_COUNT_16_BIT);
|
let max_supported_sample_count = device.max_supported_sample_count(VK_SAMPLE_COUNT_16_BIT);
|
||||||
|
|
||||||
let vertex_shader = ShaderModule::from_slice(
|
let vertex_shader =
|
||||||
device.clone(),
|
ShaderModule::from_slice(device.clone(), include_bytes!("generator.vert.spv"))?;
|
||||||
include_bytes!("generator.vert.spv"),
|
let fragment_shader =
|
||||||
ShaderType::Vertex,
|
ShaderModule::from_slice(device.clone(), include_bytes!("generator.frag.spv"))?;
|
||||||
)?;
|
|
||||||
let fragment_shader = ShaderModule::from_slice(
|
|
||||||
device.clone(),
|
|
||||||
include_bytes!("generator.frag.spv"),
|
|
||||||
ShaderType::Fragment,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(image_infos
|
Ok(image_infos
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -93,23 +86,7 @@ impl BackgroundGenerator {
|
||||||
.build(device.clone())?;
|
.build(device.clone())?;
|
||||||
|
|
||||||
let pipeline = Pipeline::new_graphics()
|
let pipeline = Pipeline::new_graphics()
|
||||||
.set_vertex_shader(
|
.set_vertex_shader::<PositionOnlyVertex>(vertex_shader.clone())
|
||||||
vertex_shader.clone(),
|
|
||||||
vec![VkVertexInputBindingDescription {
|
|
||||||
binding: 0,
|
|
||||||
stride: mem::size_of::<PositionOnlyVertex>() as u32,
|
|
||||||
inputRate: VK_VERTEX_INPUT_RATE_VERTEX,
|
|
||||||
}],
|
|
||||||
vec![
|
|
||||||
// position
|
|
||||||
VkVertexInputAttributeDescription {
|
|
||||||
location: 0,
|
|
||||||
binding: 0,
|
|
||||||
format: VK_FORMAT_R32G32B32A32_SFLOAT,
|
|
||||||
offset: 0,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
)
|
|
||||||
.set_fragment_shader(fragment_shader.clone())
|
.set_fragment_shader(fragment_shader.clone())
|
||||||
.input_assembly(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, false)
|
.input_assembly(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, false)
|
||||||
.default_depth_stencil(false, false)
|
.default_depth_stencil(false, false)
|
||||||
|
|
|
@ -8,6 +8,11 @@ pub use pedals::*;
|
||||||
pub use radar::*;
|
pub use radar::*;
|
||||||
pub use watermark::*;
|
pub use watermark::*;
|
||||||
|
|
||||||
|
use std::mem;
|
||||||
|
use vulkan_rs::prelude::*;
|
||||||
|
|
||||||
|
#[derive_ReprC]
|
||||||
|
#[repr(C)]
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct PositionOnlyVertex {
|
pub struct PositionOnlyVertex {
|
||||||
pub position: cgmath::Vector4<f32>,
|
pub position: cgmath::Vector4<f32>,
|
||||||
|
@ -46,3 +51,25 @@ impl PositionOnlyVertex {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl VertexInputDescription for PositionOnlyVertex {
|
||||||
|
fn bindings() -> Vec<vulkan_rs::prelude::VkVertexInputBindingDescription> {
|
||||||
|
vec![VkVertexInputBindingDescription {
|
||||||
|
binding: 0,
|
||||||
|
stride: mem::size_of::<PositionOnlyVertex>() as u32,
|
||||||
|
inputRate: VK_VERTEX_INPUT_RATE_VERTEX,
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn attributes() -> Vec<vulkan_rs::prelude::VkVertexInputAttributeDescription> {
|
||||||
|
vec![
|
||||||
|
// position
|
||||||
|
VkVertexInputAttributeDescription {
|
||||||
|
location: 0,
|
||||||
|
binding: 0,
|
||||||
|
format: VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||||
|
offset: 0,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use vulkan_rs::prelude::*;
|
use vulkan_rs::prelude::*;
|
||||||
|
|
||||||
use std::{mem, sync::Arc};
|
use std::sync::Arc;
|
||||||
|
|
||||||
use super::super::PositionOnlyVertex;
|
use super::super::PositionOnlyVertex;
|
||||||
|
|
||||||
|
@ -17,16 +17,10 @@ impl HistoryPipeline {
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let vertex_shader = ShaderModule::from_slice(
|
let vertex_shader =
|
||||||
device.clone(),
|
ShaderModule::from_slice(device.clone(), include_bytes!("history.vert.spv"))?;
|
||||||
include_bytes!("history.vert.spv"),
|
let fragment_shader =
|
||||||
ShaderType::Vertex,
|
ShaderModule::from_slice(device.clone(), include_bytes!("history.frag.spv"))?;
|
||||||
)?;
|
|
||||||
let fragment_shader = ShaderModule::from_slice(
|
|
||||||
device.clone(),
|
|
||||||
include_bytes!("history.frag.spv"),
|
|
||||||
ShaderType::Fragment,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let descriptor_layout = DescriptorSetLayout::builder()
|
let descriptor_layout = DescriptorSetLayout::builder()
|
||||||
.add_layout_binding(
|
.add_layout_binding(
|
||||||
|
@ -59,23 +53,7 @@ impl HistoryPipeline {
|
||||||
};
|
};
|
||||||
|
|
||||||
let pipeline = Pipeline::new_graphics()
|
let pipeline = Pipeline::new_graphics()
|
||||||
.set_vertex_shader(
|
.set_vertex_shader::<PositionOnlyVertex>(vertex_shader.clone())
|
||||||
vertex_shader.clone(),
|
|
||||||
vec![VkVertexInputBindingDescription {
|
|
||||||
binding: 0,
|
|
||||||
stride: mem::size_of::<PositionOnlyVertex>() as u32,
|
|
||||||
inputRate: VK_VERTEX_INPUT_RATE_VERTEX,
|
|
||||||
}],
|
|
||||||
vec![
|
|
||||||
// position
|
|
||||||
VkVertexInputAttributeDescription {
|
|
||||||
location: 0,
|
|
||||||
binding: 0,
|
|
||||||
format: VK_FORMAT_R32G32B32A32_SFLOAT,
|
|
||||||
offset: 0,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
)
|
|
||||||
.set_fragment_shader(fragment_shader.clone())
|
.set_fragment_shader(fragment_shader.clone())
|
||||||
.input_assembly(VK_PRIMITIVE_TOPOLOGY_LINE_STRIP, false)
|
.input_assembly(VK_PRIMITIVE_TOPOLOGY_LINE_STRIP, false)
|
||||||
.default_depth_stencil(false, false)
|
.default_depth_stencil(false, false)
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
mod pipeline;
|
mod pipeline;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use cgmath::{ortho, vec2, vec3, vec4, Deg, InnerSpace, Matrix4, Rad, Vector2, Vector3};
|
|
||||||
use rfactor_sm_reader::*;
|
use rfactor_sm_reader::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use vulkan_rs::prelude::cgmath::{
|
||||||
|
ortho, vec2, vec3, vec4, Deg, InnerSpace, Matrix4, Rad, Vector2, Vector3,
|
||||||
|
};
|
||||||
use vulkan_rs::prelude::*;
|
use vulkan_rs::prelude::*;
|
||||||
|
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use vulkan_rs::prelude::*;
|
use vulkan_rs::prelude::*;
|
||||||
|
|
||||||
use std::{mem, sync::Arc};
|
use std::sync::Arc;
|
||||||
|
|
||||||
use super::PositionOnlyVertex;
|
use super::PositionOnlyVertex;
|
||||||
|
|
||||||
|
@ -17,16 +17,10 @@ impl SingleColorPipeline {
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let vertex_shader = ShaderModule::from_slice(
|
let vertex_shader =
|
||||||
device.clone(),
|
ShaderModule::from_slice(device.clone(), include_bytes!("single_color.vert.spv"))?;
|
||||||
include_bytes!("single_color.vert.spv"),
|
let fragment_shader =
|
||||||
ShaderType::Vertex,
|
ShaderModule::from_slice(device.clone(), include_bytes!("single_color.frag.spv"))?;
|
||||||
)?;
|
|
||||||
let fragment_shader = ShaderModule::from_slice(
|
|
||||||
device.clone(),
|
|
||||||
include_bytes!("single_color.frag.spv"),
|
|
||||||
ShaderType::Fragment,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let descriptor_layout = DescriptorSetLayout::builder()
|
let descriptor_layout = DescriptorSetLayout::builder()
|
||||||
.add_layout_binding(
|
.add_layout_binding(
|
||||||
|
@ -59,23 +53,7 @@ impl SingleColorPipeline {
|
||||||
};
|
};
|
||||||
|
|
||||||
let pipeline = Pipeline::new_graphics()
|
let pipeline = Pipeline::new_graphics()
|
||||||
.set_vertex_shader(
|
.set_vertex_shader::<PositionOnlyVertex>(vertex_shader.clone())
|
||||||
vertex_shader.clone(),
|
|
||||||
vec![VkVertexInputBindingDescription {
|
|
||||||
binding: 0,
|
|
||||||
stride: mem::size_of::<PositionOnlyVertex>() as u32,
|
|
||||||
inputRate: VK_VERTEX_INPUT_RATE_VERTEX,
|
|
||||||
}],
|
|
||||||
vec![
|
|
||||||
// position
|
|
||||||
VkVertexInputAttributeDescription {
|
|
||||||
location: 0,
|
|
||||||
binding: 0,
|
|
||||||
format: VK_FORMAT_R32G32B32A32_SFLOAT,
|
|
||||||
offset: 0,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
)
|
|
||||||
.set_fragment_shader(fragment_shader.clone())
|
.set_fragment_shader(fragment_shader.clone())
|
||||||
.input_assembly(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, false)
|
.input_assembly(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, false)
|
||||||
.default_depth_stencil(false, false)
|
.default_depth_stencil(false, false)
|
||||||
|
|
Loading…
Reference in a new issue