Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/dxc/Support/HLSLOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ struct RewriterOpts {
};

enum class ValidatorSelection : int {
Auto, // Try DXIL.dll; fallback to internal validator
Auto, // Force internal validator (even if DXIL.dll is present)
Internal, // Force internal validator (even if DXIL.dll is present)
External, // Use DXIL.dll, failing compilation if not available
Invalid = -1 // Invalid
Expand Down
24 changes: 17 additions & 7 deletions tools/clang/tools/dxcompiler/dxcutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,33 @@ HRESULT RunInternalValidator(IDxcValidator *pValidator,
namespace {
// AssembleToContainer helper functions.

// return true if the internal validator was used, false otherwise
bool CreateValidator(CComPtr<IDxcValidator> &pValidator,
hlsl::options::ValidatorSelection SelectValidator =
hlsl::options::ValidatorSelection::Auto) {
bool bInternal =
SelectValidator == hlsl::options::ValidatorSelection::Internal;
bool bExternal =
SelectValidator == hlsl::options::ValidatorSelection::External;
if (!bInternal && DxilLibIsEnabled())
DxilLibCreateInstance(CLSID_DxcValidator, &pValidator);
bool bAuto = SelectValidator == hlsl::options::ValidatorSelection::Auto;

bool bInternalValidator = false;
if (pValidator == nullptr) {
IFTBOOL(!bExternal, DXC_E_VALIDATOR_MISSING);
// default behavior uses internal validator, as well as
// explicitly specifying internal
if (bInternal || bAuto) {
IFT(CreateDxcValidator(IID_PPV_ARGS(&pValidator)));
bInternalValidator = true;
return true;
}

if (bExternal) {
// if external was explicitly specified, but no
// external validator could be found (no DXIL.dll), then error
IFTBOOL(!DxilLibIsEnabled(), DXC_E_VALIDATOR_MISSING);
IFT(DxilLibCreateInstance(CLSID_DxcValidator, &pValidator));

return false;
}
return bInternalValidator;

return false;
}

} // namespace
Expand Down