Jump to content
  • Advertisement
Sign in to follow this  
ADDMX

DX12 DXR and LocalRootSignatures

Recommended Posts

Hi

I'm trying to implement DXR (just true DXR, not the fallback layer) into my home-made engine (thankfully already DX12 centered), and I have couple of questions that bother my mind.

Looking at all the examples (from microsoft ATG and NVidia) the HitGroups just have ClosestHitShaderImport (for D3D12_HIT_GROUP_TYPE_TRIANGLES) but to support alpha-tested geometry I also need AnyHitShaderImport right ?
If so, my AnyHitShaderImport need it's LocalRootSignature (as it needs descriptor table to be able to sample texture, resolve UV from VB etc.), then where do I need to put those arguments (in shaders table) ?
So questions: Do ClosestHitShaderImport and AnyHitShaderImport _must_ share that same LocalRootSignature (and in general all shaders in HitGroup must share that _same_ LocalRootSignature and they have only 1 entry in shaders table for arguments - seems logical)
If they do not need to share that same LocalRootSignature what is the layout ?
(I know that every entry in shaders table is D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES + largest possible LocalRootSignature data size aligned to D3D12_RAYTRACING_SHADER_RECORD_BYTE_ALIGNMENT, but the exaples does not cover cases with multiple shaders in single HitGroup)

Second question is about ShaderLibraries in D3D12_STATE_OBJECT_DESC, as I understand I may have as many of them (D3D12_DXIL_LIBRARY_DESC subobjects) as I like, but the exports from them need to have unique names - is that right ?
(I realy want to have many of them, since each different (hit)shader then will live in it's own (material)library (that same library where original rasterize-pipeline VS/PS live))

Share this post


Link to post
Share on other sites
Advertisement
  1. Yes,you need to specify the name of your AnyHit shader for the AnyHitShaderImport member of the hit group desc in order to add alpha-testing. 
  2. Local root signatures are associated with hit groups, so you need to share the same local RS between ClosestHit and AnyHit shaders within a hit group.
  3. When you have two shaders in your hit group, then the layout of your shader record goes like this:
    1. Shader identifier for ClosestHitShader
    2. Shader identifier for AnyHitShader
    3. All local RS parameters
  4. Yes, I believe the export names all need to be unique. But I'm not 100% sure on that

By the way, if you want to see an example of alpha testing working in DXR you can check out my simple path tracer. You can find the code for setting up the state object here.

Share this post


Link to post
Share on other sites

Are you sure about point 3. ?

In your code (and in all DXR samples) the table entry is: [ShaderID of HitGroup][LocalRootSignatureData]

there are no individual ShaderIDs in table, just HitGroups IDs

anyway thanks for clarification about LocalRootSignatures

 

Share this post


Link to post
Share on other sites

Re, 3. @ADDMX you're right that the shader identifier in the record is that of the Hit Group's export name, not those of individual shaders within the hit group.

Share this post


Link to post
Share on other sites

Whoops, sorry about that. I was misremembering how it worked. 🙂

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
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!