PDB Util shouldn't fail on DXIL with no debug info (#3337)
This commit is contained in:
Родитель
4c66d72760
Коммит
897fee8ba9
|
@ -91,7 +91,7 @@ private:
|
|||
};
|
||||
|
||||
CComPtr<IDxcBlob> m_InputBlob;
|
||||
CComPtr<IDxcBlob> m_pDxilPartBlob;
|
||||
CComPtr<IDxcBlob> m_pDebugProgramBlob;
|
||||
CComPtr<IDxcBlob> m_ContainerBlob;
|
||||
std::vector<Source_File> m_SourceFiles;
|
||||
std::vector<std::wstring> m_Defines;
|
||||
|
@ -104,7 +104,7 @@ private:
|
|||
CComPtr<IDxcBlob> m_HashBlob;
|
||||
|
||||
void Reset() {
|
||||
m_pDxilPartBlob = nullptr;
|
||||
m_pDebugProgramBlob = nullptr;
|
||||
m_InputBlob = nullptr;
|
||||
m_ContainerBlob = nullptr;
|
||||
m_SourceFiles.clear();
|
||||
|
@ -301,25 +301,22 @@ public:
|
|||
|
||||
// PDB
|
||||
if (SUCCEEDED(hlsl::pdb::LoadDataFromStream(m_pMalloc, pStream, &m_ContainerBlob))) {
|
||||
IFR(HandleDxilContainer(m_ContainerBlob, &m_pDxilPartBlob));
|
||||
if (m_pDxilPartBlob) {
|
||||
IFR(HandleDebugProgramHeaderLegacy(m_pDxilPartBlob));
|
||||
IFR(HandleDxilContainer(m_ContainerBlob, &m_pDebugProgramBlob));
|
||||
if (m_pDebugProgramBlob) {
|
||||
IFR(HandleDebugProgramHeaderLegacy(m_pDebugProgramBlob));
|
||||
}
|
||||
else {
|
||||
// Must have a dxil part
|
||||
// Must have a debug program part
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
// DXIL Container
|
||||
else if (hlsl::IsValidDxilContainer((const hlsl::DxilContainerHeader *)pPdbOrDxil->GetBufferPointer(), pPdbOrDxil->GetBufferSize())) {
|
||||
m_ContainerBlob = pPdbOrDxil;
|
||||
IFR(HandleDxilContainer(m_ContainerBlob, &m_pDxilPartBlob));
|
||||
if (m_pDxilPartBlob) {
|
||||
IFR(HandleDebugProgramHeaderLegacy(m_pDxilPartBlob));
|
||||
}
|
||||
else {
|
||||
// Must have a dxil part
|
||||
return E_FAIL;
|
||||
IFR(HandleDxilContainer(m_ContainerBlob, &m_pDebugProgramBlob));
|
||||
// If we have a Debug DXIL, populate the debug info.
|
||||
if (m_pDebugProgramBlob) {
|
||||
IFR(HandleDebugProgramHeaderLegacy(m_pDebugProgramBlob));
|
||||
}
|
||||
}
|
||||
// DXIL program header
|
||||
|
@ -328,8 +325,8 @@ public:
|
|||
IFR(hlsl::DxcCreateBlobWithEncodingFromPinned(
|
||||
(hlsl::DxilProgramHeader *)pPdbOrDxil->GetBufferPointer(),
|
||||
pPdbOrDxil->GetBufferSize(), CP_ACP, &pProgramHeaderBlob));
|
||||
IFR(pProgramHeaderBlob.QueryInterface(&m_pDxilPartBlob));
|
||||
IFR(HandleDebugProgramHeaderLegacy(m_pDxilPartBlob));
|
||||
IFR(pProgramHeaderBlob.QueryInterface(&m_pDebugProgramBlob));
|
||||
IFR(HandleDebugProgramHeaderLegacy(m_pDebugProgramBlob));
|
||||
}
|
||||
else {
|
||||
return E_INVALIDARG;
|
||||
|
@ -387,7 +384,7 @@ public:
|
|||
}
|
||||
|
||||
virtual BOOL STDMETHODCALLTYPE IsFullPDB() override {
|
||||
return m_pDxilPartBlob != nullptr;
|
||||
return m_pDebugProgramBlob != nullptr;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetFullPDB(_COM_Outptr_ IDxcBlob **ppFullPDB) override {
|
||||
|
@ -411,7 +408,7 @@ public:
|
|||
virtual STDMETHODIMP NewDxcPixDxilDebugInfo(
|
||||
_COM_Outptr_ IDxcPixDxilDebugInfo **ppDxilDebugInfo) override
|
||||
{
|
||||
if (!m_pDxilPartBlob)
|
||||
if (!m_pDebugProgramBlob)
|
||||
return E_FAIL;
|
||||
|
||||
DxcThreadMalloc TM(m_pMalloc);
|
||||
|
@ -421,7 +418,7 @@ public:
|
|||
(void **)&pDataSource));
|
||||
|
||||
CComPtr<IStream> pStream;
|
||||
IFR(hlsl::CreateReadOnlyBlobStream(m_pDxilPartBlob, &pStream));
|
||||
IFR(hlsl::CreateReadOnlyBlobStream(m_pDebugProgramBlob, &pStream));
|
||||
|
||||
IFR(pDataSource->loadDataFromIStream(pStream));
|
||||
|
||||
|
|
|
@ -127,6 +127,7 @@ public:
|
|||
TEST_METHOD(CompileWhenWorksThenAddRemovePrivate)
|
||||
TEST_METHOD(CompileThenAddCustomDebugName)
|
||||
TEST_METHOD(CompileThenTestPdbUtils)
|
||||
TEST_METHOD(CompileThenTestPdbUtilsStripped)
|
||||
TEST_METHOD(CompileWithRootSignatureThenStripRootSignature)
|
||||
|
||||
TEST_METHOD(CompileWhenIncludeThenLoadInvoked)
|
||||
|
@ -1107,6 +1108,65 @@ static void VerifyPdbUtil(IDxcPdbUtils *pPdbUtils, bool HasHashAndPdbName, IDxcB
|
|||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
TEST_F(CompilerTest, CompileThenTestPdbUtilsStripped) {
|
||||
CComPtr<TestIncludeHandler> pInclude;
|
||||
CComPtr<IDxcCompiler> pCompiler;
|
||||
CComPtr<IDxcBlobEncoding> pSource;
|
||||
CComPtr<IDxcOperationResult> pOperationResult;
|
||||
|
||||
std::string main_source = "#include \"helper.h\"\r\n"
|
||||
"float4 PSMain() : SV_Target { return ZERO; }";
|
||||
std::string included_File = "#define ZERO 0";
|
||||
|
||||
VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
|
||||
CreateBlobFromText(main_source.c_str(), &pSource);
|
||||
|
||||
pInclude = new TestIncludeHandler(m_dllSupport);
|
||||
pInclude->CallResults.emplace_back(included_File.c_str());
|
||||
|
||||
const WCHAR *pArgs[] = { L"/Zi", L"/Od", L"-flegacy-macro-expansion", L"-Qstrip_debug", L"/DTHIS_IS_A_DEFINE=HELLO" };
|
||||
const DxcDefine pDefines[] = { L"THIS_IS_ANOTHER_DEFINE", L"1" };
|
||||
|
||||
VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"PSMain",
|
||||
L"ps_6_0", pArgs, _countof(pArgs), pDefines, _countof(pDefines), pInclude, &pOperationResult));
|
||||
|
||||
CComPtr<IDxcBlob> pCompiledBlob;
|
||||
VERIFY_SUCCEEDED(pOperationResult->GetResult(&pCompiledBlob));
|
||||
|
||||
CComPtr<IDxcPdbUtils> pPdbUtils;
|
||||
VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcPdbUtils, &pPdbUtils));
|
||||
|
||||
VERIFY_SUCCEEDED(pPdbUtils->Load(pCompiledBlob));
|
||||
|
||||
// PDB file path
|
||||
{
|
||||
CComBSTR pName;
|
||||
VERIFY_SUCCEEDED(pPdbUtils->GetName(&pName));
|
||||
std::wstring suffix = L".pdb";
|
||||
VERIFY_IS_TRUE(pName.Length() >= suffix.size());
|
||||
VERIFY_IS_TRUE(
|
||||
0 == std::memcmp(suffix.c_str(), &pName[pName.Length() - suffix.size()], suffix.size()));
|
||||
}
|
||||
|
||||
// There is hash and hash is not empty
|
||||
{
|
||||
CComPtr<IDxcBlob> pHash;
|
||||
VERIFY_SUCCEEDED(pPdbUtils->GetHash(&pHash));
|
||||
hlsl::DxilShaderHash EmptyHash = {};
|
||||
VERIFY_ARE_EQUAL(pHash->GetBufferSize(), sizeof(EmptyHash));
|
||||
VERIFY_IS_FALSE(0 == std::memcmp(pHash->GetBufferPointer(), &EmptyHash, sizeof(EmptyHash)));
|
||||
}
|
||||
|
||||
{
|
||||
VERIFY_IS_FALSE(pPdbUtils->IsFullPDB());
|
||||
UINT32 uSourceCount = 0;
|
||||
VERIFY_SUCCEEDED(pPdbUtils->GetSourceCount(&uSourceCount));
|
||||
VERIFY_ARE_EQUAL(uSourceCount, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST_F(CompilerTest, CompileThenTestPdbUtils) {
|
||||
CComPtr<TestIncludeHandler> pInclude;
|
||||
CComPtr<IDxcCompiler> pCompiler;
|
||||
|
@ -1142,7 +1202,6 @@ TEST_F(CompilerTest, CompileThenTestPdbUtils) {
|
|||
CComPtr<IDxcBlob> pPdbBlob;
|
||||
VERIFY_SUCCEEDED(pResult->GetOutput(DXC_OUT_PDB, IID_PPV_ARGS(&pPdbBlob), nullptr));
|
||||
|
||||
|
||||
CComPtr<IDxcPdbUtils> pPdbUtils;
|
||||
VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcPdbUtils, &pPdbUtils));
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче