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

Example for glfw/WebGPU doesn’t build on newest Dawn on MacOS #8191

Open
raddad772 opened this issue Nov 28, 2024 · 2 comments
Open

Example for glfw/WebGPU doesn’t build on newest Dawn on MacOS #8191

raddad772 opened this issue Nov 28, 2024 · 2 comments

Comments

@raddad772
Copy link

Version/Branch of Dear ImGui:

Latest master

Back-ends:

imgui_impl_glfw.cpp

Compiler, OS:

MacOS Clang

Full config/build information:

No response

Details:

My Issue/Question:

Latest version of Dawn dropped the WGPUSwapChain, after they were deprecated for a while. You’re supposed to configure a Surface I guess? I don’t know webGPU this is just what the errors say

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

// Here's some code anyone can copy and paste to reproduce your issue
ImGui::Begin("Example Bug");
MoreCodeToExplainMyIssue();
ImGui::End();

Literally just try to compile the example code with latest Dawn on MacOS

@ocornut
Copy link
Owner

ocornut commented Nov 29, 2024

You are not providing the errors. Please provide details so we don't have to guess.

@BrutPitt
Copy link

BrutPitt commented Dec 12, 2024

Hi, @ocornut
I guess the problem in the new dawn release lies in the fact that direct access to Swap Chain (now hided to end user) has been removed (and also all the references to it), so WGPUSwapChain (used in wgpu ImGui example) is "undefined".

And this not only on MacOS, but on all platforms: now the configuration of internal swap chain is done through wgpuSurfaceConfigure.
You can view these changes in dawn here:
https://issues.chromium.org/issues/42241264

Anyway this is the error (for better understanding), building for desktop (WebGPU-native) on Linux:

/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp:38:8: error: ‘WGPUSwapChain’ does not name a type
   38 | static WGPUSwapChain     wgpu_swap_chain = nullptr;
      |        ^~~~~~~~~~~~~
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp: In function ‘int main(int, char**)’:
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp:226:69: error: ‘wgpu_swap_chain’ was not declared in this scope; did you mean ‘wgpu_swap_chain_width’?
  226 |         color_attachments.view = wgpuSwapChainGetCurrentTextureView(wgpu_swap_chain);
      |                                                                     ^~~~~~~~~~~~~~~
      |                                                                     wgpu_swap_chain_width
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp:226:34: error: ‘wgpuSwapChainGetCurrentTextureView’ was not declared in this scope; did you mean ‘wgpuSurfaceGetCurrentTexture’?
  226 |         color_attachments.view = wgpuSwapChainGetCurrentTextureView(wgpu_swap_chain);
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                  wgpuSurfaceGetCurrentTexture
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp:246:9: error: ‘wgpuSwapChainPresent’ was not declared in this scope; did you mean ‘wgpuSurfacePresent’?
  246 |         wgpuSwapChainPresent(wgpu_swap_chain);
      |         ^~~~~~~~~~~~~~~~~~~~
      |         wgpuSurfacePresent
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp: In function ‘WGPUAdapterImpl* RequestAdapter(WGPUInstance)’:
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp:280:51: error: invalid user-defined conversion from ‘RequestAdapter(WGPUInstance)::<lambda(WGPURequestAdapterStatus, WGPUAdapter, const char*, void*)>’ to ‘WGPURequestAdapterCallback’ {aka ‘void (*)(WGPURequestAdapterStatus, WGPUAdapterImpl*, WGPUStringView, void*)’} [-fpermissive]
  280 |     wgpuInstanceRequestAdapter(instance, nullptr, onAdapterRequestEnded, (void*)&adapter);
      |                                                   ^~~~~~~~~~~~~~~~~~~~~
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp:272:34: note: candidate is: ‘constexpr RequestAdapter(WGPUInstance)::<lambda(WGPURequestAdapterStatus, WGPUAdapter, const char*, void*)>::operator void (*)(WGPURequestAdapterStatus, WGPUAdapter, const char*, void*)() const’ (near match)
  272 |     auto onAdapterRequestEnded = [](WGPURequestAdapterStatus status, WGPUAdapter adapter, const char* message, void* pUserData)
      |                                  ^
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp:272:34: note:   no known conversion from ‘void (*)(WGPURequestAdapterStatus, WGPUAdapter, const char*, void*)’ {aka ‘void (*)(WGPURequestAdapterStatus, WGPUAdapterImpl*, const char*, void*)’} to ‘WGPURequestAdapterCallback’ {aka ‘void (*)(WGPURequestAdapterStatus, WGPUAdapterImpl*, WGPUStringView, void*)’}
In file included from /opt/dawn/include/webgpu/webgpu.h:31,
                 from /winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/../../backends/imgui_impl_wgpu.h:31,
                 from /winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp:13:
/RamDisk/example_glfw_wgpu/debug/dawn/gen/include/dawn/webgpu.h:4098:152: note:   initializing argument 3 of ‘void wgpuInstanceRequestAdapter(WGPUInstance, const WGPURequestAdapterOptions*, WGPURequestAdapterCallback, void*)’
 4098 | WGPU_EXPORT void wgpuInstanceRequestAdapter(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPURequestAdapterCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE;
      |                                                                                                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp: In function ‘WGPUDeviceImpl* RequestDevice(WGPUAdapterImpl*&)’:
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp:294:48: error: invalid user-defined conversion from ‘RequestDevice(WGPUAdapterImpl*&)::<lambda(WGPURequestDeviceStatus, WGPUDevice, const char*, void*)>’ to ‘WGPURequestDeviceCallback’ {aka ‘void (*)(WGPURequestDeviceStatus, WGPUDeviceImpl*, WGPUStringView, void*)’} [-fpermissive]
  294 |     wgpuAdapterRequestDevice(adapter, nullptr, onDeviceRequestEnded, (void*)&device);
      |                                                ^~~~~~~~~~~~~~~~~~~~
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp:286:33: note: candidate is: ‘constexpr RequestDevice(WGPUAdapterImpl*&)::<lambda(WGPURequestDeviceStatus, WGPUDevice, const char*, void*)>::operator void (*)(WGPURequestDeviceStatus, WGPUDevice, const char*, void*)() const’ (near match)
  286 |     auto onDeviceRequestEnded = [](WGPURequestDeviceStatus status, WGPUDevice device, const char* message, void* pUserData)
      |                                 ^
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp:286:33: note:   no known conversion from ‘void (*)(WGPURequestDeviceStatus, WGPUDevice, const char*, void*)’ {aka ‘void (*)(WGPURequestDeviceStatus, WGPUDeviceImpl*, const char*, void*)’} to ‘WGPURequestDeviceCallback’ {aka ‘void (*)(WGPURequestDeviceStatus, WGPUDeviceImpl*, WGPUStringView, void*)’}
/RamDisk/example_glfw_wgpu/debug/dawn/gen/include/dawn/webgpu.h:3960:145: note:   initializing argument 3 of ‘void wgpuAdapterRequestDevice(WGPUAdapter, const WGPUDeviceDescriptor*, WGPURequestDeviceCallback, void*)’
 3960 | WGPU_EXPORT void wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE;
      |                                                                                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp: In function ‘bool InitWGPU(GLFWwindow*)’:
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp:333:5: error: ‘wgpuDeviceSetUncapturedErrorCallback’ was not declared in this scope; did you mean ‘WGPUUncapturedErrorCallback’?
  333 |     wgpuDeviceSetUncapturedErrorCallback(wgpu_device, wgpu_error_callback, nullptr);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |     WGPUUncapturedErrorCallback
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp: In function ‘void CreateSwapChain(int, int)’:
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp:340:9: error: ‘wgpu_swap_chain’ was not declared in this scope; did you mean ‘wgpu_swap_chain_width’?
  340 |     if (wgpu_swap_chain)
      |         ^~~~~~~~~~~~~~~
      |         wgpu_swap_chain_width
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp:341:9: error: ‘wgpuSwapChainRelease’ was not declared in this scope; did you mean ‘wgpuSurfaceRelease’?
  341 |         wgpuSwapChainRelease(wgpu_swap_chain);
      |         ^~~~~~~~~~~~~~~~~~~~
      |         wgpuSurfaceRelease
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp:344:5: error: ‘WGPUSwapChainDescriptor’ was not declared in this scope; did you mean ‘WGPUSurfaceDescriptor’?
  344 |     WGPUSwapChainDescriptor swap_chain_desc = {};
      |     ^~~~~~~~~~~~~~~~~~~~~~~
      |     WGPUSurfaceDescriptor
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp:345:5: error: ‘swap_chain_desc’ was not declared in this scope
  345 |     swap_chain_desc.usage = WGPUTextureUsage_RenderAttachment;
      |     ^~~~~~~~~~~~~~~
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp:350:5: error: ‘wgpu_swap_chain’ was not declared in this scope; did you mean ‘wgpu_swap_chain_width’?
  350 |     wgpu_swap_chain = wgpuDeviceCreateSwapChain(wgpu_device, wgpu_surface, &swap_chain_desc);
      |     ^~~~~~~~~~~~~~~
      |     wgpu_swap_chain_width
/winDW/-=DW=-/imgui-docking.1.91.5/examples/example_glfw_wgpu/main.cpp:350:23: error: ‘wgpuDeviceCreateSwapChain’ was not declared in this scope; did you mean ‘wgpuDeviceCreateSampler’?
  350 |     wgpu_swap_chain = wgpuDeviceCreateSwapChain(wgpu_device, wgpu_surface, &swap_chain_desc);
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                       wgpuDeviceCreateSampler
[1089/1091] Building CXX object dawn/src/dawn/native/CMakeFiles/webgpu_dawn.dir/vulkan/VulkanBackend.cpp.o

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

3 participants