How To Use Fence For Indirect Draw… | Apple Developer Forums

  • Apple Developer
  • Apple Developer
Forums Search for a topic, subtopic, or tag Clear search query Local Nav Open Menu Local Nav Close Menu
  • Search
Post Profile
  • Sign in
  • Create account
How to use fence for indirect draws? Graphics & Games General Metal You’re now watching this thread. If you’ve opted in to email or web notifications, you’ll be notified when there’s activity. Click again to stop watching or visit your profile to manage watched threads and notifications. You’ve stopped watching this thread and will no longer receive emails or web notifications when there’s activity. Click again to start watching. atyuwen OP Created May ’22 Replies 2 Boosts 0 Views 732 Participants 2

Hi, I met a problem about fences. My render steps are like the following:

[ComputeEncoder]

  1. Generate indirect buffer B.
  2. updateFence F.

[RenderEncoder]

  1. waitForFence F. // which stage?
  2. drawPrimitives with indirect buffer B.

But to call waitForFence I need to pass beforeStages, the only choices for this param are MTLRenderStageVertex orMTLRenderStageFragment. There is no stage for indirect draw like vulkan's VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT.

I tried to use MTLRenderStageVertex but it didn't work. What is the correct way to wait for a fence in this scenario?

Thanks.

Boost Copy to clipboard Share this post Copied to Clipboard Replies 2 Boosts 0 Views 732 Participants 2 atyuwen OP May ’22

Also notice that the indirect buffer B is created from a MTLHeap, so the automatic resource tracking is disabled, I have to sync manually using MTLFences.

0 comments 0 Copy to clipboard Share this post Copied to Clipboard Load more Add comment OP Apple May ’22

Hi atyuwen, you seem to be approaching this in the correct way. Metal doesn't have an explicit stage for indirect-command-buffer consumption like Vulkan does. That said, waiting before MTLRenderStageVertex will indeed wait before ICB consumption.

As long as your encoders are committed to the same MTLCommandQueue, and they are in the correct, sequential order, then what you are doing should work. I would double-check if your usage of the fence F is correct.

1 comments 0 Copy to clipboard Share this post Copied to Clipboard Load more Add comment How to use fence for indirect draws? First post date Last post date Q

Từ khóa » Vulkan Indirect