From 0a504c26478229c9ce5065b2926cf9a3d97b0e45 Mon Sep 17 00:00:00 2001 From: Matthew Pohlmann Date: Thu, 27 Jun 2024 21:41:48 -0700 Subject: [PATCH 1/2] Some fixes to wgpu_native. 1. LogCallback should have the "c" calling convention and takes a userdata pointer like other callbacks. 2. DevicePoll's wrappedSubmissionIndex argument is an optional in/out parameter. The previous wrapper method was broken since it passed a non-nil structure to the underlying API with invalid members. --- vendor/wgpu/wgpu_native.odin | 11 ++--------- vendor/wgpu/wgpu_native_types.odin | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/vendor/wgpu/wgpu_native.odin b/vendor/wgpu/wgpu_native.odin index 2b10e3c17..7c106a452 100644 --- a/vendor/wgpu/wgpu_native.odin +++ b/vendor/wgpu/wgpu_native.odin @@ -29,10 +29,9 @@ foreign { RawQueueSubmitForIndex :: proc(queue: Queue, commandCount: uint, commands: [^]CommandBuffer) -> SubmissionIndex --- // Returns true if the queue is empty, or false if there are more queue submissions still in flight. - @(link_name="wgpuDevicePoll") - RawDevicePoll :: proc(device: Device, wait: b32, /* NULLABLE */ wrappedSubmissionIndex: /* const */ ^WrappedSubmissionIndex) -> b32 --- + DevicePoll :: proc(device: Device, wait: b32, /* NULLABLE */ wrappedSubmissionIndex: /* const */ ^WrappedSubmissionIndex = nil) -> b32 --- - SetLogCallback :: proc "odin" (callback: LogCallback) --- + SetLogCallback :: proc(callback: LogCallback, userdata: rawptr) --- SetLogLevel :: proc(level: LogLevel) --- @@ -67,9 +66,3 @@ InstanceEnumerateAdapters :: proc(instance: Instance, options: ^InstanceEnumerat QueueSubmitForIndex :: proc(queue: Queue, commands: []CommandBuffer) -> SubmissionIndex { return RawQueueSubmitForIndex(queue, len(commands), raw_data(commands)) } - -DevicePoll :: proc(device: Device, wait: b32) -> (wrappedSubmissionIndex: WrappedSubmissionIndex, ok: bool) { - ok = bool(RawDevicePoll(device, wait, &wrappedSubmissionIndex)) - return -} - diff --git a/vendor/wgpu/wgpu_native_types.odin b/vendor/wgpu/wgpu_native_types.odin index b0837198f..441cbdec6 100644 --- a/vendor/wgpu/wgpu_native_types.odin +++ b/vendor/wgpu/wgpu_native_types.odin @@ -182,7 +182,7 @@ SurfaceConfigurationExtras :: struct { desiredMaximumFrameLatency: i32, } -LogCallback :: #type proc "odin" (level: LogLevel, message: cstring) +LogCallback :: #type proc "c" (level: LogLevel, message: cstring, userdata: rawptr) // Wrappers From 4bf9de72370d4ab0a8dcea0a09b1eaa30aa0de7f Mon Sep 17 00:00:00 2001 From: Matthew Pohlmann Date: Thu, 27 Jun 2024 21:53:16 -0700 Subject: [PATCH 2/2] SupportedLimitsExtras.chain should be a ChainedStructOut to properly chain from SupportedLimits --- vendor/wgpu/wgpu_native_types.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/wgpu/wgpu_native_types.odin b/vendor/wgpu/wgpu_native_types.odin index 441cbdec6..2133fdd50 100644 --- a/vendor/wgpu/wgpu_native_types.odin +++ b/vendor/wgpu/wgpu_native_types.odin @@ -79,7 +79,7 @@ RequiredLimitsExtras :: struct { } SupportedLimitsExtras :: struct { - using chain: ChainedStruct, + using chain: ChainedStructOut, limits: NativeLimits, }