diff --git a/Gryphn/GryphnLoader/src/device/gryphn_device.c b/Gryphn/GryphnLoader/src/device/gryphn_device.c index 55f2b25..bf13d94 100644 --- a/Gryphn/GryphnLoader/src/device/gryphn_device.c +++ b/Gryphn/GryphnLoader/src/device/gryphn_device.c @@ -9,3 +9,9 @@ gnReturnCode gnCreateDevice(gnInstance instance, gnDeviceCreateInfo* createInfo, *device = newDevice; return instance->dispatchTable.createDevice(instance, createInfo, newDevice); } + +gnReturnCode gnDestroyDevice(gnDevice* device) { + gnReturnCode returnCode = (*device)->dispatchTable.destroyDevice(*device); + *device = NULL; + return returnCode; +} diff --git a/Gryphn/GryphnLoader/src/device/gryphn_device.h b/Gryphn/GryphnLoader/src/device/gryphn_device.h index c734afc..4a6a3f5 100644 --- a/Gryphn/GryphnLoader/src/device/gryphn_device.h +++ b/Gryphn/GryphnLoader/src/device/gryphn_device.h @@ -13,3 +13,4 @@ typedef struct gnDevice_t { } gnDevice_t; gnReturnCode gnCreateDevice(gnInstance instance, gnDeviceCreateInfo* createInfo, gnDevice* device); +gnReturnCode gnDestroyDevice(gnDevice* device); diff --git a/Gryphn/GryphnLoader/src/instance/dispatch/gryphn_device_dispatch_table.h b/Gryphn/GryphnLoader/src/instance/dispatch/gryphn_device_dispatch_table.h index 95024dd..a281544 100644 --- a/Gryphn/GryphnLoader/src/instance/dispatch/gryphn_device_dispatch_table.h +++ b/Gryphn/GryphnLoader/src/instance/dispatch/gryphn_device_dispatch_table.h @@ -1,7 +1,8 @@ #pragma once #include "gryphn_handle.h" +typedef gnReturnCode (*PFN_gnDestroyDevice)(gnDevice); typedef struct gnDeviceDispatchTable { - + PFN_gnDestroyDevice destroyDevice; } gnDeviceDispatchTable; diff --git a/Gryphn/apis/GryphnMetal/src/metal_device.m b/Gryphn/apis/GryphnMetal/src/metal_device.m index 4326108..d1aab41 100644 --- a/Gryphn/apis/GryphnMetal/src/metal_device.m +++ b/Gryphn/apis/GryphnMetal/src/metal_device.m @@ -57,6 +57,12 @@ gnReturnCode metalGetPhysicalDeviceProperties(gnPhysicalDevice device, gnPhysica } gnReturnCode metalCreateDevice(gnInstance instance, gnDeviceCreateInfo* createInfo, gnDevice device) { + device->dispatchTable.destroyDevice = metalDestroyDevice; device->internalData = createInfo->physicalDevice->internalData; return GN_SUCCESS; } + +gnReturnCode metalDestroyDevice(gnDevice device) { + // [device->internalData release]; + return GN_SUCCESS; +} diff --git a/Gryphn/apis/GryphnMetal/src/metal_functions.h b/Gryphn/apis/GryphnMetal/src/metal_functions.h index 2fd6ecc..8be9654 100644 --- a/Gryphn/apis/GryphnMetal/src/metal_functions.h +++ b/Gryphn/apis/GryphnMetal/src/metal_functions.h @@ -8,3 +8,4 @@ gnReturnCode metalEnumeratePhysicalDevices(gnInstance instance, uint32_t* deviceCount, gnPhysicalDevice* devices); gnReturnCode metalGetPhysicalDeviceProperties(gnPhysicalDevice device, gnPhysicalDeviceProperties* properties); gnReturnCode metalCreateDevice(gnInstance instance, gnDeviceCreateInfo* createInfo, gnDevice device); +gnReturnCode metalDestroyDevice(gnDevice device); diff --git a/main.cpp b/main.cpp index 1822793..b26fd94 100644 --- a/main.cpp +++ b/main.cpp @@ -68,5 +68,6 @@ int main() { std::cerr << "Caught Exception: " << e.what() << "\n"; return 0; } + gnDestroyDevice(&device); gnDestroyInstance(&instance); }