Skip to content

example_glfw_wgpu does not compile with Dawn #8567

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

Open
brccabral opened this issue Apr 13, 2025 · 2 comments
Open

example_glfw_wgpu does not compile with Dawn #8567

brccabral opened this issue Apr 13, 2025 · 2 comments

Comments

@brccabral
Copy link

Version/Branch of Dear ImGui:

Version 1.92.0, Branch: master

Back-ends:

imgui_impl_wgpu.cpp + imgui_impl_glfw.cpp

Compiler, OS:

Linux + /usr/bin/c++

Full config/build information:

git clone --depth 1 https://dawn.googlesource.com/dawn $HOME/dawn.d
cd imgui/examples/example_glfw_wgpu
mkdir build
cd build
cmake -DIMGUI_DAWN_DIR=$HOME/dawn.d ..
cmake --build . --target example_glfw_wgpu -j10

Details:

The example_glfw_wgpu does not compile with Dawn, with Emscripten it works fine, but as Dawn is suggested in the CMakeLists.txt I tried it.

Is Dawn supported?

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

The examples/example_glfw_wgpu/main.cpp without any modifications.

Dawn compiles libwebgpu_dawn.so, imgui backends compiles, but examples/example_glfw_wgpu/main.cpp fails.

Is Dawn supported?

[100%] Built target dawn_native_objects
[100%] Building CXX object dawn/src/dawn/native/CMakeFiles/webgpu_dawn.dir/__/__/__/gen/src/dawn/native/webgpu_dawn_native_proc.cpp.o
[100%] Building CXX object dawn/src/dawn/native/CMakeFiles/webgpu_dawn.dir/null/NullBackend.cpp.o
[100%] Building CXX object dawn/src/dawn/native/CMakeFiles/webgpu_dawn.dir/opengl/OpenGLBackend.cpp.o
[100%] Building CXX object dawn/src/dawn/native/CMakeFiles/webgpu_dawn.dir/DawnNative.cpp.o
[100%] Building CXX object dawn/src/dawn/native/CMakeFiles/webgpu_dawn.dir/vulkan/VulkanBackend.cpp.o
[100%] Linking CXX shared library libwebgpu_dawn.so
[100%] Built target webgpu_dawn
[100%] Building CXX object CMakeFiles/example_glfw_wgpu.dir/main.cpp.o
[100%] Building CXX object CMakeFiles/example_glfw_wgpu.dir/mnt/HDExtra/CPP_Projects/imgui/imgui.cpp.o
[100%] Building CXX object CMakeFiles/example_glfw_wgpu.dir/mnt/HDExtra/CPP_Projects/imgui/imgui_draw.cpp.o
[100%] Building CXX object CMakeFiles/example_glfw_wgpu.dir/mnt/HDExtra/CPP_Projects/imgui/backends/imgui_impl_glfw.cpp.o
[100%] Building CXX object CMakeFiles/example_glfw_wgpu.dir/mnt/HDExtra/CPP_Projects/imgui/imgui_tables.cpp.o
[100%] Building CXX object CMakeFiles/example_glfw_wgpu.dir/mnt/HDExtra/CPP_Projects/imgui/imgui_widgets.cpp.o
[100%] Building CXX object CMakeFiles/example_glfw_wgpu.dir/mnt/HDExtra/CPP_Projects/imgui/backends/imgui_impl_wgpu.cpp.o
[100%] Building CXX object CMakeFiles/example_glfw_wgpu.dir/mnt/HDExtra/CPP_Projects/imgui/imgui_demo.cpp.o
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp:38:8: error: ‘WGPUSwapChain’ does not name a type
   38 | static WGPUSwapChain     wgpu_swap_chain = nullptr;
      |        ^~~~~~~~~~~~~
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp: In function ‘void wgpu_error_callback(WGPUErrorType, const char*, void*)’:
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp:59:10: error: ‘WGPUErrorType_DeviceLost’ was not declared in this scope; did you mean ‘WGPUErrorType_Force32’?
   59 |     case WGPUErrorType_DeviceLost:  error_type_lbl = "Device lost"; break;
      |          ^~~~~~~~~~~~~~~~~~~~~~~~
      |          WGPUErrorType_Force32
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp: In function ‘int main(int, char**)’:
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp:225:69: error: ‘wgpu_swap_chain’ was not declared in this scope; did you mean ‘wgpu_swap_chain_width’?
  225 |         color_attachments.view = wgpuSwapChainGetCurrentTextureView(wgpu_swap_chain);
      |                                                                     ^~~~~~~~~~~~~~~
      |                                                                     wgpu_swap_chain_width
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp:225:34: error: ‘wgpuSwapChainGetCurrentTextureView’ was not declared in this scope; did you mean ‘wgpuSurfaceGetCurrentTexture’?
  225 |         color_attachments.view = wgpuSwapChainGetCurrentTextureView(wgpu_swap_chain);
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                  wgpuSurfaceGetCurrentTexture
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp:245:9: error: ‘wgpuSwapChainPresent’ was not declared in this scope; did you mean ‘wgpuSurfacePresent’?
  245 |         wgpuSwapChainPresent(wgpu_swap_chain);
      |         ^~~~~~~~~~~~~~~~~~~~
      |         wgpuSurfacePresent
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp: In function ‘WGPUAdapterImpl* RequestAdapter(WGPUInstance)’:
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp:279:51: error: could not convert ‘onAdapterRequestEnded’ from ‘RequestAdapter(WGPUInstance)::<lambda(WGPURequestAdapterStatus, WGPUAdapter, const char*, void*)>’ to ‘WGPURequestAdapterCallbackInfo’
  279 |     wgpuInstanceRequestAdapter(instance, nullptr, onAdapterRequestEnded, (void*)&adapter);
      |                                                   ^~~~~~~~~~~~~~~~~~~~~
      |                                                   |
      |                                                   RequestAdapter(WGPUInstance)::<lambda(WGPURequestAdapterStatus, WGPUAdapter, const char*, void*)>
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp: In function ‘WGPUDeviceImpl* RequestDevice(WGPUAdapterImpl*&)’:
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp:293:48: error: could not convert ‘onDeviceRequestEnded’ from ‘RequestDevice(WGPUAdapterImpl*&)::<lambda(WGPURequestDeviceStatus, WGPUDevice, const char*, void*)>’ to ‘WGPURequestDeviceCallbackInfo’
  293 |     wgpuAdapterRequestDevice(adapter, nullptr, onDeviceRequestEnded, (void*)&device);
      |                                                ^~~~~~~~~~~~~~~~~~~~
      |                                                |
      |                                                RequestDevice(WGPUAdapterImpl*&)::<lambda(WGPURequestDeviceStatus, WGPUDevice, const char*, void*)>
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp: In function ‘bool InitWGPU(GLFWwindow*)’:
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp:332:5: error: ‘wgpuDeviceSetUncapturedErrorCallback’ was not declared in this scope; did you mean ‘WGPUUncapturedErrorCallback’?
  332 |     wgpuDeviceSetUncapturedErrorCallback(wgpu_device, wgpu_error_callback, nullptr);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |     WGPUUncapturedErrorCallback
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp: In function ‘void CreateSwapChain(int, int)’:
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp:339:9: error: ‘wgpu_swap_chain’ was not declared in this scope; did you mean ‘wgpu_swap_chain_width’?
  339 |     if (wgpu_swap_chain)
      |         ^~~~~~~~~~~~~~~
      |         wgpu_swap_chain_width
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp:340:9: error: ‘wgpuSwapChainRelease’ was not declared in this scope; did you mean ‘wgpuSurfaceRelease’?
  340 |         wgpuSwapChainRelease(wgpu_swap_chain);
      |         ^~~~~~~~~~~~~~~~~~~~
      |         wgpuSurfaceRelease
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp:343:5: error: ‘WGPUSwapChainDescriptor’ was not declared in this scope; did you mean ‘WGPUSurfaceDescriptor’?
  343 |     WGPUSwapChainDescriptor swap_chain_desc = {};
      |     ^~~~~~~~~~~~~~~~~~~~~~~
      |     WGPUSurfaceDescriptor
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp:344:5: error: ‘swap_chain_desc’ was not declared in this scope
  344 |     swap_chain_desc.usage = WGPUTextureUsage_RenderAttachment;
      |     ^~~~~~~~~~~~~~~
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp:349:5: error: ‘wgpu_swap_chain’ was not declared in this scope; did you mean ‘wgpu_swap_chain_width’?
  349 |     wgpu_swap_chain = wgpuDeviceCreateSwapChain(wgpu_device, wgpu_surface, &swap_chain_desc);
      |     ^~~~~~~~~~~~~~~
      |     wgpu_swap_chain_width
