From 7518516097368b0ce27ae35dda42946b5d9726bc Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Sun, 16 Jan 2022 15:10:45 +0100 Subject: [PATCH] bevy_render: Do not automatically enable MAPPABLE_PRIMARY_BUFFERS When using `WgpuOptionsPriority::Functionality`, which is the default, wgpu::Features::MAPPABLE_PRIMARY_BUFFERS would be automatically enabled. This feature can and does have a significant negative impact on performance for discrete GPUs where resizable bar is not supported, which is a common case. As such, this feature should not be automatically enabled. More changes will be made separately to make the configuration more flexible. --- crates/bevy_render/src/renderer/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/bevy_render/src/renderer/mod.rs b/crates/bevy_render/src/renderer/mod.rs index 088ed97ad98dd..1e5486f90b1eb 100644 --- a/crates/bevy_render/src/renderer/mod.rs +++ b/crates/bevy_render/src/renderer/mod.rs @@ -61,6 +61,11 @@ pub type RenderQueue = Arc; /// aswell as to create [`WindowSurfaces`](crate::view::window::WindowSurfaces). pub type RenderInstance = Instance; +/// `wgpu::Features` that are not automatically enabled due to having possibly-negative side effects. +/// `MAPPABLE_PRIMARY_BUFFERS` can have a significant, negative performance impact so should not be +/// automatically enabled. +pub const DEFAULT_DISABLED_WGPU_FEATURES: wgpu::Features = wgpu::Features::MAPPABLE_PRIMARY_BUFFERS; + /// Initializes the renderer by retrieving and preparing the GPU instance, device and queue /// for the specified backend. pub async fn initialize_renderer( @@ -86,8 +91,9 @@ pub async fn initialize_renderer( let trace_path = None; if matches!(options.priority, WgpuOptionsPriority::Functionality) { - options.features = - adapter.features() | wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES; + options.features = (adapter.features() + | wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES) + - DEFAULT_DISABLED_WGPU_FEATURES; options.limits = adapter.limits(); }