Jump to content
  • Advertisement
Sign in to follow this  
Funkymunky

DX12 [D3D12] Separate Clear list?

This topic is 1070 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Up until now I've been using one command list.  It starts out with:

 

 

commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(renderTargets[frameIndex].Get(), D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET));
 
commandList->ClearRenderTargetView(rtvHandle, clearColor, 0, nullptr);
 
 
and finishes with
 
 
commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(renderTargets[frameIndex].Get(), D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT));
 
 
After this I call ExecuteCommandList.  I've been playing back bundles on this command list to draw my objects.  Now, I want to use separate command lists.  But if I execute them in between the start and end of this master command list, it comes through and and the clear command clears the render target of anything they've done!
 
So do I want to make a second command list for that second ResourceBarrier call?  Or do I want to use the same list/allocator, but put a fence in before it calls that second ResourceBarrier?

Share this post


Link to post
Share on other sites
Advertisement

It seems like I should use two command lists and allocators.  One for the ClearRenderTargetView and ResourceBarrier from PRESENT to RENDER_TARGET, and then a second one for the ResourceBarrier from RENDER_TARGET to PRESENT.

 

If I use the same list//allocator, but close it after the first ResourceBarrier, then I need to use a fence to ensure that it executes before using it again (for the second ResourceBarrier).  Otherwise I get an error about the Allocator being in use.  Rather than waiting on a fence, it seems like a better idea to just use another list//allocator that calls that second ResourceBarrier.

Edited by Funkymunky

Share this post


Link to post
Share on other sites

After this I call ExecuteCommandList.  I've been playing back bundles on this command list to draw my objects.  Now, I want to use separate command lists.  But if I execute them in between the start and end of this master command list, it comes through and and the clear command clears the render target of anything they've done!

I don't quite understand.... You issue drae bundles and then issue a clear, which is bad...
Why can't you just not clear after submitting your bundles?

Share this post


Link to post
Share on other sites

Well, it has more to do with the ResourceBarrier calls.  I want to call ResourceBarrier and Clear at the beginning of rendering, then draw all my objects, and then call ResourceBarrier at the end.

 

This works fine when I just play back bundles on the one command list that contains these three calls.  But I was looking to execute different command lists.  I execute that main command list last, so that the second ResourceBarrier call will be the last command executed.  But this would call Clear after rendering all my other objects.

 

So I split it into two Command Lists:  One that does the first ResourceBarrier and Clear, and a second that just does the second ResourceBarrier.  Then I can render other command lists in between.

Edited by Funkymunky

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!