mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-12-06 14:04:01 -05:00
M3: on Windows, a GPU wgpu can only reach through OpenGL draws with eframe's OpenGL renderer (#4134)
An Intel HD 2500 or 4000 (Ivy Bridge) has no Direct3D 12 driver, so wgpu
picks its OpenGL backend. That backend fails in Surface::configure a few
seconds after the window opens ("Failed to wait for GPU to come idle"),
after the start-up retry with OpenGL can help, so the app closed with a
white window (#519, #4134, #5553). eframe's own OpenGL renderer works on
the same GPUs, which is the PDFCRAFT_RENDERER=gl workaround.
The adapter selector now declines an adapter on wgpu's OpenGL backend on
Windows, unless WGPU_BACKEND asked for it, so the existing start-up retry
draws with eframe's OpenGL renderer instead.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
dd875e867b
commit
dbfb847f03
2 files changed
+33
No files matched your search
@@ -796,6 +796,15 @@ fn configure_gpu(native: &mut eframe::NativeOptions) {
|
||||
})
|
||||
.collect();
|
||||
let picked = pick_adapter(&infos, &displays, compositor).and_then(|i| usable.get(i)).map(|a| (*a).clone());
|
||||
if let Some(a) = &picked
|
||||
&& !wgpu_draws_with(a.get_info().backend, cfg!(target_os = "windows"), std::env::var_os("WGPU_BACKEND").is_some())
|
||||
{
|
||||
log::warn!(
|
||||
"wgpu found no Direct3D 12 adapter for {}, only its OpenGL backend: drawing with eframe's OpenGL renderer instead",
|
||||
a.get_info().name
|
||||
);
|
||||
return Err("wgpu would draw through its OpenGL backend".to_string());
|
||||
}
|
||||
match &picked {
|
||||
// Which GPU draws is the first question when a window stays black (#8, #378, #445).
|
||||
Some(a) => {
|
||||
@@ -816,6 +825,16 @@ fn configure_gpu(native: &mut eframe::NativeOptions) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether wgpu should draw with the adapter it picked on `backend`. On Windows (`windows`) wgpu
|
||||
/// reaches its OpenGL backend only for a GPU with no Direct3D 12 driver, such as Intel's Ivy
|
||||
/// Bridge, and there that backend fails in `Surface::configure` a few seconds after the window
|
||||
/// opens: too late for the start-up retry with OpenGL, so the app closed (#519, #4134, #5553).
|
||||
/// eframe's own OpenGL renderer works on the same GPUs, so wgpu declines and that retry takes over.
|
||||
/// A backend asked for with `WGPU_BACKEND` (`backend_chosen`) is kept.
|
||||
fn wgpu_draws_with(backend: eframe::wgpu::Backend, windows: bool, backend_chosen: bool) -> bool {
|
||||
!(windows && backend == eframe::wgpu::Backend::Gl && !backend_chosen)
|
||||
}
|
||||
|
||||
/// How Direct3D 12 presents on Windows: through a DirectComposition visual (issue #2738), unless
|
||||
/// `WGPU_DX12_PRESENTATION_SYSTEM` asked for something else (`asked`).
|
||||
fn dx12_presentation(asked: Option<eframe::wgpu::Dx12SwapchainKind>) -> eframe::wgpu::Dx12SwapchainKind {
|
||||
|
||||
@@ -19,6 +19,20 @@ pub(crate) fn install_runtime(ctx: &egui::Context) {
|
||||
craft::ui::shell::embed::install(ctx, spec, &pdfcraft_ui_egui::fonts::ui_fonts(Lang::EN)).expect("the runtime installs on a fresh context");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn on_windows_wgpu_leaves_an_opengl_only_gpu_to_eframes_opengl_renderer() {
|
||||
use eframe::wgpu::Backend;
|
||||
// Issues #4134 and #5553: an Intel HD 4000 has no Direct3D 12 driver, so wgpu picks its
|
||||
// OpenGL backend, which fails a few seconds after the window opens.
|
||||
assert!(!super::wgpu_draws_with(Backend::Gl, true, false), "declined, so the start-up retry uses glow");
|
||||
// Everything else draws with wgpu as before.
|
||||
assert!(super::wgpu_draws_with(Backend::Dx12, true, false));
|
||||
assert!(super::wgpu_draws_with(Backend::Gl, true, true), "WGPU_BACKEND asked for it");
|
||||
for backend in [Backend::Gl, Backend::Vulkan, Backend::Metal] {
|
||||
assert!(super::wgpu_draws_with(backend, false, false), "{backend:?} off Windows");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn opengl_is_the_fallback_unless_a_renderer_was_chosen() {
|
||||
use super::{RendererChoice, native_options, renderer_choice, retry_with_gl};
|
||||
|
||||
Reference in new issue
Block a user