notedeck icon indicating copy to clipboard operation
notedeck copied to clipboard

Fallback to glow when wgpu fails

Open jb55 opened this issue 1 year ago • 7 comments

For some reason when the wgpu backend fails it just halts instead of switching to glow. We need to figure out if this is a bug in eframe (@emilk), if this is something we're doing wrong, or if this is even supported.

jb55 avatar Apr 29 '24 22:04 jb55

looking at the code it does not look like this is supported. I tried to make it fallback but the AppCreator is moved and I'm not able to retry with a new backend. I will need to ponder on how to do this properly.

jb55 avatar Apr 29 '24 22:04 jb55

eframe has no built-in rendering fallback, no.

Instead of falling back on glow, you could also experiment with having wgpu fall back to a different wgpu::backend, e.g. to wgpu::Backend::Gl.

@Wumpf probably has some smart ideas related to that.

emilk avatar Apr 30 '24 05:04 emilk

eframe would need quite a bit of refactor to make a runtime decision about glow vs wgpu but as emilk says, ideally you'd just use wgpu with different backends.

There's some important fixes in wgpu 0.20 (will update egui soon!) regarding corner cases of backend selection when a backend is available but the surface is not compatible (should never happen but window managers can be weird on Linux...). If for some reason you have to redecide on the backend you could try restarting eframe but with a smaller selection of wgpu::Backends.

I'm ofc also very curious how wgpu fails, did you report a bug (please do!)? Is it a known issue? Other than failing to start, all wgpu almost all errors should be recoverable if the right error callbacks are set.

Wumpf avatar Apr 30 '24 08:04 Wumpf

@Wumpf Here's the log, it fails on my intel graphics laptop on linux (nixos):

