mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-29 18:31:31 +11:00
Add support for renderdoc capturing (dx12 only)
This commit is contained in:
parent
637a5da382
commit
78fd0a9141
|
@ -10,7 +10,8 @@ use hal::command::RawCommandBuffer;
|
||||||
use hal::queue::RawCommandQueue;
|
use hal::queue::RawCommandQueue;
|
||||||
|
|
||||||
use std::ffi::{CStr, CString};
|
use std::ffi::{CStr, CString};
|
||||||
use std::mem;
|
use std::{mem, ptr};
|
||||||
|
use std::os::raw::c_void;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -537,6 +538,12 @@ pub extern "C" fn gfxCreateDevice(
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
#[cfg(feature = "renderdoc")]
|
||||||
|
let mut renderdoc = {
|
||||||
|
use renderdoc::RenderDoc;
|
||||||
|
RenderDoc::new().expect("Failed to init renderdoc")
|
||||||
|
};
|
||||||
|
|
||||||
let gpu = adapter.physical_device.open(&request_infos);
|
let gpu = adapter.physical_device.open(&request_infos);
|
||||||
|
|
||||||
match gpu {
|
match gpu {
|
||||||
|
@ -555,14 +562,28 @@ pub extern "C" fn gfxCreateDevice(
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
#[cfg(feature = "renderdoc")]
|
||||||
|
let rd_device = {
|
||||||
|
use renderdoc::api::RenderDocV100;
|
||||||
|
|
||||||
|
let rd_device = unsafe { gpu.device.as_raw() };
|
||||||
|
renderdoc.start_frame_capture(rd_device, ::std::ptr::null());
|
||||||
|
rd_device
|
||||||
|
};
|
||||||
|
|
||||||
let gpu = Gpu {
|
let gpu = Gpu {
|
||||||
device: gpu.device,
|
device: gpu.device,
|
||||||
queues,
|
queues,
|
||||||
|
#[cfg(feature = "renderdoc")]
|
||||||
|
renderdoc,
|
||||||
|
#[cfg(feature = "renderdoc")]
|
||||||
|
capturing: rd_device as *mut _,
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
*pDevice = DispatchHandle::new(gpu);
|
*pDevice = DispatchHandle::new(gpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult::VK_SUCCESS
|
VkResult::VK_SUCCESS
|
||||||
}
|
}
|
||||||
Err(err) => conv::map_err_device_creation(err),
|
Err(err) => conv::map_err_device_creation(err),
|
||||||
|
@ -570,9 +591,16 @@ pub extern "C" fn gfxCreateDevice(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern "C" fn gfxDestroyDevice(gpu: VkDevice, _pAllocator: *const VkAllocationCallbacks) {
|
pub extern "C" fn gfxDestroyDevice(mut gpu: VkDevice, _pAllocator: *const VkAllocationCallbacks) {
|
||||||
// release all the owned command queues
|
// release all the owned command queues
|
||||||
if let Some(d) = gpu.unbox() {
|
if let Some(d) = gpu.unbox() {
|
||||||
|
#[cfg(feature = "renderdoc")]
|
||||||
|
{
|
||||||
|
use renderdoc::api::RenderDocV100;
|
||||||
|
let device = gpu.capturing as *mut c_void;
|
||||||
|
gpu.renderdoc.end_frame_capture(device as *mut _, ptr::null());
|
||||||
|
}
|
||||||
|
|
||||||
for (_, family) in d.queues {
|
for (_, family) in d.queues {
|
||||||
for queue in family {
|
for queue in family {
|
||||||
let _ = queue.unbox();
|
let _ = queue.unbox();
|
||||||
|
|
|
@ -18,6 +18,8 @@ extern crate lazy_static;
|
||||||
extern crate log;
|
extern crate log;
|
||||||
#[cfg(feature = "env_logger")]
|
#[cfg(feature = "env_logger")]
|
||||||
extern crate env_logger;
|
extern crate env_logger;
|
||||||
|
#[cfg(feature = "renderdoc")]
|
||||||
|
extern crate renderdoc;
|
||||||
|
|
||||||
mod conv;
|
mod conv;
|
||||||
mod handle;
|
mod handle;
|
||||||
|
@ -66,6 +68,10 @@ pub struct RawInstance {
|
||||||
pub struct Gpu<B: hal::Backend> {
|
pub struct Gpu<B: hal::Backend> {
|
||||||
device: B::Device,
|
device: B::Device,
|
||||||
queues: HashMap<QueueFamilyIndex, Vec<VkQueue>>,
|
queues: HashMap<QueueFamilyIndex, Vec<VkQueue>>,
|
||||||
|
#[cfg(feature = "renderdoc")]
|
||||||
|
renderdoc: renderdoc::RenderDoc<renderdoc::V110>,
|
||||||
|
#[cfg(feature = "renderdoc")]
|
||||||
|
capturing: *mut (),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Pipeline<B: hal::Backend> {
|
pub enum Pipeline<B: hal::Backend> {
|
||||||
|
|
Loading…
Reference in a new issue