Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apple/examples.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@
# include "../examples/dynamicrendering/dynamicrendering.cpp"
#endif

#ifdef MVK_dynamicrenderinglocalread
# include "../examples/dynamicrenderinglocalread/dynamicrenderinglocalread.cpp"
#endif

#ifdef MVK_dynamicrenderingmultisampling
# include "../examples/dynamicrenderingmultisampling/dynamicrenderingmultisampling.cpp"
#endif
Expand Down
33 changes: 29 additions & 4 deletions examples/dynamicrenderinglocalread/dynamicrenderinglocalread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ class VulkanExample : public VulkanExampleBase
.synchronization2 = VK_TRUE,
};
deviceCreatepNextChain = &enabledSynchronization2FeaturesKHR;

#if (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT)) && TARGET_OS_SIMULATOR
Comment thread
SRSaunders marked this conversation as resolved.
Outdated
static const VkBool32 valueFalse = VK_FALSE;

// On iOS Simulator use layer setting to disable MoltenVK's Metal argument buffers - otherwise blank display
VkLayerSettingEXT layerSetting;
layerSetting.pLayerName = "MoltenVK";
layerSetting.pSettingName = "MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS";
layerSetting.type = VK_LAYER_SETTING_TYPE_BOOL32_EXT;
layerSetting.pValues = &valueFalse;
layerSetting.valueCount = 1;

enabledLayerSettings.push_back( layerSetting );
#endif
}

~VulkanExample()
Expand All @@ -124,6 +138,8 @@ class VulkanExample : public VulkanExampleBase
for (auto& buffer : uniformBuffers) {
buffer.destroy();
}
vkDestroyBuffer(device, lightsBuffer.buffer, nullptr);
vkFreeMemory(device, lightsBuffer.memory, nullptr);
}
}

Expand Down Expand Up @@ -156,7 +172,7 @@ class VulkanExample : public VulkanExampleBase
}

// Enable physical device features required for this example
virtual void getEnabledFeatures()
virtual void getEnabledFeatures() override
{
// Enable anisotropic filtering if supported
if (deviceFeatures.samplerAnisotropy) {
Expand Down Expand Up @@ -440,7 +456,7 @@ class VulkanExample : public VulkanExampleBase
}
}

void prepare()
void prepare() override
{
VulkanExampleBase::prepare();
// Since we use an extension, we need to expliclity load the function pointers for extension related Vulkan commands
Expand Down Expand Up @@ -494,7 +510,7 @@ class VulkanExample : public VulkanExampleBase
colorAttachments[i] = {
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
.imageView = imageViewList[i],
.imageLayout = VK_IMAGE_LAYOUT_RENDERING_LOCAL_READ_KHR,
.imageLayout = (i == 0) ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_RENDERING_LOCAL_READ_KHR,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this needs fixing. IMO this is a false positive and I've raised an issue in the VVL repo about this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Referring to your issue KhronosGroup/Vulkan-ValidationLayers#12039 where you discuss VK_ATTACHMENT_UNUSED, do you think this requires the VK_EXT_dynamic_rendering_unused_attachments extension to make this work for dynamic rendering?

MoltenVK does not support this extension so I can't test there. However, I will try on my Windows 11 and linux machines to see if my AMD card supports it, and report back later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scratch that idea re the VK_EXT_dynamic_rendering_unused_attachments extension. Looks like that is for adapting to multiple pipelines where you can have an unused attachment in one, but not the other.

I will leave my original change in place for now and resolve once your VVL issue is looked at.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SaschaWillems I have given up waiting for the VVL team to fix this defect. I have reverted my workaround in this PR and limited the scope to fixing the remaining colorAttachmentCount validation issue, as well as correcting a few IDE static analysis warnings. See updated description at the top of this PR.

Should now be ready for your review and merge.

.resolveMode = VK_RESOLVE_MODE_NONE,
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
Expand Down Expand Up @@ -565,6 +581,15 @@ class VulkanExample : public VulkanExampleBase
vkCmdBindDescriptorSets(cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, passes.composition.pipelineLayout, 0, 1, &passes.composition.descriptorSet, 0, nullptr);
vkCmdDraw(cmdBuffer, 3, 1, 0, 0);

vkCmdEndRenderingKHR(cmdBuffer);

// Update renderingInfo to use current swapchain image as single color attachment for the UI
colorAttachments[0].imageView = swapChain.imageViews[currentImageIndex];
colorAttachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
renderingInfo.colorAttachmentCount = 1;

vkCmdBeginRenderingKHR(cmdBuffer, &renderingInfo);

drawUI(cmdBuffer);

vkCmdEndRenderingKHR(cmdBuffer);
Expand All @@ -584,7 +609,7 @@ class VulkanExample : public VulkanExampleBase
VK_CHECK_RESULT(vkEndCommandBuffer(cmdBuffer));
}

virtual void render()
virtual void render() override
{
if (!prepared)
return;
Expand Down
Loading