How to preserve attachment content between render passes

nikitablack

I have multiple "renderers" which should draw to the same attachment (swap chain image to be precise). I don't know the number of such renderers beforehand so I can't use subpasses. This is how I wanted to implement it:

VkCommandBuffer cb{...}; // get current "main" command buffer
for(auto r : renderers)
{
    VkRenderPassBeginInfo renderPassBeginInfo{get_render_pass_begin_info(...)};
    vkCmdBeginRenderPass(cb, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
    array<VkCommandBuffer, 2> buffs{r->getCommandBuffers()}; // renderer build two secondary command buffers...
    vkCmdExecuteCommands(cb, 1, buffs[0]); // first should be used in a render pass
    vkCmdEndRenderPass(cb);
    vkCmdExecuteCommands(cb, 1, buffs[1]); // second should be used ooutside of a render pass
}

The problem here is that each new call to vkCmdBeginRenderPass clears the target. This happens because the attachment was created with loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR because I need to clear it (but only once).

The solution in my case would be to move vkCmdBeginRenderPass and vkCmdEndRenderPass outside of the loop, but in this case, I need to "collect" all secondary command buffers that can't be used inside a render pass and execute them later.

But since the concept of render passes doesn't go into my head I wonder if there may be a way to keep the attachment's data between render passes?

Nicol Bolas

You could stop clearing the attachments on load. Just manually clear them, either before the render pass begins or at the start of the first subpass.

That being said, render passes are not cheap, and this is really not the way to use them. The correct solution is to restructure your rendering code so that you only need a single render pass.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Synchronizing two render passes: color attachment to sampled?

分類Dev

What is the relation between render passes, command buffers and clearing of attachments in vulkan?

分類Dev

How to share cl::opt arguments between passes?

分類Dev

How to render async content on React?

分類Dev

How to render async content on React?

分類Dev

How to use Abdera atom client to send content and attachment

分類Dev

How to render content from backend in templates?

分類Dev

React - how to render content from JSON file?

分類Dev

HttpResponseMessage.Content as an attachment for an email

分類Dev

How to render html content in postfuntion name of jira workflow add-on?

分類Dev

How to render dynamic content "component" with custom tabs VueJs

分類Dev

How to send email with html attachment

分類Dev

Does HashSet preserve order between enumerations?

分類Dev

Render HTML content to google spreadsheet

分類Dev

How to insert line breaks between numbers and content in ordered list

分類Dev

How to get content between the div tags in C#

分類Dev

How to encode an attachment to Base64 in Jmeter?

分類Dev

how can I save an attachment using exchangelib

分類Dev

How to make outlook mail attachment from memory?

分類Dev

How to open email composer with attachment in titanium?

分類Dev

Use v:content.render in a Contentelement

分類Dev

Div Content Does Not Render After Display Block

分類Dev

ReactDom.render not rendering the html content

分類Dev

Is there a way to have node preserve command line history between sessions?

分類Dev

Pandoc lua filter: How to preserve footnotes' formatting?

分類Dev

How to preserve initial state in React Component?

分類Dev

how to preserve selection when sorting QTableView

分類Dev

How to check how many passes are needed to sort the elements in an ArrayList?

分類Dev

How to render a HOC in react

Related 関連記事

  1. 1

    Synchronizing two render passes: color attachment to sampled?

  2. 2

    What is the relation between render passes, command buffers and clearing of attachments in vulkan?

  3. 3

    How to share cl::opt arguments between passes?

  4. 4

    How to render async content on React?

  5. 5

    How to render async content on React?

  6. 6

    How to use Abdera atom client to send content and attachment

  7. 7

    How to render content from backend in templates?

  8. 8

    React - how to render content from JSON file?

  9. 9

    HttpResponseMessage.Content as an attachment for an email

  10. 10

    How to render html content in postfuntion name of jira workflow add-on?

  11. 11

    How to render dynamic content "component" with custom tabs VueJs

  12. 12

    How to send email with html attachment

  13. 13

    Does HashSet preserve order between enumerations?

  14. 14

    Render HTML content to google spreadsheet

  15. 15

    How to insert line breaks between numbers and content in ordered list

  16. 16

    How to get content between the div tags in C#

  17. 17

    How to encode an attachment to Base64 in Jmeter?

  18. 18

    how can I save an attachment using exchangelib

  19. 19

    How to make outlook mail attachment from memory?

  20. 20

    How to open email composer with attachment in titanium?

  21. 21

    Use v:content.render in a Contentelement

  22. 22

    Div Content Does Not Render After Display Block

  23. 23

    ReactDom.render not rendering the html content

  24. 24

    Is there a way to have node preserve command line history between sessions?

  25. 25

    Pandoc lua filter: How to preserve footnotes' formatting?

  26. 26

    How to preserve initial state in React Component?

  27. 27

    how to preserve selection when sorting QTableView

  28. 28

    How to check how many passes are needed to sort the elements in an ArrayList?

  29. 29

    How to render a HOC in react

ホットタグ

アーカイブ