Compare commits
2 commits
19f33b2fe1
...
e4bb7fc2b6
Author | SHA1 | Date | |
---|---|---|---|
e4bb7fc2b6 | |||
2a14cd60ca |
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" }
|
||||
|
||||
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"
|
||||
serde = "1.0.152"
|
||||
serde_json = "1.0.91"
|
||||
|
|
|
@ -3,7 +3,6 @@ use cgmath::{ortho, vec2, Deg};
|
|||
use vulkan_rs::prelude::*;
|
||||
|
||||
use std::{
|
||||
mem,
|
||||
sync::{Arc, Mutex},
|
||||
time::Duration,
|
||||
};
|
||||
|
@ -21,16 +20,10 @@ impl BackgroundGenerator {
|
|||
) -> Result<[Arc<Image>; N]> {
|
||||
let max_supported_sample_count = device.max_supported_sample_count(VK_SAMPLE_COUNT_16_BIT);
|
||||
|
||||
let vertex_shader = ShaderModule::from_slice(
|
||||
device.clone(),
|
||||
include_bytes!("generator.vert.spv"),
|
||||
ShaderType::Vertex,
|
||||
)?;
|
||||
let fragment_shader = ShaderModule::from_slice(
|
||||
device.clone(),
|
||||
include_bytes!("generator.frag.spv"),
|
||||
ShaderType::Fragment,
|
||||
)?;
|
||||
let vertex_shader =
|
||||
ShaderModule::from_slice(device.clone(), include_bytes!("generator.vert.spv"))?;
|
||||
let fragment_shader =
|
||||
ShaderModule::from_slice(device.clone(), include_bytes!("generator.frag.spv"))?;
|
||||
|
||||
Ok(image_infos
|
||||
.iter()
|
||||
|
@ -93,23 +86,7 @@ impl BackgroundGenerator {
|
|||
.build(device.clone())?;
|
||||
|
||||
let pipeline = Pipeline::new_graphics()
|
||||
.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_vertex_shader::<PositionOnlyVertex>(vertex_shader.clone())
|
||||
.set_fragment_shader(fragment_shader.clone())
|
||||
.input_assembly(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, false)
|
||||
.default_depth_stencil(false, false)
|
||||
|
|
|
@ -8,6 +8,11 @@ pub use pedals::*;
|
|||
pub use radar::*;
|
||||
pub use watermark::*;
|
||||
|
||||
use std::mem;
|
||||
use vulkan_rs::prelude::*;
|
||||
|
||||
#[derive_ReprC]
|
||||
#[repr(C)]
|
||||
#[derive(Clone)]
|
||||
pub struct PositionOnlyVertex {
|
||||
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 vulkan_rs::prelude::*;
|
||||
|
||||
use std::{mem, sync::Arc};
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::super::PositionOnlyVertex;
|
||||
|
||||
|
@ -17,16 +17,10 @@ impl HistoryPipeline {
|
|||
width: u32,
|
||||
height: u32,
|
||||
) -> Result<Self> {
|
||||
let vertex_shader = ShaderModule::from_slice(
|
||||
device.clone(),
|
||||
include_bytes!("history.vert.spv"),
|
||||
ShaderType::Vertex,
|
||||
)?;
|
||||
let fragment_shader = ShaderModule::from_slice(
|
||||
device.clone(),
|
||||
include_bytes!("history.frag.spv"),
|
||||
ShaderType::Fragment,
|
||||
)?;
|
||||
let vertex_shader =
|
||||
ShaderModule::from_slice(device.clone(), include_bytes!("history.vert.spv"))?;
|
||||
let fragment_shader =
|
||||
ShaderModule::from_slice(device.clone(), include_bytes!("history.frag.spv"))?;
|
||||
|
||||
let descriptor_layout = DescriptorSetLayout::builder()
|
||||
.add_layout_binding(
|
||||
|
@ -59,23 +53,7 @@ impl HistoryPipeline {
|
|||
};
|
||||
|
||||
let pipeline = Pipeline::new_graphics()
|
||||
.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_vertex_shader::<PositionOnlyVertex>(vertex_shader.clone())
|
||||
.set_fragment_shader(fragment_shader.clone())
|
||||
.input_assembly(VK_PRIMITIVE_TOPOLOGY_LINE_STRIP, false)
|
||||
.default_depth_stencil(false, false)
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
mod pipeline;
|
||||
|
||||
use anyhow::Result;
|
||||
use cgmath::{ortho, vec2, vec3, vec4, Deg, InnerSpace, Matrix4, Rad, Vector2, Vector3};
|
||||
use rfactor_sm_reader::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vulkan_rs::prelude::cgmath::{
|
||||
ortho, vec2, vec3, vec4, Deg, InnerSpace, Matrix4, Rad, Vector2, Vector3,
|
||||
};
|
||||
use vulkan_rs::prelude::*;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use anyhow::Result;
|
||||
use vulkan_rs::prelude::*;
|
||||
|
||||
use std::{mem, sync::Arc};
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::PositionOnlyVertex;
|
||||
|
||||
|
@ -17,16 +17,10 @@ impl SingleColorPipeline {
|
|||
width: u32,
|
||||
height: u32,
|
||||
) -> Result<Self> {
|
||||
let vertex_shader = ShaderModule::from_slice(
|
||||
device.clone(),
|
||||
include_bytes!("single_color.vert.spv"),
|
||||
ShaderType::Vertex,
|
||||
)?;
|
||||
let fragment_shader = ShaderModule::from_slice(
|
||||
device.clone(),
|
||||
include_bytes!("single_color.frag.spv"),
|
||||
ShaderType::Fragment,
|
||||
)?;
|
||||
let vertex_shader =
|
||||
ShaderModule::from_slice(device.clone(), include_bytes!("single_color.vert.spv"))?;
|
||||
let fragment_shader =
|
||||
ShaderModule::from_slice(device.clone(), include_bytes!("single_color.frag.spv"))?;
|
||||
|
||||
let descriptor_layout = DescriptorSetLayout::builder()
|
||||
.add_layout_binding(
|
||||
|
@ -59,23 +53,7 @@ impl SingleColorPipeline {
|
|||
};
|
||||
|
||||
let pipeline = Pipeline::new_graphics()
|
||||
.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_vertex_shader::<PositionOnlyVertex>(vertex_shader.clone())
|
||||
.set_fragment_shader(fragment_shader.clone())
|
||||
.input_assembly(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, false)
|
||||
.default_depth_stencil(false, false)
|
||||
|
|
Loading…
Reference in a new issue