Skip to content

Commit 0fd79eb

Browse files
authored
Change default validation behavior (#7392)
This PR changes the default validation behavior to use the internal validator by default. If no options are specified, the internal validator will be used, and if it fails, then compilation fails. The external validator can still be run but must be explicitly chosen. Specifying internal works just as before. There is plenty of testing and infrastructure that needs to be added to verify this change, but that needs to be added in a separate change. This change is step 1. Addresses #7389
1 parent 3bf6305 commit 0fd79eb

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

include/dxc/Support/HLSLOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ struct RewriterOpts {
115115
};
116116

117117
enum class ValidatorSelection : int {
118-
Auto, // Try DXIL.dll; fallback to internal validator
118+
Auto, // Force internal validator (even if DXIL.dll is present)
119119
Internal, // Force internal validator (even if DXIL.dll is present)
120120
External, // Use DXIL.dll, failing compilation if not available
121121
Invalid = -1 // Invalid

tools/clang/tools/dxcompiler/dxcutil.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,33 @@ HRESULT RunInternalValidator(IDxcValidator *pValidator,
4949
namespace {
5050
// AssembleToContainer helper functions.
5151

52+
// return true if the internal validator was used, false otherwise
5253
bool CreateValidator(CComPtr<IDxcValidator> &pValidator,
5354
hlsl::options::ValidatorSelection SelectValidator =
5455
hlsl::options::ValidatorSelection::Auto) {
5556
bool bInternal =
5657
SelectValidator == hlsl::options::ValidatorSelection::Internal;
5758
bool bExternal =
5859
SelectValidator == hlsl::options::ValidatorSelection::External;
59-
if (!bInternal && DxilLibIsEnabled())
60-
DxilLibCreateInstance(CLSID_DxcValidator, &pValidator);
60+
bool bAuto = SelectValidator == hlsl::options::ValidatorSelection::Auto;
6161

62-
bool bInternalValidator = false;
63-
if (pValidator == nullptr) {
64-
IFTBOOL(!bExternal, DXC_E_VALIDATOR_MISSING);
62+
// default behavior uses internal validator, as well as
63+
// explicitly specifying internal
64+
if (bInternal || bAuto) {
6565
IFT(CreateDxcValidator(IID_PPV_ARGS(&pValidator)));
66-
bInternalValidator = true;
66+
return true;
67+
}
68+
69+
if (bExternal) {
70+
// if external was explicitly specified, but no
71+
// external validator could be found (no DXIL.dll), then error
72+
IFTBOOL(DxilLibIsEnabled(), DXC_E_VALIDATOR_MISSING);
73+
IFT(DxilLibCreateInstance(CLSID_DxcValidator, &pValidator));
74+
75+
return false;
6776
}
68-
return bInternalValidator;
77+
78+
return false;
6979
}
7080

7181
} // namespace

0 commit comments

Comments
 (0)