submitted command buffers + subpass depends
This commit is contained in:
@@ -57,12 +57,26 @@ gnReturnCode gnCreateRenderPassDescriptorFn(struct gnRenderPassDescriptor_t* ren
|
||||
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){
|
||||
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
|
||||
.attachmentCount = info.attachmentCount,
|
||||
.pAttachments = attachments,
|
||||
.subpassCount = info.subpassCount,
|
||||
.pSubpasses = subpasses
|
||||
.pSubpasses = subpasses,
|
||||
.dependencyCount = info.dependencyCount,
|
||||
.pDependencies = dependencies
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
Reference in New Issue
Block a user