Skip to content

Commit

Permalink
[Vulkan] Fix several validation warnings and errors.
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
mellinoe committed Apr 8, 2018
1 parent 18126ee commit 31ac583
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/Veldrid/Vk/VkFramebuffer.cs
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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)
{
Expand Down
6 changes: 1 addition & 5 deletions src/Veldrid/Vk/VkPipeline.cs
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 31ac583

Please sign in to comment.