From 31ac5837c0198c4e80f59e13837a26f55273cc0f Mon Sep 17 00:00:00 2001 From: Eric Mellino Date: Sat, 7 Apr 2018 18:54:40 -0700 Subject: [PATCH] [Vulkan] Fix several validation warnings and errors. * Use VkAttachmentLoadOp.Clear instead of Load in VkFramebuffer.cs. * Destroy the new VkRenderPass object being created in VkFramebuffer during disposal. * Don't set sampleShadingEnable in VkPipeline -- it doesn't do what I thought it does. * Use VkAttachmentLoadOp.DontCare when layout is undefined in VkPipeline. --- src/Veldrid/Vk/VkFramebuffer.cs | 3 ++- src/Veldrid/Vk/VkPipeline.cs | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Veldrid/Vk/VkFramebuffer.cs b/src/Veldrid/Vk/VkFramebuffer.cs index f8b280c09..cca845358 100644 --- a/src/Veldrid/Vk/VkFramebuffer.cs +++ b/src/Veldrid/Vk/VkFramebuffer.cs @@ -141,7 +141,7 @@ public VkFramebuffer(VkGraphicsDevice gd, ref FramebufferDescription description bool hasStencil = FormatHelpers.IsStencilFormat(DepthTarget.Value.Target.Format); if (hasStencil) { - attachments[attachments.Count - 1].stencilLoadOp = VkAttachmentLoadOp.Load; + attachments[attachments.Count - 1].stencilLoadOp = VkAttachmentLoadOp.Clear; } } @@ -266,6 +266,7 @@ public override void Dispose() { vkDestroyFramebuffer(_gd.Device, _deviceFramebuffer, null); vkDestroyRenderPass(_gd.Device, _renderPassNoClear, null); + vkDestroyRenderPass(_gd.Device, _renderPassNoClearLoad, null); vkDestroyRenderPass(_gd.Device, _renderPassClear, null); foreach (VkImageView view in _attachmentViews) { diff --git a/src/Veldrid/Vk/VkPipeline.cs b/src/Veldrid/Vk/VkPipeline.cs index 2355b417b..500683669 100644 --- a/src/Veldrid/Vk/VkPipeline.cs +++ b/src/Veldrid/Vk/VkPipeline.cs @@ -114,10 +114,6 @@ public VkPipeline(VkGraphicsDevice gd, ref GraphicsPipelineDescription descripti VkPipelineMultisampleStateCreateInfo multisampleCI = VkPipelineMultisampleStateCreateInfo.New(); VkSampleCountFlags vkSampleCount = VkFormats.VdToVkSampleCount(description.Outputs.SampleCount); multisampleCI.rasterizationSamples = vkSampleCount; - if (vkSampleCount != VkSampleCountFlags.Count1) - { - multisampleCI.sampleShadingEnable = true; - } pipelineCI.pMultisampleState = &multisampleCI; @@ -252,7 +248,7 @@ public VkPipeline(VkGraphicsDevice gd, ref GraphicsPipelineDescription descripti depthAttachmentDesc.samples = vkSampleCount; depthAttachmentDesc.loadOp = VkAttachmentLoadOp.DontCare; depthAttachmentDesc.storeOp = VkAttachmentStoreOp.Store; - depthAttachmentDesc.stencilLoadOp = hasStencil ? VkAttachmentLoadOp.Load : VkAttachmentLoadOp.DontCare; + depthAttachmentDesc.stencilLoadOp = VkAttachmentLoadOp.DontCare; depthAttachmentDesc.stencilStoreOp = hasStencil ? VkAttachmentStoreOp.Store : VkAttachmentStoreOp.DontCare; depthAttachmentDesc.initialLayout = VkImageLayout.Undefined; depthAttachmentDesc.finalLayout = VkImageLayout.DepthStencilAttachmentOptimal;