Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panicking Thread on WSL2: Error in wgpuSurfaceGetPreferredFormat: unsupported format #393

Open
gselzer opened this issue Jun 12, 2024 · 3 comments

Comments

@gselzer
Copy link

gselzer commented Jun 12, 2024

Reporting here because the error asks me to!

I was running the following script from the pygfx README:

import pygfx as gfx
import pylinalg as la

cube = gfx.Mesh(
    gfx.box_geometry(200, 200, 200),
    gfx.MeshPhongMaterial(color="#336699"),
)

rot = la.quat_from_euler((0, 0.01), order="XY")

def animate():
    cube.local.rotation = la.quat_mul(rot, cube.local.rotation)

if __name__ == "__main__":
    gfx.show(cube, before_render=animate)

When running the script (with the RUST_BACKTRACE environment variable set), I receive the following error, observed both with Qt and glfw windows:

thread '<unnamed>' panicked at src/lib.rs:3849:17:
Error in wgpuSurfaceGetPreferredFormat: unsupported format.
Please report it to https://github.com/gfx-rs/wgpu-native
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
   2: wgpuSurfaceGetPreferredFormat
   3: ffi_call_unix64
   4: ffi_call_int
   5: cdata_call
             at /project/src/c/_cffi_backend.c:3201:5
   6: _PyObject_Call
             at /usr/local/src/conda/python-3.11.9/Objects/call.c:343:19
   7: PyObject_Call
             at /usr/local/src/conda/python-3.11.9/Objects/call.c:355:12
   8: do_call_core
             at /usr/local/src/conda/python-3.11.9/Python/ceval.c:7349:12
   9: _PyEval_EvalFrameDefault
             at /usr/local/src/conda/python-3.11.9/Python/ceval.c:5376:22
  10: _PyEval_EvalFrame
             at /usr/local/src/conda/python-3.11.9/Include/internal/pycore_ceval.h:73:16
  11: _PyEval_Vector
             at /usr/local/src/conda/python-3.11.9/Python/ceval.c:6434:24
  12: _PyFunction_Vectorcall
             at /usr/local/src/conda/python-3.11.9/Objects/call.c:393:16
  13: _PyObject_FastCallDictTstate
             at /usr/local/src/conda/python-3.11.9/Objects/call.c:141:15
  14: _PyObject_Call_Prepend
             at /usr/local/src/conda/python-3.11.9/Objects/call.c:482:24
  15: slot_tp_init
             at /usr/local/src/conda/python-3.11.9/Objects/typeobject.c:7855:15
  16: type_call
             at /usr/local/src/conda/python-3.11.9/Objects/typeobject.c:1103:19
  17: _PyObject_MakeTpCall
             at /usr/local/src/conda/python-3.11.9/Objects/call.c:214:18
  18: _PyEval_EvalFrameDefault
             at /usr/local/src/conda/python-3.11.9/Python/ceval.c:4769:23
  19: _PyEval_EvalFrame
             at /usr/local/src/conda/python-3.11.9/Include/internal/pycore_ceval.h:73:16
  20: _PyEval_Vector
             at /usr/local/src/conda/python-3.11.9/Python/ceval.c:6434:24
  21: PyEval_EvalCode
             at /usr/local/src/conda/python-3.11.9/Python/ceval.c:1148:21
  22: run_eval_code_obj
             at /usr/local/src/conda/python-3.11.9/Python/pythonrun.c:1741:9
  23: run_mod
             at /usr/local/src/conda/python-3.11.9/Python/pythonrun.c:1762:19
  24: pyrun_file
             at /usr/local/src/conda/python-3.11.9/Python/pythonrun.c:1657:15
  25: _PyRun_SimpleFileObject
             at /usr/local/src/conda/python-3.11.9/Python/pythonrun.c:440:13
  26: _PyRun_AnyFileObject
             at /usr/local/src/conda/python-3.11.9/Python/pythonrun.c:79:15
  27: pymain_run_file_obj
             at /usr/local/src/conda/python-3.11.9/Modules/main.c:360:15
  28: pymain_run_file
             at /usr/local/src/conda/python-3.11.9/Modules/main.c:379:15
  29: pymain_run_python
             at /usr/local/src/conda/python-3.11.9/Modules/main.c:601:21
  30: Py_RunMain
             at /usr/local/src/conda/python-3.11.9/Modules/main.c:680:5
  31: Py_BytesMain
             at /usr/local/src/conda/python-3.11.9/Modules/main.c:734:12
  32: <unknown>
  33: __libc_start_main
  34: <unknown>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
fatal runtime error: failed to initiate panic, error 5

pygfx: 0.2.0
wgpu: 0.15.3
System: Ubuntu 22.04.3 LTS, WSL2

Notably, the script runs just fine on Windows.

@almarklein
Copy link
Collaborator

Can you try the cube.py example from wgpu-py. That's a bit closer to the metal, and you could also try replacing this line
https://github.com/pygfx/wgpu-py/blob/b5e9f66e13fb83b8976e65ad7aea8fa35437bd3f/examples/cube.py#L30
with render_texture_format = wgpu.TextureFormat.bgra8unorm_srgb.

@gselzer
Copy link
Author

gselzer commented Jun 14, 2024

@almarklein thanks for the reply!

Can you try the cube.py example from wgpu-py. That's a bit closer to the metal, and you could also try replacing this line https://github.com/pygfx/wgpu-py/blob/b5e9f66e13fb83b8976e65ad7aea8fa35437bd3f/examples/cube.py#L30 with render_texture_format = wgpu.TextureFormat.bgra8unorm_srgb.

Cube example raises a simliar panic as the one I reported above.

Using your suggested Texture Format raises a different, non-panic exception, encountered on the following line:

Available adapters on this system:
llvmpipe (LLVM 15.0.7, 256 bits) (CPU) via Vulkan
D3D12 (Intel(R) Iris(R) Xe Graphics) (IntegratedGPU) via OpenGL
Traceback (most recent call last):
  File "/home/g/code/vispy/vispy/tmp.py", line 32, in <module>
    present_context.configure(device=device, format=render_texture_format)
  File "/home/g/miniforge3/envs/pymmcore-plus-sandbox/lib/python3.11/site-packages/wgpu/backends/wgpu_native/_api.py", line 461, in configure
    raise ValueError(
ValueError: Given format 'bgra8unorm-srgb' is not in supported formats []

@almarklein
Copy link
Collaborator

It looks like wgpu reports that the surface simply has zero supported formats. Could this be because it's on WSL2? Ideas @rajveermalviya ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants