Skip to content
TheChatArchiveThe Chat Archive
Metallama-2-13b-chat· MetaHugging Face Arena Human Preference 55K

in my vulkan app i have a renderpass with 2 subpasses. the first writes into a color…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Microsoftwizardlm-13b’s answer.
  1. 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

  2. Meta Assistant

    Yes, you are correct. When you don't have a draw call after cmd_next_subpass, the GPU is allowed to overwrite the color attachment that is being used as an input attachment in the second subpass, resulting in a write-after-write hazard.

    To avoid this issue, you can use a barrier() command after cmd_next_subpass to ensure that the GPU does not overwrite the color attachment until the second subpass has completed. A barrier() command forces the GPU to wait until all previous commands have finished before proceeding with the next command.

    Here's an example of how you can modify your code to avoid the write-after-write hazard:

    cmd_next_subpass();
    
    // Add a barrier() command here to ensure that the GPU does not overwrite the color attachment
    barrier();
    
    // Perform the second subpass
    cmd_begin_renderpass( RenderPass::SecondSubpass, true );
    
    // Use the color attachment as an input attachment in the second subpass
    // ...
    
    cmd_end_renderpass();
    

    By adding the barrier() command after cmd_next_subpass, you ensure that the GPU does not overwrite the color attachment until the second subpass has completed, avoiding the write-after-write hazard.

    Note that you can also use the cmd_wait_idle() command instead of barrier() to achieve the same result. cmd_wait_idle() forces the GPU to wait until all previous commands have finished and the command buffer is idle, before proceeding with the next command.

    I hope this helps! Let me know if you have any other questions.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.