From bb8a8c363139c05a652a94da4c4e2de88695b4d5 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sat, 26 Feb 2022 19:12:20 -0700 Subject: [PATCH] gpu-dawn: add ability to get C WGPUInstance Signed-off-by: Stephen Gutekanst --- gpu-dawn/src/dawn/dawn_native_mach.cpp | 7 +++---- gpu-dawn/src/dawn/dawn_native_mach.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gpu-dawn/src/dawn/dawn_native_mach.cpp b/gpu-dawn/src/dawn/dawn_native_mach.cpp index 9c4023b2..72d1a01b 100644 --- a/gpu-dawn/src/dawn/dawn_native_mach.cpp +++ b/gpu-dawn/src/dawn/dawn_native_mach.cpp @@ -147,6 +147,9 @@ MACH_EXPORT MachDawnNativeInstance machDawnNativeInstance_init(void) { MACH_EXPORT void machDawnNativeInstance_deinit(MachDawnNativeInstance instance) { delete reinterpret_cast(instance); } +MACH_EXPORT WGPUInstance machDawnNativeInstance_get(MachDawnNativeInstance instance) { + return reinterpret_cast(instance)->Get(); +} // TODO(dawn-native-mach): These API* methods correlate to the new API (which is unified between Dawn // and wgpu-native?), e.g. dawn_native::Instance::APIRequestAdapter corresponds to wgpuInstanceRequestAdapter // These are not implemented in Dawn yet according to austineng, but we should switch to this API once they do: @@ -218,10 +221,6 @@ MACH_EXPORT const DawnProcTable* machDawnNativeGetProcs() { // TODO(dawn-native-mach): // void SetPlatform(dawn_platform::Platform* platform); -// TODO(dawn-native-mach): -// // Returns the underlying WGPUInstance object. -// WGPUInstance Get() const; - // typedef struct MachUtilsBackendBindingImpl* MachUtilsBackendBinding; MACH_EXPORT MachUtilsBackendBinding machUtilsCreateBinding(WGPUBackendType backendType, GLFWwindow* window, WGPUDevice device) { diff --git a/gpu-dawn/src/dawn/dawn_native_mach.h b/gpu-dawn/src/dawn/dawn_native_mach.h index 91e1340e..2b942461 100644 --- a/gpu-dawn/src/dawn/dawn_native_mach.h +++ b/gpu-dawn/src/dawn/dawn_native_mach.h @@ -80,6 +80,7 @@ typedef struct MachDawnNativeInstanceImpl* MachDawnNativeInstance; MACH_EXPORT MachDawnNativeInstance machDawnNativeInstance_init(void); MACH_EXPORT void machDawnNativeInstance_deinit(MachDawnNativeInstance); +MACH_EXPORT WGPUInstance machDawnNativeInstance_get(MachDawnNativeInstance instance); MACH_EXPORT void machDawnNativeInstance_discoverDefaultAdapters(MachDawnNativeInstance); // Adds adapters that can be discovered with the options provided (like a getProcAddress).