shader-slang / slang

Making it easier to work with shaders
MIT License
1.98k stars 169 forks source link

Support "State Objects" #4747

Open jkwak-work opened 1 month ago

jkwak-work commented 1 month ago

With shader models 6.3 and later, applications have the convenience and flexibility of being able to define DXR state objects directly in HLSL shader code in addition to using Direct3D 12 APIs.

This is called "State objects" in HLSL, and slang doesn't seem to recognize them.

This is required for full support of WorkGraphs.

The syntax is

TYPE name = { field1, field2, ... };

where TYPE can be one of the followings,

One of the examples that uses GlobalRootSignature can be found from here.

GlobalRootSignature globalRS = { "UAV(u0)" };
csyonghe commented 1 month ago

we will need a solution to generalize this to all different targets. Also need to check how spirv/vulkan plans to represent this.

jkwak-work commented 1 month ago

It turned out that this is not needed for supporting WorkGraph yet.

There is a proposal to add more nodes to a node array at runtime via "AddToStateObject()". But it is not supported; in other words, it is not a part of SM 6.8.

See the document for more details if needed.

A proposal not supported yet is allowing the AddToStateObject() API that currently exists for DXR to be extended to support cheaply adding leaf nodes to an existing array in a work graph after the work graph has been created.