-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcpphelper.h
67 lines (59 loc) · 1.21 KB
/
cpphelper.h
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#pragma once
#include <vector>
#include <string>
#include <sstream>
#include <d3d11.h>
#include <d3d11_1.h>
#include <d3d11_2.h>
#include <d3d11_3.h>
#include <d3d11_4.h>
#include <d3dcompiler.h>
#include <dxgi.h>
#include <dxgi1_2.h>
#include <dxgi1_3.h>
#include <dxgidebug.h>
#include <unordered_map>
#include <map>
#include <fstream>
#include <assert.h>
#include <mutex>
#include <atomic>
#include <thread>
char const *blobIn();
template<typename T>
T const *getInBlobPtr(size_t offset)
{
if (!offset)
{
return nullptr;
}
auto blob = blobIn();
return (T *)&blob[offset];
}
template<typename T>
T const &getInBlobRef(size_t offset)
{
auto blob = blobIn();
return *(T const *)&blob[offset];
}
std::unordered_map<size_t, size_t> &getInterfaceTable();
struct MapDesc
{
char *pData;
size_t size;
};
// pResource -> subresourceID -> MapDesc
std::map<std::pair<ID3D11Resource *, UINT>, MapDesc> &getMapTable();
template<typename T> T *getInterface(size_t index)
{
if (!index)
{
return nullptr;
}
assert(getInterfaceTable().find(index) != getInterfaceTable().end());
return (T*)getInterfaceTable().find(index)->second;
}
static void setInterface(size_t index, void *ptr)
{
getInterfaceTable()[index] = (size_t)ptr;
}