From 89ba9c52ff38b3b6c0c1b757f74a63ea533f679e Mon Sep 17 00:00:00 2001 From: TheSpydog Date: Tue, 24 Jan 2023 00:15:02 +0000 Subject: [PATCH] vulkan: Fix framebuffer creation with mip levels (#36) Before this change, framebuffers were created based on the attachments' full dimensions, instead of the dimensions of the requested mip level. This fixes validation errors in the RenderTextureMipmaps test program. Co-authored-by: Caleb Cornett Reviewed-on: https://gitea.moonside.games/MoonsideGames/Refresh/pulls/36 Co-authored-by: TheSpydog Co-committed-by: TheSpydog --- src/Refresh_Driver_Vulkan.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Refresh_Driver_Vulkan.c b/src/Refresh_Driver_Vulkan.c index f102f5a..b79d0b4 100644 --- a/src/Refresh_Driver_Vulkan.c +++ b/src/Refresh_Driver_Vulkan.c @@ -8299,6 +8299,7 @@ static void VULKAN_BeginRenderPass( VulkanFramebuffer *framebuffer; VulkanTexture *texture; + uint32_t w, h; VkClearValue *clearValues; uint32_t clearCount = colorAttachmentCount; uint32_t multisampleAttachmentCount = 0; @@ -8314,30 +8315,34 @@ static void VULKAN_BeginRenderPass( for (i = 0; i < colorAttachmentCount; i += 1) { texture = (VulkanTexture*) colorAttachmentInfos[i].texture; + w = texture->dimensions.width >> colorAttachmentInfos[i].level; + h = texture->dimensions.height >> colorAttachmentInfos[i].level; - if (texture->dimensions.width < framebufferWidth) + if (w < framebufferWidth) { - framebufferWidth = texture->dimensions.width; + framebufferWidth = w; } - if (texture->dimensions.height < framebufferHeight) + if (h < framebufferHeight) { - framebufferHeight = texture->dimensions.height; + framebufferHeight = h; } } if (depthStencilAttachmentInfo != NULL) { texture = (VulkanTexture*) depthStencilAttachmentInfo->texture; + w = texture->dimensions.width >> depthStencilAttachmentInfo->level; + h = texture->dimensions.height >> depthStencilAttachmentInfo->level; - if (texture->dimensions.width < framebufferWidth) + if (w < framebufferWidth) { - framebufferWidth = texture->dimensions.width; + framebufferWidth = w; } - if (texture->dimensions.height < framebufferHeight) + if (h < framebufferHeight) { - framebufferHeight = texture->dimensions.height; + framebufferHeight = h; } }