- 
                Notifications
    
You must be signed in to change notification settings  - Fork 15.1k
 
[DirectX] Set shader feature flags MinimumPrecision and NativeLowPrecision, and refactor the logic for setting low-precision-related flags #139623
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
          
          
            8 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      2039fa7
              
                Set shader feature flags MinimumPrecision and NativeLowPrecision
              
              
                Icohedron aa824ac
              
                Refactor flags related to low precision data types and combine the Na…
              
              
                Icohedron 4cb533b
              
                Fix comment about the -enable-16bit-types flag
              
              
                Icohedron 610f435
              
                Set default value of NativeLowPrecisionAvailable to false
              
              
                Icohedron bc8396d
              
                Reintroduce Native Low Precision module flag, and refactor module flags
              
              
                Icohedron 70d4849
              
                Revise descriptions of flags related to low-precision data types
              
              
                Icohedron fe5d588
              
                Assign bool value of NativeLowPrecisionMode directly
              
              
                Icohedron c0dbfbb
              
                Rename bools set by module flags to be consistent
              
              
                Icohedron 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
    
  
  
    
              
  
    
      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 | 
|---|---|---|
| @@ -1,30 +1,44 @@ | ||
| ; RUN: opt -S --passes="print-dx-shader-flags" 2>&1 %s | FileCheck %s | ||
| ; RUN: llc %s --filetype=obj -o - | obj2yaml | FileCheck %s --check-prefix=DXC | ||
| 
     | 
||
| ; Check that when the dx.nativelowprec module flag is not specified, the | ||
| ; module-level shader flag UseNativeLowPrecision is not set, and the | ||
| ; MinimumPrecision feature flag is set due to the presence of half and i16 | ||
| ; without native low precision. | ||
| 
     | 
||
| target triple = "dxil-pc-shadermodel6.7-library" | ||
| 
     | 
||
| ;CHECK: ; Combined Shader Flags for Module | ||
| ;CHECK-NEXT: ; Shader Flags Value: 0x00000020 | ||
| ;CHECK-NEXT: ; | ||
| ;CHECK-NEXT: ; Note: shader requires additional functionality: | ||
| ;CHECK-NEXT: ; Minimum-precision data types | ||
| ;CHECK-NEXT: ; Note: extra DXIL module flags: | ||
| ;CHECK-NEXT: ; Low-precision data types | ||
| ;CHECK-NEXT: ; Low-precision data types present | ||
| ;CHECK-NEXT: ; | ||
| ;CHECK-NEXT: ; Shader Flags for Module Functions | ||
| 
     | 
