Skip to content

Commit

Permalink
Make d3d12 build by default if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
SafariMonkey committed Dec 1, 2023
1 parent 6ba84a7 commit 82a4a25
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "MIT/Apache-2.0"


[features]
default = ["linked", "vulkan"]
default = ["linked", "vulkan", "d3d12"]
linked = ["openxr/linked"]
vulkan = ["wgpu-core/vulkan"]
d3d12 = ["wgpu-core/dx12", "dep:winapi", "dep:d3d12"]
Expand All @@ -21,19 +21,21 @@ anyhow = "1.0.75"
ash = "0.37.3"
bevy = "0.12"
mint = "0.5.9"
winapi = { version = "0.3.9", optional = true }
wgpu = "0.17.1"
wgpu-core = { version = "0.17.1" }
wgpu-hal = "0.17.1"
wgpu-types = "0.18.0" # until InstanceFlags helpers make it to wgpu
d3d12 = { version = "0.7", features = ["libloading"], optional = true }

[target.'cfg( target_family = "unix" )'.dependencies]
openxr = { version = "0.17.1", features = ["mint"], git = "https://github.com/Ralith/openxrs" }

[target.'cfg(not(target_family = "unix"))'.dependencies]
openxr = { version = "0.17.1", features = ["mint", "static"], git = "https://github.com/Ralith/openxrs" }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.9", optional = true }
d3d12 = { version = "0.7", features = ["libloading"], optional = true }

[dev-dependencies]
bevy = "0.12"
color-eyre = "0.6.2"
Expand Down
4 changes: 2 additions & 2 deletions src/graphics/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(feature = "d3d12")]
#[cfg(all(feature = "d3d12", windows))]
mod d3d12;
#[cfg(feature = "vulkan")]
mod vulkan;
Expand Down Expand Up @@ -58,7 +58,7 @@ pub fn initialize_xr_graphics(
}
return vulkan::initialize_xr_graphics(window, xr_entry, available_extensions)
}
#[cfg(feature = "d3d12")]
#[cfg(all(feature = "d3d12", windows))]
Backend::D3D12 => {
if !available_extensions.khr_d3d12_enable {
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Default for OpenXrPlugin {
OpenXrPlugin{backend_preference: vec![
#[cfg(feature = "vulkan")]
Backend::Vulkan,
#[cfg(feature = "d3d12")]
#[cfg(all(feature = "d3d12", windows))]
Backend::D3D12,
]}
}
Expand All @@ -50,7 +50,7 @@ impl Default for OpenXrPlugin {
pub enum Backend {
#[cfg(feature = "vulkan")]
Vulkan,
#[cfg(feature = "d3d12")]
#[cfg(all(feature = "d3d12", windows))]
D3D12,
}

Expand Down
14 changes: 7 additions & 7 deletions src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ xr_arc_resource_wrapper!(XrViews, Mutex<Vec<xr::View>>);
pub enum Swapchain {
#[cfg(feature = "vulkan")]
Vulkan(SwapchainInner<xr::Vulkan>),
#[cfg(feature = "d3d12")]
#[cfg(all(feature = "d3d12", windows))]
D3D12(SwapchainInner<xr::D3D12>),
}

Expand All @@ -28,7 +28,7 @@ impl Swapchain {
match self {
#[cfg(feature = "vulkan")]
Swapchain::Vulkan(swapchain) => swapchain.begin(),
#[cfg(feature = "d3d12")]
#[cfg(all(feature = "d3d12", windows))]
Swapchain::D3D12(swapchain) => swapchain.begin(),
}
}
Expand All @@ -37,7 +37,7 @@ impl Swapchain {
match self {
#[cfg(feature = "vulkan")]
Swapchain::Vulkan(swapchain) => swapchain.get_render_views(),
#[cfg(feature = "d3d12")]
#[cfg(all(feature = "d3d12", windows))]
Swapchain::D3D12(swapchain) => swapchain.get_render_views(),
}
}
Expand All @@ -46,7 +46,7 @@ impl Swapchain {
match self {
#[cfg(feature = "vulkan")]
Swapchain::Vulkan(swapchain) => swapchain.acquire_image(),
#[cfg(feature = "d3d12")]
#[cfg(all(feature = "d3d12", windows))]
Swapchain::D3D12(swapchain) => swapchain.acquire_image(),
}
}
Expand All @@ -55,7 +55,7 @@ impl Swapchain {
match self {
#[cfg(feature = "vulkan")]
Swapchain::Vulkan(swapchain) => swapchain.wait_image(),
#[cfg(feature = "d3d12")]
#[cfg(all(feature = "d3d12", windows))]
Swapchain::D3D12(swapchain) => swapchain.wait_image(),
}
}
Expand All @@ -64,7 +64,7 @@ impl Swapchain {
match self {
#[cfg(feature = "vulkan")]
Swapchain::Vulkan(swapchain) => swapchain.release_image(),
#[cfg(feature = "d3d12")]
#[cfg(all(feature = "d3d12", windows))]
Swapchain::D3D12(swapchain) => swapchain.release_image(),
}
}
Expand All @@ -86,7 +86,7 @@ impl Swapchain {
resolution,
environment_blend_mode,
),
#[cfg(feature = "d3d12")]
#[cfg(all(feature = "d3d12", windows))]
Swapchain::D3D12(swapchain) => swapchain.end(
predicted_display_time,
views,
Expand Down

0 comments on commit 82a4a25

Please sign in to comment.