reimplement gnCreateOutputDevice
This commit is contained in:
@@ -11,10 +11,6 @@ struct gnInstanceMessage {
|
|||||||
typedef struct gnPlatformInstance_t {
|
typedef struct gnPlatformInstance_t {
|
||||||
VkInstance vk_instance;
|
VkInstance vk_instance;
|
||||||
VkApplicationInfo appInfo;
|
VkApplicationInfo appInfo;
|
||||||
// VkSurfaceKHR window_surface;
|
|
||||||
|
|
||||||
// uint16_t extensionCount;
|
|
||||||
// const char** extensions;
|
|
||||||
|
|
||||||
uint16_t instanceMessageCount;
|
uint16_t instanceMessageCount;
|
||||||
struct gnInstanceMessage* instanceMessages;
|
struct gnInstanceMessage* instanceMessages;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
|
|
||||||
const uint32_t deviceExtensionCount = 2;
|
static const uint32_t deviceExtensionCount = 2;
|
||||||
static const char* deviceExtensions[2] = {
|
static const char* deviceExtensions[2] = {
|
||||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
||||||
"VK_KHR_portability_subset"
|
"VK_KHR_portability_subset"
|
||||||
|
@@ -1,84 +0,0 @@
|
|||||||
#include <vulkan/vulkan.h>
|
|
||||||
// #include "presentation_queue/vulkan_queue_families.h"
|
|
||||||
// #include "presentation_queue/vulkan_swapchain.h"
|
|
||||||
#include "vulkan_device_extensions.h"
|
|
||||||
#include "vulkan_output_devices.h"
|
|
||||||
#include <instance/vulkan_instance.h>
|
|
||||||
#include "vulkan_physical_device.h"
|
|
||||||
#include "presentation_queue/vulkan_queue_families.h"
|
|
||||||
// #include <set>
|
|
||||||
|
|
||||||
GN_EXPORT gnReturnCode gnRegisterOutputDeviceFn(gnOutputDevice* outputDevice, gnInstance* instance, const gnPhysicalDevice physicalDevice) {
|
|
||||||
if (outputDevice->outputDevice == nullptr) outputDevice->outputDevice = new gnPlatformOutputDevice();
|
|
||||||
|
|
||||||
//instance.instance->window_surface,
|
|
||||||
// QueueFamilyIndices indices = findQueueFamilies(physicalDevice.physicalDevice->device);
|
|
||||||
|
|
||||||
// std::vector<VkDeviceQueueCreateInfo> queueCreateInfos;
|
|
||||||
//indices.presentFamily.value()
|
|
||||||
// std::set<uint32_t> uniqueQueueFamilies = {indices.graphicsFamily.value()};
|
|
||||||
|
|
||||||
// float queuePriority = 1.0f;
|
|
||||||
// for (uint32_t queueFamily : uniqueQueueFamilies) {
|
|
||||||
// VkDeviceQueueCreateInfo queueCreateInfo{};
|
|
||||||
// queueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
|
||||||
// queueCreateInfo.queueFamilyIndex = queueFamily;
|
|
||||||
// queueCreateInfo.queueCount = 1;
|
|
||||||
// queueCreateInfo.pQueuePriorities = &queuePriority;
|
|
||||||
// queueCreateInfos.push_back(queueCreateInfo);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// VkPhysicalDeviceFeatures deviceFeatures{};
|
|
||||||
// deviceFeatures.samplerAnisotropy = VK_TRUE;
|
|
||||||
|
|
||||||
// VkDeviceCreateInfo createInfo{};
|
|
||||||
// createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
|
|
||||||
// createInfo.queueCreateInfoCount = static_cast<uint32_t>(queueCreateInfos.size());
|
|
||||||
// createInfo.pQueueCreateInfos = queueCreateInfos.data();
|
|
||||||
|
|
||||||
|
|
||||||
// createInfo.pEnabledFeatures = &deviceFeatures;
|
|
||||||
|
|
||||||
// createInfo.enabledExtensionCount = static_cast<uint32_t>(deviceExtensions.size());
|
|
||||||
// createInfo.ppEnabledExtensionNames = deviceExtensions.data();
|
|
||||||
|
|
||||||
// const char* validation_layers[1] = { "VK_LAYER_KHRONOS_validation" };
|
|
||||||
|
|
||||||
// createInfo.enabledLayerCount = 1;
|
|
||||||
// createInfo.ppEnabledLayerNames = validation_layers;
|
|
||||||
|
|
||||||
// if (vkCreateDevice(physicalDevice.physicalDevice->device, &createInfo, nullptr, &outputDevice->outputDevice->device) != VK_SUCCESS) {
|
|
||||||
// return GN_FAILED_TO_CREATE_DEVICE;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// vkGetDeviceQueue(outputDevice->outputDevice->device, indices.graphicsFamily.value(), 0, &outputDevice->outputDevice->graphicsQueue);
|
|
||||||
// vkGetDeviceQueue(outputDevice->outputDevice->device, indices.presentFamily.value(), 0, &outputDevice->outputDevice->presentQueue);
|
|
||||||
// outputDevice->physicalOutputDevice = const_cast<gnPhysicalOutputDevice*>(&physicalDevice);
|
|
||||||
|
|
||||||
// {
|
|
||||||
// QueueFamilyIndices queueFamilyIndices = findQueueFamilies(
|
|
||||||
// outputDevice->physicalOutputDevice->physicalOutputDevice->instance->instance->window_surface,
|
|
||||||
// outputDevice->physicalOutputDevice->physicalOutputDevice->device
|
|
||||||
// );
|
|
||||||
|
|
||||||
// VkCommandPoolCreateInfo poolInfo{};
|
|
||||||
// poolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
|
||||||
// poolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
|
|
||||||
// poolInfo.queueFamilyIndex = queueFamilyIndices.graphicsFamily.value();
|
|
||||||
|
|
||||||
// if (vkCreateCommandPool(outputDevice->outputDevice->device, &poolInfo, nullptr, &outputDevice->outputDevice->commandPool) != VK_SUCCESS) {
|
|
||||||
// return GN_FAILED;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
return GN_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
GN_EXPORT void gnWaitForDeviceFn(const gnOutputDevice& device) {
|
|
||||||
vkDeviceWaitIdle(device.outputDevice->device);
|
|
||||||
}
|
|
||||||
|
|
||||||
GN_EXPORT void gnDestroyOutputDeviceFn(gnOutputDevice& device) {
|
|
||||||
// vkDestroyCommandPool(device.outputDevice->device, device.outputDevice->commandPool, nullptr);
|
|
||||||
vkDestroyDevice(device.outputDevice->device, nullptr);
|
|
||||||
}
|
|
@@ -4,7 +4,11 @@
|
|||||||
|
|
||||||
typedef struct gnPlatformOutputDevice_t {
|
typedef struct gnPlatformOutputDevice_t {
|
||||||
VkDevice device;
|
VkDevice device;
|
||||||
VkQueue presentQueue;
|
|
||||||
VkQueue graphicsQueue;
|
uint32_t queueCount;
|
||||||
|
VkQueue* queues;
|
||||||
|
|
||||||
|
// VkQueue presentQueue;
|
||||||
|
// VkQueue graphicsQueue;
|
||||||
// VkCommandPool commandPool;
|
// VkCommandPool commandPool;
|
||||||
} gnPlatformOutputDevice;
|
} gnPlatformOutputDevice;
|
||||||
|
@@ -3,6 +3,9 @@
|
|||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
|
|
||||||
gnReturnCode gnCreateDebugger(gnDebugger* debugger, gnInstance* instance, const struct gnDebuggerInfo_t info) {
|
gnReturnCode gnCreateDebugger(gnDebugger* debugger, gnInstance* instance, const struct gnDebuggerInfo_t info) {
|
||||||
|
if (instance->debugger != NULL)
|
||||||
|
return GN_DEBUGGER_EXISTS;
|
||||||
|
debugger->info = info;
|
||||||
debugger->instance = instance;
|
debugger->instance = instance;
|
||||||
return instance->functions->_gnCreateDebugger(debugger, instance, info);
|
return instance->functions->_gnCreateDebugger(debugger, instance, info);
|
||||||
}
|
}
|
||||||
|
@@ -46,6 +46,7 @@ typedef struct gnDebuggerInfo_t {
|
|||||||
|
|
||||||
typedef struct gnDebugger_t {
|
typedef struct gnDebugger_t {
|
||||||
struct gnPlatformDebugger_t* debugger;
|
struct gnPlatformDebugger_t* debugger;
|
||||||
|
struct gnDebuggerInfo_t info;
|
||||||
gnInstance* instance;
|
gnInstance* instance;
|
||||||
} gnDebugger;
|
} gnDebugger;
|
||||||
|
|
||||||
|
@@ -14,10 +14,9 @@ typedef struct gnFunctions_t {
|
|||||||
gnReturnCode (*_gnCreateDebugger)(gnDebugger* debugger, gnInstance* instance, const struct gnDebuggerInfo_t info);
|
gnReturnCode (*_gnCreateDebugger)(gnDebugger* debugger, gnInstance* instance, const struct gnDebuggerInfo_t info);
|
||||||
void (*_gnDestroyDebugger)(gnDebugger* debugger);
|
void (*_gnDestroyDebugger)(gnDebugger* debugger);
|
||||||
|
|
||||||
gnBool (*_gnDeviceSupportsAPI)(const gnPhysicalDevice device);
|
|
||||||
gnPhysicalDevice* (*_gnGetPhysicalDevices)(gnInstance* instance, uint32_t* count);
|
gnPhysicalDevice* (*_gnGetPhysicalDevices)(gnInstance* instance, uint32_t* count);
|
||||||
|
|
||||||
gnReturnCode (*_gnRegisterOutputDevice)(gnOutputDevice* outputDevice, gnInstance* instance, const gnPhysicalDevice physicalDevice);
|
gnReturnCode (*_gnCreateOutputDevoce)(gnOutputDevice* device, gnInstance* instance, struct gnOutputDeviceInfo_t deviceInfo);
|
||||||
void (*_gnDestroyOutputDevice)(gnOutputDevice* device);
|
void (*_gnDestroyOutputDevice)(gnOutputDevice* device);
|
||||||
|
|
||||||
#ifdef GN_PLATFORM_LINUX
|
#ifdef GN_PLATFORM_LINUX
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info) {
|
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info) {
|
||||||
if (!gnIsAPISupported(info.renderingAPI)) return GN_UNSUPPORTED_RENDERING_API;
|
if (!gnIsAPISupported(info.renderingAPI)) return GN_UNSUPPORTED_RENDERING_API;
|
||||||
|
instance->debugger = NULL;
|
||||||
instance->dynamicLib = gnLoadRenderingDLL(info.renderingAPI);
|
instance->dynamicLib = gnLoadRenderingDLL(info.renderingAPI);
|
||||||
if (instance->dynamicLib == NULL) return GN_UNABLE_TO_LOAD_DYNAMIC_LIBARRY;
|
if (instance->dynamicLib == NULL) return GN_UNABLE_TO_LOAD_DYNAMIC_LIBARRY;
|
||||||
instance->functions = malloc(sizeof(struct gnFunctions_t));
|
instance->functions = malloc(sizeof(struct gnFunctions_t));
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
struct gnPlatformInstance_t;
|
struct gnPlatformInstance_t;
|
||||||
struct gnFunctions_t;
|
struct gnFunctions_t;
|
||||||
struct gnDynamicLibrary_t;
|
struct gnDynamicLibrary_t;
|
||||||
|
struct gnDebugger_t;
|
||||||
|
|
||||||
typedef struct gnInstanceInfo_t {
|
typedef struct gnInstanceInfo_t {
|
||||||
gnString applicationName;
|
gnString applicationName;
|
||||||
@@ -22,6 +23,8 @@ typedef struct gnInstance_t {
|
|||||||
|
|
||||||
struct gnFunctions_t* functions;
|
struct gnFunctions_t* functions;
|
||||||
struct gnDynamicLibrary_t* dynamicLib;
|
struct gnDynamicLibrary_t* dynamicLib;
|
||||||
|
|
||||||
|
struct gnDebugger_t* debugger;
|
||||||
} gnInstance;
|
} gnInstance;
|
||||||
|
|
||||||
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info);
|
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info);
|
||||||
|
@@ -42,8 +42,7 @@ void gnLoadFunctions(struct gnDynamicLibrary_t* lib, struct gnFunctions_t* funct
|
|||||||
gnLoadDLLFunction(lib, functions->_gnCreateDebugger, "gnCreateDebuggerFn");
|
gnLoadDLLFunction(lib, functions->_gnCreateDebugger, "gnCreateDebuggerFn");
|
||||||
gnLoadDLLFunction(lib, functions->_gnDestroyDebugger, "gnDestroyDebuggerFn");
|
gnLoadDLLFunction(lib, functions->_gnDestroyDebugger, "gnDestroyDebuggerFn");
|
||||||
gnLoadDLLFunction(lib, functions->_gnGetPhysicalDevices, "gnGetPhysicalDevicesFn");
|
gnLoadDLLFunction(lib, functions->_gnGetPhysicalDevices, "gnGetPhysicalDevicesFn");
|
||||||
gnLoadDLLFunction(lib, functions->_gnDeviceSupportsAPI, "gnDeviceSupportsAPIFn");
|
gnLoadDLLFunction(lib, functions->_gnCreateOutputDevoce, "gnCreateOutputDeviceFn");
|
||||||
gnLoadDLLFunction(lib, functions->_gnRegisterOutputDevice, "gnRegisterOutputDeviceFn");
|
|
||||||
gnLoadDLLFunction(lib, functions->_gnDestroyOutputDevice, "gnDestroyOutputDeviceFn");
|
gnLoadDLLFunction(lib, functions->_gnDestroyOutputDevice, "gnDestroyOutputDeviceFn");
|
||||||
|
|
||||||
#ifdef GN_PLATFORM_LINUX
|
#ifdef GN_PLATFORM_LINUX
|
||||||
|
@@ -3,12 +3,13 @@
|
|||||||
#include "core/gryphn_platform_functions.h"
|
#include "core/gryphn_platform_functions.h"
|
||||||
#include "core/instance/init/gryphn_init.h"
|
#include "core/instance/init/gryphn_init.h"
|
||||||
|
|
||||||
gnReturnCode gnRegisterOutputDevice(gnOutputDevice* outputDevice, gnInstance* instance, const gnPhysicalDevice physicalDevice) {
|
gnReturnCode gnCreateOutputDevice(gnOutputDevice* outputDevice, gnInstance* instance, struct gnOutputDeviceInfo_t deviceInfo) {
|
||||||
outputDevice->deviceFunctions = malloc(sizeof(gnDeviceFunctions));
|
outputDevice->deviceFunctions = malloc(sizeof(gnDeviceFunctions));
|
||||||
gnLoadDeviceFunctions(instance->dynamicLib, outputDevice->deviceFunctions);
|
gnLoadDeviceFunctions(instance->dynamicLib, outputDevice->deviceFunctions);
|
||||||
outputDevice->physicalDevice = (gnPhysicalDevice*)(&physicalDevice);
|
outputDevice->instance = instance;
|
||||||
return instance->functions->_gnRegisterOutputDevice(outputDevice, instance, physicalDevice);
|
// outputDevice->physicalDevice = (gnPhysicalDevice*)(&deviceInfo.physicalDevice);
|
||||||
|
return instance->functions->_gnCreateOutputDevoce(outputDevice, instance, deviceInfo);
|
||||||
}
|
}
|
||||||
void gnDestroyOutputDevice(gnOutputDevice* device) {
|
void gnDestroyOutputDevice(gnOutputDevice* device) {
|
||||||
device->physicalDevice->instance->functions->_gnDestroyOutputDevice(device);
|
device->instance->functions->_gnDestroyOutputDevice(device);
|
||||||
}
|
}
|
||||||
|
@@ -4,13 +4,27 @@
|
|||||||
struct gnPlatformOutputDevice_t;
|
struct gnPlatformOutputDevice_t;
|
||||||
struct gnDeviceFunctions_t;
|
struct gnDeviceFunctions_t;
|
||||||
|
|
||||||
|
typedef struct gnDeviceQueueInfo_t {
|
||||||
|
int queueIndex;
|
||||||
|
int queueCount;
|
||||||
|
// float* queuePriority;
|
||||||
|
} gnDeviceQueueInfo;
|
||||||
|
|
||||||
|
typedef struct gnOutputDeviceInfo_t {
|
||||||
|
uint32_t queueInfoCount;
|
||||||
|
struct gnDeviceQueueInfo_t* queueInfos;
|
||||||
|
struct gnPhysicalDeviceFeatures_t enabledFeatures;
|
||||||
|
const gnPhysicalDevice physicalDevice;
|
||||||
|
} gnOutputDeviceInfo;
|
||||||
|
|
||||||
typedef struct gnOutputDevice_t {
|
typedef struct gnOutputDevice_t {
|
||||||
struct gnPlatformOutputDevice_t* outputDevice;
|
struct gnPlatformOutputDevice_t* outputDevice;
|
||||||
struct gnDeviceFunctions_t* deviceFunctions;
|
struct gnDeviceFunctions_t* deviceFunctions;
|
||||||
gnPhysicalDevice* physicalDevice;
|
gnInstance* instance;
|
||||||
|
// gnPhysicalDevice* physicalDevice;
|
||||||
} gnOutputDevice;
|
} gnOutputDevice;
|
||||||
|
|
||||||
gnReturnCode gnRegisterOutputDevice(gnOutputDevice* outputDevice, gnInstance* instance, const gnPhysicalDevice physicalDevice);
|
gnReturnCode gnCreateOutputDevice(gnOutputDevice* outputDevice, gnInstance* instance, struct gnOutputDeviceInfo_t deviceInfo);
|
||||||
void gnDestroyOutputDevice(gnOutputDevice* device);
|
void gnDestroyOutputDevice(gnOutputDevice* device);
|
||||||
|
|
||||||
// inline void (*gnWaitForDevice)(const gnOutputDevice& device);
|
// inline void (*gnWaitForDevice)(const gnOutputDevice& device);
|
||||||
|
@@ -8,6 +8,3 @@ gnPhysicalDevice* gnGetPhyscialDevices(gnInstance* instance, uint32_t* count) {
|
|||||||
}
|
}
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
gnBool gnDeviceSupportsAPI(const gnPhysicalDevice device) {
|
|
||||||
return device.instance->functions->_gnDeviceSupportsAPI(device);
|
|
||||||
}
|
|
||||||
|
@@ -7,6 +7,10 @@ typedef struct gnPhysicalDeviceProperties_t {
|
|||||||
gnString name;
|
gnString name;
|
||||||
} gnPhysicalDeviceProperties;
|
} gnPhysicalDeviceProperties;
|
||||||
|
|
||||||
|
typedef struct gnPhysicalDeviceFeatures_t {
|
||||||
|
// no freatures
|
||||||
|
} gnPhysicalDeviceFeatures;
|
||||||
|
|
||||||
typedef enum gnQueueTypeFlags_e {
|
typedef enum gnQueueTypeFlags_e {
|
||||||
GN_QUEUE_GRAPHICS = 0x00000001,
|
GN_QUEUE_GRAPHICS = 0x00000001,
|
||||||
GN_QUEUE_COMPUTE = 0x00000002,
|
GN_QUEUE_COMPUTE = 0x00000002,
|
||||||
@@ -27,6 +31,7 @@ typedef struct gnPhysicalDeviceQueueProperties_t {
|
|||||||
typedef struct gnPhysicalDevice_t {
|
typedef struct gnPhysicalDevice_t {
|
||||||
struct gnPlatformPhysicalDevice_t* physicalDevice;
|
struct gnPlatformPhysicalDevice_t* physicalDevice;
|
||||||
struct gnPhysicalDeviceProperties_t properties;
|
struct gnPhysicalDeviceProperties_t properties;
|
||||||
|
struct gnPhysicalDeviceFeatures_t features;
|
||||||
struct gnPhysicalDeviceQueueProperties_t queueProperties;
|
struct gnPhysicalDeviceQueueProperties_t queueProperties;
|
||||||
|
|
||||||
gnInstance* instance;
|
gnInstance* instance;
|
||||||
|
Reference in New Issue
Block a user