Use vk rs

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

View file

@ -9,5 +9,6 @@ edition = "2021"
crate-type = ["cdylib"]
[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"] }

View file

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

View file

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

View file

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

View file

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