- 
                Notifications
    You must be signed in to change notification settings 
- Fork 15k
[NFC] Refactoring DXContainerYaml Root Parameter representation #138318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
            joaosaffran
  merged 32 commits into
  llvm:main
from
joaosaffran:refactoring/dxcontainer-yaml
  
      
      
   
  May 27, 2025 
      
    
  
     Merged
                    Changes from 31 commits
      Commits
    
    
            Show all changes
          
          
            32 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      0abacfc
              
                adding support for Root Descriptors
              
              
                 8b8c02a
              
                clean up
              
              
                 7ac9641
              
                addressing comments
              
              
                 c105458
              
                formating
              
              
                 efe76aa
              
                try fix test
              
              
                 a928e9d
              
                addressing comments
              
              
                 a38f10b
              
                refactoring mcdxbc struct to store root parameters out of order
              
              
                 9a7c359
              
                changing name
              
              
                 d6c2b55
              
                changing variant to host pointers
              
              
                 93e4cf2
              
                clean up
              
              
                 b45b1b6
              
                fix
              
              
                 f804a23
              
                fix
              
              
                 44bd13a
              
                making read work
              
              
                 ac51bf6
              
                adding reading logic
              
              
                 97fb003
              
                test pass locally
              
              
                 93e04bd
              
                adding tests
              
              
                 2f6d579
              
                adding more tests
              
              
                 76b1b75
              
                clean up
              
              
                 b2bfb02
              
                refactoring root signature dxcontainer yaml representation
              
              
                 9ee2964
              
                clean up
              
              
                 2527580
              
                fix test
              
              
                 c3a46da
              
                copy test
              
              
                 df194b0
              
                Merge branch 'main' into refactoring/dxcontainer-yaml
              
              
                 0136cfc
              
                fix testing issues
              
              
                 b589d10
              
                clean up
              
              
                 c7042b2
              
                clean up
              
              
                 70a9b7f
              
                addressing PR Comments
              
              
                 f1dd0ce
              
                formating
              
              
                 aabd424
              
                addressing comments
              
              
                 e8ab8f7
              
                addressing commets
              
              
                 bf5e7d3
              
                clean up
              
              
                 ea57253
              
                address pr comments
              
              
                 File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|  | @@ -263,47 +263,55 @@ void DXContainerWriter::writeParts(raw_ostream &OS) { | |||||||||
| case dxbc::PartType::Unknown: | ||||||||||
| break; // Skip any handling for unrecognized parts. | ||||||||||
| case dxbc::PartType::RTS0: | ||||||||||
| if (!P.RootSignature.has_value()) | ||||||||||
| continue; | ||||||||||
|  | ||||||||||
| mcdxbc::RootSignatureDesc RS; | ||||||||||
| RS.Flags = P.RootSignature->getEncodedFlags(); | ||||||||||
| RS.Version = P.RootSignature->Version; | ||||||||||
| RS.RootParameterOffset = P.RootSignature->RootParametersOffset; | ||||||||||
| RS.NumStaticSamplers = P.RootSignature->NumStaticSamplers; | ||||||||||
| RS.StaticSamplersOffset = P.RootSignature->StaticSamplersOffset; | ||||||||||
|  | ||||||||||
| for (const auto &Param : P.RootSignature->Parameters) { | ||||||||||
| dxbc::RootParameterHeader Header{Param.Type, Param.Visibility, | ||||||||||
| Param.Offset}; | ||||||||||
|  | ||||||||||
| switch (Param.Type) { | ||||||||||
| case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit): | ||||||||||
| dxbc::RootConstants Constants; | ||||||||||
| Constants.Num32BitValues = Param.Constants.Num32BitValues; | ||||||||||
| Constants.RegisterSpace = Param.Constants.RegisterSpace; | ||||||||||
| Constants.ShaderRegister = Param.Constants.ShaderRegister; | ||||||||||
| RS.ParametersContainer.addParameter(Header, Constants); | ||||||||||
| break; | ||||||||||
| case llvm::to_underlying(dxbc::RootParameterType::SRV): | ||||||||||
| case llvm::to_underlying(dxbc::RootParameterType::UAV): | ||||||||||
| case llvm::to_underlying(dxbc::RootParameterType::CBV): | ||||||||||
| dxbc::RTS0::v2::RootDescriptor Descriptor; | ||||||||||
| Descriptor.RegisterSpace = Param.Descriptor.RegisterSpace; | ||||||||||
| Descriptor.ShaderRegister = Param.Descriptor.ShaderRegister; | ||||||||||
| if (RS.Version > 1) | ||||||||||
| Descriptor.Flags = Param.Descriptor.getEncodedFlags(); | ||||||||||
| RS.ParametersContainer.addParameter(Header, Descriptor); | ||||||||||
| break; | ||||||||||
| default: | ||||||||||
| // Handling invalid parameter type edge case. We intentionally let | ||||||||||
| // obj2yaml/yaml2obj parse and emit invalid dxcontainer data, in order | ||||||||||
| // for that to be used as a testing tool more effectively. | ||||||||||
| RS.ParametersContainer.addInvalidParameter(Header); | ||||||||||
| } | ||||||||||
| } | ||||||||||
|  | ||||||||||
| RS.write(OS); | ||||||||||
| if (!P.RootSignature.has_value()) | ||||||||||
| continue; | ||||||||||
|  | ||||||||||
| mcdxbc::RootSignatureDesc RS; | ||||||||||
| RS.Flags = P.RootSignature->getEncodedFlags(); | ||||||||||
| RS.Version = P.RootSignature->Version; | ||||||||||
| RS.RootParameterOffset = P.RootSignature->RootParametersOffset; | ||||||||||
| RS.NumStaticSamplers = P.RootSignature->NumStaticSamplers; | ||||||||||
| RS.StaticSamplersOffset = P.RootSignature->StaticSamplersOffset; | ||||||||||
|  | ||||||||||
| for (DXContainerYAML::RootParameterLocationYaml &L : | ||||||||||
| P.RootSignature->Parameters.Locations) { | ||||||||||
| auto Header = dxbc::RootParameterHeader{ | ||||||||||
| L.Header.Type, L.Header.Visibility, L.Header.Offset}; | ||||||||||
|          | ||||||||||
| auto Header = dxbc::RootParameterHeader{ | |
| L.Header.Type, L.Header.Visibility, L.Header.Offset}; | |
| dxbc::RootParameterHeader Header{ | |
| L.Header.Type, L.Header.Visibility, L.Header.Offset}; | 
        
          
              
                Outdated
          
        
      There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why make a copy here? This should be a reference.
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a funny whitespace change here, please double check.