JuliaWGPU / WGPUgfx.jl

WGPU graphics library julia
MIT License
8 stars 4 forks source link

Error running examples #11

Open VarLad opened 1 year ago

VarLad commented 1 year ago

Hey, I've been trying to run the example uiExample.jl from the master branch I see the window but then it crashes with:

[ Info: Setting Log level : WGPULogLevel_Debug
INFO Instance version: 0x403105
INFO Enabling device properties2
DEBUG Client extensions: []
INFO EGL_MESA_platform_surfaceless not available. Using default platform
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', /root/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/011a4e2/wgpu-hal/src/gles/egl.rs:751:73
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5

Any idea whats going on?

arhik commented 1 year ago

@VarLad Are you on Linux machine ? Linux machine has issues with GLFW library. It works on Mac and Windows. Thats something I couldn't narrow it down. I will raise issue with minimum code. It should give you an insight.

arhik commented 1 year ago

Raised issue here with minimal code example #12. FYI.

arhik commented 1 year ago

@VarLad Can you verify by trying minimal code I shared in #12.

VarLad commented 1 year ago

@arhik uiExample.jl is giving a different error now:

[ Info: Setting Log level : WGPULogLevel_Debug
INFO Instance version: 0x4030fa
INFO Enabling device properties2
DEBUG Client extensions: [
    "EGL_EXT_platform_base",
    "EGL_EXT_device_base",
    "EGL_EXT_device_enumeration",
    "EGL_EXT_device_query",
    "EGL_KHR_client_get_all_proc_addresses",
    "EGL_EXT_client_extensions",
    "EGL_KHR_debug",
    "EGL_KHR_platform_x11",
    "EGL_EXT_platform_x11",
    "EGL_EXT_platform_device",
    "EGL_MESA_platform_surfaceless",
    "EGL_EXT_explicit_device",
    "EGL_KHR_platform_wayland",
    "EGL_EXT_platform_wayland",
    "EGL_KHR_platform_gbm",
    "EGL_MESA_platform_gbm",
    "EGL_EXT_platform_xcb",
]
INFO Loading Wayland library to get the current display
INFO Loading X11 library to get the current display
INFO No windowing system present. Using surfaceless platform
INFO Display vendor "NVIDIA", version (1, 5)
DEBUG Display extensions: [
    "EGL_EXT_buffer_age",
    "EGL_EXT_client_sync",
    "EGL_EXT_create_context_robustness",
    "EGL_EXT_image_dma_buf_import",
    "EGL_EXT_image_dma_buf_import_modifiers",
    "EGL_MESA_image_dma_buf_export",
    "EGL_EXT_output_base",
    "EGL_EXT_protected_content",
    "EGL_EXT_stream_acquire_mode",
    "EGL_EXT_sync_reuse",
    "EGL_IMG_context_priority",
    "EGL_KHR_config_attribs",
    "EGL_KHR_create_context_no_error",
    "EGL_KHR_context_flush_control",
    "EGL_KHR_create_context",
    "EGL_KHR_fence_sync",
    "EGL_KHR_get_all_proc_addresses",
    "EGL_KHR_partial_update",
    "EGL_KHR_swap_buffers_with_damage",
    "EGL_KHR_no_config_context",
    "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_reusable_sync",
    "EGL_KHR_stream",
    "EGL_KHR_stream_attrib",
    "EGL_KHR_stream_consumer_gltexture",
    "EGL_KHR_stream_cross_process_fd",
    "EGL_KHR_stream_fifo",
    "EGL_KHR_stream_producer_eglsurface",
    "EGL_KHR_surfaceless_context",
    "EGL_KHR_wait_sync",
    "EGL_NV_nvrm_fence_sync",
    "EGL_NV_quadruple_buffer",
    "EGL_NV_stream_consumer_eglimage",
    "EGL_NV_stream_cross_display",
    "EGL_NV_stream_cross_object",
    "EGL_NV_stream_cross_process",
    "EGL_NV_stream_cross_system",
    "EGL_NV_stream_dma",
    "EGL_NV_stream_flush",
    "EGL_NV_stream_metadata",
    "EGL_NV_stream_remote",
    "EGL_NV_stream_reset",
    "EGL_NV_stream_socket",
    "EGL_NV_stream_socket_inet",
    "EGL_NV_stream_socket_unix",
    "EGL_NV_stream_sync",
    "EGL_NV_stream_fifo_next",
    "EGL_NV_stream_fifo_synchronous",
    "EGL_NV_stream_consumer_gltexture_yuv",
    "EGL_NV_stream_attrib",
    "EGL_NV_stream_origin",
    "EGL_NV_system_time",
    "EGL_NV_output_drm_flip_event",
    "EGL_NV_triple_buffer",
    "EGL_NV_robustness_video_memory_purge",
    "EGL_EXT_present_opaque",
    "EGL_WL_bind_wayland_display",
    "EGL_WL_wayland_eglstream",
]
INFO    EGL surface: +srgb
INFO    Trying native-render
WARN No config found!
INFO    Trying presentation
WARN No config found!
INFO    Trying off-screen
INFO    EGL context: +robust access
INFO    EGL context: +surfaceless
ERROR: LoadError: MethodError: no method matching unsafe_convert(::Type{Ptr{WGPUInstanceImpl}}, ::Base.RefValue{Ptr{WGPUInstanceImpl}})

Closest candidates are:
  unsafe_convert(::Type{Ptr{T}}, ::Array{T}) where T
   @ Base pointer.jl:65
  unsafe_convert(::Type{Ptr{T}}, ::PermutedDimsArray{T}) where T
   @ Base permuteddimsarray.jl:55
  unsafe_convert(::Type{Ptr{T}}, ::MArray{S, T}) where {S, T}
   @ StaticArrays ~/.julia/packages/StaticArrays/cZ1ET/src/MArray.jl:49
  ...

Stacktrace:
 [1] wgpuInstanceCreateSurface(instance::Base.RefValue{Ptr{WGPUInstanceImpl}}, descriptor::Ptr{WGPUSurfaceDescriptor})
   @ WGPUNative.LibWGPU ~/.julia/packages/WGPUNative/eNU81/src/LibWGPU.jl:1965
 [2] defaultCanvas(::Type{WGPUCore.LinuxCanvas}; windowSize::Tuple{Int64, Int64})
   @ WGPUCore ~/.julia/packages/WGPUCore/RXkz2/src/linuxglfw.jl:82
 [3] defaultCanvas(::Type{WGPUCore.LinuxCanvas})
   @ WGPUCore ~/.julia/packages/WGPUCore/RXkz2/src/linuxglfw.jl:53
 [4] Scene()
   @ WGPUgfx ~/.julia/packages/WGPUgfx/6vv4c/src/scene.jl:22
 [5] top-level scope
   @ ~/.julia/packages/WGPUgfx/6vv4c/examples/uiExample.jl:12
in expression starting at /var/home/varlad/.julia/packages/WGPUgfx/6vv4c/examples/uiExample.jl:12

Can you give me a minimal simpler working example to try? By the way, I'm using the main branch of WGPUgfx.jl WGPUNative and WGPUCore if that makes any difference.

arhik commented 1 year ago

At line https://github.com/JuliaWGPU/WGPUCore.jl/blob/main/src/linuxglfw.jl#L83C43-L83C43 replace instance with instance[].

arhik commented 1 year ago

linuxglfw.jl needs changes with API changes. But will be minimal. uiExample.jl is incomplete, but you can still use it. It's all display code that needs to be fixed. If I could fix linux issue I will push it myself. But it could good first PR for you to get started.

arhik commented 1 year ago

The code in the following commit worked for me. https://github.com/JuliaWGPU/WGPUCore.jl/commit/734f4027e9a20874da945291a15544c9ae42c657

Run recently edited examples. Other examples need to be updated.

arhik commented 1 year ago

This should work now. I tested it on a Linux x86_64 hardware.

arhik commented 11 months ago

@VarLad Let me know if this can be closed once checking on your system.