Merge pull request 'Update from dev' (#53) from dev into master
Reviewed-on: #53
This commit is contained in:
commit
c4d199ac4b
6 changed files with 76 additions and 30 deletions
|
@ -7,7 +7,7 @@ pkgdesc="Vulkan overlay layer for rFactor 2"
|
||||||
arch=('x86_64')
|
arch=('x86_64')
|
||||||
url="https://gavania.de/hodasemi/${_pkgbase}"
|
url="https://gavania.de/hodasemi/${_pkgbase}"
|
||||||
license=('GPL-3.0')
|
license=('GPL-3.0')
|
||||||
makedepends=('rust' 'ctags' 'glslang')
|
makedepends=('rust' 'ctags' 'glslang' 'vulkan-headers')
|
||||||
depends=()
|
depends=()
|
||||||
conflicts=("${_pkgbase}")
|
conflicts=("${_pkgbase}")
|
||||||
source=("git+${url}")
|
source=("git+${url}")
|
||||||
|
|
|
@ -218,7 +218,7 @@ impl LeaderBoardEntry {
|
||||||
if best_lap > 60.0 {
|
if best_lap > 60.0 {
|
||||||
let (full_minutes, remainder) = Self::split_minute(best_lap);
|
let (full_minutes, remainder) = Self::split_minute(best_lap);
|
||||||
|
|
||||||
format!("{:.0}:{:.3}", full_minutes, remainder)
|
format!("{:.0}:{:06.3}", full_minutes, remainder)
|
||||||
} else {
|
} else {
|
||||||
format!("{:.3}", best_lap)
|
format!("{:.3}", best_lap)
|
||||||
}
|
}
|
||||||
|
@ -307,5 +307,7 @@ mod test {
|
||||||
let behind_leader = LeaderBoardEntry::calculate_behind_leader(BehindLeader::Time(85.42));
|
let behind_leader = LeaderBoardEntry::calculate_behind_leader(BehindLeader::Time(85.42));
|
||||||
let behind_next = LeaderBoardEntry::calculate_behind_next(150.213423);
|
let behind_next = LeaderBoardEntry::calculate_behind_next(150.213423);
|
||||||
let best_lap = LeaderBoardEntry::calculuate_best_lap(97.23436);
|
let best_lap = LeaderBoardEntry::calculuate_best_lap(97.23436);
|
||||||
|
|
||||||
|
let t = LeaderBoardEntry::calculuate_best_lap(65.23436);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,16 @@ impl Pedals {
|
||||||
|
|
||||||
write_log!("allocate throttle descriptor");
|
write_log!("allocate throttle descriptor");
|
||||||
|
|
||||||
let throttle_descriptor = descriptor_pool.prepare_set().allocate()?;
|
let throttle_descriptor = match descriptor_pool.prepare_set().allocate() {
|
||||||
|
Ok(d) => d,
|
||||||
|
Err(err) => {
|
||||||
|
write_log!(format!("desc alloc {:?}, {}", err, err.backtrace()));
|
||||||
|
return Err(err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
write_log!("update throttle descriptor");
|
||||||
|
|
||||||
throttle_descriptor.update(&[DescriptorWrite::uniform_buffers(
|
throttle_descriptor.update(&[DescriptorWrite::uniform_buffers(
|
||||||
0,
|
0,
|
||||||
&[&throttle_color_buffer],
|
&[&throttle_color_buffer],
|
||||||
|
@ -130,6 +139,8 @@ impl Pedals {
|
||||||
brake_samples.push_overwrite(0.0);
|
brake_samples.push_overwrite(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
write_log!(format!("create vertex buffers ({icon_width})"));
|
||||||
|
|
||||||
let brake_vertex_buffer = Self::create_vertex_buffer(&device, icon_width as VkDeviceSize)?;
|
let brake_vertex_buffer = Self::create_vertex_buffer(&device, icon_width as VkDeviceSize)?;
|
||||||
let throttle_vertex_buffer =
|
let throttle_vertex_buffer =
|
||||||
Self::create_vertex_buffer(&device, icon_width as VkDeviceSize)?;
|
Self::create_vertex_buffer(&device, icon_width as VkDeviceSize)?;
|
||||||
|
@ -160,6 +171,8 @@ impl Pedals {
|
||||||
throttle_vertex_buffer,
|
throttle_vertex_buffer,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
write_log!("update vertex buffers");
|
||||||
|
|
||||||
me.update_vertex_buffers()?;
|
me.update_vertex_buffers()?;
|
||||||
|
|
||||||
Ok(me)
|
Ok(me)
|
||||||
|
@ -207,26 +220,27 @@ impl Pedals {
|
||||||
let command_buffer =
|
let command_buffer =
|
||||||
CommandBuffer::new_primary().build(self.device.clone(), self.queue.clone())?;
|
CommandBuffer::new_primary().build(self.device.clone(), self.queue.clone())?;
|
||||||
|
|
||||||
if self.enable {
|
{
|
||||||
let mut recorder = command_buffer.begin(VkCommandBufferBeginInfo::new(
|
let mut recorder = command_buffer.begin(VkCommandBufferBeginInfo::new(
|
||||||
VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
|
VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
|
||||||
| VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT,
|
| VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT,
|
||||||
))?;
|
))?;
|
||||||
|
if self.enable {
|
||||||
|
self.render_target
|
||||||
|
.begin(&mut recorder, VK_SUBPASS_CONTENTS_INLINE, 0);
|
||||||
|
|
||||||
self.render_target
|
recorder.bind_pipeline(self.pipeline.pipeline())?;
|
||||||
.begin(&mut recorder, VK_SUBPASS_CONTENTS_INLINE, 0);
|
|
||||||
|
|
||||||
recorder.bind_pipeline(self.pipeline.pipeline())?;
|
recorder.bind_descriptor_sets_minimal(&[&self.throttle_descriptor]);
|
||||||
|
recorder.bind_vertex_buffer(&self.throttle_vertex_buffer);
|
||||||
|
recorder.draw_complete_single_instance(self.throttle_vertex_buffer.size() as u32);
|
||||||
|
|
||||||
recorder.bind_descriptor_sets_minimal(&[&self.throttle_descriptor]);
|
recorder.bind_descriptor_sets_minimal(&[&self.brake_descriptor]);
|
||||||
recorder.bind_vertex_buffer(&self.throttle_vertex_buffer);
|
recorder.bind_vertex_buffer(&self.brake_vertex_buffer);
|
||||||
recorder.draw_complete_single_instance(self.throttle_vertex_buffer.size() as u32);
|
recorder.draw_complete_single_instance(self.brake_vertex_buffer.size() as u32);
|
||||||
|
|
||||||
recorder.bind_descriptor_sets_minimal(&[&self.brake_descriptor]);
|
self.render_target.end(&mut recorder);
|
||||||
recorder.bind_vertex_buffer(&self.brake_vertex_buffer);
|
}
|
||||||
recorder.draw_complete_single_instance(self.brake_vertex_buffer.size() as u32);
|
|
||||||
|
|
||||||
self.render_target.end(&mut recorder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(command_buffer)
|
Ok(command_buffer)
|
||||||
|
|
|
@ -222,29 +222,31 @@ impl Radar {
|
||||||
let command_buffer =
|
let command_buffer =
|
||||||
CommandBuffer::new_primary().build(self.device.clone(), self.queue.clone())?;
|
CommandBuffer::new_primary().build(self.device.clone(), self.queue.clone())?;
|
||||||
|
|
||||||
if self.enable {
|
{
|
||||||
let mut recorder = command_buffer.begin(VkCommandBufferBeginInfo::new(
|
let mut recorder = command_buffer.begin(VkCommandBufferBeginInfo::new(
|
||||||
VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
|
VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
|
||||||
| VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT,
|
| VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT,
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
self.render_target.begin(
|
if self.enable {
|
||||||
&mut recorder,
|
self.render_target.begin(
|
||||||
VK_SUBPASS_CONTENTS_INLINE,
|
&mut recorder,
|
||||||
image_index as usize,
|
VK_SUBPASS_CONTENTS_INLINE,
|
||||||
);
|
image_index as usize,
|
||||||
|
);
|
||||||
|
|
||||||
recorder.bind_pipeline(self.pipeline.pipeline())?;
|
recorder.bind_pipeline(self.pipeline.pipeline())?;
|
||||||
|
|
||||||
for object in self.objects() {
|
for object in self.objects() {
|
||||||
let buffer = &object.position_buffer;
|
let buffer = &object.position_buffer;
|
||||||
|
|
||||||
recorder.bind_descriptor_sets_minimal(&[&object.descriptor_set]);
|
recorder.bind_descriptor_sets_minimal(&[&object.descriptor_set]);
|
||||||
recorder.bind_vertex_buffer(buffer);
|
recorder.bind_vertex_buffer(buffer);
|
||||||
recorder.draw_complete_single_instance(buffer.size() as u32);
|
recorder.draw_complete_single_instance(buffer.size() as u32);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.render_target.end(&mut recorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.render_target.end(&mut recorder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(command_buffer)
|
Ok(command_buffer)
|
||||||
|
|
|
@ -55,6 +55,8 @@ extern "system" fn get_device_proc_addr(
|
||||||
_device: VkDevice,
|
_device: VkDevice,
|
||||||
function_name: *const c_char,
|
function_name: *const c_char,
|
||||||
) -> PFN_vkVoidFunction {
|
) -> PFN_vkVoidFunction {
|
||||||
|
write_log!("get_device_proc_addr");
|
||||||
|
|
||||||
let func_string = match VkString::try_from(function_name) {
|
let func_string = match VkString::try_from(function_name) {
|
||||||
Ok(func) => func,
|
Ok(func) => func,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
@ -65,6 +67,8 @@ extern "system" fn get_device_proc_addr(
|
||||||
|
|
||||||
let s = func_string.as_str();
|
let s = func_string.as_str();
|
||||||
|
|
||||||
|
write_log!(format!("\t{}", s));
|
||||||
|
|
||||||
if let Some(func) = Functions::get_vk_func(s) {
|
if let Some(func) = Functions::get_vk_func(s) {
|
||||||
return func.convert();
|
return func.convert();
|
||||||
}
|
}
|
||||||
|
@ -73,6 +77,8 @@ extern "system" fn get_device_proc_addr(
|
||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
write_log!("\t-> returning null");
|
||||||
|
|
||||||
Functions::Null.convert()
|
Functions::Null.convert()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +87,8 @@ extern "system" fn get_instance_proc_addr(
|
||||||
_instance: VkInstance,
|
_instance: VkInstance,
|
||||||
function_name: *const c_char,
|
function_name: *const c_char,
|
||||||
) -> PFN_vkVoidFunction {
|
) -> PFN_vkVoidFunction {
|
||||||
|
write_log!("get_instance_proc_addr");
|
||||||
|
|
||||||
let func_string = match VkString::try_from(function_name) {
|
let func_string = match VkString::try_from(function_name) {
|
||||||
Ok(func) => func,
|
Ok(func) => func,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
@ -91,6 +99,8 @@ extern "system" fn get_instance_proc_addr(
|
||||||
|
|
||||||
let s = func_string.as_str();
|
let s = func_string.as_str();
|
||||||
|
|
||||||
|
write_log!(format!("\t{}", s));
|
||||||
|
|
||||||
if let Some(func) = Functions::get_vk_func(s) {
|
if let Some(func) = Functions::get_vk_func(s) {
|
||||||
return func.convert();
|
return func.convert();
|
||||||
}
|
}
|
||||||
|
@ -99,6 +109,8 @@ extern "system" fn get_instance_proc_addr(
|
||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
write_log!("\t-> returning null");
|
||||||
|
|
||||||
Functions::Null.convert()
|
Functions::Null.convert()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +156,8 @@ pub(crate) extern "system" fn create_instance(
|
||||||
|
|
||||||
// DXVK workaround, it creates the instance twice with different properties
|
// DXVK workaround, it creates the instance twice with different properties
|
||||||
if ext_names.contains(&VkString::new("VK_KHR_surface")) {
|
if ext_names.contains(&VkString::new("VK_KHR_surface")) {
|
||||||
|
write_log!("found VK_KHR_surface");
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let panic_result =
|
let panic_result =
|
||||||
match std::panic::catch_unwind(|| -> anyhow::Result<std::sync::Arc<Instance>> {
|
match std::panic::catch_unwind(|| -> anyhow::Result<std::sync::Arc<Instance>> {
|
||||||
|
@ -151,7 +165,11 @@ pub(crate) extern "system" fn create_instance(
|
||||||
*instance,
|
*instance,
|
||||||
proc_addr,
|
proc_addr,
|
||||||
&ext_names,
|
&ext_names,
|
||||||
(*(*create_info).pApplicationInfo).apiVersion,
|
if (*create_info).pApplicationInfo == ptr::null() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some((*(*create_info).pApplicationInfo).apiVersion)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}) {
|
}) {
|
||||||
Ok(panic_ok) => panic_ok,
|
Ok(panic_ok) => panic_ok,
|
||||||
|
@ -178,6 +196,8 @@ pub(crate) extern "system" fn create_instance(
|
||||||
write_log!("-> created local instance handle");
|
write_log!("-> created local instance handle");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
write_log!("returning from create_instance");
|
||||||
|
|
||||||
VK_SUCCESS
|
VK_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@ use anyhow::Result;
|
||||||
use std::{collections::HashMap, ffi::c_void, mem, ptr};
|
use std::{collections::HashMap, ffi::c_void, mem, ptr};
|
||||||
use vulkan_rs::prelude::*;
|
use vulkan_rs::prelude::*;
|
||||||
|
|
||||||
|
use crate::write_log;
|
||||||
|
|
||||||
static mut FN_HANDLES: Option<VkTypedefHandles> = None;
|
static mut FN_HANDLES: Option<VkTypedefHandles> = None;
|
||||||
|
|
||||||
pub fn vk_handles() -> &'static VkTypedefHandles {
|
pub fn vk_handles() -> &'static VkTypedefHandles {
|
||||||
|
@ -43,7 +45,10 @@ impl VkTypedefHandles {
|
||||||
let function = proc_addr(instance, name.as_ptr());
|
let function = proc_addr(instance, name.as_ptr());
|
||||||
|
|
||||||
if mem::transmute::<PFN_vkVoidFunction, *const c_void>(function) != ptr::null() {
|
if mem::transmute::<PFN_vkVoidFunction, *const c_void>(function) != ptr::null() {
|
||||||
|
write_log!(format!("layer (instance): successfully read: {}", symbol));
|
||||||
self.functions.insert(symbol.clone(), function);
|
self.functions.insert(symbol.clone(), function);
|
||||||
|
} else {
|
||||||
|
write_log!(format!("layer (instance): failed reading {}", symbol));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +61,10 @@ impl VkTypedefHandles {
|
||||||
let function = proc_addr(device, name.as_ptr());
|
let function = proc_addr(device, name.as_ptr());
|
||||||
|
|
||||||
if mem::transmute::<PFN_vkVoidFunction, *const c_void>(function) != ptr::null() {
|
if mem::transmute::<PFN_vkVoidFunction, *const c_void>(function) != ptr::null() {
|
||||||
|
write_log!(format!("layer (device): successfully read: {}", symbol));
|
||||||
self.functions.insert(symbol.clone(), function);
|
self.functions.insert(symbol.clone(), function);
|
||||||
|
} else {
|
||||||
|
write_log!(format!("layer (device): failed reading {}", symbol));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue