Skip to content

Commit c482c96

Browse files
committed
Add test for UseNativeLowPrecision shader flag
1 parent 554859c commit c482c96

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
; RUN: opt -S --passes="print-dx-shader-flags" 2>&1 %s | FileCheck %s
2+
; RUN: llc %s --filetype=obj -o - | obj2yaml | FileCheck %s --check-prefix=DXC
3+
4+
target triple = "dxil-pc-shadermodel6.7-library"
5+
6+
;CHECK: ; Combined Shader Flags for Module
7+
;CHECK-NEXT: ; Shader Flags Value: 0x00800020
8+
;CHECK-NEXT: ;
9+
;CHECK-NEXT: ; Note: shader requires additional functionality:
10+
;CHECK-NEXT: ; Note: extra DXIL module flags:
11+
;CHECK-NEXT: ; D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION
12+
;CHECK-NEXT: ; Native 16bit types enabled
13+
;CHECK-NEXT: ;
14+
;CHECK-NEXT: ; Shader Flags for Module Functions
15+
16+
;CHECK-LABEL: ; Function add_i16 : 0x00800020
17+
define i16 @add_i16(i16 %a, i16 %b) #0 {
18+
%sum = add i16 %a, %b
19+
ret i16 %sum
20+
}
21+
22+
; NOTE: The flag for native low precision is set for every function in the
23+
; module regardless of whether or not the function uses low precision data
24+
; types. This matches the behavior in DXC
25+
;CHECK-LABEL: ; Function add_i32 : 0x00800000
26+
define i32 @add_i32(i32 %a, i32 %b) #0 {
27+
%sum = add i32 %a, %b
28+
ret i32 %sum
29+
}
30+
31+
;CHECK-LABEL: ; Function add_half : 0x00800020
32+
define half @add_half(half %a, half %b) #0 {
33+
%sum = fadd half %a, %b
34+
ret half %sum
35+
}
36+
37+
attributes #0 = { convergent norecurse nounwind "hlsl.export" }
38+
39+
!llvm.module.flags = !{!0}
40+
!0 = !{i32 1, !"dx.nativelowprec", i32 1}
41+
42+
; DXC: - Name: SFI0
43+
; DXC-NEXT: Size: 8
44+
; DXC-NOT: Flags:
45+
; DXC: ...

0 commit comments

Comments
 (0)