Skip to content

Commit e48506e

Browse files
committed
refactor
1 parent 0068337 commit e48506e

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

tools/clang/tools/dxcompiler/dxcutil.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,36 @@ 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) {
55-
bool bInternalValidator = false;
5656
bool bInternal =
5757
SelectValidator == hlsl::options::ValidatorSelection::Internal;
5858
bool bExternal =
5959
SelectValidator == hlsl::options::ValidatorSelection::External;
60+
bool bAuto = SelectValidator == hlsl::options::ValidatorSelection::Auto;
6061

61-
if (!bExternal) {
62+
// default behavior uses internal validator, as well as
63+
// explicitly specifying internal
64+
if (bInternal || bAuto) {
6265
IFT(CreateDxcValidator(IID_PPV_ARGS(&pValidator)));
63-
bInternalValidator = true;
66+
return true;
6467
}
6568

66-
if (pValidator == nullptr && DxilLibIsEnabled()) {
67-
IFTBOOL(!bInternal, DXC_E_VALIDATOR_MISSING);
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);
6873
DxilLibCreateInstance(CLSID_DxcValidator, &pValidator);
74+
75+
// if external was explicitly specified, but the validator
76+
// failed to be created, then error.
77+
IFTBOOL(pValidator, DXC_E_VALIDATOR_MISSING);
78+
return false;
6979
}
7080

71-
return bInternalValidator;
81+
return false;
7282
}
7383

7484
} // namespace

0 commit comments

Comments
 (0)