feat(deno): Add DENO_WEBGPU_DX12_COMPILER env var

- Use the env var to select DXC in cts_runner
- Sync a few other env vars from `ci.yml`
This commit is contained in:
Andy Leiserson committed 2026-03-10 16:57:39 -07:00
1 parent cca21e665c
commit a16ca5cb42
4 files changed
+29 -14

No files matched your search

+1 -1
View File
@@ -88,7 +88,7 @@ Testing, examples, and `::from_env()` methods use a standardized set of environm
See the [documentation](https://docs.rs/wgpu/latest/wgpu/index.html?search=env) for more environment variables.
When running the CTS, use the variables `DENO_WEBGPU_ADAPTER_NAME`, `DENO_WEBGPU_BACKEND`, `DENO_WEBGPU_POWER_PREFERENCE`.
When running the CTS, use the variables `DENO_WEBGPU_ADAPTER_NAME`, `DENO_WEBGPU_BACKEND`, `DENO_WEBGPU_POWER_PREFERENCE`, and `DENO_WEBGPU_DX12_COMPILER`.
## Repo Overview
+1 -1
View File
@@ -289,7 +289,7 @@ webgpu:api,validation,texture,destroy:twice:*
webgpu:api,validation,texture,float32_filterable:create_bind_group:*
webgpu:api,validation,texture,rg11b10ufloat_renderable:*
webgpu:shader,execution,expression,call,builtin,atan2:f16:*
fails-if(dx12) webgpu:shader,execution,expression,call,builtin,atan2:f16:*
webgpu:shader,execution,expression,call,builtin,atan2:f32:*
webgpu:shader,execution,expression,call,builtin,dot:abstract_int_vec2:*
webgpu:shader,execution,expression,call,builtin,dot:abstract_int_vec3:*
+5 -1
View File
@@ -171,6 +171,9 @@ impl GPU {
) -> Option<adapter::GPUAdapter> {
let mut state = state.borrow_mut();
let dx12_compiler = std::env::var("DENO_WEBGPU_DX12_COMPILER")
.ok()
.and_then(|s| s.parse().ok());
let backends = std::env::var("DENO_WEBGPU_BACKEND").map_or_else(
|_| wgpu_types::Backends::all(),
|s| wgpu_types::Backends::from_comma_list(&s),
@@ -189,7 +192,8 @@ impl GPU {
},
backend_options: wgpu_types::BackendOptions {
dx12: wgpu_types::Dx12BackendOptions {
shader_compiler: wgpu_types::Dx12Compiler::Fxc,
shader_compiler: dx12_compiler
.unwrap_or(wgpu_types::Dx12Compiler::Fxc),
..Default::default()
},
gl: wgpu_types::GlBackendOptions::default(),
+22 -11
View File
@@ -1,7 +1,7 @@
//! [`Backend`], [`Backends`], and backend-specific options.
use alloc::string::String;
use core::hash::Hash;
use core::{hash::Hash, str::FromStr};
#[cfg(any(feature = "serde", test))]
use serde::{Deserialize, Serialize};
@@ -632,16 +632,13 @@ impl Dx12Compiler {
/// - `StaticDxc`
#[must_use]
pub fn from_env() -> Option<Self> {
let value = crate::env::var("WGPU_DX12_COMPILER")
.as_deref()?
.to_lowercase();
match value.as_str() {
"dxc" | "dynamicdxc" => Some(Self::default_dynamic_dxc()),
"staticdxc" => Some(Self::StaticDxc),
"fxc" => Some(Self::Fxc),
"auto" => Some(Self::Auto),
_ => None,
}
let env = crate::env::var("WGPU_DX12_COMPILER")?;
env.parse().map_err(|expected_msg| {
log::warn!(
"Unknown value `{env:?}` for `WGPU_DX12_COMPILER` environment variable. {expected_msg}"
)
})
.ok()
}
/// Takes the given compiler, modifies it based on the `WGPU_DX12_COMPILER` environment variable, and returns the result.
@@ -657,6 +654,20 @@ impl Dx12Compiler {
}
}
impl FromStr for Dx12Compiler {
type Err = &'static str;
fn from_str(value: &str) -> Result<Self, Self::Err> {
Ok(match value.to_lowercase().as_str() {
"dxc" | "dynamicdxc" => Self::default_dynamic_dxc(),
"staticdxc" => Self::StaticDxc,
"fxc" => Self::Fxc,
"auto" => Self::Auto,
_ => return Err("Expected `dynamicdxc` (alias `dxc`), `staticdxc`, `fxc`, or `auto`."),
})
}
}
/// Whether and how to use a waitable handle obtained from `GetFrameLatencyWaitableObject`.
#[derive(Clone, Debug, Default)]
pub enum Dx12UseFrameLatencyWaitableObject {