present stuff
This commit is contained in:
@@ -20,3 +20,4 @@
|
|||||||
#include <core/sync/semaphore/gryphn_semaphore.h>
|
#include <core/sync/semaphore/gryphn_semaphore.h>
|
||||||
#include <core/sync/fence/gryphn_fence.h>
|
#include <core/sync/fence/gryphn_fence.h>
|
||||||
#include <core/submit/gryphn_submit.h>
|
#include <core/submit/gryphn_submit.h>
|
||||||
|
#include <core/present/gryphn_present.h>
|
||||||
|
28
rendering_api/vulkan/src/present/vulkan_present.c
Normal file
28
rendering_api/vulkan/src/present/vulkan_present.c
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#include "core/present/gryphn_present.h"
|
||||||
|
#include "sync/semaphore/vulkan_semaphore.h"
|
||||||
|
#include "presentation_queue/vulkan_presentation_queue.h"
|
||||||
|
#include "output_device/vulkan_output_devices.h"
|
||||||
|
|
||||||
|
gnReturnCode gnPresentFn(struct gnOutputDevice_t* device, struct gnPresentInfo_t info) {
|
||||||
|
VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount);
|
||||||
|
for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i].semaphore->semaphore;
|
||||||
|
|
||||||
|
VkSwapchainKHR* swapchains = malloc(sizeof(VkSwapchainKHR) * info.presentationQueueCount);
|
||||||
|
for (int i = 0; i < info.presentationQueueCount; i++) swapchains[i] = info.presentationQueues[i].presentationQueue->swapChain;
|
||||||
|
|
||||||
|
VkPresentInfoKHR presentInfo = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
|
||||||
|
.waitSemaphoreCount = info.waitCount,
|
||||||
|
.pWaitSemaphores = waitSemaphores,
|
||||||
|
.swapchainCount = info.presentationQueueCount,
|
||||||
|
.pSwapchains = swapchains,
|
||||||
|
.pImageIndices = info.imageIndices
|
||||||
|
};
|
||||||
|
|
||||||
|
VkQueue queue;
|
||||||
|
vkGetDeviceQueue(device->outputDevice->device, info.queueIndex, 0, &queue);
|
||||||
|
|
||||||
|
vkQueuePresentKHR(queue, &presentInfo);
|
||||||
|
|
||||||
|
return GN_SUCCESS;
|
||||||
|
}
|
@@ -17,6 +17,7 @@
|
|||||||
#include "sync/fence/gryphn_fence.h"
|
#include "sync/fence/gryphn_fence.h"
|
||||||
#include "sync/semaphore/gryphn_semaphore.h"
|
#include "sync/semaphore/gryphn_semaphore.h"
|
||||||
#include "core/submit/gryphn_submit.h"
|
#include "core/submit/gryphn_submit.h"
|
||||||
|
#include "core/present/gryphn_present.h"
|
||||||
|
|
||||||
typedef struct gnFunctions_t {
|
typedef struct gnFunctions_t {
|
||||||
gnReturnCode (*_gnCreateInstance)(gnInstance* instance, struct gnInstanceInfo_t info);
|
gnReturnCode (*_gnCreateInstance)(gnInstance* instance, struct gnInstanceInfo_t info);
|
||||||
@@ -87,6 +88,7 @@ typedef struct gnDeviceFunctions_t {
|
|||||||
void (*_gnDestroyFence)(struct gnFence_t* fence);
|
void (*_gnDestroyFence)(struct gnFence_t* fence);
|
||||||
|
|
||||||
gnReturnCode (*_gnSubmit)(struct gnOutputDevice_t* device, struct gnSubmitInfo_t submit);
|
gnReturnCode (*_gnSubmit)(struct gnOutputDevice_t* device, struct gnSubmitInfo_t submit);
|
||||||
|
gnReturnCode (*_gnPresent)(struct gnOutputDevice_t* device, struct gnPresentInfo_t info);
|
||||||
} gnDeviceFunctions;
|
} gnDeviceFunctions;
|
||||||
|
|
||||||
typedef struct gnCommandFunctions_t {
|
typedef struct gnCommandFunctions_t {
|
||||||
|
@@ -90,6 +90,7 @@ void gnLoadDeviceFunctions(struct gnDynamicLibrary_t* lib, struct gnDeviceFuncti
|
|||||||
gnLoadDLLFunction(lib, functions->_gnResetFence, "gnResetFenceFn");
|
gnLoadDLLFunction(lib, functions->_gnResetFence, "gnResetFenceFn");
|
||||||
gnLoadDLLFunction(lib, functions->_gnDestroyFence, "gnDestroyFenceFn");
|
gnLoadDLLFunction(lib, functions->_gnDestroyFence, "gnDestroyFenceFn");
|
||||||
gnLoadDLLFunction(lib, functions->_gnSubmit, "gnSubmitFn");
|
gnLoadDLLFunction(lib, functions->_gnSubmit, "gnSubmitFn");
|
||||||
|
gnLoadDLLFunction(lib, functions->_gnPresent, "gnPresentFn");
|
||||||
}
|
}
|
||||||
|
|
||||||
void gnLoadCommandFunctions(struct gnDynamicLibrary_t* lib, struct gnCommandFunctions_t* functions) {
|
void gnLoadCommandFunctions(struct gnDynamicLibrary_t* lib, struct gnCommandFunctions_t* functions) {
|
||||||
|
6
src/core/present/gryphn_present.c
Normal file
6
src/core/present/gryphn_present.c
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include "core/gryphn_platform_functions.h"
|
||||||
|
#include "gryphn_present.h"
|
||||||
|
|
||||||
|
gnReturnCode gnPresent(struct gnOutputDevice_t* device, struct gnPresentInfo_t info) {
|
||||||
|
return device->deviceFunctions->_gnPresent(device, info);
|
||||||
|
}
|
14
src/core/present/gryphn_present.h
Normal file
14
src/core/present/gryphn_present.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "core/sync/semaphore/gryphn_semaphore.h"
|
||||||
|
#include "core/presentation_queue/gryphn_presentation_queue.h"
|
||||||
|
|
||||||
|
typedef struct gnPresentInfo_t {
|
||||||
|
uint32_t waitCount;
|
||||||
|
struct gnSemaphore_t* waitSemaphores;
|
||||||
|
uint32_t presentationQueueCount;
|
||||||
|
struct gnPresentationQueue_t* presentationQueues;
|
||||||
|
uint32_t* imageIndices;
|
||||||
|
uint32_t queueIndex;
|
||||||
|
} gnPresentInfo;
|
||||||
|
|
||||||
|
gnReturnCode gnPresent(struct gnOutputDevice_t* device, struct gnPresentInfo_t info);
|
Reference in New Issue
Block a user