vulkan physical device get properties
This commit is contained in:
@@ -10,6 +10,7 @@ gryphnInstanceFunctionLayers loadVulkanAPILayer(void) {
|
||||
.isSuitable = vulkanIsInstanceSuitable,
|
||||
.destroyInstance = vulkanDestroyInstance,
|
||||
.queryDevices = vulkanQueryDevices,
|
||||
.getPhysicalDeviceProperties = vulkanQueryPhysicalDeviceProperties,
|
||||
.next = NULL
|
||||
};
|
||||
}
|
||||
|
@@ -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; }
|
||||
|
@@ -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);
|
||||
|
@@ -2,9 +2,10 @@
|
||||
#include "instance/gryphn_instance.h"
|
||||
#include "loader/src/gryphn_instance_functions.h"
|
||||
|
||||
gnPhysicalDeviceProperties gnQueryPhysicalDeviceProperties(gnInstanceHandle instance, gnPhysicalDeviceHandle device) {
|
||||
return instance->functions->getPhysicalDeviceProperties(instance, device, instance->functions->next);
|
||||
}
|
||||
|
||||
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; }
|
||||
|
@@ -34,17 +34,7 @@ typedef struct gnPhysicalDeviceFeatures {
|
||||
uint32_t maxPushConstantSize;
|
||||
} gnPhysicalDeviceFeatures;
|
||||
|
||||
// #ifdef GN_REVEAL_IMPL
|
||||
// typedef struct gnPhysicalDevice_t {
|
||||
// struct gnPlatformPhysicalDevice_t* physicalDevice;
|
||||
// gnPhysicalDeviceProperties properties;
|
||||
// gnPhysicalDeviceFeatures features;
|
||||
|
||||
// gnInstanceHandle instance;
|
||||
// } gnPhysicalOutputDevice_t;
|
||||
// #endif
|
||||
// gnPhysicalDeviceProperties gnQueryPhysicalDeviceFeatures(gnInstanceHandle instance, gn);
|
||||
gnPhysicalDeviceProperties gnQueryPhysicalDeviceProperties(gnInstanceHandle instance, gnPhysicalDeviceHandle handle);
|
||||
|
||||
gnBool gnPhysicalDeviceCanPresentToSurface(gnInstance instance, gnPhysicalDeviceHandle device, gnWindowSurfaceHandle windowSurface);
|
||||
|
||||
gnPhysicalDeviceProperties gnGetPhysicalDeviceProperties(gnPhysicalDeviceHandle device);
|
||||
gnPhysicalDeviceFeatures gnGetPhysicalDeviceFeatures(gnPhysicalDeviceHandle device);
|
||||
|
@@ -26,7 +26,7 @@ typedef gnBool (*PFN_gnIsInstanceSuitable)(gnInstanceHandle, gnSuitableField, gr
|
||||
typedef gnReturnCode (*PFN_gnInstanceQueryDevices)(gnInstanceHandle, uint32_t*, gnPhysicalDeviceHandle*, gryphnInstanceFunctionLayers*);
|
||||
typedef void (*PFN_gnDestroyInstance)(gnInstanceHandle, gryphnInstanceFunctionLayers*, gnAllocators*);
|
||||
|
||||
typedef gnPhysicalDeviceProperties (*PFN_gnQueryPhysicalDeviceProperties)(gnInstance, gnPhysicalDeviceHandle);
|
||||
typedef gnPhysicalDeviceProperties (*PFN_gnQueryPhysicalDeviceProperties)(gnInstance, gnPhysicalDeviceHandle, gryphnInstanceFunctionLayers*);
|
||||
|
||||
typedef struct gnInstanceFunctions {
|
||||
gnBool (*_gnPhysicalDeviceCanPresentToSurface)(gnPhysicalDevice device, gnWindowSurfaceHandle windowSurface);
|
||||
|
@@ -18,6 +18,7 @@ typedef struct gryphnInstanceFunctionLayers {
|
||||
PFN_gnIsInstanceSuitable isSuitable;
|
||||
PFN_gnInstanceQueryDevices queryDevices;
|
||||
PFN_gnDestroyInstance destroyInstance;
|
||||
PFN_gnQueryPhysicalDeviceProperties getPhysicalDeviceProperties;
|
||||
struct gryphnInstanceFunctionLayers* next;
|
||||
} gryphnInstanceFunctionLayers;
|
||||
|
||||
|
Reference in New Issue
Block a user