diff --git a/src/Refresh_Driver_Vulkan.c b/src/Refresh_Driver_Vulkan.c index 9521ae5..c2fb0fe 100644 --- a/src/Refresh_Driver_Vulkan.c +++ b/src/Refresh_Driver_Vulkan.c @@ -5446,7 +5446,7 @@ static VulkanRenderTarget* VULKAN_INTERNAL_CreateRenderTarget( VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT ); - renderTarget->multisampleCount = multisampleCount; + renderTarget->multisampleCount = RefreshToVK_SampleCount[multisampleCount]; } /* create framebuffer compatible views for RenderTarget */ @@ -5810,7 +5810,9 @@ static VkRenderPass VULKAN_INTERNAL_CreateTransientRenderPass( attachmentDescriptions[attachmentDescriptionCount].format = RefreshToVK_SurfaceFormat[ attachmentDescription.format ]; - attachmentDescriptions[attachmentDescriptionCount].samples = VK_SAMPLE_COUNT_1_BIT; + attachmentDescriptions[attachmentDescriptionCount].samples = RefreshToVK_SampleCount[ + attachmentDescription.sampleCount + ]; attachmentDescriptions[attachmentDescriptionCount].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; attachmentDescriptions[attachmentDescriptionCount].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; attachmentDescriptions[attachmentDescriptionCount].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; @@ -8307,6 +8309,7 @@ static void VULKAN_BeginRenderPass( VulkanTexture *texture; VkClearValue *clearValues; uint32_t clearCount = colorAttachmentCount; + uint32_t multisampleAttachmentCount = 0; uint32_t i; VkImageAspectFlags depthAspectFlags; Refresh_Viewport defaultViewport; @@ -8393,6 +8396,12 @@ static void VULKAN_BeginRenderPass( &texture->resourceAccessType ); + if (colorAttachmentInfos[i].sampleCount > 1) + { + clearCount += 1; + multisampleAttachmentCount += 1; + } + VULKAN_INTERNAL_TrackTexture(renderer, vulkanCommandBuffer, texture); } @@ -8430,12 +8439,21 @@ static void VULKAN_BeginRenderPass( clearValues = SDL_stack_alloc(VkClearValue, clearCount); - for (i = 0; i < colorAttachmentCount; i += 1) + for (i = 0; i < colorAttachmentCount + multisampleAttachmentCount; i += 1) { clearValues[i].color.float32[0] = colorAttachmentInfos[i].clearColor.x; clearValues[i].color.float32[1] = colorAttachmentInfos[i].clearColor.y; clearValues[i].color.float32[2] = colorAttachmentInfos[i].clearColor.z; clearValues[i].color.float32[3] = colorAttachmentInfos[i].clearColor.w; + + if (colorAttachmentInfos[i].sampleCount > 0) + { + i += 1; + clearValues[i].color.float32[0] = colorAttachmentInfos[i].clearColor.x; + clearValues[i].color.float32[1] = colorAttachmentInfos[i].clearColor.y; + clearValues[i].color.float32[2] = colorAttachmentInfos[i].clearColor.z; + clearValues[i].color.float32[3] = colorAttachmentInfos[i].clearColor.w; + } } if (depthStencilAttachmentInfo != NULL)