2024-04-29T22:00:53.840704Z  INFO eframe: Both the glow and wgpu renderers are available. Using wgpu.    
2024-04-29T22:00:53.840737Z DEBUG eframe: Using the wgpu renderer    
2024-04-29T22:00:53.848316Z DEBUG eframe::native::wgpu_integration: Event::Resumed    
2024-04-29T22:00:53.848538Z  INFO winit::platform_impl::platform::x11::window: Guessed window scale factor: 1.6666666666666667    
2024-04-29T22:00:53.848547Z DEBUG winit::platform_impl::platform::x11::window: Calculated physical dimensions: 800x600    
2024-04-29T22:00:53.872645Z DEBUG wgpu_hal::vulkan::instance: Instance version: 0x403113    
2024-04-29T22:00:53.872669Z  INFO wgpu_hal::vulkan::instance: Debug utils not enabled: debug_utils_user_data not passed to Instance::from_raw    
2024-04-29T22:00:53.872672Z DEBUG wgpu_hal::vulkan::instance: Enabling device properties2    
2024-04-29T22:00:53.872695Z DEBUG wgpu_core::instance: Instance::new: created Vulkan backend    
2024-04-29T22:00:53.873748Z DEBUG wgpu_hal::gles::egl: Client extensions: [
    "EGL_EXT_device_base", "EGL_EXT_device_enumeration", "EGL_EXT_device_query", "EGL_EXT_platform_base", "EGL_KHR_client_get_all_proc_addresses", "EGL_EXT_client_extensions", "EGL_KHR_debug", "EGL_EXT_platform_device", "EGL_EXT_explicit_device", "EGL_EXT_platform_wayland", "EGL_KHR_platform_wayland", "EGL_EXT_platform_x11", "EGL_KHR_platform_x11", "EGL_EXT_platform_xcb", "EGL_MESA_platform_gbm", "EGL_KHR_platform_gbm", "EGL_MESA_platform_surfaceless",
]    
2024-04-29T22:00:53.873774Z DEBUG wgpu_hal::gles::egl: Loading Wayland library to get the current display    
2024-04-29T22:00:53.873831Z DEBUG wgpu_hal::gles::egl: Loading X11 library to get the current display    
2024-04-29T22:00:53.874299Z  INFO wgpu_hal::gles::egl: Using X11 platform    
2024-04-29T22:00:53.889807Z DEBUG wgpu_hal::gles::egl: Display vendor "Mesa Project", version (1, 5)    
2024-04-29T22:00:53.889828Z DEBUG wgpu_hal::gles::egl: Display extensions: [
    "EGL_ANDROID_blob_cache", "EGL_ANDROID_native_fence_sync", "EGL_CHROMIUM_sync_control", "EGL_ANGLE_sync_control_rate", "EGL_EXT_buffer_age", "EGL_EXT_create_context_robustness", "EGL_EXT_image_dma_buf_import", "EGL_EXT_image_dma_buf_import_modifiers", "EGL_EXT_swap_buffers_with_damage", "EGL_IMG_context_priority", "EGL_KHR_cl_event2", "EGL_KHR_config_attribs", "EGL_KHR_context_flush_control", "EGL_KHR_create_context", "EGL_KHR_create_context_no_error", "EGL_KHR_fence_sync", "EGL_KHR_get_all_proc_addresses", "EGL_KHR_gl_colorspace", "EGL_KHR_gl_renderbuffer_image", "EGL_KHR_gl_texture_2D_image", "EGL_KHR_gl_texture_3D_image", "EGL_KHR_gl_texture_cubemap_image", "EGL_KHR_image", "EGL_KHR_image_base", "EGL_KHR_image_pixmap", "EGL_KHR_no_config_context", "EGL_KHR_reusable_sync", "EGL_KHR_surfaceless_context", "EGL_KHR_swap_buffers_with_damage", "EGL_EXT_pixel_format_float", "EGL_KHR_wait_sync", "EGL_MESA_configless_context", "EGL_MESA_drm_image", "EGL_MESA_gl_interop", "EGL_MESA_image_dma_buf_export", "EGL_MESA_query_driver", "EGL_NOK_texture_from_pixmap", "EGL_WL_bind_wayland_display",
]    
2024-04-29T22:00:53.889856Z DEBUG wgpu_hal::gles::egl: 	EGL surface: +srgb    
2024-04-29T22:00:53.890025Z DEBUG wgpu_hal::gles::egl: 	Trying native-render    
2024-04-29T22:00:53.890048Z DEBUG wgpu_hal::gles::egl: 	EGL context: +robust access EXT    
2024-04-29T22:00:53.890867Z DEBUG wgpu_hal::gles::egl: 	EGL context: +surfaceless    
2024-04-29T22:00:53.890876Z DEBUG wgpu_core::instance: Instance::new: created Gl backend    
2024-04-29T22:00:53.891310Z ERROR wgpu_hal::vulkan::instance: enumerate_adapters: Initialization of an object has failed    
2024-04-29T22:00:53.892737Z DEBUG wgpu_hal::gles::adapter: Vendor: Intel    
2024-04-29T22:00:53.892746Z DEBUG wgpu_hal::gles::adapter: Renderer: Mesa Intel(R) HD Graphics 620 (KBL GT2)    
2024-04-29T22:00:53.892748Z DEBUG wgpu_hal::gles::adapter: Version: OpenGL ES 3.2 Mesa 23.3.5    
2024-04-29T22:00:53.892753Z DEBUG wgpu_hal::gles::adapter: SL version: OpenGL ES GLSL ES 3.20    
2024-04-29T22:00:53.892756Z DEBUG wgpu_hal::gles::adapter: Supported GL Extensions: {
    "GL_EXT_texture_compression_rgtc", "GL_NV_draw_buffers", "GL_NV_pixel_buffer_object", "GL_EXT_texture_compression_dxt1", "GL_EXT_shader_framebuffer_fetch_non_coherent", "GL_OES_sample_shading", "GL_OES_texture_float", "GL_INTEL_blackhole_render", "GL_OES_vertex_array_object", "GL_EXT_occlusion_query_boolean", "GL_EXT_EGL_image_storage", "GL_EXT_texture_format_BGRA8888", "GL_EXT_polygon_offset_clamp", "GL_EXT_texture_norm16", "GL_EXT_texture_view", "GL_NV_read_buffer", "GL_OES_depth24", "GL_EXT_render_snorm", "GL_MESA_sampler_objects", "GL_EXT_color_buffer_float", "GL_OES_geometry_point_size", "GL_EXT_texture_query_lod", "GL_OES_texture_cube_map_array", "GL_ANDROID_extension_pack_es31a", "GL_EXT_tessellation_shader", "GL_EXT_texture_rg", "GL_EXT_geometry_point_size", "GL_OES_required_internalformat", "GL_ANGLE_texture_compression_dxt5", "GL_EXT_blend_func_extended", "GL_EXT_texture_filter_anisotropic", "GL_EXT_multi_draw_arrays", "GL_EXT_sRGB_write_control", "GL_EXT_texture_shadow_lod", "GL_OES_texture_npot", "GL_KHR_robustness", "GL_EXT_disjoint_timer_query", "GL_EXT_map_buffer_range", "GL_MESA_framebuffer_flip_y", "GL_EXT_compressed_ETC1_RGB8_sub_texture", "GL_ANGLE_texture_compression_dxt3", "GL_KHR_blend_equation_advanced", "GL_EXT_clip_cull_distance", "GL_KHR_debug", "GL_NV_alpha_to_coverage_dither_control", "GL_APPLE_sync", "GL_OES_depth_texture", "GL_EXT_draw_buffers_indexed", "GL_MESA_texture_const_bandwidth", "GL_OES_shader_io_blocks", "GL_EXT_texture_type_2_10_10_10_REV", "GL_OES_EGL_image", "GL_OES_stencil8", "GL_NV_conditional_render", "GL_OES_standard_derivatives", "GL_EXT_draw_instanced", "GL_NV_compute_shader_derivatives", "GL_NV_read_depth_stencil", "GL_NV_fbo_color_attachments", "GL_EXT_copy_image", "GL_EXT_separate_shader_objects", "GL_MESA_bgra", "GL_EXT_read_format_bgra", "GL_OES_viewport_array", "GL_EXT_tessellation_point_size", "GL_EXT_robustness", "GL_NV_shader_noperspective_interpolation", "GL_OES_geometry_shader", "GL_EXT_clip_control", "GL_EXT_gpu_shader5", "GL_OES_copy_image", "GL_OES_texture_border_clamp", "GL_NV_read_stencil", "GL_EXT_frag_depth", "GL_EXT_texture_compression_s3tc", "GL_EXT_texture_mirror_clamp_to_edge", "GL_INTEL_performance_query", "GL_NV_read_depth", "GL_EXT_semaphore", "GL_NV_pack_subimage", "GL_OES_EGL_image_external", "GL_ANGLE_pack_reverse_row_order", "GL_EXT_debug_label", "GL_EXT_texture_compression_s3tc_srgb", "GL_EXT_unpack_subimage", "GL_OES_shader_image_atomic", "GL_EXT_blend_minmax", "GL_OES_element_index_uint", "GL_EXT_float_blend", "GL_KHR_texture_compression_astc_ldr", "GL_OES_mapbuffer", "GL_EXT_texture_sRGB_R8", "GL_OES_gpu_shader5", "GL_OES_compressed_ETC1_RGB8_texture", "GL_EXT_draw_elements_base_vertex", "GL_EXT_texture_sRGB_decode", "GL_OES_texture_storage_multisample_2d_array", "GL_EXT_clear_texture", "GL_EXT_shader_io_blocks", "GL_EXT_demote_to_helper_invocation", "GL_KHR_no_error", "GL_EXT_shader_implicit_conversions", "GL_OES_EGL_image_external_essl3", "GL_KHR_blend_equation_advanced_coherent", "GL_EXT_geometry_shader", "GL_OES_primitive_bounding_box", "GL_AMD_performance_monitor", "GL_OES_fbo_render_mipmap", "GL_EXT_shader_integer_mix", "GL_OES_tessellation_shader", "GL_OES_rgb8_rgba8", "GL_OES_sample_variables", "GL_KHR_context_flush_control", "GL_EXT_draw_buffers", "GL_OES_draw_elements_base_vertex", "GL_EXT_color_buffer_half_float", "GL_EXT_primitive_bounding_box", "GL_KHR_texture_compression_astc_sliced_3d", "GL_OES_shader_multisample_interpolation", "GL_OES_surfaceless_context", "GL_EXT_memory_object", "GL_EXT_discard_framebuffer", "GL_EXT_texture_border_clamp", "GL_EXT_semaphore_fd", "GL_OES_packed_depth_stencil", "GL_OES_depth_texture_cube_map", "GL_INTEL_conservative_rasterization", "GL_EXT_shader_framebuffer_fetch", "GL_EXT_texture_cube_map_array", "GL_OES_texture_half_float_linear", "GL_OES_texture_stencil8", "GL_NV_fragment_shader_interlock", "GL_OES_texture_view", "GL_EXT_depth_clamp", "GL_EXT_texture_compression_bptc", "GL_NV_generate_mipmap_sRGB", "GL_OES_tessellation_point_size", "GL_OES_texture_buffer", "GL_EXT_texture_buffer", "GL_OES_draw_buffers_indexed", "GL_EXT_base_instance", "GL_OES_EGL_sync", "GL_NV_image_formats", "GL_OES_texture_3D", "GL_KHR_robust_buffer_access_behavior", "GL_APPLE_texture_max_level", "GL_EXT_instanced_arrays", "GL_MESA_shader_integer_functions", "GL_OES_get_program_binary", "GL_OES_vertex_half_float", "GL_EXT_buffer_storage", "GL_EXT_shader_group_vote", "GL_EXT_memory_object_fd", "GL_NV_texture_barrier", "GL_OES_texture_float_linear", "GL_OES_texture_half_float", "GL_KHR_parallel_shader_compile", "GL_EXT_shader_samples_identical",
}    
2024-04-29T22:00:53.892878Z  WARN wgpu_hal::gles::adapter: Detected skylake derivative running on mesa i915. Clears to srgb textures will use manual shader clears.    
2024-04-29T22:00:53.892891Z  INFO wgpu_core::instance: Adapter Gl AdapterInfo { name: "Mesa Intel(R) HD Graphics 620 (KBL GT2)", vendor: 32902, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Gl }    
2024-04-29T22:00:53.892911Z ERROR wgpu_hal::vulkan::instance: enumerate_adapters: Initialization of an object has failed    
2024-04-29T22:00:53.893271Z DEBUG wgpu_hal::gles::adapter: Vendor: Intel    
2024-04-29T22:00:53.893274Z DEBUG wgpu_hal::gles::adapter: Renderer: Mesa Intel(R) HD Graphics 620 (KBL GT2)    
2024-04-29T22:00:53.893276Z DEBUG wgpu_hal::gles::adapter: Version: OpenGL ES 3.2 Mesa 23.3.5    
2024-04-29T22:00:53.893279Z DEBUG wgpu_hal::gles::adapter: SL version: OpenGL ES GLSL ES 3.20    
2024-04-29T22:00:53.893280Z DEBUG wgpu_hal::gles::adapter: Supported GL Extensions: {
    "GL_KHR_blend_equation_advanced_coherent", "GL_EXT_float_blend", "GL_INTEL_conservative_rasterization", "GL_MESA_bgra", "GL_OES_texture_border_clamp", "GL_OES_compressed_ETC1_RGB8_texture", "GL_EXT_texture_compression_dxt1", "GL_EXT_texture_compression_rgtc", "GL_MESA_framebuffer_flip_y", "GL_EXT_color_buffer_half_float", "GL_OES_geometry_shader", "GL_KHR_robustness", "GL_OES_depth24", "GL_ANGLE_pack_reverse_row_order", "GL_EXT_multi_draw_arrays", "GL_OES_tessellation_point_size", "GL_EXT_discard_framebuffer", "GL_EXT_instanced_arrays", "GL_OES_depth_texture_cube_map", "GL_OES_texture_view", "GL_EXT_clear_texture", "GL_MESA_texture_const_bandwidth", "GL_EXT_tessellation_point_size", "GL_NV_draw_buffers", "GL_OES_texture_storage_multisample_2d_array", "GL_EXT_draw_elements_base_vertex", "GL_OES_fbo_render_mipmap", "GL_EXT_draw_instanced", "GL_OES_texture_cube_map_array", "GL_ANGLE_texture_compression_dxt3", "GL_OES_viewport_array", "GL_EXT_demote_to_helper_invocation", "GL_OES_rgb8_rgba8", "GL_EXT_gpu_shader5", "GL_EXT_texture_query_lod", "GL_OES_shader_image_atomic", "GL_EXT_clip_cull_distance", "GL_OES_element_index_uint", "GL_ANGLE_texture_compression_dxt5", "GL_OES_geometry_point_size", "GL_OES_depth_texture", "GL_OES_sample_variables", "GL_ANDROID_extension_pack_es31a", "GL_OES_copy_image", "GL_OES_surfaceless_context", "GL_EXT_draw_buffers", "GL_EXT_texture_shadow_lod", "GL_EXT_color_buffer_float", "GL_OES_shader_io_blocks", "GL_EXT_unpack_subimage", "GL_OES_required_internalformat", "GL_EXT_render_snorm", "GL_EXT_shader_io_blocks", "GL_NV_fragment_shader_interlock", "GL_EXT_texture_sRGB_decode", "GL_INTEL_performance_query", "GL_KHR_texture_compression_astc_sliced_3d", "GL_KHR_no_error", "GL_OES_tessellation_shader", "GL_OES_vertex_half_float", "GL_EXT_disjoint_timer_query", "GL_NV_alpha_to_coverage_dither_control", "GL_EXT_texture_compression_s3tc_srgb", "GL_AMD_performance_monitor", "GL_EXT_draw_buffers_indexed", "GL_KHR_context_flush_control", "GL_NV_fbo_color_attachments", "GL_EXT_texture_sRGB_R8", "GL_EXT_memory_object_fd", "GL_OES_mapbuffer", "GL_EXT_shader_implicit_conversions", "GL_EXT_texture_compression_bptc", "GL_NV_pixel_buffer_object", "GL_EXT_EGL_image_storage", "GL_OES_texture_float_linear", "GL_OES_texture_npot", "GL_NV_pack_subimage", "GL_NV_shader_noperspective_interpolation", "GL_EXT_geometry_shader", "GL_EXT_map_buffer_range", "GL_EXT_tessellation_shader", "GL_NV_generate_mipmap_sRGB", "GL_EXT_memory_object", "GL_OES_draw_elements_base_vertex", "GL_OES_texture_buffer", "GL_OES_texture_float", "GL_MESA_sampler_objects", "GL_EXT_texture_type_2_10_10_10_REV", "GL_OES_texture_half_float_linear", "GL_EXT_texture_rg", "GL_OES_stencil8", "GL_OES_texture_3D", "GL_NV_read_buffer", "GL_EXT_compressed_ETC1_RGB8_sub_texture", "GL_KHR_parallel_shader_compile", "GL_OES_texture_stencil8", "GL_EXT_blend_minmax", "GL_NV_read_depth_stencil", "GL_OES_EGL_image", "GL_KHR_texture_compression_astc_ldr", "GL_OES_draw_buffers_indexed", "GL_EXT_copy_image", "GL_MESA_shader_integer_functions", "GL_EXT_primitive_bounding_box", "GL_EXT_occlusion_query_boolean", "GL_EXT_texture_filter_anisotropic", "GL_EXT_texture_mirror_clamp_to_edge", "GL_EXT_texture_norm16", "GL_EXT_shader_framebuffer_fetch", "GL_NV_texture_barrier", "GL_OES_EGL_image_external_essl3", "GL_OES_packed_depth_stencil", "GL_EXT_frag_depth", "GL_OES_shader_multisample_interpolation", "GL_OES_texture_half_float", "GL_EXT_shader_integer_mix", "GL_EXT_shader_samples_identical", "GL_EXT_texture_cube_map_array", "GL_NV_image_formats", "GL_EXT_texture_buffer", "GL_NV_read_stencil", "GL_OES_standard_derivatives", "GL_KHR_robust_buffer_access_behavior", "GL_EXT_clip_control", "GL_OES_EGL_sync", "GL_APPLE_texture_max_level", "GL_EXT_texture_border_clamp", "GL_INTEL_blackhole_render", "GL_OES_vertex_array_object", "GL_OES_sample_shading", "GL_EXT_semaphore", "GL_EXT_shader_framebuffer_fetch_non_coherent", "GL_EXT_debug_label", "GL_EXT_read_format_bgra", "GL_EXT_shader_group_vote", "GL_EXT_texture_compression_s3tc", "GL_OES_get_program_binary", "GL_APPLE_sync", "GL_EXT_base_instance", "GL_NV_read_depth", "GL_EXT_geometry_point_size", "GL_EXT_polygon_offset_clamp", "GL_NV_conditional_render", "GL_OES_gpu_shader5", "GL_EXT_separate_shader_objects", "GL_EXT_blend_func_extended", "GL_NV_compute_shader_derivatives", "GL_KHR_blend_equation_advanced", "GL_EXT_texture_format_BGRA8888", "GL_EXT_buffer_storage", "GL_OES_EGL_image_external", "GL_KHR_debug", "GL_EXT_robustness", "GL_EXT_sRGB_write_control", "GL_EXT_depth_clamp", "GL_EXT_texture_view", "GL_OES_primitive_bounding_box", "GL_EXT_semaphore_fd",
}    
2024-04-29T22:00:53.893413Z  WARN wgpu_hal::gles::adapter: Detected skylake derivative running on mesa i915. Clears to srgb textures will use manual shader clears.    
2024-04-29T22:00:53.893436Z  INFO egui_wgpu: The only available wgpu adapter was not suitable: backend: Gl, device_type: IntegratedGpu, name: "Mesa Intel(R) HD Graphics 620 (KBL GT2)", vendor: 0x8086    
2024-04-29T22:00:53.894677Z ERROR eframe::native::run: Exiting because of error: WGPU error: Failed to create wgpu adapter, no suitable adapter found. during event Resumed    
2024-04-29T22:00:53.894691Z DEBUG eframe::native::run: Asking to exit event loop…    
2024-04-29T22:00:53.894736Z DEBUG eframe::native::run: Received Event::LoopExiting - saving app state…    
2024-04-29T22:00:53.894794Z DEBUG eframe::native::run: eframe window closed    

