only load device functions once per instance

This commit is contained in:
Greg Wells
2025-05-29 14:04:18 -04:00
parent 3f776277cd
commit 088d5a2adf
4 changed files with 12 additions and 3 deletions

View File

@@ -13,3 +13,4 @@
#include <core/renderpass/gryphn_render_pass_descriptor.h>
#include <core/framebuffer/gryphn_framebuffer.h>
#include <core/textures/gryphn_texture.h>
#include <core/command/command_pool/gryphn_command_pool.h>

View File

@@ -5,6 +5,7 @@
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info) {
if (!gnIsAPISupported(info.renderingAPI)) return GN_UNSUPPORTED_RENDERING_API;
instance->loadDeviceFunctions = gnFalse;
instance->debugger = NULL;
instance->dynamicLib = gnLoadRenderingDLL(info.renderingAPI);
if (instance->dynamicLib == NULL) return GN_UNABLE_TO_LOAD_DYNAMIC_LIBARRY;

View File

@@ -19,9 +19,10 @@ typedef struct gnInstanceInfo_t {
typedef struct gnInstance_t {
struct gnPlatformInstance_t* instance;
gnBool valid;
gnBool valid, loadDeviceFunctions;
struct gnFunctions_t* functions;
struct gnDeviceFunctions_t* deviceFunctions;
struct gnDynamicLibrary_t* dynamicLib;
struct gnDebugger_t* debugger;

View File

@@ -4,8 +4,14 @@
#include "core/instance/init/gryphn_init.h"
gnReturnCode gnCreateOutputDevice(gnOutputDevice* outputDevice, gnInstance* instance, struct gnOutputDeviceInfo_t deviceInfo) {
outputDevice->deviceFunctions = malloc(sizeof(gnDeviceFunctions));
gnLoadDeviceFunctions(instance->dynamicLib, outputDevice->deviceFunctions);
if (instance->loadDeviceFunctions == gnFalse) {
instance->deviceFunctions = malloc(sizeof(struct gnDeviceFunctions_t));
gnLoadDeviceFunctions(instance->dynamicLib, instance->deviceFunctions);
instance->loadDeviceFunctions = gnTrue;
}
outputDevice->deviceFunctions = instance->deviceFunctions;
outputDevice->instance = instance;
outputDevice->physicalDevice = deviceInfo.physicalDevice;
outputDevice->deviceInfo = deviceInfo;