From 9099148be9b5e68cdd61b140bb30a1c188910e73 Mon Sep 17 00:00:00 2001 From: Greg Wells Date: Tue, 27 May 2025 13:07:41 -0400 Subject: [PATCH] Device type --- .../metal/src/core/devices/metal_physical_device.m | 9 ++++++++- .../vulkan/src/output_device/vulkan_physical_device.c | 8 ++++++++ src/core/output_device/gryphn_physical_output_device.h | 7 ++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/rendering_api/metal/src/core/devices/metal_physical_device.m b/rendering_api/metal/src/core/devices/metal_physical_device.m index 309683c..ae5f26c 100644 --- a/rendering_api/metal/src/core/devices/metal_physical_device.m +++ b/rendering_api/metal/src/core/devices/metal_physical_device.m @@ -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 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)); diff --git a/rendering_api/vulkan/src/output_device/vulkan_physical_device.c b/rendering_api/vulkan/src/output_device/vulkan_physical_device.c index 6c962d4..bd01dc2 100644 --- a/rendering_api/vulkan/src/output_device/vulkan_physical_device.c +++ b/rendering_api/vulkan/src/output_device/vulkan_physical_device.c @@ -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); diff --git a/src/core/output_device/gryphn_physical_output_device.h b/src/core/output_device/gryphn_physical_output_device.h index 76c0c31..3af945b 100644 --- a/src/core/output_device/gryphn_physical_output_device.h +++ b/src/core/output_device/gryphn_physical_output_device.h @@ -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 {