Set !dx.valver in Linker (#1031)
This commit is contained in:
Родитель
88b02078a1
Коммит
acf2bc48d9
|
@ -33,7 +33,7 @@ class DxilResourceBase;
|
|||
class DxilLinker {
|
||||
public:
|
||||
virtual ~DxilLinker() {}
|
||||
static DxilLinker *CreateLinker(llvm::LLVMContext &Ctx);
|
||||
static DxilLinker *CreateLinker(llvm::LLVMContext &Ctx, unsigned valMajor, unsigned valMinor);
|
||||
|
||||
virtual bool HasLibNameRegistered(llvm::StringRef name) = 0;
|
||||
virtual bool RegisterLib(llvm::StringRef name,
|
||||
|
@ -47,8 +47,9 @@ public:
|
|||
llvm::StringRef profile) = 0;
|
||||
|
||||
protected:
|
||||
DxilLinker(llvm::LLVMContext &Ctx) : m_ctx(Ctx) {}
|
||||
DxilLinker(llvm::LLVMContext &Ctx, unsigned valMajor, unsigned valMinor) : m_ctx(Ctx), m_valMajor(valMajor), m_valMinor(valMinor) {}
|
||||
llvm::LLVMContext &m_ctx;
|
||||
unsigned m_valMajor, m_valMinor;
|
||||
};
|
||||
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -127,7 +127,7 @@ struct DxilLinkJob;
|
|||
|
||||
class DxilLinkerImpl : public hlsl::DxilLinker {
|
||||
public:
|
||||
DxilLinkerImpl(LLVMContext &Ctx) : DxilLinker(Ctx) {}
|
||||
DxilLinkerImpl(LLVMContext &Ctx, unsigned valMajor, unsigned valMinor) : DxilLinker(Ctx, valMajor, valMinor) {}
|
||||
virtual ~DxilLinkerImpl() {}
|
||||
bool HasLibNameRegistered(StringRef name) override;
|
||||
bool RegisterLib(StringRef name, std::unique_ptr<llvm::Module> pModule,
|
||||
|
@ -315,7 +315,7 @@ DxilResourceBase *DxilLib::GetResource(const llvm::Constant *GV) {
|
|||
namespace {
|
||||
// Create module from link defines.
|
||||
struct DxilLinkJob {
|
||||
DxilLinkJob(LLVMContext &Ctx) : m_ctx(Ctx) {}
|
||||
DxilLinkJob(LLVMContext &Ctx, unsigned valMajor, unsigned valMinor) : m_ctx(Ctx), m_valMajor(valMajor), m_valMinor(valMinor) {}
|
||||
std::unique_ptr<llvm::Module>
|
||||
Link(std::pair<DxilFunctionLinkInfo *, DxilLib *> &entryLinkPair,
|
||||
StringRef profile);
|
||||
|
@ -336,6 +336,7 @@ private:
|
|||
llvm::StringMap<std::pair<DxilResourceBase *, llvm::GlobalVariable *>>
|
||||
m_resourceMap;
|
||||
LLVMContext &m_ctx;
|
||||
unsigned m_valMajor, m_valMinor;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
@ -350,6 +351,7 @@ const char kNoEntryProps[] =
|
|||
"Cannot find function property for entry function ";
|
||||
const char kRedefineResource[] =
|
||||
"Resource already exists as ";
|
||||
const char kInvalidValidatorVersion[] = "Validator version does not support target profile ";
|
||||
} // namespace
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -540,6 +542,16 @@ DxilLinkJob::Link(std::pair<DxilFunctionLinkInfo *, DxilLib *> &entryLinkPair,
|
|||
const bool bSkipInit = true;
|
||||
DxilModule &DM = pM->GetOrCreateDxilModule(bSkipInit);
|
||||
DM.SetShaderModel(pSM);
|
||||
|
||||
// Set Validator version, verifying that it supports the requested profile
|
||||
unsigned minValMajor, minValMinor;
|
||||
DM.GetMinValidatorVersion(minValMajor, minValMinor);
|
||||
if (minValMajor > m_valMajor || (minValMajor == m_valMajor && minValMinor > m_valMinor)) {
|
||||
m_ctx.emitError(Twine(kInvalidValidatorVersion) + profile);
|
||||
return nullptr;
|
||||
}
|
||||
DM.SetValidatorVersion(m_valMajor, m_valMinor);
|
||||
|
||||
// Add type sys
|
||||
DxilTypeSystem &typeSys = DM.GetTypeSystem();
|
||||
|
||||
|
@ -891,7 +903,7 @@ std::unique_ptr<llvm::Module> DxilLinkerImpl::Link(StringRef entry,
|
|||
SmallVector<StringRef, 4> workList;
|
||||
workList.emplace_back(entry);
|
||||
|
||||
DxilLinkJob linkJob(m_ctx);
|
||||
DxilLinkJob linkJob(m_ctx, m_valMajor, m_valMinor);
|
||||
|
||||
DenseSet<DxilLib *> libSet;
|
||||
if (!AddFunctions(workList, libSet, addedFunctionSet, linkJob,
|
||||
|
@ -922,7 +934,7 @@ std::unique_ptr<llvm::Module> DxilLinkerImpl::Link(StringRef entry,
|
|||
|
||||
namespace hlsl {
|
||||
|
||||
DxilLinker *DxilLinker::CreateLinker(LLVMContext &Ctx) {
|
||||
return new DxilLinkerImpl(Ctx);
|
||||
DxilLinker *DxilLinker::CreateLinker(LLVMContext &Ctx, unsigned valMajor, unsigned valMinor) {
|
||||
return new DxilLinkerImpl(Ctx, valMajor, valMinor);
|
||||
}
|
||||
} // namespace hlsl
|
|
@ -91,7 +91,9 @@ public:
|
|||
}
|
||||
|
||||
void Initialize() {
|
||||
m_pLinker.reset(DxilLinker::CreateLinker(m_Ctx));
|
||||
UINT32 valMajor, valMinor;
|
||||
dxcutil::GetValidatorVersion(&valMajor, &valMinor);
|
||||
m_pLinker.reset(DxilLinker::CreateLinker(m_Ctx, valMajor, valMinor));
|
||||
}
|
||||
|
||||
~DxcLinker() {
|
||||
|
@ -182,19 +184,8 @@ HRESULT STDMETHODCALLTYPE DxcLinker::Link(
|
|||
|
||||
std::string warnings;
|
||||
llvm::raw_string_ostream w(warnings);
|
||||
|
||||
{
|
||||
UINT32 majorVer, minorVer;
|
||||
dxcutil::GetValidatorVersion(&majorVer, &minorVer);
|
||||
// TODO: use validation version when link.
|
||||
(majorVer);
|
||||
(minorVer);
|
||||
}
|
||||
|
||||
IFT(CreateMemoryStream(pMalloc, &pDiagStream));
|
||||
|
||||
raw_stream_ostream DiagStream(pDiagStream);
|
||||
|
||||
llvm::DiagnosticPrinterRawOStream DiagPrinter(DiagStream);
|
||||
PrintDiagnosticContext DiagContext(DiagPrinter);
|
||||
m_Ctx.setDiagnosticHandler(PrintDiagnosticContext::PrintDiagnosticHandler,
|
||||
|
|
Загрузка…
Ссылка в новой задаче