Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wgpu-hal(vk): Add WGPU_ALLOW_NONCOMPLIANT_ADAPTER #4754

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Bottom level categories:

## Unreleased

### `WGPU_ALLOW_NONCOMPLIANT_ADAPTER` environment variable

This adds a way to allow a Vulkan driver which is non-compliant per VK_KHR_driver_properties to be enumerated. This is intended for testing new Vulkan drivers which are not Vulkan compliant yet.

### New Features

#### General
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ All testing and example infrastructure shares the same set of environment variab
- `WGPU_POWER_PREF` with the power preference to choose when a specific adapter name isn't specified (`high`, `low` or `none`)
- `WGPU_DX12_COMPILER` with the DX12 shader compiler you wish to use (`dxc` or `fxc`, note that `dxc` requires `dxil.dll` and `dxcompiler.dll` to be in the working directory otherwise it will fall back to `fxc`)
- `WGPU_GLES_MINOR_VERSION` with the minor OpenGL ES 3 version number to request (`0`, `1`, `2` or `automatic`).
- `WGPU_ALLOW_NONCOMPLIANT_ADAPTER` with a boolean whether non-compliant drivers are enumerated (`0` for false, `1` for true).

When running the CTS, use the variables `DENO_WEBGPU_ADAPTER_NAME`, `DENO_WEBGPU_BACKEND`, `DENO_WEBGPU_POWER_PREFERENCE`.

Expand Down
6 changes: 6 additions & 0 deletions wgpu-hal/src/vulkan/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,12 @@ impl super::Instance {
if driver.conformance_version.major == 0 {
if driver.driver_id == ash::vk::DriverId::MOLTENVK {
log::debug!("Adapter is not Vulkan compliant, but is MoltenVK, continuing");
} else if self
.shared
.flags
.contains(wgt::InstanceFlags::ALLOW_NONCOMPLIANT_ADAPTER)
{
log::warn!("Adapter is not Vulkan compliant: {}", info.name);
} else {
log::warn!(
"Adapter is not Vulkan compliant, hiding adapter: {}",
Expand Down
8 changes: 8 additions & 0 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,11 @@ bitflags::bitflags! {
const VALIDATION = 1 << 1;
/// Don't pass labels to wgpu-hal.
const DISCARD_HAL_LABELS = 1 << 2;
/// Whether non-compliant adapters should be enumerated.
///
/// This mainly applies to a Vulkan driver's compliance version. If the major compliance version
/// is `0`, then the driver is ignored. This flag allows that driver to be enabled for testing.
const ALLOW_NONCOMPLIANT_ADAPTER = 1 << 3;
}
}

Expand Down Expand Up @@ -910,6 +915,9 @@ impl InstanceFlags {
if let Some(bit) = env("WGPU_DEBUG") {
self.set(Self::DEBUG, bit);
}
if let Some(bit) = env("WGPU_ALLOW_NONCOMPLIANT_ADAPTER") {
self.set(Self::ALLOW_NONCOMPLIANT_ADAPTER, bit);
}

self
}
Expand Down
Loading