Fixes #112267 Implement the shader flag analysis to set the UseNativeLowPrecision DXIL module flag. The flag is only able to be set when the command-line flag `-enable-16bit-types` is passed to clang-dxc, or equivalently `-fnative-half-type` is passed to clang. When the command-line flag is passed, a module metadata flag called "dx.nativelowprec" is set to 1. The DXILShaderFlags shader flags analysis checks that the module metadata flag "dx.nativelowprec" is set to 1 and the DXIL Version is 1.2 or greater before setting the UseNativeLowPrecision DXIL module flag.
38 lines
1.2 KiB
LLVM
38 lines
1.2 KiB
LLVM
; RUN: opt -S --passes="print-dx-shader-flags" 2>&1 %s | FileCheck %s
|
|
|
|
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: ; Note: extra DXIL module flags:
|
|
;CHECK-NEXT: ; D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION
|
|
;CHECK-NEXT: ; Native 16bit types enabled
|
|
;CHECK-NEXT: ;
|
|
;CHECK-NEXT: ; Shader Flags for Module Functions
|
|
|
|
;CHECK-LABEL: ; Function add_i16 : 0x00800020
|
|
define i16 @add_i16(i16 %a, i16 %b) {
|
|
%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) {
|
|
%sum = add i32 %a, %b
|
|
ret i32 %sum
|
|
}
|
|
|
|
;CHECK-LABEL: ; Function add_half : 0x00800020
|
|
define half @add_half(half %a, half %b) {
|
|
%sum = fadd half %a, %b
|
|
ret half %sum
|
|
}
|
|
|
|
!llvm.module.flags = !{!0}
|
|
!0 = !{i32 1, !"dx.nativelowprec", i32 1}
|