Add -precise-output (#2827)
This commit is contained in:
Родитель
7d665725a8
Коммит
8b92463c32
|
@ -125,6 +125,7 @@ public:
|
|||
llvm::StringRef RootSignatureDefine; // OPT_rootsig_define
|
||||
llvm::StringRef FloatDenormalMode; // OPT_denorm
|
||||
std::vector<std::string> Exports; // OPT_exports
|
||||
std::vector<std::string> PreciseOutputs; // OPT_precise_output
|
||||
llvm::StringRef DefaultLinkage; // OPT_default_linkage
|
||||
unsigned DefaultTextCodePage = DXC_CP_UTF8; // OPT_encoding
|
||||
|
||||
|
|
|
@ -255,6 +255,8 @@ def export_shaders_only : Flag<["-", "/"], "export-shaders-only">, Group<hlslcom
|
|||
HelpText<"Only export shaders when compiling a library">;
|
||||
def default_linkage : Separate<["-", "/"], "default-linkage">, Group<hlslcomp_Group>, Flags<[CoreOption]>,
|
||||
HelpText<"Set default linkage for non-shader functions when compiling or linking to a library target (internal, external)">;
|
||||
def precise_output : Separate<["-", "/"], "precise-output">, Group<hlslcomp_Group>, Flags<[CoreOption, HelpHidden]>,
|
||||
HelpText<"Mark output semantic as precise">;
|
||||
def encoding : Separate<["-", "/"], "encoding">, Group<hlslcomp_Group>, Flags<[CoreOption, RewriteOption, DriverOption]>,
|
||||
HelpText<"Set default encoding for text outputs (utf8|utf16) default=utf8">;
|
||||
def validator_version : Separate<["-", "/"], "validator-version">, Group<hlslcomp_Group>, Flags<[CoreOption, HelpHidden]>,
|
||||
|
|
|
@ -385,6 +385,8 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
|
|||
DXASSERT(opts.ExternalLib.empty() == opts.ExternalFn.empty(),
|
||||
"else flow above is incorrect");
|
||||
|
||||
opts.PreciseOutputs = Args.getAllArgValues(OPT_precise_output);
|
||||
|
||||
// when no-warnings option is present, do not output warnings.
|
||||
opts.OutputWarnings = Args.hasFlag(OPT_INVALID, OPT_no_warnings, true);
|
||||
opts.EntryPoint = Args.getLastArgValue(OPT_entrypoint);
|
||||
|
|
|
@ -195,6 +195,8 @@ public:
|
|||
unsigned HLSLValidatorMinorVer = 0;
|
||||
/// Define macros passed in from command line
|
||||
std::vector<std::string> HLSLDefines;
|
||||
/// Precise output passed in from command line
|
||||
std::vector<std::string> HLSLPreciseOutputs;
|
||||
/// Arguments passed in from command line
|
||||
std::vector<std::string> HLSLArguments;
|
||||
/// Helper for generating llvm bitcode for hlsl extensions.
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "clang/Lex/HLSLMacroExpander.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
#include "llvm/ADT/StringSet.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/StringSet.h"
|
||||
#include "llvm/IR/Constants.h"
|
||||
|
@ -208,6 +209,7 @@ private:
|
|||
bool bDefaultRowMajor);
|
||||
|
||||
std::unordered_map<Constant*, DxilFieldAnnotation> m_ConstVarAnnotationMap;
|
||||
StringSet<> m_PreciseOutputSet;
|
||||
|
||||
public:
|
||||
CGMSHLSLRuntime(CodeGenModule &CGM);
|
||||
|
@ -342,6 +344,11 @@ CGMSHLSLRuntime::CGMSHLSLRuntime(CodeGenModule &CGM)
|
|||
const bool skipInit = true;
|
||||
m_pHLModule = &TheModule.GetOrCreateHLModule(skipInit);
|
||||
|
||||
// Precise Output.
|
||||
for (auto &preciseOutput : CGM.getCodeGenOpts().HLSLPreciseOutputs) {
|
||||
m_PreciseOutputSet.insert(StringRef(preciseOutput).lower());
|
||||
}
|
||||
|
||||
// Set Option.
|
||||
HLOptions opts;
|
||||
opts.bIEEEStrict = CGM.getCodeGenOpts().UnsafeFPMath;
|
||||
|
@ -464,6 +471,8 @@ CGMSHLSLRuntime::SetSemantic(const NamedDecl *decl,
|
|||
if (it->getKind() == hlsl::UnusualAnnotation::UA_SemanticDecl) {
|
||||
const hlsl::SemanticDecl *sd = cast<hlsl::SemanticDecl>(it);
|
||||
paramInfo.SetSemanticString(sd->SemanticName);
|
||||
if (m_PreciseOutputSet.count(StringRef(sd->SemanticName).lower()))
|
||||
paramInfo.SetPrecise();
|
||||
return it->Loc;
|
||||
}
|
||||
}
|
||||
|
@ -965,8 +974,12 @@ unsigned CGMSHLSLRuntime::ConstructStructAnnotation(DxilStructAnnotation *annota
|
|||
|
||||
fieldAnnotation.SetCBufferOffset(CBufferOffset);
|
||||
fieldAnnotation.SetFieldName(fieldDecl->getName());
|
||||
if (!fieldSemName.empty())
|
||||
if (!fieldSemName.empty()) {
|
||||
fieldAnnotation.SetSemanticString(fieldSemName);
|
||||
|
||||
if (m_PreciseOutputSet.count(StringRef(fieldSemName).lower()))
|
||||
fieldAnnotation.SetPrecise();
|
||||
}
|
||||
}
|
||||
|
||||
annotation->SetCBufferSize(offset);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
// RUN: %dxc -E main -T vs_6_0 -precise-output d1 -precise-output SV_Position %s | FileCheck %s
|
||||
|
||||
// Make sure get ir.
|
||||
// CHECK:@main
|
||||
// Make sure precise removed fast.
|
||||
// CHECK-NOT:fast
|
||||
|
||||
struct T {
|
||||
float4 p : SV_Position;
|
||||
float a : A;
|
||||
};
|
||||
|
||||
T main(float4 a:A, float b:B, float c:C, out float d:D1) {
|
||||
|
||||
T t;
|
||||
t.p = a + b;
|
||||
t.a = b;
|
||||
d = b*c;
|
||||
return t;
|
||||
}
|
|
@ -1113,6 +1113,7 @@ public:
|
|||
compiler.getCodeGenOpts().HLSLNotUseLegacyCBufLoad = Opts.NotUseLegacyCBufLoad;
|
||||
compiler.getCodeGenOpts().HLSLLegacyResourceReservation = Opts.LegacyResourceReservation;
|
||||
compiler.getCodeGenOpts().HLSLDefines = defines;
|
||||
compiler.getCodeGenOpts().HLSLPreciseOutputs = Opts.PreciseOutputs;
|
||||
compiler.getCodeGenOpts().MainFileName = pMainFile;
|
||||
|
||||
// Translate signature packing options
|
||||
|
|
Загрузка…
Ссылка в новой задаче