Use vk rs

This commit is contained in:
hodasemi 2023-01-11 21:46:17 +01:00
parent b49c026a05
commit a7469023f6
5 changed files with 11 additions and 27 deletions

View file

@ -9,5 +9,6 @@ edition = "2021"
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
vulkan-sys = { git = "https://gavania.de/Gavania/Gavania.git", branch = "0.2.0_dev" } # vulkan-rs = { git = "ssh://gitea@gavania.de:23/Gavania/Gavania.git", branch = "0.2.0_dev" }
vulkan-rs = { path = "/home/michael/Dokumente/Workspace/Gavania/vulkan-rs" }
anyhow = { version = "1.0.68", features = ["backtrace"] } anyhow = { version = "1.0.68", features = ["backtrace"] }

View file

@ -1,7 +1,7 @@
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
use std::{mem, ptr}; use std::{mem, ptr};
use vulkan_sys::prelude::*; use vulkan_rs::prelude::*;
pub use VkLayerFunction::*; pub use VkLayerFunction::*;
pub use VkNegotiateLayerStructType::*; pub use VkNegotiateLayerStructType::*;

View file

@ -14,7 +14,7 @@ use std::{
use enums::*; use enums::*;
use structs::*; use structs::*;
use vk_handles::*; use vk_handles::*;
use vulkan_sys::prelude::*; use vulkan_rs::prelude::*;
const LOG_FILE: &'static str = "/home/michael/rf2_vk_hud.log"; const LOG_FILE: &'static str = "/home/michael/rf2_vk_hud.log";

View file

@ -2,7 +2,7 @@
use crate::enums::*; use crate::enums::*;
use vulkan_sys::prelude::*; use vulkan_rs::prelude::*;
use std::{ use std::{
mem::{self, ManuallyDrop}, mem::{self, ManuallyDrop},

View file

@ -1,6 +1,6 @@
use anyhow::Result; use anyhow::Result;
use std::{collections::HashMap, ffi::c_void, mem, ptr}; use std::{collections::HashMap, ffi::c_void, mem, ptr};
use vulkan_sys::prelude::*; use vulkan_rs::prelude::*;
static mut FN_HANDLES: Option<VkTypedefHandles> = None; static mut FN_HANDLES: Option<VkTypedefHandles> = None;
@ -19,21 +19,16 @@ pub fn set_vk_handles(handles: VkTypedefHandles) {
pub struct VkTypedefHandles { pub struct VkTypedefHandles {
typedefs: Vec<String>, typedefs: Vec<String>,
functions: HashMap<String, PFN_vkVoidFunction>, functions: HashMap<String, PFN_vkVoidFunction>,
instance: VkInstance,
device: VkDevice,
} }
impl VkTypedefHandles { impl VkTypedefHandles {
pub fn new() -> Result<Self> { pub fn new() -> Result<Self> {
let fns = include_str!("../vk_functions");
let symbols = fns.lines().map(|s| s.to_string()).collect();
Ok(Self { Ok(Self {
typedefs: symbols, typedefs: include_str!("../vk_functions")
.lines()
.map(|s| s.to_string())
.collect(),
functions: HashMap::new(), functions: HashMap::new(),
instance: VkInstance::NULL_HANDLE,
device: VkDevice::NULL_HANDLE,
}) })
} }
@ -42,8 +37,6 @@ impl VkTypedefHandles {
instance: VkInstance, instance: VkInstance,
proc_addr: PFN_vkGetInstanceProcAddr, proc_addr: PFN_vkGetInstanceProcAddr,
) { ) {
self.instance = instance;
unsafe { unsafe {
for symbol in &self.typedefs { for symbol in &self.typedefs {
let name = VkString::new(symbol); let name = VkString::new(symbol);
@ -57,8 +50,6 @@ impl VkTypedefHandles {
} }
pub fn load_device_functions(&mut self, device: VkDevice, proc_addr: PFN_vkGetDeviceProcAddr) { pub fn load_device_functions(&mut self, device: VkDevice, proc_addr: PFN_vkGetDeviceProcAddr) {
self.device = device;
unsafe { unsafe {
for symbol in &self.typedefs { for symbol in &self.typedefs {
let name = VkString::new(symbol); let name = VkString::new(symbol);
@ -74,12 +65,4 @@ impl VkTypedefHandles {
pub fn handle(&self, symbol_name: impl ToString) -> Option<PFN_vkVoidFunction> { pub fn handle(&self, symbol_name: impl ToString) -> Option<PFN_vkVoidFunction> {
self.functions.get(&symbol_name.to_string()).cloned() self.functions.get(&symbol_name.to_string()).cloned()
} }
pub fn instance(&self) -> VkInstance {
self.instance
}
pub fn device(&self) -> VkDevice {
self.device
}
} }