Debug why there is nothing rendered
This commit is contained in:
parent
ecfaa18614
commit
3478425b71
4 changed files with 79 additions and 48 deletions
|
@ -14,3 +14,4 @@ vulkan-rs = { path = "/home/michael/Dokumente/Workspace/Gavania/vulkan-rs" }
|
|||
anyhow = { version = "1.0.68", features = ["backtrace"] }
|
||||
rfactor_sm_reader = { path = "../rfactor_sm_reader" }
|
||||
cgmath = "0.18.0"
|
||||
paste = "1.0.11"
|
||||
|
|
50
src/enums.rs
50
src/enums.rs
|
@ -3,6 +3,8 @@
|
|||
use std::{mem, ptr};
|
||||
use vulkan_rs::prelude::*;
|
||||
|
||||
use crate::*;
|
||||
|
||||
pub use VkLayerFunction::*;
|
||||
pub use VkNegotiateLayerStructType::*;
|
||||
|
||||
|
@ -19,15 +21,14 @@ pub enum VkLayerFunction {
|
|||
VK_LOADER_FEATURES = 3,
|
||||
}
|
||||
|
||||
macro_rules! create_functions_enum {
|
||||
($([$pfn:ident, $func:ident],)+) => {
|
||||
paste::paste! {
|
||||
pub enum Functions {
|
||||
Null,
|
||||
CreateInstance(PFN_vkCreateInstance),
|
||||
DestroyInstance(PFN_vkDestroyInstance),
|
||||
CreateDevice(PFN_vkCreateDevice),
|
||||
DestroyDevice(PFN_vkDestroyDevice),
|
||||
CreateSwapchain(PFN_vkCreateSwapchainKHR),
|
||||
QueueSubmit(PFN_vkQueueSubmit),
|
||||
GetDeviceQueue(PFN_vkGetDeviceQueue),
|
||||
$(
|
||||
$pfn ( [<PFN_vk $pfn>] ),
|
||||
)+
|
||||
}
|
||||
|
||||
impl Functions {
|
||||
|
@ -36,13 +37,34 @@ impl Functions {
|
|||
Functions::Null => unsafe {
|
||||
mem::transmute::<*const (), PFN_vkVoidFunction>(ptr::null())
|
||||
},
|
||||
Functions::CreateInstance(func) => unsafe { mem::transmute(func) },
|
||||
Functions::DestroyInstance(func) => unsafe { mem::transmute(func) },
|
||||
Functions::CreateDevice(func) => unsafe { mem::transmute(func) },
|
||||
Functions::DestroyDevice(func) => unsafe { mem::transmute(func) },
|
||||
Functions::CreateSwapchain(func) => unsafe { mem::transmute(func) },
|
||||
Functions::QueueSubmit(func) => unsafe { mem::transmute(func) },
|
||||
Functions::GetDeviceQueue(func) => unsafe { mem::transmute(func) },
|
||||
$(
|
||||
Functions::$pfn(foo) => unsafe { mem::transmute(foo) },
|
||||
)+
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_vk_func(s:&str) -> Option<Functions> {
|
||||
match s {
|
||||
$(
|
||||
stringify!([<vk $pfn>]) => Some(Functions::$pfn($func)),
|
||||
)+
|
||||
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
create_functions_enum!(
|
||||
[CreateInstance, create_instance],
|
||||
[DestroyInstance, destroy_instance],
|
||||
[CreateDevice, create_device],
|
||||
[DestroyDevice, destroy_device],
|
||||
[CreateSwapchainKHR, create_swapchain],
|
||||
[QueueSubmit, submit_queue],
|
||||
[GetDeviceQueue, get_device_queue],
|
||||
[AcquireNextImageKHR, acquire_next_image],
|
||||
);
|
||||
|
|
46
src/lib.rs
46
src/lib.rs
|
@ -73,7 +73,7 @@ extern "system" fn get_device_proc_addr(
|
|||
|
||||
let s = func_string.as_str();
|
||||
|
||||
if let Some(func) = get_vk_func(s) {
|
||||
if let Some(func) = Functions::get_vk_func(s) {
|
||||
return func.convert();
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ extern "system" fn get_instance_proc_addr(
|
|||
|
||||
let s = func_string.as_str();
|
||||
|
||||
if let Some(func) = get_vk_func(s) {
|
||||
if let Some(func) = Functions::get_vk_func(s) {
|
||||
return func.convert();
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ extern "system" fn get_instance_proc_addr(
|
|||
Functions::Null.convert()
|
||||
}
|
||||
|
||||
extern "system" fn create_instance(
|
||||
pub extern "system" fn create_instance(
|
||||
create_info: *const VkInstanceCreateInfo,
|
||||
allocator: *const VkAllocationCallbacks,
|
||||
instance: *mut VkInstance,
|
||||
|
@ -175,7 +175,10 @@ extern "system" fn create_instance(
|
|||
VK_SUCCESS
|
||||
}
|
||||
|
||||
extern "system" fn destroy_instance(instance: VkInstance, allocator: *const VkAllocationCallbacks) {
|
||||
pub extern "system" fn destroy_instance(
|
||||
instance: VkInstance,
|
||||
allocator: *const VkAllocationCallbacks,
|
||||
) {
|
||||
write_log(" ================== vulkan layer destroy instance ==================");
|
||||
|
||||
unsafe {
|
||||
|
@ -187,7 +190,7 @@ extern "system" fn destroy_instance(instance: VkInstance, allocator: *const VkAl
|
|||
}
|
||||
}
|
||||
|
||||
extern "system" fn create_device(
|
||||
pub extern "system" fn create_device(
|
||||
physical_device: VkPhysicalDevice,
|
||||
create_info: *const VkDeviceCreateInfo<'_>,
|
||||
allocator: *const VkAllocationCallbacks,
|
||||
|
@ -263,7 +266,7 @@ extern "system" fn create_device(
|
|||
VK_SUCCESS
|
||||
}
|
||||
|
||||
extern "system" fn destroy_device(device: VkDevice, allocator: *const VkAllocationCallbacks) {
|
||||
pub extern "system" fn destroy_device(device: VkDevice, allocator: *const VkAllocationCallbacks) {
|
||||
write_log(" ================== vulkan layer destroy device ==================");
|
||||
|
||||
unsafe {
|
||||
|
@ -275,7 +278,7 @@ extern "system" fn destroy_device(device: VkDevice, allocator: *const VkAllocati
|
|||
}
|
||||
}
|
||||
|
||||
extern "system" fn create_swapchain(
|
||||
pub extern "system" fn create_swapchain(
|
||||
_device: VkDevice,
|
||||
create_info: *const VkSwapchainCreateInfoKHR,
|
||||
_allocator: *const VkAllocationCallbacks,
|
||||
|
@ -319,7 +322,7 @@ extern "system" fn create_swapchain(
|
|||
VK_SUCCESS
|
||||
}
|
||||
|
||||
extern "system" fn submit_queue(
|
||||
pub extern "system" fn submit_queue(
|
||||
queue: VkQueue,
|
||||
submit_count: u32,
|
||||
submits: *const VkSubmitInfo,
|
||||
|
@ -346,7 +349,7 @@ extern "system" fn submit_queue(
|
|||
}
|
||||
}
|
||||
|
||||
extern "system" fn get_device_queue(
|
||||
pub extern "system" fn get_device_queue(
|
||||
device: VkDevice,
|
||||
queue_family_index: u32,
|
||||
queue_index: u32,
|
||||
|
@ -377,22 +380,19 @@ extern "system" fn get_device_queue(
|
|||
}
|
||||
}
|
||||
|
||||
pub extern "system" fn acquire_next_image(
|
||||
device: VkDevice,
|
||||
swapchain: VkSwapchainKHR,
|
||||
timeout: u64,
|
||||
semaphore: VkSemaphore,
|
||||
fence: VkFence,
|
||||
pImageIndex: *mut u32,
|
||||
) -> VkResult {
|
||||
VK_SUCCESS
|
||||
}
|
||||
|
||||
pub fn write_log(msg: impl ToString) {
|
||||
if let Ok(mut file) = OpenOptions::new().append(true).create(true).open(LOG_FILE) {
|
||||
if let Err(_) = file.write_all(format!("{}\n", msg.to_string()).as_bytes()) {}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_vk_func(s: &str) -> Option<Functions> {
|
||||
match s {
|
||||
"vkCreateDevice" => Some(Functions::CreateDevice(create_device)),
|
||||
"vkDestroyDevice" => Some(Functions::DestroyDevice(destroy_device)),
|
||||
"vkCreateInstance" => Some(Functions::CreateInstance(create_instance)),
|
||||
"vkDestroyInstance" => Some(Functions::DestroyInstance(destroy_instance)),
|
||||
"vkCreateSwapchainKHR" => Some(Functions::CreateSwapchain(create_swapchain)),
|
||||
"vkQueueSubmit" => Some(Functions::QueueSubmit(submit_queue)),
|
||||
"vkGetDeviceQueue" => Some(Functions::GetDeviceQueue(get_device_queue)),
|
||||
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,6 +81,12 @@ impl Rendering {
|
|||
|
||||
write_log("-> Rendering ctor: created render_target");
|
||||
|
||||
write_log(format!(
|
||||
"-> Rendering swapchain extents ({}, {})",
|
||||
swapchain.width(),
|
||||
swapchain.height(),
|
||||
));
|
||||
|
||||
Ok(Self {
|
||||
swapchain,
|
||||
pipeline: SingleColorPipeline::new(device, render_target.render_pass())?,
|
||||
|
@ -137,6 +143,8 @@ impl Rendering {
|
|||
recorder.set_scissor(&scissor);
|
||||
recorder.set_viewport(&viewport);
|
||||
|
||||
write_log(format!("-> Rendering {} objects", objects.len()));
|
||||
|
||||
for object in objects {
|
||||
let buffer = object.buffer();
|
||||
|
||||
|
|
Loading…
Reference in a new issue