vulkan physical device get properties

This commit is contained in:
Gregory Wells
2025-09-17 13:24:30 -04:00
parent ef53ffd458
commit 17b7970aa0
7 changed files with 34 additions and 19 deletions

View File

@@ -3,6 +3,28 @@
#include <output_device/vulkan_device_extensions.h>
#include <vulkan_surface/vulkan_surface.h>
inline gnPhysicalDeviceType vulkanDeviceTypeToGryphn(VkPhysicalDeviceType type) {
switch (type) {
case VK_PHYSICAL_DEVICE_TYPE_OTHER: return GN_PHYSICAL_DEVICE_TYPE_FAKED_GPU;
case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU: return GN_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU;
case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU: return GN_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU;
case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU: return GN_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU;
case VK_PHYSICAL_DEVICE_TYPE_CPU: return GN_PHYSICAL_DEVICE_TYPE_CPU;
case VK_PHYSICAL_DEVICE_TYPE_MAX_ENUM: return GN_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU; // WE SHOULD NEVER HAVE TO DEAL WITH THIS ERROR
}
}
gnPhysicalDeviceProperties vulkanQueryPhysicalDeviceProperties(gnInstance instance, gnPhysicalDeviceHandle device, gryphnInstanceFunctionLayers* layers) {
VkPhysicalDeviceProperties properties;
vkGetPhysicalDeviceProperties((VkPhysicalDevice)device, &properties);
return (gnPhysicalDeviceProperties){
.deviceID = properties.deviceID,
.deviceName = gnCreateString(properties.deviceName),
.deviceType = vulkanDeviceTypeToGryphn(properties.deviceType),
.driverVersion = properties.driverVersion
};
}
gnMultisampleCountFlags vkSampleCountToGryphn(VkSampleCountFlags counts) {
gnMultisampleCountFlags sampleCount = 0;
if ((counts & VK_SAMPLE_COUNT_64_BIT) == VK_SAMPLE_COUNT_64_BIT) { sampleCount |= GN_SAMPLE_BIT_64; }

View File

@@ -1,4 +1,5 @@
#pragma once
#include "loader/src/gryphn_instance_functions.h"
#include <vulkan/vulkan.h>
#include <output_device/gryphn_physical_device.h>
@@ -8,9 +9,8 @@ typedef struct vulkanNeededQueue {
uint32_t queueIndex;
} vulkanNeededQueue;
gnPhysicalDevice* getPhysicalDevices(gnInstanceHandle instance, uint32_t* deviceCount);
gnPhysicalDeviceProperties vulkanQueryPhysicalDeviceProperties(gnInstance instance, gnPhysicalDeviceHandle device, gryphnInstanceFunctionLayers* layers);
gnBool deviceCanPresentToSurface(gnPhysicalDevice device, gnWindowSurface surface);
gnMultisampleCountFlags vkSampleCountToGryphn(VkSampleCountFlags counts);
VkSampleCountFlags gnSampleCountToVulkan(gnMultisampleCountFlags counts);