-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDxgiInfoManager.cpp
More file actions
53 lines (45 loc) · 1.58 KB
/
Copy pathDxgiInfoManager.cpp
File metadata and controls
53 lines (45 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "DxgiInfoManager.h"
#include "Window.h"
#include "Graphics.h"
#include <dxgidebug.h>
#include <memory>
#pragma comment(lib, "dxguid.lib")
#define GFX_THROW_NOINFO(hrcall) if( FAILED( hr = (hrcall) ) ) throw Graphics::HrException( __LINE__,__FILE__,hr )
DxgiInfoManager::DxgiInfoManager()
{
typedef HRESULT(WINAPI* DXGIGetDebugInterface)(REFIID, void**);
const auto hModDxgiDebug = LoadLibraryEx("dxgidebug.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
if (hModDxgiDebug == nullptr)
{
throw MMWND_LAST_EXCEPT();
}
const auto DxgiGetDebugInterface = reinterpret_cast<DXGIGetDebugInterface>(
reinterpret_cast<void*>(GetProcAddress(hModDxgiDebug, "DXGIGetDebugInterface"))
);
if (DxgiGetDebugInterface == nullptr)
{
throw MMWND_LAST_EXCEPT();
}
HRESULT hr;
GFX_THROW_NOINFO(DxgiGetDebugInterface(__uuidof(IDXGIInfoQueue), &pDxgiInfoQueue));
}
void DxgiInfoManager::Set() noexcept
{
next = pDxgiInfoQueue->GetNumStoredMessages(DXGI_DEBUG_ALL);
}
std::vector<std::string> DxgiInfoManager::GetMessages() const
{
std::vector<std::string> messages;
const auto end = pDxgiInfoQueue->GetNumStoredMessages(DXGI_DEBUG_ALL);
for (auto i = next; i < end; i++)
{
HRESULT hr;
SIZE_T messageLength;
GFX_THROW_NOINFO(pDxgiInfoQueue->GetMessage(DXGI_DEBUG_ALL, i, nullptr, &messageLength));
auto bytes = std::make_unique<byte[]>(messageLength);
auto pMessage = reinterpret_cast<DXGI_INFO_QUEUE_MESSAGE*>(bytes.get());
GFX_THROW_NOINFO(pDxgiInfoQueue->GetMessage(DXGI_DEBUG_ALL, i, pMessage, &messageLength));
messages.emplace_back(pMessage->pDescription);
}
return messages;
}