Skip to content

Conversation

inbelic
Copy link
Contributor

@inbelic inbelic commented Sep 1, 2025

This pr implements support for a root signature as a target, as specified here.

This is implemented in the following steps:

  1. Add rootsignature as a shader model environment type and define rootsig as a target_profile. Only valid as versions 1.0 and 1
  2. Updates HLSLFrontendAction to invoke a special handling of constructing the ASTContext if we are considering an hlsl file and with a rootsignature target
  3. Defines the special handling to minimally instantiate the Parser and Sema to insert the RootSignatureDecl
  4. Updates CGHLSLRuntime to emit the constructed root signature decl as part of dx.rootsignatures with a null entry function
  5. Updates DXILRootSignature to handle emitting a root signature without an entry function
  6. Updates ToolChains/HLSL to invoke only-section=RTS0 to strip any other generated information

Resolves: #150286.

Implementation Considerations

Ideally we could invoke this as part of clang-dxc without the need of a source file. However, the initialization of the Parser and Lexer becomes quite complicated to handle this.

Technically, we could avoid generating any of the extra information that is removed in step 6. However, it seems better to re-use the logic in llvm-objcopy without any need for additional custom logic in DXILRootSignature.

Comment on lines +1491 to +1494
// Skim through the file to parse to find the define
while (P->getCurToken().getKind() != tok::eof)
P->ConsumeAnyToken();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason this is required when invoking with clang-dxc. Without it the OBJ portion of this test case will fail with an error that EntryRS is not defined.

If these lines are removed all other test cases still pass. The other test-cases are all invoked directly with clang -cc1 and will invoke the MacroDefined callback during the first lex in P->Initialize().

Perhaps there is some option that clang-dxc invokes clang -cc1 that disables macro expansion before directly needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant