Access violation occurred when attempting to initialize dawn.

33 views
Skip to first unread message

Block Micro

unread,
Jan 26, 2024, 5:38:16 AMJan 26
to Dawn Graphics
The code is rather simple:
static void initDawn() {
  wgpu::InstanceDescriptor desc = {};
  desc.nextInChain = nullptr;
  instance = wgpu::CreateInstance(&desc);
}
int main() {
  ::initGLFW();
  ::initDawn();
}

However, it crashes with an access violation error. Here's the backtrace and exception message. Any idea?

{34C2138A-180E-4214-814C-BB18C0F47B4C}.png

Block Micro

unread,
Jan 26, 2024, 5:44:57 AMJan 26
to Dawn Graphics
other information:
the program is also linked with skia-m120 statically, with only graphite-dawn enabled.
 I used MSVC and linked with MSVCRT Release version statically

Block Micro

unread,
Jan 26, 2024, 5:45:27 AMJan 26
to Dawn Graphics
{6A43496B-DD88-4688-9801-28769A35A492}.png{E2ED4C20-2925-47f8-AE6F-0113B127FE89}.png

在2024年1月26日星期五 UTC+8 18:38:16<Block Micro> 写道:

Corentin Wallez

unread,
Jan 26, 2024, 8:50:21 AMJan 26
to Block Micro, Dawn Graphics
This is most likely caused by using libdawn_proc as the WebGPU implementation and not initializing the static proc table. Try linking against libwebgpu_dawn instead.

Dawn has multiple implementations of the WebGPU header's functions:
  • An implementation that does validation and calls the GPU driver. (libdawn_native, accessed directly with libwebgpu_dawn, which is what you should use)
  • A client-server implementation for use in Web browsers.
  • A couple implementations that allow switching between the two above by storing the pointers to all the functions in a static variable and calling them (libdawn_proc). Of course if the static table is not initialized, it will be filled with zeroes, and cause a segfault. I'm 99% sure it is what happens here.
So the problem here is not in the code, but in the build files that should link to a different target. I'm not sure what you are using, but in general a CMakeLists.txt like this one should work: https://github.com/beaufortfrancois/webgpu-cross-platform-app/blob/main/CMakeLists.txt

Hope this helps,

Cheers,

Corentin

--
You received this message because you are subscribed to the Google Groups "Dawn Graphics" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dawn-graphic...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dawn-graphics/787a0069-2121-4c4c-888d-b326b7ffd423n%40googlegroups.com.

Block Micro

unread,
Jan 26, 2024, 9:37:35 AMJan 26
to Dawn Graphics
Yes, I'm using CMake and my CMakeList.txt is literally the same as the example.

target_link_libraries(demo PUBLIC skia opengl32 glfw3 vulkan-1 webgpu_dawn webgpu_cpp webgpu_glfw)

Corentin Wallez

unread,
Jan 26, 2024, 9:39:03 AMJan 26
to Block Micro, Dawn Graphics
Then I'm not sure, it might be worth trying the demo I linked, and if it works, dig more into what could be different.

Block Micro

unread,
Jan 26, 2024, 1:01:42 PMJan 26
to Dawn Graphics
Hmm, after some investigation, I found that it's true that I'm using  libdawn_proc instead of  libdawn_native, but how..?

Block Micro

unread,
Jan 26, 2024, 1:42:15 PMJan 26
to Dawn Graphics
I finally figured it out... It's skia. Skia has a copy of dawn static lib in skia.lib, so I got two skia and ran into the issue.
Reply all
Reply to author
Forward
0 new messages