jb55 avatar Apr 30 '24 13:04 jb55

this is 0.72.2

$ cargo tree -p egui-wgpu --depth 1
egui-wgpu v0.27.2
├── bytemuck v1.14.2
├── document-features v0.2.8 (proc-macro)
├── egui v0.27.2
├── epaint v0.27.2
├── log v0.4.20
├── thiserror v1.0.56
├── type-map v0.5.0
├── web-time v0.2.4
├── wgpu v0.19.1

jb55 avatar Apr 30 '24 13:04 jb55

looks like wgpu figured it can't use Vulkan (it fails creating an adapter), then tried to pick OpenGL and rejected that as well because it didn't fit the minspec - unfortunately doesn't say what about it isn't sufficient 🤔 . The fact that it couldn't use Vulkan hints at outdated drivers usually. Which is strange because it also mentions Mesa 23.3.5 for OpenGL which is quite new.

Can you try telling wgpu to either use vulkan or gl by setting only the respective backends on egui's render config? There's a bug in wgpu 0.19 that sometimes has issues when the first backend in the list doesn't work out (fixed in wgpu 0.20) and this sounds a little bit like that. Alternatively, you can also try with egui master branch - wgpu was updated there a few hours ago

Wumpf avatar Apr 30 '24 13:04 Wumpf

On Tue, Apr 30, 2024 at 07:00:19AM GMT, Andreas Reich wrote:

looks like wgpu figured it can't use Vulkan (it fails creating an adapter), then tried to pick OpenGL and rejected that as well because it didn't fit the minspec - unfortunately doesn't say what about it isn't sufficient 🤔 . The fact that it couldn't use Vulkan hints at outdated drivers usually. Which is strange because it also mentions Mesa 23.3.5 for OpenGL which is quite new.

Can you try telling wgpu to either use vulkan or gl by setting only the respective backends on egui's render config? There's a bug in wgpu 0.19 that sometimes has issues when the first backend in the list doesn't work out (fixed in wgpu 0.20) and this sounds a little bit like that. Alternatively, you can also try with egui master branch - wgpu was updated there a few hours ago

ok will do, thanks! will report back.

jb55 avatar Apr 30 '24 16:04 jb55

@Wumpf this does appear to fix it! thanks!

jb55 avatar Jul 03 '24 00:07 jb55