Skip to content

Commit 715dacc

Browse files
Make DXC and DXV use new DxcDllExtValidationLoader to load external validator before validation. (microsoft#7749)
This PR focuses on allowing dxc to use the existing infrastructure to use a `DxcDllExtValidationLoader` object, and load an external dxil.dll with it, via the environment variable. The validate*.test was added to verify that the dll is indeed being loaded and used for external validation, which causes a failure, since the dll's validator version is older than the required minimum validator version that the metadata indicates. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 324f184 commit 715dacc

18 files changed

Lines changed: 640 additions & 89 deletions

File tree

azure-pipelines.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,23 @@ stages:
4545
- script: |
4646
call utils\hct\hctstart.cmd %HLSL_SRC_DIR% %HLSL_BLD_DIR%
4747
call utils\hct\hcttest.cmd -$(configuration) exec
48-
displayName: 'DXIL Execution Tests'
48+
displayName: 'DXIL Execution Tests'
49+
- script: |
50+
call utils\hct\hctstart.cmd %HLSL_SRC_DIR% %HLSL_BLD_DIR%
51+
call utils\hct\hcttest.cmd -$(configuration) compat-suite 1.6
52+
displayName: 'DXIL Compat Suite Tests (1.6 release)'
53+
condition: succeededOrFailed()
54+
- script: |
55+
call utils\hct\hctstart.cmd %HLSL_SRC_DIR% %HLSL_BLD_DIR%
56+
call utils\hct\hcttest.cmd -$(configuration) compat-suite 1.7
57+
displayName: 'DXIL Compat Suite Tests (1.7 release)'
58+
condition: succeededOrFailed()
59+
- script: |
60+
call utils\hct\hctstart.cmd %HLSL_SRC_DIR% %HLSL_BLD_DIR%
61+
call utils\hct\hcttest.cmd -$(configuration) compat-suite 1.8
62+
displayName: 'DXIL Compat Suite Tests (1.8 release)'
63+
condition: succeededOrFailed()
64+
4965
5066
- job: Nix
5167
timeoutInMinutes: 165

include/dxc/Support/HLSLOptions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ class DxcOpts {
227227
std::string TimeTrace = ""; // OPT_ftime_trace[EQ]
228228
unsigned TimeTraceGranularity = 500; // OPT_ftime_trace_granularity_EQ
229229
bool VerifyDiagnostics = false; // OPT_verify
230+
bool Verbose = false; // OPT_verbose
230231

231232
// Optimization pass enables, disables and selects
232233
OptimizationToggles
@@ -257,6 +258,11 @@ class DxcOpts {
257258
bool EmbedPDBName() const; // Zi or Fd
258259
bool DebugFileIsDirectory() const; // Fd ends in '\\'
259260
llvm::StringRef GetPDBName() const; // Fd name
261+
bool ProduceDxModule()
262+
const; // !AstDump && !OptDump && !GenSPIRV && !DumpDependencies &&
263+
// !VerifyDiagnostics && Preprocess.empty();
264+
bool ProduceFullContainer() const; // ProduceDxModule() && CodeGenHighLevel
265+
bool NeedsValidation() const; // ProduceFullContainer() && !DisableValidation
260266

261267
// SPIRV Change Starts
262268
#ifdef ENABLE_SPIRV_CODEGEN

include/dxc/Support/HLSLOptions.td

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,18 @@ def verify : Joined<["-"], "verify">,
197197
Group<hlslcomp_Group>, Flags<[CoreOption, DriverOption]>,
198198
HelpText<"Verify diagnostic output using comment directives">;
199199

200+
def verbose : Flag<["-"], "verbose">,
201+
Group<hlslcomp_Group>,
202+
Flags<[DriverOption]>,
203+
HelpText<"Allow emission of verbose compiler information">;
204+
205+
// Short alias '-v' for the verbose option
206+
def v : Flag<["-"], "v">,
207+
Alias<verbose>,
208+
Group<hlslcomp_Group>,
209+
Flags<[DriverOption]>,
210+
HelpText<"Alias for -verbose">;
211+
200212
/*
201213
def fno_caret_diagnostics : Flag<["-"], "fno-caret-diagnostics">, Group<hlslcomp_Group>,
202214
Flags<[CoreOption]>;

include/dxc/Support/dxcapi.extval.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#include "dxc/Support/dxcapi.use.h"
2+
#include "dxc/WinAdapter.h"
3+
#include "llvm/Support/raw_ostream.h"
4+
25
#include <cassert>
36
#include <string>
47

58
namespace dxc {
9+
610
class DxcDllExtValidationLoader : public DllLoader {
711
// DxCompilerSupport manages the
812
// lifetime of dxcompiler.dll, while DxilExtValSupport
@@ -12,8 +16,15 @@ class DxcDllExtValidationLoader : public DllLoader {
1216
std::string DxilDllPath;
1317

1418
public:
15-
std::string GetDxilDllPath() { return DxilDllPath; }
16-
bool DxilDllFailedToLoad() {
19+
std::string getDxilDllPath() { return DxilDllPath; }
20+
enum InitializationFailures {
21+
FailedNone = 0,
22+
FailedCompilerLoad,
23+
FailedDxilPath,
24+
FailedDxilLoad,
25+
} FailureReason = FailedNone;
26+
InitializationFailures getFailureReason() { return FailureReason; }
27+
bool dxilDllFailedToLoad() {
1728
return !DxilDllPath.empty() && !DxilExtValSupport.IsEnabled();
1829
}
1930

@@ -22,7 +33,8 @@ class DxcDllExtValidationLoader : public DllLoader {
2233
HRESULT CreateInstance2Impl(IMalloc *pMalloc, REFCLSID clsid, REFIID riid,
2334
IUnknown **pResult) override;
2435

25-
HRESULT Initialize();
36+
HRESULT initialize();
37+
HRESULT InitializeForDll(LPCSTR dllName, LPCSTR fnName);
2638

2739
bool IsEnabled() const override { return DxCompilerSupport.IsEnabled(); }
2840
};

lib/DxcSupport/HLSLOptions.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,24 @@ llvm::StringRef DxcOpts::GetPDBName() const {
166166
return llvm::StringRef();
167167
}
168168

169+
bool DxcOpts::ProduceDxModule() const {
170+
171+
return !AstDump && !OptDump &&
172+
#ifdef ENABLE_SPIRV_CODEGEN
173+
!GenSPIRV &&
174+
#endif
175+
!DumpDependencies && !VerifyDiagnostics && !IsRootSignatureProfile() &&
176+
Preprocess.empty();
177+
}
178+
179+
bool DxcOpts::ProduceFullContainer() const {
180+
return DxcOpts::ProduceDxModule() && !CodeGenHighLevel;
181+
}
182+
183+
bool DxcOpts::NeedsValidation() const {
184+
return ProduceFullContainer() && !DisableValidation;
185+
}
186+
169187
MainArgs::MainArgs(int argc, const wchar_t **argv, int skipArgCount) {
170188
if (argc > skipArgCount) {
171189
Utf8StringVector.reserve(argc - skipArgCount);
@@ -847,6 +865,7 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
847865
opts.TimeReport = Args.hasFlag(OPT_ftime_report, OPT_INVALID, false);
848866
opts.TimeTrace = Args.hasFlag(OPT_ftime_trace, OPT_INVALID, false) ? "-" : "";
849867
opts.VerifyDiagnostics = Args.hasFlag(OPT_verify, OPT_INVALID, false);
868+
opts.Verbose = Args.hasFlag(OPT_verbose, OPT_INVALID, false);
850869
if (Args.hasArg(OPT_ftime_trace_EQ))
851870
opts.TimeTrace = Args.getLastArgValue(OPT_ftime_trace_EQ);
852871
if (Arg *A = Args.getLastArg(OPT_ftime_trace_granularity_EQ)) {

0 commit comments

Comments
 (0)