start to redo physical device model

This commit is contained in:
Gregory Wells
2025-09-04 14:52:37 -04:00
parent a709ff8808
commit c5297cb17b
9 changed files with 43 additions and 111 deletions

View File

@@ -10,9 +10,15 @@ typedef struct type##_t* type##Handle; \
typedef struct type##_t* type
// The value of this handle is defined by the implementation
#ifndef GN_IMPLEMENTATION
#define GN_IMPLEMENTATION_HANDLE(type) \
typedef uint64_t type##Handle; \
typedef uint64_t type
#else
#define GN_IMPLEMENTATION_HANDLE(type) \
typedef uint64_t type##Handle; \
typedef uint64_t type
#endif
// can be used to alias a normal handle or an implementation handle
#define GN_HANDLE_ALIAS(handle, alias) \
@@ -20,7 +26,7 @@ typedef struct handle##_t* alias##Handle; \
typedef struct handle##_t* alias
GN_HANDLE(gnInstance);
GN_HANDLE(gnPhysicalDevice); // NOTE: needs to become a impl handle
GN_IMPLEMENTATION_HANDLE(gnPhysicalDevice); // NOTE: needs to become a impl handle
GN_HANDLE(gnWindowSurface);
GN_HANDLE(gnPresentationQueue);

View File

@@ -84,6 +84,10 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceCreateInfo*
return (*instance)->functions->createInstance(*instance, info, (*instance)->functions->next, &(*instance)->allocators);
}
gnReturnCode gnInstanceQueryDevices(gnInstanceHandle instance, uint32_t* count, gnPhysicalDeviceHandle* devices) {
return instance->functions->queryDevices(instance, count, devices);
}
void gnDestroyInstance(gnInstanceHandle* instance) {
if (instance == GN_NULL_HANDLE) return;
(*instance)->functions->destroyInstance(*instance, (*instance)->functions->next, &(*instance)->allocators);

View File

@@ -45,4 +45,5 @@ struct gnInstance_t {
#endif
gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceCreateInfo* info);
gnReturnCode gnInstanceQueryDevices(gnInstanceHandle instance, uint32_t* count, gnPhysicalDeviceHandle* devices);
void gnDestroyInstance(gnInstanceHandle* instance);

View File

@@ -4,14 +4,12 @@
gnPhysicalDeviceHandle* gnGetPhyscialDevices(gnInstanceHandle instance, uint32_t* count) {;
gnPhysicalDeviceHandle* devices = instance->callingLayer->instanceFunctions._gnGetPhysicalDevices(instance, count);
for (uint32_t i = 0; i < *count; i++)
devices[i]->instance = instance;
return devices;
}
gnBool gnPhysicalDeviceCanPresentToSurface(gnPhysicalDeviceHandle device, gnWindowSurfaceHandle windowSurface) {
return device->instance->callingLayer->instanceFunctions._gnPhysicalDeviceCanPresentToSurface(device, windowSurface);
gnBool gnPhysicalDeviceCanPresentToSurface(gnInstanceHandle instance, gnPhysicalDeviceHandle device, gnWindowSurfaceHandle windowSurface) {
return instance->callingLayer->instanceFunctions._gnPhysicalDeviceCanPresentToSurface(device, windowSurface);
}
gnPhysicalDeviceProperties gnGetPhysicalDeviceProperties(gnPhysicalDeviceHandle device) { return device->properties; }
gnPhysicalDeviceFeatures gnGetPhysicalDeviceFeatures(gnPhysicalDeviceHandle device) { return device->features; }
// gnPhysicalDeviceProperties gnGetPhysicalDeviceProperties(gnPhysicalDeviceHandle device) { return device->properties; }
// gnPhysicalDeviceFeatures gnGetPhysicalDeviceFeatures(gnPhysicalDeviceHandle device) { return device->features; }

View File

@@ -28,18 +28,18 @@ typedef struct gnPhysicalDeviceFeatures {
uint32_t maxPushConstantSize;
} gnPhysicalDeviceFeatures;
#ifdef GN_REVEAL_IMPL
typedef struct gnPhysicalDevice_t {
struct gnPlatformPhysicalDevice_t* physicalDevice;
gnPhysicalDeviceProperties properties;
gnPhysicalDeviceFeatures features;
// #ifdef GN_REVEAL_IMPL
// typedef struct gnPhysicalDevice_t {
// struct gnPlatformPhysicalDevice_t* physicalDevice;
// gnPhysicalDeviceProperties properties;
// gnPhysicalDeviceFeatures features;
gnInstanceHandle instance;
} gnPhysicalOutputDevice_t;
#endif
// gnInstanceHandle instance;
// } gnPhysicalOutputDevice_t;
// #endif
gnPhysicalDeviceHandle* gnGetPhyscialDevices(gnInstanceHandle instance, uint32_t* count);
gnBool gnPhysicalDeviceCanPresentToSurface(gnPhysicalDeviceHandle device, gnWindowSurfaceHandle windowSurface);
gnBool gnPhysicalDeviceCanPresentToSurface(gnInstance instance, gnPhysicalDeviceHandle device, gnWindowSurfaceHandle windowSurface);
gnPhysicalDeviceProperties gnGetPhysicalDeviceProperties(gnPhysicalDeviceHandle device);
gnPhysicalDeviceFeatures gnGetPhysicalDeviceFeatures(gnPhysicalDeviceHandle device);