device handles
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
#include "core/instance/gryphn_instance.h"
|
#include "core/instance/gryphn_instance.h"
|
||||||
#include <core/debugger/gryphn_debugger.h>
|
#include <core/debugger/gryphn_debugger.h>
|
||||||
|
|
||||||
gnReturnCode gnCreateOutputDeviceFn(gnOutputDevice* outputDevice, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo) {
|
gnReturnCode gnCreateOutputDeviceFn(gnOutputDeviceHandle outputDevice, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo) {
|
||||||
outputDevice->outputDevice = malloc(sizeof(gnPlatformOutputDevice));
|
outputDevice->outputDevice = malloc(sizeof(gnPlatformOutputDevice));
|
||||||
outputDevice->outputDevice->device = deviceInfo.physicalDevice.physicalDevice->device.retain;
|
outputDevice->outputDevice->device = deviceInfo.physicalDevice.physicalDevice->device.retain;
|
||||||
outputDevice->outputDevice->queueCount = deviceInfo.queueInfoCount;
|
outputDevice->outputDevice->queueCount = deviceInfo.queueInfoCount;
|
||||||
@@ -17,11 +17,11 @@ gnReturnCode gnCreateOutputDeviceFn(gnOutputDevice* outputDevice, gnInstanceHand
|
|||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gnWaitForDeviceFn(gnOutputDevice *device) {
|
void gnWaitForDeviceFn(gnOutputDeviceHandle device) {
|
||||||
[device->outputDevice->executingCommandBuffer waitUntilCompleted];
|
[device->outputDevice->executingCommandBuffer waitUntilCompleted];
|
||||||
}
|
}
|
||||||
|
|
||||||
void gnDestroyOutputDeviceFn(gnOutputDevice* device) {
|
void gnDestroyOutputDeviceFn(gnOutputDeviceHandle device) {
|
||||||
for (int i = 0; i < device->outputDevice->queueCount; i++) {
|
for (int i = 0; i < device->outputDevice->queueCount; i++) {
|
||||||
[device->outputDevice->queues[i] release];
|
[device->outputDevice->queues[i] release];
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
#include "core/texture/metal_texture.h"
|
#include "core/texture/metal_texture.h"
|
||||||
#include "core/sync/semaphore/metal_semaphore.h"
|
#include "core/sync/semaphore/metal_semaphore.h"
|
||||||
|
|
||||||
gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueue* presentationQueue, const gnOutputDevice* device, struct gnPresentationQueueInfo_t presentationInfo) {
|
gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueue* presentationQueue, const gnOutputDeviceHandle device, struct gnPresentationQueueInfo_t presentationInfo) {
|
||||||
if (presentationInfo.minImageCount > 3) {
|
if (presentationInfo.minImageCount > 3) {
|
||||||
gnDebuggerSetErrorMessage(device->instance->debugger, (gnMessageData){
|
gnDebuggerSetErrorMessage(device->instance->debugger, (gnMessageData){
|
||||||
.message = gnCreateString("On Metal you cannot have more than 3 images in a presentation queue")
|
.message = gnCreateString("On Metal you cannot have more than 3 images in a presentation queue")
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
gnReturnCode gnCreateOutputDeviceFn(gnOutputDevice* outputDevice, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo) {
|
gnReturnCode gnCreateOutputDeviceFn(gnOutputDeviceHandle outputDevice, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo) {
|
||||||
outputDevice->outputDevice = malloc(sizeof(gnPlatformOutputDevice));
|
outputDevice->outputDevice = malloc(sizeof(gnPlatformOutputDevice));
|
||||||
|
|
||||||
VkDeviceQueueCreateInfo* queueCreateInfos = malloc(sizeof(VkDeviceQueueCreateInfo) * deviceInfo.queueInfoCount);
|
VkDeviceQueueCreateInfo* queueCreateInfos = malloc(sizeof(VkDeviceQueueCreateInfo) * deviceInfo.queueInfoCount);
|
||||||
@@ -64,11 +64,11 @@ gnReturnCode gnCreateOutputDeviceFn(gnOutputDevice* outputDevice, gnInstanceHand
|
|||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gnWaitForDeviceFn(const gnOutputDevice* device) {
|
void gnWaitForDeviceFn(const gnOutputDeviceHandle device) {
|
||||||
vkDeviceWaitIdle(device->outputDevice->device);
|
vkDeviceWaitIdle(device->outputDevice->device);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gnDestroyOutputDeviceFn(gnOutputDevice* device) {
|
void gnDestroyOutputDeviceFn(gnOutputDeviceHandle device) {
|
||||||
vkDestroyDevice(device->outputDevice->device, NULL);
|
vkDestroyDevice(device->outputDevice->device, NULL);
|
||||||
free(device->outputDevice);
|
free(device->outputDevice);
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
#include "textures/vulkan_texture.h"
|
#include "textures/vulkan_texture.h"
|
||||||
#include "sync/semaphore/vulkan_semaphore.h"
|
#include "sync/semaphore/vulkan_semaphore.h"
|
||||||
|
|
||||||
gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueue* presentationQueue, const gnOutputDevice* device, struct gnPresentationQueueInfo_t presentationInfo) {
|
gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueue* presentationQueue, const gnOutputDeviceHandle device, struct gnPresentationQueueInfo_t presentationInfo) {
|
||||||
presentationQueue->presentationQueue = malloc(sizeof(struct gnPlatformPresentationQueue_t));
|
presentationQueue->presentationQueue = malloc(sizeof(struct gnPlatformPresentationQueue_t));
|
||||||
|
|
||||||
vkSwapchainSupportDetails details = vkGetSwapchainSupport(device->physicalDevice.physicalDevice->device, presentationInfo.surface.windowSurface->surface);
|
vkSwapchainSupportDetails details = vkGetSwapchainSupport(device->physicalDevice.physicalDevice->device, presentationInfo.surface.windowSurface->surface);
|
||||||
|
@@ -30,8 +30,8 @@ typedef struct gnFunctions_t {
|
|||||||
gnBool (*_gnQueueCanPresentToSurface)(const struct gnPhysicalDevice_t device, uint32_t queueIndex, const struct gnWindowSurface_t windowSurface);
|
gnBool (*_gnQueueCanPresentToSurface)(const struct gnPhysicalDevice_t device, uint32_t queueIndex, const struct gnWindowSurface_t windowSurface);
|
||||||
|
|
||||||
|
|
||||||
gnReturnCode (*_gnCreateOutputDevoce)(gnOutputDevice* device, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo);
|
gnReturnCode (*_gnCreateOutputDevoce)(gnOutputDeviceHandle device, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo);
|
||||||
void (*_gnDestroyOutputDevice)(gnOutputDevice* device);
|
void (*_gnDestroyOutputDevice)(gnOutputDeviceHandle device);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -59,38 +59,38 @@ typedef struct gnFunctions_t {
|
|||||||
|
|
||||||
#include "core/presentation_queue/gryphn_presentation_queue.h"
|
#include "core/presentation_queue/gryphn_presentation_queue.h"
|
||||||
typedef struct gnDeviceFunctions_t {
|
typedef struct gnDeviceFunctions_t {
|
||||||
gnReturnCode (*_gnCreatePresentationQueue)(gnPresentationQueue* presentationQueue, const gnOutputDevice* device, struct gnPresentationQueueInfo_t presentationInfo);
|
gnReturnCode (*_gnCreatePresentationQueue)(gnPresentationQueue* presentationQueue, const gnOutputDeviceHandle device, struct gnPresentationQueueInfo_t presentationInfo);
|
||||||
gnReturnCode (*_gnPresentationQueueGetImage)(gnPresentationQueue* presentationQueue, uint64_t timeout, struct gnSemaphore_t* semaphore, uint32_t* imageIndex);
|
gnReturnCode (*_gnPresentationQueueGetImage)(gnPresentationQueue* presentationQueue, uint64_t timeout, struct gnSemaphore_t* semaphore, uint32_t* imageIndex);
|
||||||
void (*_gnDestroyPresentationQueue)(gnPresentationQueue *presentationQueue);
|
void (*_gnDestroyPresentationQueue)(gnPresentationQueue *presentationQueue);
|
||||||
|
|
||||||
gnReturnCode (*_gnCreateShaderModule)(struct gnShaderModule_t* module, struct gnOutputDevice_t* device, struct gnShaderModuleInfo_t shaderModuleInfo);
|
gnReturnCode (*_gnCreateShaderModule)(struct gnShaderModule_t* module, gnOutputDeviceHandle device, struct gnShaderModuleInfo_t shaderModuleInfo);
|
||||||
void (*_gnDestroyShaderModule)(struct gnShaderModule_t* module);
|
void (*_gnDestroyShaderModule)(struct gnShaderModule_t* module);
|
||||||
|
|
||||||
gnReturnCode (*_gnCreateRenderPassDescriptor)(struct gnRenderPassDescriptor_t* renderPass, struct gnOutputDevice_t* device, struct gnRenderPassDescriptorInfo_t info);
|
gnReturnCode (*_gnCreateRenderPassDescriptor)(struct gnRenderPassDescriptor_t* renderPass, gnOutputDeviceHandle device, struct gnRenderPassDescriptorInfo_t info);
|
||||||
void (*_gnDestroyRenderPassDescriptor)(struct gnRenderPassDescriptor_t* renderPass);
|
void (*_gnDestroyRenderPassDescriptor)(struct gnRenderPassDescriptor_t* renderPass);
|
||||||
|
|
||||||
gnReturnCode (*_gnCreateGraphicsPipeline)(struct gnGraphicsPipeline_t* pipeline, struct gnOutputDevice_t* device, struct gnGraphicsPipelineInfo_t pipelineInfo);
|
gnReturnCode (*_gnCreateGraphicsPipeline)(struct gnGraphicsPipeline_t* pipeline, gnOutputDeviceHandle device, struct gnGraphicsPipelineInfo_t pipelineInfo);
|
||||||
void (*_gnDestroyGraphicsPipeline)(struct gnGraphicsPipeline_t* pipeline);
|
void (*_gnDestroyGraphicsPipeline)(struct gnGraphicsPipeline_t* pipeline);
|
||||||
|
|
||||||
gnReturnCode (*_gnCreateFramebuffer)(struct gnFramebuffer_t* framebuffer, struct gnOutputDevice_t* device, struct gnFramebufferInfo_t framebufferInfo);
|
gnReturnCode (*_gnCreateFramebuffer)(struct gnFramebuffer_t* framebuffer, gnOutputDeviceHandle device, struct gnFramebufferInfo_t framebufferInfo);
|
||||||
void (*_gnDestroyFramebuffer)(struct gnFramebuffer_t* framebuffer);
|
void (*_gnDestroyFramebuffer)(struct gnFramebuffer_t* framebuffer);
|
||||||
|
|
||||||
gnReturnCode (*_gnCreateCommandPool)(struct gnCommandPool_t* commandPool, struct gnOutputDevice_t* device, struct gnCommandPoolInfo_t info);
|
gnReturnCode (*_gnCreateCommandPool)(struct gnCommandPool_t* commandPool, gnOutputDeviceHandle device, struct gnCommandPoolInfo_t info);
|
||||||
void (*_gnDestroyCommandPool)(struct gnCommandPool_t* commandPool);
|
void (*_gnDestroyCommandPool)(struct gnCommandPool_t* commandPool);
|
||||||
|
|
||||||
gnReturnCode (*_gnCreateSemaphore)(struct gnSemaphore_t* semaphore, struct gnOutputDevice_t* device);
|
gnReturnCode (*_gnCreateSemaphore)(struct gnSemaphore_t* semaphore, gnOutputDeviceHandle device);
|
||||||
void (*_gnDestroySemaphore)(struct gnSemaphore_t* semaphore);
|
void (*_gnDestroySemaphore)(struct gnSemaphore_t* semaphore);
|
||||||
|
|
||||||
gnReturnCode (*_gnCreateFence)(struct gnFence_t* fence, struct gnOutputDevice_t* device);
|
gnReturnCode (*_gnCreateFence)(struct gnFence_t* fence, gnOutputDeviceHandle device);
|
||||||
void (*_gnSignalFence)(struct gnFence_t* fence);
|
void (*_gnSignalFence)(struct gnFence_t* fence);
|
||||||
void (*_gnWaitForFence)(struct gnFence_t* fence, uint64_t timeout);
|
void (*_gnWaitForFence)(struct gnFence_t* fence, uint64_t timeout);
|
||||||
void (*_gnResetFence)(struct gnFence_t* fence);
|
void (*_gnResetFence)(struct gnFence_t* fence);
|
||||||
void (*_gnDestroyFence)(struct gnFence_t* fence);
|
void (*_gnDestroyFence)(struct gnFence_t* fence);
|
||||||
|
|
||||||
gnReturnCode (*_gnSubmit)(struct gnOutputDevice_t* device, struct gnSubmitInfo_t submit);
|
gnReturnCode (*_gnSubmit)(gnOutputDeviceHandle device, struct gnSubmitInfo_t submit);
|
||||||
gnReturnCode (*_gnPresent)(struct gnOutputDevice_t* device, struct gnPresentInfo_t info);
|
gnReturnCode (*_gnPresent)(gnOutputDeviceHandle device, struct gnPresentInfo_t info);
|
||||||
|
|
||||||
void (*_gnWaitForDevice)(struct gnOutputDevice_t* device);
|
void (*_gnWaitForDevice)(gnOutputDeviceHandle device);
|
||||||
} gnDeviceFunctions;
|
} gnDeviceFunctions;
|
||||||
|
|
||||||
typedef struct gnCommandFunctions_t {
|
typedef struct gnCommandFunctions_t {
|
||||||
|
@@ -3,23 +3,26 @@
|
|||||||
#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 gnCreateOutputDevice(gnOutputDevice* outputDevice, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo) {
|
gnReturnCode gnCreateOutputDevice(gnOutputDeviceHandle* outputDevice, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo) {
|
||||||
|
*outputDevice = malloc(sizeof(struct gnOutputDevice_t));
|
||||||
|
|
||||||
if (instance->loadDeviceFunctions == gnFalse) {
|
if (instance->loadDeviceFunctions == gnFalse) {
|
||||||
instance->deviceFunctions = malloc(sizeof(struct gnDeviceFunctions_t));
|
instance->deviceFunctions = malloc(sizeof(struct gnDeviceFunctions_t));
|
||||||
gnLoadDeviceFunctions(instance->dynamicLib, instance->deviceFunctions);
|
gnLoadDeviceFunctions(instance->dynamicLib, instance->deviceFunctions);
|
||||||
instance->loadDeviceFunctions = gnTrue;
|
instance->loadDeviceFunctions = gnTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
outputDevice->deviceFunctions = instance->deviceFunctions;
|
(*outputDevice)->deviceFunctions = instance->deviceFunctions;
|
||||||
|
|
||||||
outputDevice->instance = instance;
|
(*outputDevice)->instance = instance;
|
||||||
outputDevice->physicalDevice = deviceInfo.physicalDevice;
|
(*outputDevice)->physicalDevice = deviceInfo.physicalDevice;
|
||||||
outputDevice->deviceInfo = deviceInfo;
|
(*outputDevice)->deviceInfo = deviceInfo;
|
||||||
return instance->functions->_gnCreateOutputDevoce(outputDevice, instance, deviceInfo);
|
return instance->functions->_gnCreateOutputDevoce(*outputDevice, instance, deviceInfo);
|
||||||
}
|
}
|
||||||
void gnWaitForDevice(gnOutputDevice *device) {
|
void gnWaitForDevice(gnOutputDeviceHandle device) {
|
||||||
device->deviceFunctions->_gnWaitForDevice(device);
|
device->deviceFunctions->_gnWaitForDevice(device);
|
||||||
}
|
}
|
||||||
void gnDestroyOutputDevice(gnOutputDevice* device) {
|
void gnDestroyOutputDevice(gnOutputDeviceHandle device) {
|
||||||
device->instance->functions->_gnDestroyOutputDevice(device);
|
device->instance->functions->_gnDestroyOutputDevice(device);
|
||||||
|
free(device);
|
||||||
}
|
}
|
||||||
|
@@ -17,14 +17,18 @@ typedef struct gnOutputDeviceInfo_t {
|
|||||||
struct gnPhysicalDevice_t physicalDevice;
|
struct gnPhysicalDevice_t physicalDevice;
|
||||||
} gnOutputDeviceInfo;
|
} gnOutputDeviceInfo;
|
||||||
|
|
||||||
typedef struct gnOutputDevice_t {
|
#ifdef GN_REVEAL_IMPL
|
||||||
|
struct gnOutputDevice_t {
|
||||||
struct gnPlatformOutputDevice_t* outputDevice;
|
struct gnPlatformOutputDevice_t* outputDevice;
|
||||||
struct gnDeviceFunctions_t* deviceFunctions;
|
struct gnDeviceFunctions_t* deviceFunctions;
|
||||||
struct gnOutputDeviceInfo_t deviceInfo;
|
struct gnOutputDeviceInfo_t deviceInfo;
|
||||||
gnInstanceHandle instance;
|
gnInstanceHandle instance;
|
||||||
gnPhysicalDevice physicalDevice;
|
gnPhysicalDevice physicalDevice;
|
||||||
} gnOutputDevice;
|
};
|
||||||
|
#endif
|
||||||
|
typedef struct gnOutputDevice_t* gnOutputDeviceHandle;
|
||||||
|
typedef gnOutputDeviceHandle gnOutputDevice;
|
||||||
|
|
||||||
gnReturnCode gnCreateOutputDevice(gnOutputDevice* outputDevice, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo);
|
gnReturnCode gnCreateOutputDevice(gnOutputDeviceHandle* outputDevice, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo);
|
||||||
void gnWaitForDevice(gnOutputDevice* device);
|
void gnWaitForDevice(gnOutputDeviceHandle device);
|
||||||
void gnDestroyOutputDevice(gnOutputDevice* device);
|
void gnDestroyOutputDevice(gnOutputDeviceHandle device);
|
||||||
|
Reference in New Issue
Block a user