inplement the allocators into instance creation

This commit is contained in:
Gregory Wells
2025-08-09 20:04:57 -04:00
parent af7d75b728
commit 5b37555a34
10 changed files with 54 additions and 24 deletions

View File

@@ -7,5 +7,5 @@ typedef struct gnPlatformInstance_t {
NSView* metalContentView;
} gnPlatformInstance;
gnReturnCode metalCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, gryphnInstanceFunctionLayers* next);
void metalDestroyInstance(gnInstance instance, gryphnInstanceFunctionLayers* next);
gnReturnCode metalCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, gryphnInstanceFunctionLayers* next, gnAllocators* allocators);
void metalDestroyInstance(gnInstance instance, gryphnInstanceFunctionLayers* next, gnAllocators* allocators);

View File

@@ -1,14 +1,14 @@
#include "metal_instance.h"
// metal instances are kinda useless
gnReturnCode metalCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, gryphnInstanceFunctionLayers* next) {
gnReturnCode metalCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, gryphnInstanceFunctionLayers* next, gnAllocators* allocators) {
if (next != NULL) return GN_SUCCESS;
if (instanceInfo == NULL) return GN_INCOMPLETE;
instance->instance = malloc(sizeof(gnPlatformInstance));
instance->instance = allocators->malloc(sizeof(gnPlatformInstance), allocators->userData);
return GN_SUCCESS;
}
void metalDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next) {
void metalDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next, gnAllocators* allocators) {
if (next != NULL) return;
free(instance->instance);
allocators->free(instance->instance, allocators->userData);
}