kvark / vange-rs

Rusty Vangers clone
https://vange.rs
Apache License 2.0
427 stars 21 forks source link

Support running on older Linux via Angle #163

Open kvark opened 2 years ago

kvark commented 2 years ago

As a follow-up to #161 on really old systems.

kvark commented 2 years ago

On my machine, it seems to run through Angle just fine. However, @DileSoft provided the following logs for his machine:

dilesoft@dilesoft-G41MT-S2P:~/Загрузки/vange-rs$ RUST_LOG=wgpu_hal=debug LD_LIBRARY_PATH=/home/dilesoft/Загрузки/vange-rs/angle/lib cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.17s
     Running `target/debug/road`
[2021-12-04T19:49:33Z DEBUG wgpu_hal::gles::egl] Client extensions: [
        "EGL_KHR_client_get_all_proc_addresses",
        "EGL_EXT_client_extensions",
        "EGL_EXT_platform_base",
        "EGL_EXT_platform_x11",
    ]
[2021-12-04T19:49:33Z INFO  wgpu_hal::gles::egl] Loading X11 library to get the current display
[2021-12-04T19:49:33Z INFO  wgpu_hal::gles::egl] Using default platform
[2021-12-04T19:49:33Z INFO  wgpu_hal::gles::egl] Display vendor "NVIDIA", version (1, 4)
[2021-12-04T19:49:33Z DEBUG wgpu_hal::gles::egl] Display extensions: [
        "EGL_NV_system_time",
        "EGL_KHR_surfaceless_context",
        "EGL_KHR_image",
        "EGL_KHR_image_base",
        "EGL_KHR_gl_texture_2D_image",
        "EGL_KHR_gl_texture_cubemap_image",
        "EGL_KHR_gl_renderbuffer_image",
        "EGL_KHR_config_attribs",
        "EGL_KHR_fence_sync",
        "EGL_NV_sync",
        "EGL_KHR_reusable_sync",
        "EGL_KHR_create_context",
        "EGL_EXT_create_context_robustness",
        "EGL_KHR_stream",
        "EGL_KHR_stream_fifo",
        "EGL_KHR_stream_producer_eglsurface",
        "EGL_KHR_stream_consumer_gltexture",
        "EGL_NV_stream_sync",
        "EGL_KHR_get_all_proc_addresses",
        "EGL_IMG_context_priority",
        "EGL_NV_post_sub_buffer",
        "EGL_KHR_image_pixmap",
        "EGL_EXT_buffer_age",
    ]
