pub fn prepare_windows( _marker: NonSend<'_, NonSendMarker>, windows: ResMut<'_, ExtractedWindows>, window_surfaces: ResMut<'_, WindowSurfaces>, render_device: Res<'_, RenderDevice>, render_instance: Res<'_, RenderInstance>, render_adapter: Res<'_, RenderAdapter>, screenshot_pipeline: Res<'_, ScreenshotToScreenPipeline>, pipeline_cache: Res<'_, PipelineCache>, pipelines: ResMut<'_, SpecializedRenderPipelines<ScreenshotToScreenPipeline>>, msaa: ResMut<'_, Msaa> )
Creates and (re)configures window surfaces, and obtains a swapchain texture for rendering.
prepare_windows can take a long time if the GPU workload is
the performance bottleneck. This can be seen in profiles as multiple prepare-set systems all
taking an unusually long time to complete, and all finishing at about the same time as the
prepare_windows system. Improvements in bevy are planned to avoid this happening when it
should not but it will still happen as it is easy for a user to create a large GPU workload
relative to the GPU performance and/or CPU workload.
This can be caused by many reasons, but several of them are:
- GPU workload is more than your current GPU can manage
- Error / performance bug in your custom shaders
- wgpu was unable to detect a proper GPU hardware-accelerated device given the chosen
WgpuFeatures. For example, on Windows currently
DirectX 11is not supported by wgpu 0.12 and so if your GPU/drivers do not support Vulkan, it may be that a software renderer called “Microsoft Basic Render Driver” using
DirectX 12will be chosen and performance will be very poor. This is visible in a log message that is output during renderer initialization. Future versions of wgpu will support
DirectX 11, but another alternative is to try to use
Backends::GLif your GPU/drivers support
OpenGL ES 3.0or later.