Device type

This commit is contained in:
Greg Wells
2025-05-27 13:07:41 -04:00
parent ad54ef39e3
commit 9099148be9
3 changed files with 22 additions and 2 deletions

View File

@@ -11,9 +11,16 @@ gnPhysicalDevice* gnGetPhysicalDevicesFn(gnInstance* instance, uint32_t* deviceC
devicesList[i].physicalDevice = malloc(sizeof(gnPlatformPhysicalDevice));
devicesList[i].physicalDevice->device = [devices objectAtIndex:0];
id<MTLDevice> device = [devices objectAtIndex:0];
devicesList[i].properties.name = gnCreateString([[device name] cStringUsingEncoding:NSUTF8StringEncoding]);
MTLDeviceLocation deviceLocation = device.locationNumber;
if (deviceLocation == MTLDeviceLocationBuiltIn)
devicesList[i].properties.deviceType = GN_INTEGRATED_DEVICE;
else if (deviceLocation == MTLDeviceLocationSlot)
devicesList[i].properties.deviceType = GN_DEDICATED_DEVICE;
else if (deviceLocation == MTLDeviceLocationExternal)
devicesList[i].properties.deviceType = GN_EXTERNAL_DEVICE;
// below I am going to fake that there is one queue that can support graphics, compute, and transfer queues
devicesList[i].queueProperties.queueProperties = malloc(sizeof(gnQueueProperties));

View File

@@ -19,6 +19,14 @@ gnPhysicalDevice* gnGetPhysicalDevicesFn(gnInstance* instance, uint32_t* deviceC
VkPhysicalDeviceProperties deviceProperties;
vkGetPhysicalDeviceProperties(physicalDevices[i], &deviceProperties);
outputDevices[i].properties.name = gnCreateString(deviceProperties.deviceName);
switch(deviceProperties.deviceType) {
case VK_PHYSICAL_DEVICE_TYPE_OTHER: outputDevices[i].properties.deviceType = GN_EXTERNAL_DEVICE;
case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU: outputDevices[i].properties.deviceType = GN_INTEGRATED_DEVICE;
case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU: outputDevices[i].properties.deviceType = GN_DEDICATED_DEVICE;
case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU: outputDevices[i].properties.deviceType = GN_INTEGRATED_DEVICE;
case VK_PHYSICAL_DEVICE_TYPE_CPU: outputDevices[i].properties.deviceType = GN_INTEGRATED_DEVICE;
case VK_PHYSICAL_DEVICE_TYPE_MAX_ENUM: outputDevices[i].properties.deviceType = GN_INTEGRATED_DEVICE;
}
vkGetPhysicalDeviceQueueFamilyProperties(physicalDevices[i], &outputDevices[i].queueProperties.queueCount, NULL);

View File

@@ -4,12 +4,17 @@
struct gnPlatformPhysicalDevice_t;
struct gnWindowSurface_t;
typedef enum gnDeviceType_e {
GN_DEDICATED_DEVICE, GN_INTEGRATED_DEVICE, GN_EXTERNAL_DEVICE
} gnDeviceType;
typedef struct gnPhysicalDeviceProperties_t {
gnString name;
gnDeviceType deviceType;
} gnPhysicalDeviceProperties;
typedef struct gnPhysicalDeviceFeatures_t {
// no freatures
} gnPhysicalDeviceFeatures;
typedef enum gnQueueTypeFlags_e {