Skip to content

Commit df3d100

Browse files
superdumpcart
authored andcommitted
bevy_render: Do not automatically enable MAPPABLE_PRIMARY_BUFFERS (#3698)
# Objective - 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. - Fixes the performance regression part of #3686 and at least some, if not all cases of #3687 ## Solution - When using `WgpuOptionsPriority::Functionality`, use the adapter-supported features, enable `TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES` and disable `MAPPABLE_PRIMARY_BUFFERS`
1 parent 398b15d commit df3d100

File tree

1 file changed

+8
-2
lines changed
  • crates/bevy_render/src/renderer

1 file changed

+8
-2
lines changed

crates/bevy_render/src/renderer/mod.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ pub type RenderQueue = Arc<Queue>;
6161
/// aswell as to create [`WindowSurfaces`](crate::view::window::WindowSurfaces).
6262
pub type RenderInstance = Instance;
6363

64+
/// `wgpu::Features` that are not automatically enabled due to having possibly-negative side effects.
65+
/// `MAPPABLE_PRIMARY_BUFFERS` can have a significant, negative performance impact so should not be
66+
/// automatically enabled.
67+
pub const DEFAULT_DISABLED_WGPU_FEATURES: wgpu::Features = wgpu::Features::MAPPABLE_PRIMARY_BUFFERS;
68+
6469
/// Initializes the renderer by retrieving and preparing the GPU instance, device and queue
6570
/// for the specified backend.
6671
pub async fn initialize_renderer(
@@ -86,8 +91,9 @@ pub async fn initialize_renderer(
8691
let trace_path = None;
8792

8893
if matches!(options.priority, WgpuOptionsPriority::Functionality) {
89-
options.features =
90-
adapter.features() | wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES;
94+
options.features = (adapter.features()
95+
| wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES)
96+
- DEFAULT_DISABLED_WGPU_FEATURES;
9197
options.limits = adapter.limits();
9298
}
9399

0 commit comments

Comments
 (0)