reimplement gnCreateOutputDevice

This commit is contained in:
Greg Wells
2025-05-23 15:01:59 -04:00
parent 273b1ad59e
commit 8744b56955
14 changed files with 43 additions and 104 deletions

View File

@@ -3,6 +3,9 @@
#include "stdio.h"
gnReturnCode gnCreateDebugger(gnDebugger* debugger, gnInstance* instance, const struct gnDebuggerInfo_t info) {
if (instance->debugger != NULL)
return GN_DEBUGGER_EXISTS;
debugger->info = info;
debugger->instance = instance;
return instance->functions->_gnCreateDebugger(debugger, instance, info);
}

View File

@@ -46,6 +46,7 @@ typedef struct gnDebuggerInfo_t {
typedef struct gnDebugger_t {
struct gnPlatformDebugger_t* debugger;
struct gnDebuggerInfo_t info;
gnInstance* instance;
} gnDebugger;

View File

@@ -14,10 +14,9 @@ typedef struct gnFunctions_t {
gnReturnCode (*_gnCreateDebugger)(gnDebugger* debugger, gnInstance* instance, const struct gnDebuggerInfo_t info);
void (*_gnDestroyDebugger)(gnDebugger* debugger);
gnBool (*_gnDeviceSupportsAPI)(const gnPhysicalDevice device);
gnPhysicalDevice* (*_gnGetPhysicalDevices)(gnInstance* instance, uint32_t* count);
gnReturnCode (*_gnRegisterOutputDevice)(gnOutputDevice* outputDevice, gnInstance* instance, const gnPhysicalDevice physicalDevice);
gnReturnCode (*_gnCreateOutputDevoce)(gnOutputDevice* device, gnInstance* instance, struct gnOutputDeviceInfo_t deviceInfo);
void (*_gnDestroyOutputDevice)(gnOutputDevice* device);
#ifdef GN_PLATFORM_LINUX

View File

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

View File

@@ -5,6 +5,7 @@
struct gnPlatformInstance_t;
struct gnFunctions_t;
struct gnDynamicLibrary_t;
struct gnDebugger_t;
typedef struct gnInstanceInfo_t {
gnString applicationName;
@@ -22,6 +23,8 @@ typedef struct gnInstance_t {
struct gnFunctions_t* functions;
struct gnDynamicLibrary_t* dynamicLib;
struct gnDebugger_t* debugger;
} gnInstance;
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info);

View File

@@ -42,8 +42,7 @@ void gnLoadFunctions(struct gnDynamicLibrary_t* lib, struct gnFunctions_t* funct
gnLoadDLLFunction(lib, functions->_gnCreateDebugger, "gnCreateDebuggerFn");
gnLoadDLLFunction(lib, functions->_gnDestroyDebugger, "gnDestroyDebuggerFn");
gnLoadDLLFunction(lib, functions->_gnGetPhysicalDevices, "gnGetPhysicalDevicesFn");
gnLoadDLLFunction(lib, functions->_gnDeviceSupportsAPI, "gnDeviceSupportsAPIFn");
gnLoadDLLFunction(lib, functions->_gnRegisterOutputDevice, "gnRegisterOutputDeviceFn");
gnLoadDLLFunction(lib, functions->_gnCreateOutputDevoce, "gnCreateOutputDeviceFn");
gnLoadDLLFunction(lib, functions->_gnDestroyOutputDevice, "gnDestroyOutputDeviceFn");
#ifdef GN_PLATFORM_LINUX

View File

@@ -3,12 +3,13 @@
#include "core/gryphn_platform_functions.h"
#include "core/instance/init/gryphn_init.h"
gnReturnCode gnRegisterOutputDevice(gnOutputDevice* outputDevice, gnInstance* instance, const gnPhysicalDevice physicalDevice) {
gnReturnCode gnCreateOutputDevice(gnOutputDevice* outputDevice, gnInstance* instance, struct gnOutputDeviceInfo_t deviceInfo) {
outputDevice->deviceFunctions = malloc(sizeof(gnDeviceFunctions));
gnLoadDeviceFunctions(instance->dynamicLib, outputDevice->deviceFunctions);
outputDevice->physicalDevice = (gnPhysicalDevice*)(&physicalDevice);
return instance->functions->_gnRegisterOutputDevice(outputDevice, instance, physicalDevice);
outputDevice->instance = instance;
// outputDevice->physicalDevice = (gnPhysicalDevice*)(&deviceInfo.physicalDevice);
return instance->functions->_gnCreateOutputDevoce(outputDevice, instance, deviceInfo);
}
void gnDestroyOutputDevice(gnOutputDevice* device) {
device->physicalDevice->instance->functions->_gnDestroyOutputDevice(device);
device->instance->functions->_gnDestroyOutputDevice(device);
}

View File

@@ -4,13 +4,27 @@
struct gnPlatformOutputDevice_t;
struct gnDeviceFunctions_t;
typedef struct gnDeviceQueueInfo_t {
int queueIndex;
int queueCount;
// float* queuePriority;
} gnDeviceQueueInfo;
typedef struct gnOutputDeviceInfo_t {
uint32_t queueInfoCount;
struct gnDeviceQueueInfo_t* queueInfos;
struct gnPhysicalDeviceFeatures_t enabledFeatures;
const gnPhysicalDevice physicalDevice;
} gnOutputDeviceInfo;
typedef struct gnOutputDevice_t {
struct gnPlatformOutputDevice_t* outputDevice;
struct gnDeviceFunctions_t* deviceFunctions;
gnPhysicalDevice* physicalDevice;
gnInstance* instance;
// gnPhysicalDevice* physicalDevice;
} gnOutputDevice;
gnReturnCode gnRegisterOutputDevice(gnOutputDevice* outputDevice, gnInstance* instance, const gnPhysicalDevice physicalDevice);
gnReturnCode gnCreateOutputDevice(gnOutputDevice* outputDevice, gnInstance* instance, struct gnOutputDeviceInfo_t deviceInfo);
void gnDestroyOutputDevice(gnOutputDevice* device);
// inline void (*gnWaitForDevice)(const gnOutputDevice& device);

View File

@@ -8,6 +8,3 @@ gnPhysicalDevice* gnGetPhyscialDevices(gnInstance* instance, uint32_t* count) {
}
return devices;
}
gnBool gnDeviceSupportsAPI(const gnPhysicalDevice device) {
return device.instance->functions->_gnDeviceSupportsAPI(device);
}

View File

@@ -7,6 +7,10 @@ typedef struct gnPhysicalDeviceProperties_t {
gnString name;
} gnPhysicalDeviceProperties;
typedef struct gnPhysicalDeviceFeatures_t {
// no freatures
} gnPhysicalDeviceFeatures;
typedef enum gnQueueTypeFlags_e {
GN_QUEUE_GRAPHICS = 0x00000001,
GN_QUEUE_COMPUTE = 0x00000002,
@@ -27,6 +31,7 @@ typedef struct gnPhysicalDeviceQueueProperties_t {
typedef struct gnPhysicalDevice_t {
struct gnPlatformPhysicalDevice_t* physicalDevice;
struct gnPhysicalDeviceProperties_t properties;
struct gnPhysicalDeviceFeatures_t features;
struct gnPhysicalDeviceQueueProperties_t queueProperties;
gnInstance* instance;