submitted command buffers + subpass depends
This commit is contained in:
@@ -19,3 +19,4 @@
|
|||||||
#include <core/renderpass/gryphn_render_pass.h>
|
#include <core/renderpass/gryphn_render_pass.h>
|
||||||
#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>
|
||||||
|
@@ -57,12 +57,26 @@ gnReturnCode gnCreateRenderPassDescriptorFn(struct gnRenderPassDescriptor_t* ren
|
|||||||
subpasses[i].pColorAttachments = colorAttachments;
|
subpasses[i].pColorAttachments = colorAttachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VkSubpassDependency* dependencies = malloc(sizeof(VkSubpassDependency) * info.dependencyCount);
|
||||||
|
for (int i = 0; i < info.dependencyCount; i++) {
|
||||||
|
dependencies[i] = (VkSubpassDependency) {
|
||||||
|
.srcSubpass = (info.dependencies[i].source == GN_SUBPASS_EXTERNAL) ? VK_SUBPASS_EXTERNAL : info.dependencies[i].source,
|
||||||
|
.dstSubpass = (info.dependencies[i].destination == GN_SUBPASS_EXTERNAL) ? VK_SUBPASS_EXTERNAL : info.dependencies[i].destination,
|
||||||
|
.srcStageMask = info.dependencies[i].soruceStageMask,
|
||||||
|
.srcAccessMask = info.dependencies[i].sourceAccessMask,
|
||||||
|
.dstStageMask = info.dependencies[i].destinationStageMask,
|
||||||
|
.dstAccessMask = info.dependencies[i].destinationAccessMask
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
VkRenderPassCreateInfo renderPassInfo = (VkRenderPassCreateInfo){
|
VkRenderPassCreateInfo renderPassInfo = (VkRenderPassCreateInfo){
|
||||||
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
|
||||||
.attachmentCount = info.attachmentCount,
|
.attachmentCount = info.attachmentCount,
|
||||||
.pAttachments = attachments,
|
.pAttachments = attachments,
|
||||||
.subpassCount = info.subpassCount,
|
.subpassCount = info.subpassCount,
|
||||||
.pSubpasses = subpasses
|
.pSubpasses = subpasses,
|
||||||
|
.dependencyCount = info.dependencyCount,
|
||||||
|
.pDependencies = dependencies
|
||||||
};
|
};
|
||||||
|
|
||||||
if (vkCreateRenderPass(device->outputDevice->device, &renderPassInfo, NULL, &renderPass->renderPassDescriptor->renderPass) != VK_SUCCESS) {
|
if (vkCreateRenderPass(device->outputDevice->device, &renderPassInfo, NULL, &renderPass->renderPassDescriptor->renderPass) != VK_SUCCESS) {
|
||||||
|
55
rendering_api/vulkan/src/submit/vulkan_submit.c
Normal file
55
rendering_api/vulkan/src/submit/vulkan_submit.c
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#include <vulkan/vulkan.h>
|
||||||
|
#include "core/submit/gryphn_submit.h"
|
||||||
|
#include "sync/semaphore/vulkan_semaphore.h"
|
||||||
|
#include "sync/fence/vulkan_fence.h"
|
||||||
|
#include "commands/command_buffer/vulkan_command_buffer.h"
|
||||||
|
#include "output_device/vulkan_output_devices.h"
|
||||||
|
#include "core/renderpass/gryphn_render_pass_descriptor.h"
|
||||||
|
|
||||||
|
VkPipelineStageFlags vkGryphnWaitStage(enum gnRenderPassStage_e stage) {
|
||||||
|
switch(stage) {
|
||||||
|
case GN_COLOR_ATTACHMENT_OUTPUT: return VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gnReturnCode gnSubmitFn(struct gnOutputDevice_t* device, struct gnSubmitInfo_t info) {
|
||||||
|
VK_SUBPASS_EXTERNAL;
|
||||||
|
|
||||||
|
VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount);
|
||||||
|
VkPipelineStageFlags* waitStages = malloc(sizeof(VkPipelineStageFlags) * info.waitCount);
|
||||||
|
for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i].semaphore->semaphore;
|
||||||
|
for (int i = 0; i < info.waitCount; i++) waitStages[i] = vkGryphnWaitStage(info.waitStages[i]);
|
||||||
|
|
||||||
|
VkCommandBuffer* commandBuffers = malloc(sizeof(VkCommandBuffer) * info.commandBufferCount);
|
||||||
|
for (int i = 0; i < info.commandBufferCount; i++) commandBuffers[i] = info.commandBuffers[i].commandBuffer->buffer;
|
||||||
|
|
||||||
|
VkSemaphore* signalSemaphores = malloc(sizeof(VkSemaphore) * info.signalCount);
|
||||||
|
for (int i = 0; i < info.signalCount; i++) signalSemaphores[i] = info.signalSemaphores[i].semaphore->semaphore;
|
||||||
|
|
||||||
|
VkSubmitInfo submitInfo = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
|
||||||
|
.waitSemaphoreCount = info.waitCount,
|
||||||
|
.pWaitSemaphores = waitSemaphores,
|
||||||
|
.pWaitDstStageMask = waitStages,
|
||||||
|
.commandBufferCount = info.commandBufferCount,
|
||||||
|
.pCommandBuffers = commandBuffers,
|
||||||
|
.signalSemaphoreCount = info.signalCount,
|
||||||
|
.pSignalSemaphores = signalSemaphores
|
||||||
|
};
|
||||||
|
|
||||||
|
VkQueue queue;
|
||||||
|
vkGetDeviceQueue(device->outputDevice->device, info.queueIndex, 0, &queue);
|
||||||
|
|
||||||
|
if (vkQueueSubmit(queue, 1, &submitInfo, info.fence->fence->fence) != VK_SUCCESS) {
|
||||||
|
free(waitSemaphores);
|
||||||
|
free(waitStages);
|
||||||
|
free(commandBuffers);
|
||||||
|
free(signalSemaphores);
|
||||||
|
return GN_FAILED_TO_SUBMIT_COMMAND_BUFFER;
|
||||||
|
}
|
||||||
|
free(waitSemaphores);
|
||||||
|
free(waitStages);
|
||||||
|
free(commandBuffers);
|
||||||
|
free(signalSemaphores);
|
||||||
|
return GN_SUCCESS;
|
||||||
|
}
|
@@ -16,6 +16,7 @@
|
|||||||
#include "renderpass/gryphn_render_pass.h"
|
#include "renderpass/gryphn_render_pass.h"
|
||||||
#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"
|
||||||
|
|
||||||
typedef struct gnFunctions_t {
|
typedef struct gnFunctions_t {
|
||||||
gnReturnCode (*_gnCreateInstance)(gnInstance* instance, struct gnInstanceInfo_t info);
|
gnReturnCode (*_gnCreateInstance)(gnInstance* instance, struct gnInstanceInfo_t info);
|
||||||
@@ -84,6 +85,8 @@ typedef struct gnDeviceFunctions_t {
|
|||||||
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);
|
||||||
} gnDeviceFunctions;
|
} gnDeviceFunctions;
|
||||||
|
|
||||||
typedef struct gnCommandFunctions_t {
|
typedef struct gnCommandFunctions_t {
|
||||||
|
@@ -89,6 +89,7 @@ void gnLoadDeviceFunctions(struct gnDynamicLibrary_t* lib, struct gnDeviceFuncti
|
|||||||
gnLoadDLLFunction(lib, functions->_gnWaitForFence, "gnWaitForFenceFn");
|
gnLoadDLLFunction(lib, functions->_gnWaitForFence, "gnWaitForFenceFn");
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
void gnLoadCommandFunctions(struct gnDynamicLibrary_t* lib, struct gnCommandFunctions_t* functions) {
|
void gnLoadCommandFunctions(struct gnDynamicLibrary_t* lib, struct gnCommandFunctions_t* functions) {
|
||||||
|
@@ -3,6 +3,14 @@
|
|||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
#include "core/output_device/gryphn_output_device.h"
|
#include "core/output_device/gryphn_output_device.h"
|
||||||
|
|
||||||
|
typedef enum gnRenderPassStage_e {
|
||||||
|
GN_COLOR_ATTACHMENT_OUTPUT = 0x00000400
|
||||||
|
} gnRenderPassStage; // I stole these from vulkan to make that conversion easier
|
||||||
|
|
||||||
|
typedef enum gnRenderPassAccess_e {
|
||||||
|
GN_COLOR_ATTACHMENT_WRITE = 0x00000100
|
||||||
|
} gnRenderPassAccess;
|
||||||
|
|
||||||
typedef enum gnLoadOperation_e {
|
typedef enum gnLoadOperation_e {
|
||||||
GN_LOAD_OPERATION_LOAD, GN_LOAD_OPERATION_CLEAR, GN_LOAD_OPERATION_DONT_CARE
|
GN_LOAD_OPERATION_LOAD, GN_LOAD_OPERATION_CLEAR, GN_LOAD_OPERATION_DONT_CARE
|
||||||
} gnLoadOperation;
|
} gnLoadOperation;
|
||||||
@@ -33,12 +41,27 @@ typedef struct gnSubpassInfo_t {
|
|||||||
struct gnSubpassAttachmentInfo_t* colorAttachments;
|
struct gnSubpassAttachmentInfo_t* colorAttachments;
|
||||||
} gnSubpassInfo;
|
} gnSubpassInfo;
|
||||||
|
|
||||||
|
#define GN_SUBPASS_EXTERNAL -1
|
||||||
|
|
||||||
|
typedef struct gnSubpassDependencyInfo_t {
|
||||||
|
int source, destination;
|
||||||
|
|
||||||
|
enum gnRenderPassStage_e soruceStageMask;
|
||||||
|
enum gnRenderPassAccess_e sourceAccessMask;
|
||||||
|
|
||||||
|
enum gnRenderPassStage_e destinationStageMask;
|
||||||
|
enum gnRenderPassAccess_e destinationAccessMask;
|
||||||
|
} gnSubpassDependencyInfo;
|
||||||
|
|
||||||
typedef struct gnRenderPassDescriptorInfo_t {
|
typedef struct gnRenderPassDescriptorInfo_t {
|
||||||
uint32_t attachmentCount;
|
uint32_t attachmentCount;
|
||||||
struct gnRenderPassAttachmentInfo_t* attachmentInfos;
|
struct gnRenderPassAttachmentInfo_t* attachmentInfos;
|
||||||
|
|
||||||
uint32_t subpassCount;
|
uint32_t subpassCount;
|
||||||
struct gnSubpassInfo_t* subpassInfos;
|
struct gnSubpassInfo_t* subpassInfos;
|
||||||
|
|
||||||
|
uint32_t dependencyCount;
|
||||||
|
struct gnSubpassDependencyInfo_t* dependencies;
|
||||||
} gnRenderPassDescriptorInfo;
|
} gnRenderPassDescriptorInfo;
|
||||||
|
|
||||||
struct gnPlatformRenderPassDescriptor_t;
|
struct gnPlatformRenderPassDescriptor_t;
|
||||||
|
6
src/core/submit/gryphn_submit.c
Normal file
6
src/core/submit/gryphn_submit.c
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include "gryphn_submit.h"
|
||||||
|
#include "core/gryphn_platform_functions.h"
|
||||||
|
|
||||||
|
gnReturnCode gnSubmit(struct gnOutputDevice_t* device, struct gnSubmitInfo_t info) {
|
||||||
|
return device->deviceFunctions->_gnSubmit(device, info);
|
||||||
|
}
|
20
src/core/submit/gryphn_submit.h
Normal file
20
src/core/submit/gryphn_submit.h
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "stdint.h"
|
||||||
|
#include "core/sync/semaphore/gryphn_semaphore.h"
|
||||||
|
#include "core/sync/fence/gryphn_fence.h"
|
||||||
|
#include "core/command/command_buffer/gryphn_command_buffer.h"
|
||||||
|
#include "core/output_device/gryphn_output_device.h"
|
||||||
|
|
||||||
|
typedef struct gnSubmitInfo_t {
|
||||||
|
uint32_t waitCount;
|
||||||
|
enum gnRenderPassStage_e* waitStages;
|
||||||
|
struct gnSemaphore_t* waitSemaphores;
|
||||||
|
uint32_t signalCount;
|
||||||
|
struct gnSemaphore_t* signalSemaphores;
|
||||||
|
uint32_t commandBufferCount;
|
||||||
|
struct gnCommandBuffer_t* commandBuffers;
|
||||||
|
uint32_t queueIndex;
|
||||||
|
struct gnFence_t* fence;
|
||||||
|
} gnSubmitInfo;
|
||||||
|
|
||||||
|
gnReturnCode gnSubmit(struct gnOutputDevice_t* device, struct gnSubmitInfo_t submit);
|
@@ -32,7 +32,8 @@ typedef enum gnReturnCode_t {
|
|||||||
GN_FAIELD_TO_END_RECORDING,
|
GN_FAIELD_TO_END_RECORDING,
|
||||||
GN_FAILED_TO_ALLOCATE_COMMAND_BUFFERS,
|
GN_FAILED_TO_ALLOCATE_COMMAND_BUFFERS,
|
||||||
GN_FAILED_TO_CREATE_FENCE,
|
GN_FAILED_TO_CREATE_FENCE,
|
||||||
GN_FAILED_TO_CREATE_SEMAPHORE
|
GN_FAILED_TO_CREATE_SEMAPHORE,
|
||||||
|
GN_FAILED_TO_SUBMIT_COMMAND_BUFFER
|
||||||
} gnReturnCode;
|
} gnReturnCode;
|
||||||
|
|
||||||
typedef gnReturnCode gnErrorCode;
|
typedef gnReturnCode gnErrorCode;
|
||||||
@@ -70,5 +71,6 @@ static const char* gnErrorCodeToCString(enum gnReturnCode_t returnCode) {
|
|||||||
case GN_FAILED_TO_ALLOCATE_COMMAND_BUFFERS: return "GN_FAILED_TO_ALLOCATE_COMMAND_BUFFERS";
|
case GN_FAILED_TO_ALLOCATE_COMMAND_BUFFERS: return "GN_FAILED_TO_ALLOCATE_COMMAND_BUFFERS";
|
||||||
case GN_FAILED_TO_CREATE_FENCE: return "GN_FAILED_TO_CREATE_FENCE";
|
case GN_FAILED_TO_CREATE_FENCE: return "GN_FAILED_TO_CREATE_FENCE";
|
||||||
case GN_FAILED_TO_CREATE_SEMAPHORE: return "GN_FAILED_TO_CREATE_SEMAPHORE";
|
case GN_FAILED_TO_CREATE_SEMAPHORE: return "GN_FAILED_TO_CREATE_SEMAPHORE";
|
||||||
|
case GN_FAILED_TO_SUBMIT_COMMAND_BUFFER: return "GN_FAILED_TO_SUBMIT_COMMAND_BUFFER";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user