mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 15:14:50 +00:00
bevy_render: Only auto-disable mappable primary buffers for discrete GPUs (#3803)
# Objective - While it is not safe to enable mappable primary buffers for all GPUs, it should be preferred for integrated GPUs where an integrated GPU is one that is sharing system memory. ## Solution - Auto-disable mappable primary buffers only for discrete GPUs. If the GPU is integrated and mappable primary buffers are supported, use them.
This commit is contained in:
parent
ca029ef0eb
commit
33ef5b5039
1 changed files with 12 additions and 9 deletions
|
@ -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(
|
||||
|
@ -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 = {
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue