From 453331951b0df2a612f9bc0d68eab2ad786ec5bf Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Thu, 1 Nov 2018 15:08:54 -0700 Subject: Add support for a "strict" floating-point mode (#709) This change adds an API function and command line options for controlling the default floating-point behavior for a target, with options for "fast" and "precise" computation. The "precise" option gets mapped to the "IEEE strictness" mode in `fxc` and `dxc` (there is currently no equivalent option for glslang that I could find). --- source/slang/compiler.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source/slang/compiler.cpp') diff --git a/source/slang/compiler.cpp b/source/slang/compiler.cpp index ed222d181..52a31645c 100644 --- a/source/slang/compiler.cpp +++ b/source/slang/compiler.cpp @@ -428,6 +428,18 @@ namespace Slang dxMacros = dxMacrosStorage.Buffer(); } + DWORD flags = 0; + + switch( targetReq->floatingPointMode ) + { + default: + break; + + case FloatingPointMode::Precise: + flags |= D3DCOMPILE_IEEE_STRICTNESS; + break; + } + ID3DBlob* codeBlob; ID3DBlob* diagnosticsBlob; HRESULT hr = D3DCompile_( @@ -438,8 +450,8 @@ namespace Slang nullptr, getText(entryPoint->name).begin(), GetHLSLProfileName(profile).Buffer(), - 0, - 0, + flags, + 0, // unused: effect flags &codeBlob, &diagnosticsBlob); -- cgit v1.2.3