From 0cac5fd72e26e67f964e6a65c5f13b87314783fb Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Sat, 6 Jul 2024 11:11:54 +0200 Subject: [PATCH] Introduce `hlsl-out-if-target-windows` feature to Naga --- naga/Cargo.toml | 11 +++++++++++ naga/build.rs | 2 +- wgpu-hal/Cargo.toml | 6 +++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/naga/Cargo.toml b/naga/Cargo.toml index 4e098f3ddb..8478cc6f7b 100644 --- a/naga/Cargo.toml +++ b/naga/Cargo.toml @@ -43,7 +43,18 @@ spv-in = ["dep:petgraph", "dep:spirv"] spv-out = ["dep:spirv"] wgsl-in = ["dep:hexf-parse", "dep:unicode-xid", "compact"] wgsl-out = [] + +## Enables outputting to HLSL (Microsoft's High-Level Shader Language). +## +## This enables HLSL output regardless of the target platform. +## If you want to enable it only when targeting Windows, use `hlsl-out-if-target-windows`. hlsl-out = [] + +## Enables outputting to HLSL (Microsoft's High-Level Shader Language) only if the target platform is Windows. +## +## If you want to enable HLSL output it regardless of the target platform, use `naga/hlsl-out`. +hlsl-out-if-target-windows = [] + compact = [] [dependencies] diff --git a/naga/build.rs b/naga/build.rs index 011f67ebcb..e263f626a9 100644 --- a/naga/build.rs +++ b/naga/build.rs @@ -2,7 +2,7 @@ fn main() { cfg_aliases::cfg_aliases! { dot_out: { feature = "dot-out" }, glsl_out: { feature = "glsl-out" }, - hlsl_out: { feature = "hlsl-out" }, + hlsl_out: { any(feature = "hlsl-out", all(target_os = "windows", feature = "hlsl-out-if-target-windows")) }, msl_out: { any(feature = "msl-out", all(any(target_os = "ios", target_os = "macos"), feature = "msl-out-if-target-apple")) }, spv_out: { feature = "spv-out" }, wgsl_out: { feature = "wgsl-out" }, diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index df6ad003e3..5b1fcb7261 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -63,8 +63,12 @@ gles = [ "dep:ndk-sys", "winapi/libloaderapi", ] +## Enables the DX12 backend when targeting Windows. +## +## Has no effect if not targeting Windows. dx12 = [ - "naga/hlsl-out", + # DX12 is only available on Windows, therefore request HLSL output also only if we target Windows. + "naga/hlsl-out-if-target-windows", "dep:d3d12", "dep:bit-set", "dep:libloading",