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

[Merged by Bors] - bevy_render: Only auto-disable mappable primary buffers for discrete GPUs #3803

Closed
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
21 changes: 12 additions & 9 deletions crates/bevy_render/src/renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ pub type RenderQueue = Arc<Queue>;
/// 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(
Expand All @@ -78,7 +73,8 @@ pub async fn initialize_renderer(
.await
.expect("Unable to find a GPU! Make sure you have installed required drivers!");

info!("{:?}", adapter.get_info());
let adapter_info = adapter.get_info();
info!("{:?}", adapter_info);

#[cfg(feature = "wgpu_trace")]
let trace_path = {
Expand All @@ -91,9 +87,16 @@ 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)
- DEFAULT_DISABLED_WGPU_FEATURES;
let mut features =
adapter.features() | wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES;
if adapter_info.device_type == wgpu::DeviceType::DiscreteGpu {
// `MAPPABLE_PRIMARY_BUFFERS` can have a significant, negative performance impact for
// discrete GPUs due to having to transfer data across the PCI-E bus and so it
// should not be automatically enabled in this case. It is however beneficial for
// integrated GPUs.
features -= wgpu::Features::MAPPABLE_PRIMARY_BUFFERS;
}
options.features = features;
options.limits = adapter.limits();
}

Expand Down