/mnt/HDExtra/CPP_Projects/imgui/examples/example_glfw_wgpu/main.cpp:349:23: error: ‘wgpuDeviceCreateSwapChain’ was not declared in this scope; did you mean ‘wgpuDeviceCreateSampler’?
  349 |     wgpu_swap_chain = wgpuDeviceCreateSwapChain(wgpu_device, wgpu_surface, &swap_chain_desc);
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                       wgpuDeviceCreateSampler
At global scope:
cc1plus: note: unrecognized command-line option ‘-Wno-nullability-extension’ may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option ‘-Wno-unreachable-code-break’ may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option ‘-Wno-gcc-compat’ may have been intended to silence earlier diagnostics
gmake[3]: *** [CMakeFiles/example_glfw_wgpu.dir/build.make:76: CMakeFiles/example_glfw_wgpu.dir/main.cpp.o] Error 1
gmake[3]: *** Waiting for unfinished jobs....
gmake[2]: *** [CMakeFiles/Makefile2:1447: CMakeFiles/example_glfw_wgpu.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:1454: CMakeFiles/example_glfw_wgpu.dir/rule] Error 2
gmake: *** [Makefile:124: example_glfw_wgpu] Error 2
@ocornut
Copy link
Owner

ocornut commented Apr 13, 2025

Are you setting #define IMGUI_IMPL_WEBGPU_BACKEND_DAWN ?

@brccabral
Copy link
Author

I am running the example CMakeLists.txt as is. It does

  target_compile_definitions(example_glfw_wgpu PUBLIC
    "IMGUI_IMPL_WEBGPU_BACKEND_DAWN"
  )

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

No branches or pull requests

2 participants