Jump to content
  • Advertisement
Sign in to follow this  
Yu Liu

CBV or SRV shared by more than one shader in D3D12

This topic is 946 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

I'm thinking about a resource (CB or SRV) can be accessed by both VS and PS, a typical example is a SRV can be accessed by VS as well. But in D3D12 each resource stored in descriptor heap has its explicit visibility setting in a corresponding root parameter.  As a result, by default we need to set a resource for VS to access or or PS, but not both.

 

One possible way would be (haven't tried yet, just my guess), use a single ID3D12Resource to create 2 different resource views and store both them in descriptor heap.

 

Any comments?

Share this post


Link to post
Share on other sites
Advertisement

It's said in the using SHADER_VISIBILITY_ALL will mean bad performance (indeed for the scenario I described I just need VS and PS to access nothing else), besides I've tried SHADER_VISIBILITY_ALL in my app and it didn't work at all, after which I chose to create 2 views in descriptor heaps and it worked.

 

Anyone has experience on that?

Share this post


Link to post
Share on other sites
You can use a same heap location for several root parameter if needed. Although I think there is no big performance penalty in setting visibility to all. Maybe there is a threshold effect.

Share this post


Link to post
Share on other sites

You can use a same heap location for several root parameter if needed. Although I think there is no big performance penalty in setting visibility to all. Maybe there is a threshold effect.

use ID3D12GraphicsCommandList::SetGraphicsRootDescriptorTable() twice to set the same descriptor to multiple root parameters?

 

Sounds good idea, it's worth trying.

Share this post


Link to post
Share on other sites

 

  • ALL is better than setting the same descriptor table 5 times.
  • Setting the same table twice is better than using ALL when all 5 shader stages are visible to the root signature.
  • ALL with the DENY flags for unused shader stages (making your root signature only able to service VS and PS) is better than setting the table twice.

So it depends on how many shader stages your root signature will service, whether it's better to use ALL or N, but choosing N explicitly when ALL means the same thing is always a worse choice.

 

 

I've rewritten my app with SHADER_VISIBILITY_ALL and it's working fine without problem this time. Sounds like that's the solution (though may not be the best in performance)

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!