gpu: utilize gpu.Adapter.BackendType in example

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-03-11 18:35:50 -07:00 committed by Stephen Gutekanst
parent 40f92dd9d9
commit 6c7ea283fe
2 changed files with 38 additions and 34 deletions

View file

@ -23,7 +23,7 @@ pub fn main() !void {
// If targeting OpenGL, we can't use the newer WGPUSurface API. Instead, we need to use the
// older Dawn-specific API. https://bugs.chromium.org/p/dawn/issues/detail?id=269&q=surface&can=2
const use_legacy_api = setup.backend_type == c.WGPUBackendType_OpenGL or setup.backend_type == c.WGPUBackendType_OpenGLES;
const use_legacy_api = setup.backend_type == .opengl or setup.backend_type == .opengles;
var descriptor: gpu.SwapChain.Descriptor = undefined;
if (!use_legacy_api) {
window_data.swap_chain_format = .bgra8_unorm;
@ -42,7 +42,7 @@ pub fn main() !void {
comptime sample_utils.detectGLFWOptions(),
);
} else {
const binding = c.machUtilsCreateBinding(setup.backend_type, @ptrCast(*c.GLFWwindow, setup.window.handle), @ptrCast(c.WGPUDevice, setup.device.ptr));
const binding = c.machUtilsCreateBinding(@enumToInt(setup.backend_type), @ptrCast(*c.GLFWwindow, setup.window.handle), @ptrCast(c.WGPUDevice, setup.device.ptr));
if (binding == null) {
@panic("failed to create Dawn backend binding");
}