- 
                Notifications
    
You must be signed in to change notification settings  - Fork 15.1k
 
[NFC] Refactoring MCDXBC to support out of order storage of root parameters #137284
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
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            30 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
              
              
                 15eb6f5
              
                fix naming
              
              
                 b9d7f07
              
                fix naming
              
              
                 46cc8c1
              
                addressing comments
              
              
                 1b3e10a
              
                addressing comments
              
              
                 1f31957
              
                addressing comments
              
              
                 e8fbfce
              
                clean up
              
              
                 a31e5a5
              
                removing v parameter
              
              
                 a394ad0
              
                Merge branch 'obj2yaml/root-descriptors' into refactoring/remove-union
              
              
                 ad415a7
              
                clean up
              
              
                 8ff4845
              
                Merge branch 'main' into refactoring/remove-union
              
              
                 d67f7d3
              
                addressing comment
              
              
                 5453ad0
              
                clean up
              
              
                 836a8a8
              
                format
              
              
                 5bd57a6
              
                adding comment
              
              
                 960cb9c
              
                adrresing comments
              
              
                 a60c7a3
              
                clean up
              
              
                 2a4c2cb
              
                formatting
              
              
                 c29d3f2
              
                addressing 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
    
  
  
    
              
  
    
      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 | 
|---|---|---|
| 
          
            
          
           | 
    @@ -30,10 +30,10 @@ static void rewriteOffsetToCurrentByte(raw_svector_ostream &Stream, | |
| 
     | 
||
| size_t RootSignatureDesc::getSize() const { | ||
| size_t Size = sizeof(dxbc::RootSignatureHeader) + | ||
| Parameters.size() * sizeof(dxbc::RootParameterHeader); | ||
| ParametersContainer.size() * sizeof(dxbc::RootParameterHeader); | ||
| 
     | 
||
| for (const mcdxbc::RootParameter &P : Parameters) { | ||
| switch (P.Header.ParameterType) { | ||
| for (const RootParameterInfo &I : ParametersContainer) { | ||
| switch (I.Header.ParameterType) { | ||
| case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit): | ||
| Size += sizeof(dxbc::RootConstants); | ||
| break; | ||
| 
        
          
        
         | 
    @@ -56,7 +56,7 @@ void RootSignatureDesc::write(raw_ostream &OS) const { | |
| raw_svector_ostream BOS(Storage); | ||
| BOS.reserveExtraSpace(getSize()); | ||
| 
     | 
||
| const uint32_t NumParameters = Parameters.size(); | ||
| const uint32_t NumParameters = ParametersContainer.size(); | ||
| 
     | 
||
| support::endian::write(BOS, Version, llvm::endianness::little); | ||
| support::endian::write(BOS, NumParameters, llvm::endianness::little); | ||
| 
        
          
        
         | 
    @@ -66,7 +66,7 @@ void RootSignatureDesc::write(raw_ostream &OS) const { | |
| support::endian::write(BOS, Flags, llvm::endianness::little); | ||
| 
     | 
||
| SmallVector<uint32_t> ParamsOffsets; | ||
| for (const mcdxbc::RootParameter &P : Parameters) { | ||
| for (const RootParameterInfo &P : ParametersContainer) { | ||
| support::endian::write(BOS, P.Header.ParameterType, | ||
| llvm::endianness::little); | ||
| support::endian::write(BOS, P.Header.ShaderVisibility, | ||
| 
        
          
        
         | 
    @@ -78,27 +78,33 @@ void RootSignatureDesc::write(raw_ostream &OS) const { | |
| assert(NumParameters == ParamsOffsets.size()); | ||
| for (size_t I = 0; I < NumParameters; ++I) { | ||
| rewriteOffsetToCurrentByte(BOS, ParamsOffsets[I]); | ||
| const mcdxbc::RootParameter &P = Parameters[I]; | ||
| 
     | 
||
| switch (P.Header.ParameterType) { | ||
| case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit): | ||
| support::endian::write(BOS, P.Constants.ShaderRegister, | ||
| const auto &[Type, Loc] = ParametersContainer.getTypeAndLocForParameter(I); | ||
| switch (Type) { | ||
| case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit): { | ||
| const dxbc::RootConstants &Constants = | ||
| ParametersContainer.getConstant(Loc); | ||
| support::endian::write(BOS, Constants.ShaderRegister, | ||
| llvm::endianness::little); | ||
| support::endian::write(BOS, P.Constants.RegisterSpace, | ||
| support::endian::write(BOS, Constants.RegisterSpace, | ||
| llvm::endianness::little); | ||
| support::endian::write(BOS, P.Constants.Num32BitValues, | ||
| support::endian::write(BOS, Constants.Num32BitValues, | ||
| llvm::endianness::little); | ||
| break; | ||
| } | ||
| case llvm::to_underlying(dxbc::RootParameterType::CBV): | ||
| case llvm::to_underlying(dxbc::RootParameterType::SRV): | ||
| case llvm::to_underlying(dxbc::RootParameterType::UAV): | ||
| support::endian::write(BOS, P.Descriptor.ShaderRegister, | ||
| case llvm::to_underlying(dxbc::RootParameterType::UAV): { | ||
| const dxbc::RTS0::v2::RootDescriptor &Descriptor = | ||
| ParametersContainer.getRootDescriptor(Loc); | ||
| 
     | 
||
| support::endian::write(BOS, Descriptor.ShaderRegister, | ||
| llvm::endianness::little); | ||
| support::endian::write(BOS, P.Descriptor.RegisterSpace, | ||
| support::endian::write(BOS, Descriptor.RegisterSpace, | ||
| llvm::endianness::little); | ||
| if (Version > 1) | ||
| support::endian::write(BOS, P.Descriptor.Flags, | ||
| llvm::endianness::little); | ||
| support::endian::write(BOS, Descriptor.Flags, llvm::endianness::little); | ||
| break; | ||
| } | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing   | 
||
| } | ||
| } | ||
| assert(Storage.size() == getSize()); | ||
| 
          
            
          
           | 
    ||
  
    
      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
    
  
  
    
              
  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.
(I thought I commented on this already, but I think github ate it...)
Seeing these next to
getTypeAndLocForParameterandgetHeader, "Index" is maybe ambiguous as a variable name. Let's call these ones "Location" instead to differentiate that these are indices into the particular type of object not the index into headers used elsewhere