Merge pull request 'Update from dev' (#53) from dev into master

Reviewed-on: #53
This commit is contained in:
hodasemi 2023-08-16 09:05:10 +02:00
commit c4d199ac4b
6 changed files with 76 additions and 30 deletions

View file

@ -7,7 +7,7 @@ pkgdesc="Vulkan overlay layer for rFactor 2"
arch=('x86_64')
url="https://gavania.de/hodasemi/${_pkgbase}"
license=('GPL-3.0')
makedepends=('rust' 'ctags' 'glslang')
makedepends=('rust' 'ctags' 'glslang' 'vulkan-headers')
depends=()
conflicts=("${_pkgbase}")
source=("git+${url}")

View file

@ -218,7 +218,7 @@ impl LeaderBoardEntry {
if best_lap > 60.0 {
let (full_minutes, remainder) = Self::split_minute(best_lap);
format!("{:.0}:{:.3}", full_minutes, remainder)
format!("{:.0}:{:06.3}", full_minutes, remainder)
} else {
format!("{:.3}", best_lap)
}
@ -307,5 +307,7 @@ mod test {
let behind_leader = LeaderBoardEntry::calculate_behind_leader(BehindLeader::Time(85.42));
let behind_next = LeaderBoardEntry::calculate_behind_next(150.213423);
let best_lap = LeaderBoardEntry::calculuate_best_lap(97.23436);
let t = LeaderBoardEntry::calculuate_best_lap(65.23436);
}
}

View file

@ -116,7 +116,16 @@ impl Pedals {
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(
0,
&[&throttle_color_buffer],
@ -130,6 +139,8 @@ impl Pedals {
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 throttle_vertex_buffer =
Self::create_vertex_buffer(&device, icon_width as VkDeviceSize)?;
@ -160,6 +171,8 @@ impl Pedals {
throttle_vertex_buffer,
};
write_log!("update vertex buffers");
me.update_vertex_buffers()?;
Ok(me)
@ -207,12 +220,12 @@ impl Pedals {
let command_buffer =
CommandBuffer::new_primary().build(self.device.clone(), self.queue.clone())?;
if self.enable {
{
let mut recorder = command_buffer.begin(VkCommandBufferBeginInfo::new(
VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
| VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT,
))?;
if self.enable {
self.render_target
.begin(&mut recorder, VK_SUBPASS_CONTENTS_INLINE, 0);
@ -228,6 +241,7 @@ impl Pedals {
self.render_target.end(&mut recorder);
}
}
Ok(command_buffer)
}

View file

@ -222,12 +222,13 @@ impl Radar {
let command_buffer =
CommandBuffer::new_primary().build(self.device.clone(), self.queue.clone())?;
if self.enable {
{
let mut recorder = command_buffer.begin(VkCommandBufferBeginInfo::new(
VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
| VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT,
))?;
if self.enable {
self.render_target.begin(
&mut recorder,
VK_SUBPASS_CONTENTS_INLINE,
@ -246,6 +247,7 @@ impl Radar {
self.render_target.end(&mut recorder);
}
}
Ok(command_buffer)
}

View file

@ -55,6 +55,8 @@ extern "system" fn get_device_proc_addr(
_device: VkDevice,
function_name: *const c_char,
) -> PFN_vkVoidFunction {
write_log!("get_device_proc_addr");
let func_string = match VkString::try_from(function_name) {
Ok(func) => func,
Err(_) => {
@ -65,6 +67,8 @@ extern "system" fn get_device_proc_addr(
let s = func_string.as_str();
write_log!(format!("\t{}", s));
if let Some(func) = Functions::get_vk_func(s) {
return func.convert();
}
@ -73,6 +77,8 @@ extern "system" fn get_device_proc_addr(
return func;
}
write_log!("\t-> returning null");
Functions::Null.convert()
}
@ -81,6 +87,8 @@ extern "system" fn get_instance_proc_addr(
_instance: VkInstance,
function_name: *const c_char,
) -> PFN_vkVoidFunction {
write_log!("get_instance_proc_addr");
let func_string = match VkString::try_from(function_name) {
Ok(func) => func,
Err(_) => {
@ -91,6 +99,8 @@ extern "system" fn get_instance_proc_addr(
let s = func_string.as_str();
write_log!(format!("\t{}", s));
if let Some(func) = Functions::get_vk_func(s) {
return func.convert();
}
@ -99,6 +109,8 @@ extern "system" fn get_instance_proc_addr(
return func;
}
write_log!("\t-> returning null");
Functions::Null.convert()
}
@ -144,6 +156,8 @@ pub(crate) extern "system" fn create_instance(
// DXVK workaround, it creates the instance twice with different properties
if ext_names.contains(&VkString::new("VK_KHR_surface")) {
write_log!("found VK_KHR_surface");
unsafe {
let panic_result =
match std::panic::catch_unwind(|| -> anyhow::Result<std::sync::Arc<Instance>> {
@ -151,7 +165,11 @@ pub(crate) extern "system" fn create_instance(
*instance,
proc_addr,
&ext_names,
(*(*create_info).pApplicationInfo).apiVersion,
if (*create_info).pApplicationInfo == ptr::null() {
None
} else {
Some((*(*create_info).pApplicationInfo).apiVersion)
},
)
}) {
Ok(panic_ok) => panic_ok,
@ -178,6 +196,8 @@ pub(crate) extern "system" fn create_instance(
write_log!("-> created local instance handle");
}
write_log!("returning from create_instance");
VK_SUCCESS
}

View file

@ -2,6 +2,8 @@ use anyhow::Result;
use std::{collections::HashMap, ffi::c_void, mem, ptr};
use vulkan_rs::prelude::*;
use crate::write_log;
static mut FN_HANDLES: Option<VkTypedefHandles> = None;
pub fn vk_handles() -> &'static VkTypedefHandles {
@ -43,7 +45,10 @@ impl VkTypedefHandles {
let function = proc_addr(instance, name.as_ptr());
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);
} else {
write_log!(format!("layer (instance): failed reading {}", symbol));
}
}
}
@ -56,7 +61,10 @@ impl VkTypedefHandles {
let function = proc_addr(device, name.as_ptr());
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);
} else {
write_log!(format!("layer (device): failed reading {}", symbol));
}
}
}