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
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[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"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
image = "0.24.5"
|
image = "0.24.6"
|
||||||
vulkan-sys = { path = "../vulkan-sys" }
|
vulkan-sys = { path = "../vulkan-sys" }
|
||||||
vma-rs = { path = "../vma-rs" }
|
vma-rs = { path = "../vma-rs" }
|
||||||
anyhow = { version = "1.0.70", features = ["backtrace"] }
|
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::os::raw::c_void;
|
||||||
|
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::ffi::CString;
|
|
||||||
|
|
||||||
Extensions!(InstanceExtensions, {
|
Extensions!(InstanceExtensions, {
|
||||||
(xlib_surface, "VK_KHR_xlib_surface"),
|
(xlib_surface, "VK_KHR_xlib_surface"),
|
||||||
|
@ -433,9 +432,8 @@ impl Instance {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let tmp1 = unsafe { CString::from_raw(msg as *mut c_char) };
|
let s = match VkString::try_from(msg) {
|
||||||
let tmp2 = match tmp1.into_string() {
|
Ok(s) => s,
|
||||||
Ok(string) => string,
|
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
println!("{}", err);
|
println!("{}", err);
|
||||||
|
|
||||||
|
@ -444,7 +442,7 @@ impl Instance {
|
||||||
};
|
};
|
||||||
|
|
||||||
output += " ):\n\t";
|
output += " ):\n\t";
|
||||||
output += tmp2.as_ref();
|
output += s.as_str();
|
||||||
|
|
||||||
println!("{}", output);
|
println!("{}", output);
|
||||||
|
|
||||||
|
|
|
@ -126,9 +126,9 @@ impl PhysicalDevice {
|
||||||
let (major, minor, patch) = VK_GET_VERSION(properties.apiVersion);
|
let (major, minor, patch) = VK_GET_VERSION(properties.apiVersion);
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"\nVulkan Device ({}, Driver: {}, {}.{}.{})",
|
"\nVulkan Device (Device Name: {}, Driver Version: {}, Vulkan Version: {}.{}.{})",
|
||||||
properties.device_name(),
|
properties.device_name(),
|
||||||
properties.driverVersion,
|
properties.driver_version(),
|
||||||
major,
|
major,
|
||||||
minor,
|
minor,
|
||||||
patch
|
patch
|
||||||
|
|
|
@ -8,6 +8,23 @@ use std::sync::{
|
||||||
Arc, Mutex,
|
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)]
|
#[derive(Debug)]
|
||||||
pub struct Swapchain {
|
pub struct Swapchain {
|
||||||
width: AtomicU32,
|
width: AtomicU32,
|
||||||
|
@ -187,17 +204,24 @@ impl Swapchain {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn acquire_next_image(
|
pub fn acquire_next_image<'a>(
|
||||||
&self,
|
&self,
|
||||||
time_out: u64,
|
time_out: u64,
|
||||||
present_complete_semaphore: Option<&Arc<Semaphore>>,
|
synchro: impl Into<NextImageSynchronization<'a>>,
|
||||||
fence: Option<&Arc<Fence>>,
|
|
||||||
) -> Result<OutOfDate<u32>> {
|
) -> Result<OutOfDate<u32>> {
|
||||||
|
let synchro = synchro.into();
|
||||||
|
|
||||||
let res = self.device.acquire_next_image(
|
let res = self.device.acquire_next_image(
|
||||||
*self.swapchain.lock().unwrap(),
|
*self.swapchain.lock().unwrap(),
|
||||||
time_out,
|
time_out,
|
||||||
present_complete_semaphore.map(|sem| sem.vk_handle()),
|
match synchro {
|
||||||
fence.map(|fence| fence.vk_handle()),
|
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 {
|
if let Ok(r) = &res {
|
||||||
|
|
|
@ -23,6 +23,24 @@ impl VkPhysicalDeviceProperties {
|
||||||
let device_name_cstr = unsafe { CStr::from_ptr(self.deviceName.as_ptr()) };
|
let device_name_cstr = unsafe { CStr::from_ptr(self.deviceName.as_ptr()) };
|
||||||
device_name_cstr.to_str().unwrap().to_string()
|
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 {
|
impl Default for VkPhysicalDeviceProperties {
|
||||||
|
|
Loading…
Reference in a new issue