in my vulkan app i have a renderpass with 2 subpasses. the first writes into a color…
- User
in my vulkan app i have a renderpass with 2 subpasses. the first writes into a color attachment, which is used as input attachment in the second subpass. my dependencies are all fine, except when i don't do any draw call after cmd_next_subpass. So basically as soon as i don't have a draw call, i get a write after write hazard because of the transition of the attachment that is shared by both subpasses
Assistant
A "write after write hazard" in Vulkan typically occurs when you're trying to write to a memory location that has already been written to, without ensuring that the previous write operation has completed. This can lead to incorrect results or undefined behavior.
In your case, it seems like you're transitioning from one subpass to another without performing a draw call in between. This can cause a write after write hazard if the color attachment is being used as an input attachment in the second subpass and is not being written to in the first subpass.
To resolve this issue, you should ensure that you're always performing a draw call between subpasses, or that you're not using the color attachment as an input attachment in the second subpass if it's not being written to in the first subpass.
Here's an example of how you can modify your code to ensure that the color attachment is always written to before being used as an input attachment in the second subpass:
// Create a new framebuffer for each subpass VkFramebuffer framebuffer; VkRenderPassCreateInfo renderPassInfo = {}; renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; renderPassInfo.attachmentCount = 2; renderPassInfo.pAttachments = attachments; // Assuming attachments is an array of attachment descriptions // Create a render pass if (vkCreateRenderPass(device, &renderPassInfo, nullptr, &framebuffer) != VK_SUCCESS) { throw std::runtime_error("failed to create render pass"); } // Create a pipeline for the first subpass // ... // Start recording commands for the first subpass vkCmdBeginRenderPass(cmdBuffer, VK_SUBPASS_CONTENTS_INLINE); // Perform draw call in the first subpass // ... // End recording commands for the first subpass vkCmdEndRenderPass(cmdBuffer); // Start recording commands for the second subpass vkCmdBeginRenderPass(cmdBuffer, VK_SUBPASS_CONTENTS_INLINE); // Use the color attachment as an input attachment in the second subpass // ... // End recording commands
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.