[2021-12-04T19:49:33Z WARN  wgpu_hal::gles::egl]   EGL surface: -srgb
[2021-12-04T19:49:33Z INFO  wgpu_hal::gles::egl]   Trying native-render
[2021-12-04T19:49:33Z WARN  wgpu_hal::gles::egl] No config found!
[2021-12-04T19:49:33Z INFO  wgpu_hal::gles::egl]   Trying presentation
[2021-12-04T19:49:33Z WARN  wgpu_hal::gles::egl] EGL says it can present to the window but not natively. This has been confirmed to malfunction on Intel+NV laptops.
[2021-12-04T19:49:33Z INFO  wgpu_hal::gles::egl]   EGL context: +debug KHR
[2021-12-04T19:49:33Z INFO  wgpu_hal::gles::egl]   EGL context: +robust access EXT
[2021-12-04T19:49:33Z INFO  wgpu_hal::gles::egl]   EGL context: +surfaceless
[2021-12-04T19:49:34Z INFO  wgpu_hal::gles::egl] Max label length: 256
[2021-12-04T19:49:34Z INFO  wgpu_hal::gles::egl] Enabling GLES debug output
[2021-12-04T19:49:34Z INFO  wgpu_hal::gles::adapter] Vendor: NVIDIA Corporation
[2021-12-04T19:49:34Z INFO  wgpu_hal::gles::adapter] Renderer: GeForce 9600 GT/PCIe/SSE2
[2021-12-04T19:49:34Z INFO  wgpu_hal::gles::adapter] Version: OpenGL ES 2.0 340.108
[2021-12-04T19:49:34Z DEBUG wgpu_hal::gles::adapter] Extensions: {
        "GL_NV_pixel_buffer_object",
        "GL_OES_get_program_binary",
        "GL_NV_bgr",
        "GL_NV_occlusion_query_samples",
        "GL_EXT_shadow_samplers",
        "GL_NV_timer_query",
        "GL_NV_copy_image",
        "GL_NV_texture_border_clamp",
        "GL_OES_element_index_uint",
        "GL_KHR_debug",
        "GL_EXT_texture_format_BGRA8888",
        "GL_NV_texture_compression_latc",
        "GL_EXT_frag_depth",
        "GL_NV_draw_buffers",
        "GL_EXT_separate_shader_objects",
        "GL_NV_framebuffer_blit",
        "GL_NV_packed_float_linear",
        "GL_EXT_unpack_subimage",
        "GL_OES_mapbuffer",
        "GL_OES_vertex_half_float",
        "GL_EXT_map_buffer_range",
        "GL_NV_texture_compression_s3tc",
        "GL_NV_sRGB_formats",
        "GL_NV_read_depth_stencil",
        "GL_NV_read_buffer",
        "GL_EXT_texture_sRGB_decode",
        "GL_NV_fbo_color_attachments",
        "GL_EXT_color_buffer_half_float",
        "GL_NV_generate_mipmap_sRGB",
        "GL_NV_read_depth",
        "GL_EXT_texture_filter_anisotropic",
        "GL_OES_texture_npot",
        "GL_NV_texture_compression_s3tc_update",
        "GL_OES_depth_texture_cube_map",
        "GL_OES_fbo_render_mipmap",
        "GL_EXT_shader_integer_mix",
        "GL_EXT_texture_storage",
        "GL_OES_EGL_sync",
        "GL_EXT_debug_label",
        "GL_NV_pack_subimage",
        "GL_NV_read_stencil",
        "GL_EXT_blend_minmax",
        "GL_EXT_texture_compression_s3tc",
        "GL_EXT_texture_compression_dxt1",
        "GL_OES_EGL_image",
        "GL_NV_non_square_matrices",
        "",
        "GL_NV_texture_array",
        "GL_OES_texture_half_float",
        "GL_OES_texture_half_float_linear",
        "GL_OES_vertex_array_object",
        "GL_NV_framebuffer_multisample",
        "GL_NV_shadow_samplers_array",
        "GL_OES_depth_texture",
        "GL_NV_copy_buffer",
        "GL_OES_depth24",
        "GL_OES_packed_depth_stencil",
        "GL_NV_explicit_attrib_location",
        "GL_NV_instanced_arrays",
        "GL_EXT_robustness",
        "GL_NV_packed_float",
        "GL_OES_surfaceless_context",
        "GL_OES_compressed_ETC1_RGB8_texture",
        "GL_OES_depth32",
        "GL_EXT_texture_rg",
        "GL_NV_draw_instanced",
        "GL_OES_rgb8_rgba8",
        "GL_NV_EGL_stream_consumer_external",
        "GL_EXT_sRGB",
        "GL_NV_shadow_samplers_cube",
        "GL_EXT_sRGB_write_control",
        "GL_OES_standard_derivatives",
        "GL_EXT_occlusion_query_boolean",
    }
[2021-12-04T19:49:34Z WARN  wgpu_hal::gles::adapter] Returned GLES context is 2.0, when 3.0+ was requested
thread 'main' panicked at 'Unable to initialize GPU via the selected backend.', bin/road/../boilerplate.rs:86:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
kvark commented 2 years ago

Turns out, we need to symlink libEGL.so.1 to libEGL.so for Angle to be picked up, actually. First error is:

INFO: EGL ERROR: eglCreateContext: Unknown attribute: 0x31b2X

This is caused by this code:

        if needs_robustness {
            if version >= (1, 5) {
                log::info!("\tEGL context: +robust access");
                context_attributes.push(egl::CONTEXT_OPENGL_ROBUST_ACCESS);
                context_attributes.push(egl::TRUE as _);
            } else if display_extensions.contains("EGL_EXT_create_context_robustness") {
                log::info!("\tEGL context: +robust access EXT");
                context_attributes.push(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT);
                context_attributes.push(egl::TRUE as _);
            } else {
                log::warn!("\tEGL context: -robust access");
            }

            //TODO do we need `egl::CONTEXT_OPENGL_NOTIFICATION_STRATEGY_EXT`?
        }

