From 653c52844142e30a6b638d9efe4749b2dc6c5d84 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Fri, 18 Mar 2022 19:52:48 -0700 Subject: [PATCH] gpu: implement Device.features, Device.limits Signed-off-by: Stephen Gutekanst --- gpu/src/NativeInstance.zig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gpu/src/NativeInstance.zig b/gpu/src/NativeInstance.zig index 9f1ee9b8..80bf8bd1 100644 --- a/gpu/src/NativeInstance.zig +++ b/gpu/src/NativeInstance.zig @@ -303,15 +303,15 @@ const adapter_vtable = Adapter.VTable{ }; fn wrapDevice(device: c.WGPUDevice) Device { - // TODO: implement Device interface - // WGPU_EXPORT size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeature * features); - // WGPU_EXPORT bool wgpuDeviceGetLimits(WGPUDevice device, WGPUSupportedLimits * limits); + var features: [std.enums.values(Feature).len]c.WGPUFeatureName = undefined; + const features_len = c.wgpuDeviceEnumerateFeatures(device.?, &features[0]); + + var supported_limits: c.WGPUSupportedLimits = undefined; + if (!c.wgpuDeviceGetLimits(device.?, &supported_limits)) @panic("failed to get device limits (this is a bug in mach/gpu)"); return .{ - // TODO: - .features = undefined, - // TODO: - .limits = undefined, + .features = @bitCast([]Feature, features[0..features_len]), + .limits = @bitCast(Limits, supported_limits.limits), .ptr = device.?, .vtable = &device_vtable, };