enumerate through physical devices
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
#include "instance/gryphn_instance.h"
|
#include "instance/gryphn_instance.h"
|
||||||
#include "gryphn_handle.h"
|
#include "gryphn_handle.h"
|
||||||
#include "vulkan/vulkan.h"
|
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
#include <vulkan/vulkan_core.h>
|
#include <vulkan/vulkan_core.h>
|
||||||
|
#include "vulkan_functions.h"
|
||||||
|
|
||||||
gnReturnCode vulkanCodeToGryphnCode(VkResult result) {
|
gnReturnCode vulkanCodeToGryphnCode(VkResult result) {
|
||||||
if (result != VK_SUCCESS) {
|
if (result != VK_SUCCESS) {
|
||||||
@@ -72,7 +72,7 @@ gnReturnCode initBackend(gnInstance instance, gnInstanceCreateInfo* info) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
instance->dispatchTable.destroyInstance = destroyBackend;
|
instance->dispatchTable.destroyInstance = destroyBackend;
|
||||||
// instance->dispatchTable.enumeratePhysicalDevices = NULL;
|
instance->dispatchTable.enumeratePhysicalDevices = vulkanEnumeratePhysicalDevices;
|
||||||
// instance->dispatchTable.getPhysicalDeviceProperties = NULL;
|
// instance->dispatchTable.getPhysicalDeviceProperties = NULL;
|
||||||
// instance->dispatchTable.createDevice = NULL;
|
// instance->dispatchTable.createDevice = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#include "stdlib.h"
|
||||||
|
#include "gryphn_return_code.h"
|
||||||
|
#include "vulkan_functions.h"
|
||||||
|
#include "vulkan_helpers.h"
|
||||||
|
#include "instance/gryphn_instance.h"
|
||||||
|
#include "device/gryphn_physical_device.h"
|
||||||
|
#include <vulkan/vulkan_core.h>
|
||||||
|
|
||||||
|
gnReturnCode vulkanEnumeratePhysicalDevices(gnInstance instance, uint32_t* deviceCount, gnPhysicalDevice* devices) {
|
||||||
|
if (devices == NULL) {
|
||||||
|
vkEnumeratePhysicalDevices(instance->internalData, deviceCount, NULL);
|
||||||
|
return GN_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
VkPhysicalDevice* vulkanDevices = malloc(sizeof(VkPhysicalDevice) * (*deviceCount));
|
||||||
|
VkResult result = vkEnumeratePhysicalDevices(instance->internalData, deviceCount, vulkanDevices);
|
||||||
|
|
||||||
|
if (result != VK_SUCCESS) {
|
||||||
|
free(vulkanDevices);
|
||||||
|
return vulkanCodeToGryphnCode(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < *deviceCount; i++) {
|
||||||
|
devices[i] = malloc(sizeof(gnPhysicalDevice_t));
|
||||||
|
devices[i]->instance = instance;
|
||||||
|
devices[i]->internalData = vulkanDevices[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
free(vulkanDevices);
|
||||||
|
return GN_SUCCESS;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "stdint.h"
|
||||||
|
#include "gryphn_handle.h"
|
||||||
|
#include "gryphn_return_code.h"
|
||||||
|
|
||||||
|
gnReturnCode vulkanEnumeratePhysicalDevices(gnInstance instance, uint32_t* deviceCount, gnPhysicalDevice* devices);
|
||||||
Reference in New Issue
Block a user