Compare commits

..

No commits in common. "e4bb7fc2b6f577684c49e49e07badde938348bc3" and "19f33b2fe15b67d0d2650ffffd66b0a3d288006b" have entirely different histories.

6 changed files with 86 additions and 48 deletions

View file

@ -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"] }
safer-ffi = { version = "0.0.10", features = ["proc_macros"] } cgmath = { version = "0.18.0", features = ["swizzle", "serde"] }
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"

View file

@ -3,6 +3,7 @@ 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,
}; };
@ -20,10 +21,16 @@ 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 = let vertex_shader = ShaderModule::from_slice(
ShaderModule::from_slice(device.clone(), include_bytes!("generator.vert.spv"))?; device.clone(),
let fragment_shader = include_bytes!("generator.vert.spv"),
ShaderModule::from_slice(device.clone(), include_bytes!("generator.frag.spv"))?; ShaderType::Vertex,
)?;
let fragment_shader = ShaderModule::from_slice(
device.clone(),
include_bytes!("generator.frag.spv"),
ShaderType::Fragment,
)?;
Ok(image_infos Ok(image_infos
.iter() .iter()
@ -86,7 +93,23 @@ impl BackgroundGenerator {
.build(device.clone())?; .build(device.clone())?;
let pipeline = Pipeline::new_graphics() let pipeline = Pipeline::new_graphics()
.set_vertex_shader::<PositionOnlyVertex>(vertex_shader.clone()) .set_vertex_shader(
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)

View file

@ -8,11 +8,6 @@ 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>,
@ -51,25 +46,3 @@ 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,
},
]
}
}

View file

@ -1,7 +1,7 @@
use anyhow::Result; use anyhow::Result;
use vulkan_rs::prelude::*; use vulkan_rs::prelude::*;
use std::sync::Arc; use std::{mem, sync::Arc};
use super::super::PositionOnlyVertex; use super::super::PositionOnlyVertex;
@ -17,10 +17,16 @@ impl HistoryPipeline {
width: u32, width: u32,
height: u32, height: u32,
) -> Result<Self> { ) -> Result<Self> {
let vertex_shader = let vertex_shader = ShaderModule::from_slice(
ShaderModule::from_slice(device.clone(), include_bytes!("history.vert.spv"))?; device.clone(),
let fragment_shader = include_bytes!("history.vert.spv"),
ShaderModule::from_slice(device.clone(), include_bytes!("history.frag.spv"))?; ShaderType::Vertex,
)?;
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(
@ -53,7 +59,23 @@ impl HistoryPipeline {
}; };
let pipeline = Pipeline::new_graphics() let pipeline = Pipeline::new_graphics()
.set_vertex_shader::<PositionOnlyVertex>(vertex_shader.clone()) .set_vertex_shader(
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)

View file

@ -1,11 +1,9 @@
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};

View file

@ -1,7 +1,7 @@
use anyhow::Result; use anyhow::Result;
use vulkan_rs::prelude::*; use vulkan_rs::prelude::*;
use std::sync::Arc; use std::{mem, sync::Arc};
use super::PositionOnlyVertex; use super::PositionOnlyVertex;
@ -17,10 +17,16 @@ impl SingleColorPipeline {
width: u32, width: u32,
height: u32, height: u32,
) -> Result<Self> { ) -> Result<Self> {
let vertex_shader = let vertex_shader = ShaderModule::from_slice(
ShaderModule::from_slice(device.clone(), include_bytes!("single_color.vert.spv"))?; device.clone(),
let fragment_shader = include_bytes!("single_color.vert.spv"),
ShaderModule::from_slice(device.clone(), include_bytes!("single_color.frag.spv"))?; ShaderType::Vertex,
)?;
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(
@ -53,7 +59,23 @@ impl SingleColorPipeline {
}; };
let pipeline = Pipeline::new_graphics() let pipeline = Pipeline::new_graphics()
.set_vertex_shader::<PositionOnlyVertex>(vertex_shader.clone()) .set_vertex_shader(
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)