So it's not clear to me why it considers the attribute to be unknown. It reports EGL version 1.5, and the specification for egl-1.5 has this enum value...

kvark commented 2 years ago

If we work around it, the next error is:

[2021-12-04T20:36:17Z WARN  wgpu_hal::gles::adapter] Detected skylake derivative running on mesa i915. Clears to srgb textures will use manual shader clears.
[2021-12-04T20:36:17Z WARN  wgpu_hal::gles::egl] Error in create_platform_window_surface: BadNativeWindow
thread 'main' panicked at 'Error in Surface::configure: invalid surface', /x/code/wgpu/wgpu/src/backend/direct.rs:214:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
kvark commented 2 years ago

Looks like there is still an issue on some platforms.

dilesoft@dilesoft-G41MT-S2P:~/Загрузки/vange-rs$ RUST_LOG=wgpu_hal=debug LD_LIBRARY_PATH=/home/dilesoft/Загрузки/vange-rs/angle/lib cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.17s
     Running `target/debug/road`
[2021-12-05T07:40:29Z DEBUG wgpu_hal::gles::egl] Client extensions: [
        "EGL_EXT_client_extensions",
        "EGL_EXT_device_query",
        "EGL_EXT_platform_base",
        "EGL_ANGLE_platform_angle",
        "EGL_ANGLE_platform_angle_device_type_egl_angle",
        "EGL_ANGLE_platform_angle_device_type_swiftshader",
        "EGL_ANGLE_platform_angle_opengl",
        "EGL_ANGLE_platform_angle_null",
        "EGL_ANGLE_platform_angle_vulkan",
        "EGL_ANGLE_x11_visual",
        "EGL_KHR_client_get_all_proc_addresses",
        "EGL_KHR_debug",
        "EGL_ANGLE_feature_control",
    ]
[2021-12-05T07:40:29Z INFO  wgpu_hal::gles::egl] Loading X11 library to get the current display
[2021-12-05T07:40:29Z INFO  wgpu_hal::gles::egl] Using Angle platform with X11
[2021-12-05T07:40:29Z INFO  wgpu_hal::gles::egl] Enabling EGL debug output
[2021-12-05T07:40:29Z INFO  wgpu_hal::gles::egl] Display vendor "Google Inc. (NVIDIA Corporation)", version (1, 5)
[2021-12-05T07:40:29Z DEBUG wgpu_hal::gles::egl] Display extensions: [
        "EGL_EXT_create_context_robustness",
        "EGL_KHR_create_context",
        "EGL_KHR_get_all_proc_addresses",
        "EGL_ANGLE_create_context_webgl_compatibility",
        "EGL_CHROMIUM_create_context_bind_generates_resource",
        "EGL_EXT_pixel_format_float",
        "EGL_KHR_surfaceless_context",
        "EGL_ANGLE_display_texture_share_group",
        "EGL_ANGLE_display_semaphore_share_group",
        "EGL_ANGLE_create_context_client_arrays",
        "EGL_ANGLE_program_cache_control",
        "EGL_ANGLE_robust_resource_initialization",
        "EGL_ANGLE_create_context_extensions_enabled",
        "EGL_ANDROID_blob_cache",
        "EGL_ANDROID_recordable",
        "EGL_ANGLE_create_context_backwards_compatible",
        "EGL_KHR_create_context_no_error",
        "EGL_NOK_texture_from_pixmap",
        "EGL_KHR_reusable_sync",
        "EGL_KHR_mutable_render_buffer",
    ]
[2021-12-05T07:40:29Z INFO  wgpu_hal::gles::egl]   EGL surface: +srgb
[2021-12-05T07:40:29Z INFO  wgpu_hal::gles::egl]   Trying native-render
[2021-12-05T07:40:29Z INFO  wgpu_hal::gles::egl]   EGL context: +debug
[2021-12-05T07:40:29Z INFO  wgpu_hal::gles::egl]   EGL context: +robust access EXT
[2021-12-05T07:40:29Z WARN  wgpu_hal::gles::egl] unable to create GLES 3.x context: BadMatch
thread 'main' panicked at 'Unable to initialize GPU via the selected backend.', bin/road/../boilerplate.rs:86:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace