Jump to content
  • Advertisement
mark_braga

DX12 Is there a way to declare and describe static sampler in shader without fully describing root signature?

This topic is 448 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 am implementing static samplers / immutable samplers in the framework. All the examples I have seen that use static samplers declare them in the root signature string. But I dont ever describe the root signature in shader code to keep things consistent with Vulkan. So I am wondering if there is another way to declare a sampler as static sampler in shader code?

Or do I have to parse the shader myself and use some naming convention like all samplers with prefix "STATIC_" are to be considered static samplers. And then put the description above the sampler in comments. That would be a pain so if there is a way to just declare a static sampler without using the root signature string it would be really helpful.

Thank you

Share this post


Link to post
Share on other sites
Advertisement

Not that I know of, I think you're stuck parsing it yourself. The old effects framework used to have ways of passing through metadata, but that doesn't work with normal HLSL. 

Share this post


Link to post
Share on other sites

I declare all my shader resources in a meta-language, which is used to generate HLSL code at compile time... I also use this to reflect on the shaders and allow the shader author to specify extra information, such as whether a sampler should be static, or how descriptor tables should be laid out, etc...

Share this post


Link to post
Share on other sites

You can serialize your own root signature ( with D3D12SerializeRootSignature), and use it to create the root signature to provide at the PSO creation.

That way, you don't have to provide the root signature string. You can also unserialize the generated one and just modify the samplers portions.

Edited by galop1n

Share this post


Link to post
Share on other sites

I can do that? That sounds like a good way. I always thought specifying root signature in the shader means you can only use that particular root signature with that shader. If that's not the case then I can just specify a dummy root signature with the static sampler in it. Thanks a lot

Share this post


Link to post
Share on other sites

On PC, the real gpu program compilation happen in CreatePipelineState, The DXBC and the Root Signature object connect only at that time to let the driver build the final mapping. If you provide a root signature in your hlsl, it is mostly for preemptive error validation, and store it serialized in the DXBC for convenience. You can also "serialize" a root signature and provide it to the compiler directly.

There is no requirement for the root signature at CreatePipelineState to match the one you gave in the HLSL and is serialized in the DXBC blob. As long as the root signature map everything the shader need, you are good, you can reorder root parameters, make samplers static, using a root CBV instead of a DescriptorTable, change the visibility, …

 

 

Share this post


Link to post
Share on other sites

  • 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!