Merge branch 'master' of ssh://gavania.de:23/hodasemi/vulkan_lib
This commit is contained in:
commit
eae46a0d5e
6 changed files with 54 additions and 14 deletions
|
@ -7,4 +7,4 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.158", features = ["derive"] }
|
||||
serde = { version = "1.0.159", features = ["derive"] }
|
||||
|
|
|
@ -5,7 +5,7 @@ authors = ["hodasemi <superschneider@t-online.de>"]
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
image = "0.24.5"
|
||||
image = "0.24.6"
|
||||
vulkan-sys = { path = "../vulkan-sys" }
|
||||
vma-rs = { path = "../vma-rs" }
|
||||
anyhow = { version = "1.0.70", features = ["backtrace"] }
|
||||
|
|
|
@ -12,7 +12,6 @@ use std::os::raw::c_char;
|
|||
use std::os::raw::c_void;
|
||||
|
||||
use std::ffi::CStr;
|
||||
use std::ffi::CString;
|
||||
|
||||
Extensions!(InstanceExtensions, {
|
||||
(xlib_surface, "VK_KHR_xlib_surface"),
|
||||
|
@ -433,9 +432,8 @@ impl Instance {
|
|||
}
|
||||
};
|
||||
|
||||
let tmp1 = unsafe { CString::from_raw(msg as *mut c_char) };
|
||||
let tmp2 = match tmp1.into_string() {
|
||||
Ok(string) => string,
|
||||
let s = match VkString::try_from(msg) {
|
||||
Ok(s) => s,
|
||||
Err(err) => {
|
||||
println!("{}", err);
|
||||
|
||||
|
@ -444,7 +442,7 @@ impl Instance {
|
|||
};
|
||||
|
||||
output += " ):\n\t";
|
||||
output += tmp2.as_ref();
|
||||
output += s.as_str();
|
||||
|
||||
println!("{}", output);
|
||||
|
||||
|
|
|
@ -126,9 +126,9 @@ impl PhysicalDevice {
|
|||
let (major, minor, patch) = VK_GET_VERSION(properties.apiVersion);
|
||||
|
||||
println!(
|
||||
"\nVulkan Device ({}, Driver: {}, {}.{}.{})",
|
||||
"\nVulkan Device (Device Name: {}, Driver Version: {}, Vulkan Version: {}.{}.{})",
|
||||
properties.device_name(),
|
||||
properties.driverVersion,
|
||||
properties.driver_version(),
|
||||
major,
|
||||
minor,
|
||||
patch
|
||||
|
|
|
@ -8,6 +8,23 @@ use std::sync::{
|
|||
Arc, Mutex,
|
||||
};
|
||||
|
||||
pub enum NextImageSynchronization<'a> {
|
||||
Semaphore(&'a Arc<Semaphore>),
|
||||
Fence(&'a Arc<Fence>),
|
||||
}
|
||||
|
||||
impl<'a> From<&'a Arc<Semaphore>> for NextImageSynchronization<'a> {
|
||||
fn from(value: &'a Arc<Semaphore>) -> Self {
|
||||
Self::Semaphore(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a Arc<Fence>> for NextImageSynchronization<'a> {
|
||||
fn from(value: &'a Arc<Fence>) -> Self {
|
||||
Self::Fence(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Swapchain {
|
||||
width: AtomicU32,
|
||||
|
@ -187,17 +204,24 @@ impl Swapchain {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn acquire_next_image(
|
||||
pub fn acquire_next_image<'a>(
|
||||
&self,
|
||||
time_out: u64,
|
||||
present_complete_semaphore: Option<&Arc<Semaphore>>,
|
||||
fence: Option<&Arc<Fence>>,
|
||||
synchro: impl Into<NextImageSynchronization<'a>>,
|
||||
) -> Result<OutOfDate<u32>> {
|
||||
let synchro = synchro.into();
|
||||
|
||||
let res = self.device.acquire_next_image(
|
||||
*self.swapchain.lock().unwrap(),
|
||||
time_out,
|
||||
present_complete_semaphore.map(|sem| sem.vk_handle()),
|
||||
fence.map(|fence| fence.vk_handle()),
|
||||
match synchro {
|
||||
NextImageSynchronization::Semaphore(semaphore) => Some(semaphore.vk_handle()),
|
||||
NextImageSynchronization::Fence(_) => None,
|
||||
},
|
||||
match synchro {
|
||||
NextImageSynchronization::Semaphore(_) => None,
|
||||
NextImageSynchronization::Fence(fence) => Some(fence.vk_handle()),
|
||||
},
|
||||
);
|
||||
|
||||
if let Ok(r) = &res {
|
||||
|
|
|
@ -23,6 +23,24 @@ impl VkPhysicalDeviceProperties {
|
|||
let device_name_cstr = unsafe { CStr::from_ptr(self.deviceName.as_ptr()) };
|
||||
device_name_cstr.to_str().unwrap().to_string()
|
||||
}
|
||||
|
||||
pub fn driver_version(&self) -> String {
|
||||
if self.vendorID == 4318 {
|
||||
let major = (self.driverVersion >> 22) & 0x3ff;
|
||||
let minor = (self.driverVersion >> 14) & 0x0ff;
|
||||
let secondary_branch = (self.driverVersion >> 6) & 0x0ff;
|
||||
let tertiary_branch = self.driverVersion & 0x003f;
|
||||
|
||||
format!(
|
||||
"{}.{}.{}.{}",
|
||||
major, minor, secondary_branch, tertiary_branch
|
||||
)
|
||||
} else {
|
||||
let (major, minor, patch) = VK_GET_VERSION(self.driverVersion);
|
||||
|
||||
format!("{}.{}.{}", major, minor, patch)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for VkPhysicalDeviceProperties {
|
||||
|
|
Loading…
Reference in a new issue