Remove wgpu features for indicating Vulkan extension availability (#10635)

This commit is contained in:
Andy Leiserson authored and GitHub committed 2026-10-22 06:20:43 +00:00
1 parent ade0590d81
commit 4e3916783a
6 files changed
+43 -105

No files matched your search

+1
View File
@@ -202,6 +202,7 @@ By @sagudev in [#10307](https://github.com/gfx-rs/wgpu/pull/10307).
#### Vulkan
- Removed the `VULKAN_GOOGLE_DISPLAY_TIMING`, `VULKAN_EXTERNAL_MEMORY_WIN32`, `VULKAN_EXTERNAL_MEMORY_FD`, and `VULKAN_EXTERNAL_MEMORY_DMA_BUF` features. wgpu enables the corresponding Vulkan extensions whenever the adapter supports them. To check for support, use `Adapter::as_hal::<wgpu::hal::api::Vulkan>()` and call `physical_device_capabilities().supports_extension()` with the extension name. By @andyleiserson in [#10635](https://github.com/gfx-rs/wgpu/pull/10635).
- Sub-allocate `wgpu_hal::MemoryFlags::TRANSIENT` buffers and acceleration structure build scratch from a separate Vulkan memory pool, so short-lived allocations no longer pin memory blocks shared with long-lived resources. By @stuartparmenter in [#10232](https://github.com/gfx-rs/wgpu/pull/10232).
- Allocate acceleration structures created with `AccelerationStructureFlags::ALLOW_COMPACTION` from the transient Vulkan memory pool, since they are usually replaced by their compacted copies. By @stuartparmenter in [#10233](https://github.com/gfx-rs/wgpu/pull/10233).
+5 -24
View File
@@ -1059,25 +1059,6 @@ impl PhysicalDeviceFeatures {
);
}
features.set(
F::VULKAN_GOOGLE_DISPLAY_TIMING,
caps.supports_extension(google::display_timing::NAME),
);
features.set(
F::VULKAN_EXTERNAL_MEMORY_WIN32,
caps.supports_extension(khr::external_memory_win32::NAME),
);
features.set(
F::VULKAN_EXTERNAL_MEMORY_FD,
caps.supports_extension(khr::external_memory_fd::NAME),
);
features.set(
F::VULKAN_EXTERNAL_MEMORY_DMA_BUF,
caps.supports_extension(khr::external_memory_fd::NAME)
&& caps.supports_extension(ext::external_memory_dma_buf::NAME)
&& caps.supports_extension(ext::image_drm_format_modifier::NAME),
);
features.set(
F::EXPERIMENTAL_MESH_SHADER,
caps.supports_extension(ext::mesh_shader::NAME),
@@ -1424,6 +1405,11 @@ impl PhysicalDeviceProperties {
extensions.push(ext::image_drm_format_modifier::NAME);
}
// Optional `VK_GOOGLE_display_timing`
if self.supports_extension(google::display_timing::NAME) {
extensions.push(google::display_timing::NAME);
}
// Optional `VK_EXT_memory_budget`
if self.supports_extension(ext::memory_budget::NAME) {
extensions.push(ext::memory_budget::NAME);
@@ -1493,11 +1479,6 @@ impl PhysicalDeviceProperties {
extensions.push(ext::shader_atomic_float::NAME);
}
// Require VK_GOOGLE_display_timing if the associated feature was requested
if requested_features.contains(wgt::Features::VULKAN_GOOGLE_DISPLAY_TIMING) {
extensions.push(google::display_timing::NAME);
}
if requested_features.contains(wgt::Features::EXPERIMENTAL_MESH_SHADER) {
extensions.push(ext::mesh_shader::NAME);
}
+7 -8
View File
@@ -491,8 +491,8 @@ impl super::Device {
) -> Result<super::Texture, crate::DeviceError> {
if !self
.shared
.features
.contains(wgt::Features::VULKAN_EXTERNAL_MEMORY_WIN32)
.enabled_extensions
.contains(&ash::khr::external_memory_win32::NAME)
{
log::error!("Vulkan driver does not support VK_KHR_external_memory_win32");
return Err(crate::DeviceError::Unexpected);
@@ -549,8 +549,8 @@ impl super::Device {
///
/// # Safety
///
/// - Requires `VULKAN_EXTERNAL_MEMORY_DMA_BUF` feature (implies VK_EXT_external_memory_dma_buf
/// and VK_EXT_image_drm_format_modifier)
/// - Requires the VK_KHR_external_memory_fd, VK_EXT_external_memory_dma_buf, and
/// VK_EXT_image_drm_format_modifier extensions
/// - The `fd` must be a valid DMA-buf file descriptor matching `desc`
/// - On success, Vulkan takes ownership of the file descriptor. On failure,
/// the file descriptor is closed.
@@ -566,10 +566,9 @@ impl super::Device {
) -> Result<super::Texture, crate::DeviceError> {
use std::os::unix::io::IntoRawFd;
if !self
.shared
.features
.contains(wgt::Features::VULKAN_EXTERNAL_MEMORY_DMA_BUF)
let enabled_extensions = &self.shared.enabled_extensions;
if !enabled_extensions.contains(&ext::external_memory_dma_buf::NAME)
|| !enabled_extensions.contains(&ext::image_drm_format_modifier::NAME)
{
log::error!(
"Vulkan driver does not support VK_EXT_external_memory_dma_buf \
+1 -1
View File
@@ -274,7 +274,7 @@ impl Surface {
///
/// - If the surface hasn't been configured.
/// - If the surface has been configured for a DXGI swapchain.
/// - If the device doesn't [support present timing](wgt::Features::VULKAN_GOOGLE_DISPLAY_TIMING).
/// - If the device doesn't have the [VK_GOOGLE_display_timing] extension enabled.
///
/// [VK_GOOGLE_display_timing]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_GOOGLE_display_timing.html
#[track_caller]
+11 -14
View File
@@ -3,7 +3,7 @@
use alloc::{boxed::Box, sync::Arc, vec::Vec};
use core::any::Any;
use ash::{khr, vk};
use ash::{google, khr, vk};
use wgpu_sync::{Mutex, MutexGuard};
use crate::vulkan::{
@@ -384,8 +384,7 @@ pub(crate) struct NativeSwapchain {
///
/// # Safety
///
/// This must only be set if [`wgt::Features::VULKAN_GOOGLE_DISPLAY_TIMING`] is enabled, and
/// so the VK_GOOGLE_display_timing extension is present.
/// This must only be set if the VK_GOOGLE_display_timing extension is enabled.
next_present_time: Option<vk::PresentTimeGOOGLE>,
/// A caller-provided `pNext` chain to attach to the [`vk::PresentInfoKHR`] of the next
@@ -639,9 +638,9 @@ impl Swapchain for NativeSwapchain {
let mut vk_info = if let Some(present_time) = self.next_present_time.take() {
debug_assert!(
self.device
.features
.contains(wgt::Features::VULKAN_GOOGLE_DISPLAY_TIMING),
"`next_present_time` should only be set if `VULKAN_GOOGLE_DISPLAY_TIMING` is enabled"
.enabled_extensions
.contains(&google::display_timing::NAME),
"`next_present_time` should only be set if VK_GOOGLE_display_timing is enabled"
);
present_times = [present_time];
display_timing = vk::PresentTimesInfoGOOGLE::default().times(&present_times);
@@ -695,17 +694,15 @@ impl NativeSwapchain {
}
pub fn set_next_present_time(&mut self, present_timing: vk::PresentTimeGOOGLE) {
let features = wgt::Features::VULKAN_GOOGLE_DISPLAY_TIMING;
if self.device.features.contains(features) {
if self
.device
.enabled_extensions
.contains(&google::display_timing::NAME)
{
self.next_present_time = Some(present_timing);
} else {
// Ideally we'd use something like `device.required_features` here, but that's in `wgpu-core`, which we are a dependency of
panic!(
concat!(
"Tried to set display timing properties ",
"without the corresponding feature ({:?}) enabled."
),
features
"Tried to set display timing properties without the VK_GOOGLE_display_timing extension enabled."
);
}
}
+18 -58
View File
@@ -27,6 +27,9 @@ pub use webgpu_impl::*;
mod webgpu_impl {
//! Constant values for [`super::FeaturesWebGPU`], separated so they can be picked up by
//! `cbindgen` in `mozilla-central` (where Firefox is developed).
//!
//! Bitmask feature encoding is not defined by the WebGPU specification, and the values
//! are subject to change.
#![allow(missing_docs)]
#[doc(hidden)]
@@ -582,6 +585,9 @@ features! {
#[doc = link_to_wgpu_docs!(["`RenderPass::multi_draw_indexed_indirect_count`"]: "struct.RenderPass.html#method.multi_draw_indexed_indirect_count")]
#[name("wgpu-multi-draw-indirect-count", "multi-draw-indirect-count")]
const MULTI_DRAW_INDIRECT_COUNT = 1 << 15;
// Bit 16 is available.
/// Allows the use of [`AddressMode::ClampToBorder`] with a border color
/// of [`SamplerBorderColor::Zero`].
///
@@ -673,6 +679,13 @@ features! {
/// This is a native only feature.
#[name("wgpu-clear-texture", "clear-texture")]
const CLEAR_TEXTURE = 1 << 23;
/// Allows for constructing ray tracing pipelines.
#[name("wgpu-ray-tracing-pipelines")]
const EXPERIMENTAL_RAY_TRACING_PIPELINES = 1 << 24;
// Bit 25 is available.
/// Enables multiview render passes and `builtin(view_index)` in vertex/mesh shaders.
///
/// Supported platforms:
@@ -781,7 +794,7 @@ features! {
#[name("wgpu-shader-i16", "shader-i16")]
const SHADER_I16 = 1 << 34;
// Bit 35 is used by VULKAN_EXTERNAL_MEMORY_FD.
// Bit 35 is available.
/// Allows shaders to use the `early_depth_test` attribute.
///
@@ -889,61 +902,10 @@ features! {
/// This is a native only feature.
#[name("wgpu-shader-int64-atomic-all-ops")]
const SHADER_INT64_ATOMIC_ALL_OPS = 1 << 43;
/// Allows using the [VK_GOOGLE_display_timing] Vulkan extension.
///
/// This is used for frame pacing to reduce latency, and is generally only available on Android.
///
/// This feature does not have a `wgpu`-level API, and so users of wgpu wishing
/// to use this functionality must access it using various `as_hal` functions,
/// primarily [`Surface::as_hal()`], to then use.
///
/// Supported platforms:
/// - Vulkan (with [VK_GOOGLE_display_timing])
///
/// This is a native only feature.
///
/// [VK_GOOGLE_display_timing]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_GOOGLE_display_timing.html
#[doc = link_to_wgpu_docs!(["`Surface::as_hal()`"]: "struct.Surface.html#method.as_hal")]
#[name("wgpu-vulkan-google-display-timing")]
const VULKAN_GOOGLE_DISPLAY_TIMING = 1 << 44;
/// Allows using the [VK_KHR_external_memory_win32] Vulkan extension.
///
/// Supported platforms:
/// - Vulkan (with [VK_KHR_external_memory_win32])
///
/// This is a native only feature.
///
/// [VK_KHR_external_memory_win32]: https://registry.khronos.org/vulkan/specs/latest/man/html/VK_KHR_external_memory_win32.html
#[name("wgpu-vulkan-external-memory-win32")]
const VULKAN_EXTERNAL_MEMORY_WIN32 = 1 << 45;
// Bit 44 is available.
/// Allows using the [VK_KHR_external_memory_fd] Vulkan extension.
///
/// Supported platforms:
/// - Vulkan (with [VK_KHR_external_memory_fd])
///
/// This is a native only feature.
///
/// [VK_KHR_external_memory_fd]: https://registry.khronos.org/vulkan/specs/latest/man/html/VK_KHR_external_memory_fd.html
#[name("wgpu-vulkan-external-memory-fd")]
const VULKAN_EXTERNAL_MEMORY_FD = 1 << 35;
/// Allows using the [VK_EXT_external_memory_dma_buf] Vulkan extension
/// for importing DMA-buf textures on Linux.
///
/// Requires [VK_EXT_image_drm_format_modifier] for specifying the
/// DRM format modifier and plane layout during import.
///
/// Supported platforms:
/// - Vulkan (with [VK_EXT_external_memory_dma_buf] and [VK_EXT_image_drm_format_modifier])
///
/// This is a native only feature.
///
/// [VK_EXT_external_memory_dma_buf]: https://registry.khronos.org/vulkan/specs/latest/man/html/VK_EXT_external_memory_dma_buf.html
/// [VK_EXT_image_drm_format_modifier]: https://registry.khronos.org/vulkan/specs/latest/man/html/VK_EXT_image_drm_format_modifier.html
#[name("wgpu-vulkan-external-memory-dma-buf")]
const VULKAN_EXTERNAL_MEMORY_DMA_BUF = 1 << 63;
// Bit 45 is available.
/// Enables R64Uint image atomic min and max.
///
@@ -1183,11 +1145,9 @@ features! {
#[name("wgpu-memory-decoration-volatile")]
const MEMORY_DECORATION_VOLATILE = 1 << 62;
/// Allows for constructing ray tracing pipelines.
#[name("wgpu-ray-tracing-pipelines")]
const EXPERIMENTAL_RAY_TRACING_PIPELINES = 1 << 24;
// Bit 63 is available.
// Adding a new feature? All bits in the first u64 are used. Use the second u64 (bits 64+).
// Search for "is available" to check for free bits earlier in the list.
}
/// Features that are not guaranteed to be supported.