MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / GetDevice

Function GetDevice

test/webgpu_basic_rendering.cpp:70–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68static wgpu::RenderPipeline pipeline;
69
70void GetDevice(void (*callback)()) {
71 instance.RequestAdapter(nullptr, wgpu::CallbackMode::AllowSpontaneous, [=](wgpu::RequestAdapterStatus status, wgpu::Adapter a, wgpu::StringView message) {
72 if (message.length) {
73 printf("RequestAdapter: %.*s\n", int(message.length), message.data);
74 }
75 assert(status == wgpu::RequestAdapterStatus::Success);
76
77 wgpu::DeviceDescriptor desc;
78 desc.SetUncapturedErrorCallback(
79 [](const wgpu::Device&, wgpu::ErrorType errorType, wgpu::StringView message) {
80 printf("UncapturedError (type=%d): %.*s\n", errorType, int(message.length), message.data);
81 });
82
83 adapter = a;
84 adapter.RequestDevice(&desc, wgpu::CallbackMode::AllowSpontaneous, [=](wgpu::RequestDeviceStatus status, wgpu::Device d, wgpu::StringView message) {
85 if (message.length) {
86 printf("RequestDevice: %.*s\n", int(message.length), message.data);
87 }
88 assert(status == wgpu::RequestDeviceStatus::Success);
89
90 device = d;
91 callback();
92 });
93 });
94}
95
96void init() {
97 queue = device.GetQueue();

Callers 1

mainFunction · 0.85

Calls 3

printfFunction · 0.85
assertFunction · 0.50
callbackFunction · 0.50

Tested by

no test coverage detected