add session creation next chain infrastructure
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
use bevy::log::error;
|
||||
use openxr::sys;
|
||||
use wgpu_hal::{Adapter, Instance};
|
||||
use winapi::shared::dxgiformat::DXGI_FORMAT;
|
||||
use winapi::um::d3d12 as winapi_d3d12;
|
||||
|
||||
use super::{GraphicsExt, GraphicsType, GraphicsWrap};
|
||||
use crate::error::OxrError;
|
||||
use crate::session::OxrSessionCreateNextChain;
|
||||
use crate::types::{AppInfo, OxrExtensions, Result, WgpuGraphics};
|
||||
|
||||
unsafe impl GraphicsExt for openxr::D3D12 {
|
||||
@@ -155,6 +157,49 @@ unsafe impl GraphicsExt for openxr::D3D12 {
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
unsafe fn create_session(
|
||||
instance: &openxr::Instance,
|
||||
system_id: openxr::SystemId,
|
||||
info: &Self::SessionCreateInfo,
|
||||
session_create_info_chain: &mut OxrSessionCreateNextChain,
|
||||
) -> openxr::Result<(
|
||||
openxr::Session<Self>,
|
||||
openxr::FrameWaiter,
|
||||
openxr::FrameStream<Self>,
|
||||
)> {
|
||||
let binding = sys::GraphicsBindingD3D12KHR {
|
||||
ty: sys::GraphicsBindingD3D12KHR::TYPE,
|
||||
next: session_create_info_chain.chain_pointer(),
|
||||
device: info.device,
|
||||
queue: info.queue,
|
||||
};
|
||||
let info = sys::SessionCreateInfo {
|
||||
ty: sys::SessionCreateInfo::TYPE,
|
||||
next: &binding as *const _ as *const _,
|
||||
create_flags: Default::default(),
|
||||
system_id: system_id,
|
||||
};
|
||||
let mut out = sys::Session::NULL;
|
||||
cvt((instance.fp().create_session)(
|
||||
instance.as_raw(),
|
||||
&info,
|
||||
&mut out,
|
||||
))?;
|
||||
Ok(openxr::Session::from_raw(
|
||||
instance.clone(),
|
||||
out,
|
||||
Box::new(()),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn cvt(x: sys::Result) -> openxr::Result<sys::Result> {
|
||||
if x.into_raw() >= 0 {
|
||||
Ok(x)
|
||||
} else {
|
||||
Err(x)
|
||||
}
|
||||
}
|
||||
|
||||
// Extracted from https://github.com/gfx-rs/wgpu/blob/1161a22f4fbb4fc204eb06f2ac4243f83e0e980d/wgpu-hal/src/dx12/adapter.rs#L73-L94
|
||||
@@ -345,3 +390,4 @@ fn wgpu_to_d3d12(format: wgpu::TextureFormat) -> Option<DXGI_FORMAT> {
|
||||
} => return None,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user