From faf536377f0f53d4a0bd185ef1465f3bec8ef7bd Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Fri, 18 Dec 2020 16:42:54 -0800 Subject: [PATCH] add depth stencil target to createFramebuffer --- src/Refresh_Driver_Vulkan.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Refresh_Driver_Vulkan.c b/src/Refresh_Driver_Vulkan.c index f995386..587f201 100644 --- a/src/Refresh_Driver_Vulkan.c +++ b/src/Refresh_Driver_Vulkan.c @@ -2161,23 +2161,33 @@ static REFRESH_Framebuffer* VULKAN_CreateFramebuffer( VkImageView *imageViews; uint32_t colorAttachmentCount = framebufferCreateInfo->colorTargetCount; - + uint32_t attachmentCount = colorAttachmentCount; uint32_t i; VulkanRenderer *renderer = (VulkanRenderer*) driverData; - imageViews = SDL_stack_alloc(VkImageView, colorAttachmentCount); + if (framebufferCreateInfo->pDepthTarget != NULL) + { + attachmentCount += 1; + } + + imageViews = SDL_stack_alloc(VkImageView, attachmentCount); for (i = 0; i < colorAttachmentCount; i += 1) { imageViews[i] = ((VulkanColorTarget*)framebufferCreateInfo->pColorTargets[i])->view; } + if (framebufferCreateInfo->pDepthTarget != NULL) + { + imageViews[colorAttachmentCount] = ((VulkanDepthStencilTarget*)framebufferCreateInfo->pDepthTarget)->view; + } + vkFramebufferCreateInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; vkFramebufferCreateInfo.pNext = NULL; vkFramebufferCreateInfo.flags = 0; vkFramebufferCreateInfo.renderPass = (VkRenderPass) framebufferCreateInfo->renderPass; - vkFramebufferCreateInfo.attachmentCount = framebufferCreateInfo->colorTargetCount; + vkFramebufferCreateInfo.attachmentCount = attachmentCount; vkFramebufferCreateInfo.pAttachments = imageViews; vkFramebufferCreateInfo.width = framebufferCreateInfo->width; vkFramebufferCreateInfo.height = framebufferCreateInfo->height;