||
| ;CHECK-LABEL: ; Function add_i16 : 0x00000020 | ||
| define i16 @add_i16(i16 %a, i16 %b) { | ||
| define i16 @add_i16(i16 %a, i16 %b) "hlsl.export" { | ||
| %sum = add i16 %a, %b | ||
| ret i16 %sum | ||
| } | ||
| 
     | 
||
| ;CHECK-LABEL: ; Function add_i32 : 0x00000000 | ||
| define i32 @add_i32(i32 %a, i32 %b) { | ||
| define i32 @add_i32(i32 %a, i32 %b) "hlsl.export" { | ||
| %sum = add i32 %a, %b | ||
| ret i32 %sum | ||
| } | ||
| 
     | 
||
| ;CHECK-LABEL: ; Function add_half : 0x00000020 | ||
| define half @add_half(half %a, half %b) { | ||
| define half @add_half(half %a, half %b) "hlsl.export" { | ||
| %sum = fadd half %a, %b | ||
| ret half %sum | ||
| } | ||
| 
     | 
||
| ; DXC: - Name: SFI0 | ||
| ; DXC-NEXT: Size: 8 | ||
| ; DXC-NEXT: Flags: | ||
| ; DXC: MinimumPrecision: true | ||
| ; DXC: NativeLowPrecision: false | ||
| ; DXC: ... | 
  
    
      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
    
  
  
    
              
        
          
          
            22 changes: 16 additions & 6 deletions
          
          22 
        
  llvm/test/CodeGen/DirectX/ShaderFlags/use-native-low-precision-0.ll
  
  
      
      
   
        
      
      
    
  
    
      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 | 
|---|---|---|
| @@ -1,37 +1,47 @@ | ||
| ; RUN: opt -S --passes="print-dx-shader-flags" 2>&1 %s | FileCheck %s | ||
| ; RUN: llc %s --filetype=obj -o - | obj2yaml | FileCheck %s --check-prefix=DXC | ||
| 
     | 
||
| ; Check that when the dx.nativelowprec module flag is set to 0, the module-level | ||
| ; shader flag UseNativeLowPrecision is not set | ||
| ; shader flag UseNativeLowPrecision is not set, and the MinimumPrecision feature | ||
| ; flag is set due to the presence of half and i16 without native low precision. | ||
| 
     | 
||
| target triple = "dxil-pc-shadermodel6.7-library" | ||
| 
     | 
||
| ;CHECK: ; Combined Shader Flags for Module | ||
| ;CHECK-NEXT: ; Shader Flags Value: 0x00000020 | ||
| ;CHECK-NEXT: ; | ||
| ;CHECK-NEXT: ; Note: shader requires additional functionality: | ||
| ;CHECK-NEXT: ; Minimum-precision data types | ||
| ;CHECK-NEXT: ; Note: extra DXIL module flags: | ||
| ;CHECK-NEXT: ; Low-precision data types | ||
| ;CHECK-NOT: ; Native 16bit types enabled | ||
| ;CHECK-NEXT: ; Low-precision data types present | ||
| ;CHECK-NOT: ; Enable native low-precision data types | ||
| ;CHECK-NEXT: ; | ||
| ;CHECK-NEXT: ; Shader Flags for Module Functions | ||
| 
     | 
||
| ;CHECK-LABEL: ; Function add_i16 : 0x00000020 | ||
| define i16 @add_i16(i16 %a, i16 %b) { | ||
| define i16 @add_i16(i16 %a, i16 %b) "hlsl.export" { | ||
| %sum = add i16 %a, %b | ||
| ret i16 %sum | ||
| } | ||
| 
     | 
||
| ;CHECK-LABEL: ; Function add_i32 : 0x00000000 | ||
| define i32 @add_i32(i32 %a, i32 %b) { | ||
| define i32 @add_i32(i32 %a, i32 %b) "hlsl.export" { | ||
| %sum = add i32 %a, %b | ||
| ret i32 %sum | ||
| } | ||
| 
     | 
||
| ;CHECK-LABEL: ; Function add_half : 0x00000020 | ||
| define half @add_half(half %a, half %b) { | ||
| define half @add_half(half %a, half %b) "hlsl.export" { | ||
| %sum = fadd half %a, %b | ||
| ret half %sum | ||
| } | ||
| 
     | 
||
| !llvm.module.flags = !{!0} | ||
| !0 = !{i32 1, !"dx.nativelowprec", i32 0} | ||
| 
     | 
||
| ; DXC: - Name: SFI0 | ||
| ; DXC-NEXT: Size: 8 | ||
| ; DXC-NEXT: Flags: | ||
| ; DXC: MinimumPrecision: true | ||
| ; DXC: NativeLowPrecision: false | ||
| ; DXC: ... | 
        
          
          
            32 changes: 21 additions & 11 deletions
          
          32 
        
  llvm/test/CodeGen/DirectX/ShaderFlags/use-native-low-precision-1.ll
  
  
      
      
   
        
      
      
    
  
    
      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 | 
|---|---|---|
| @@ -1,37 +1,47 @@ | ||
| ; RUN: opt -S --passes="print-dx-shader-flags" 2>&1 %s | FileCheck %s | ||
| ; RUN: llc %s --filetype=obj -o - | obj2yaml | FileCheck %s --check-prefix=DXC | ||
| 
     | 
||
| ; Check that when the dx.nativelowprec module flag is set to 1, the module-level | ||
| ; shader flag UseNativeLowPrecision is set, and the NativeLowPrecision feature | ||
| ; flag is set | ||
| 
     | 
||
| target triple = "dxil-pc-shadermodel6.7-library" | ||
| 
     | 
||
| ;CHECK: ; Combined Shader Flags for Module | ||
| ;CHECK-NEXT: ; Shader Flags Value: 0x00800020 | ||
| ;CHECK-NEXT: ; | ||
| ;CHECK-NEXT: ; Note: shader requires additional functionality: | ||
| ;CHECK-NEXT: ; Native low-precision data types | ||
| ;CHECK-NEXT: ; Note: extra DXIL module flags: | ||
| ;CHECK-NEXT: ; Low-precision data types | ||
| ;CHECK-NEXT: ; Use native low precision | ||
| ;CHECK-NEXT: ; Low-precision data types present | ||
| ;CHECK-NEXT: ; Enable native low-precision data types | ||
| ;CHECK-NEXT: ; | ||
| ;CHECK-NEXT: ; Shader Flags for Module Functions | ||
| 
     | 
||
| ;CHECK-LABEL: ; Function add_i16 : 0x00800020 | ||
| define i16 @add_i16(i16 %a, i16 %b) { | ||
| ;CHECK-LABEL: ; Function add_i16 : 0x00000020 | ||
| define i16 @add_i16(i16 %a, i16 %b) "hlsl.export" { | ||
| %sum = add i16 %a, %b | ||
| ret i16 %sum | ||
| } | ||
| 
     | 
||
| ; NOTE: The flag for native low precision (0x80000) is set for every function | ||
| ; in the module regardless of whether or not the function uses low precision | ||
| ; data types (flag 0x20). This matches the behavior in DXC | ||
| ;CHECK-LABEL: ; Function add_i32 : 0x00800000 | ||
| define i32 @add_i32(i32 %a, i32 %b) { | ||
| ;CHECK-LABEL: ; Function add_i32 : 0x00000000 | ||
| define i32 @add_i32(i32 %a, i32 %b) "hlsl.export" { | ||
| %sum = add i32 %a, %b | ||
| ret i32 %sum | ||
| } | ||
| 
     | 
||
| ;CHECK-LABEL: ; Function add_half : 0x00800020 | ||
| define half @add_half(half %a, half %b) { | ||
| ;CHECK-LABEL: ; Function add_half : 0x00000020 | ||
| define half @add_half(half %a, half %b) "hlsl.export" { | ||
| %sum = fadd half %a, %b | ||
| ret half %sum | ||
| } | ||
| 
     | 
||
| !llvm.module.flags = !{!0} | ||
| !0 = !{i32 1, !"dx.nativelowprec", i32 1} | ||
| 
     | 
||
| ; DXC: - Name: SFI0 | ||
| ; DXC-NEXT: Size: 8 | ||
| ; DXC-NEXT: Flags: | ||
| ; DXC: MinimumPrecision: false | ||
| ; DXC: NativeLowPrecision: true | ||
| ; DXC: ... | 
  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.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.