| 68 | static wgpu::RenderPipeline pipeline; |
| 69 | |
| 70 | void 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 | |
| 96 | void init() { |
| 97 | queue = device.GetQueue(); |