-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDXXModule.h
More file actions
executable file
·227 lines (180 loc) · 6.05 KB
/
Copy pathDXXModule.h
File metadata and controls
executable file
·227 lines (180 loc) · 6.05 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
//==============================================================================
// Copyright (c) 2011-2016 Advanced Micro Devices, Inc. All rights reserved.
/// \author AMD Developer Tools
/// \file
/// \brief This class manages the dynamic loading of atidxx{32,64}.dll
//==============================================================================
#ifndef _DXX_MODULE_H_
#define _DXX_MODULE_H_
#ifndef _WIN32
#error "This makes no sense if you are not on Windows."
#endif
#include "AmdDxGsaCompile.h"
#include "DynamicLibraryModule.h"
#define AMDDXX_INTERFACE_TABLE \
X(AmdDxGsaCompileShader) \
X(AmdDxGsaFreeCompiledShader)
// These are also present, but I don't immediately have their prototypes.
// I also don't need them to get started.
// TODO: complete this later?
// X(AmdDxExtCreate) \
// X(AmdDxExtCreate11) \
// X(OpenAdapter10) \
// X(OpenAdapter10_2) \
// X(XdxInitXopAdapterServices) \
// X(XdxInitXopServices)
/// This class handles the dynamic loading of atidxx{32,64}.dll
/// \note There will typically be one of these objects.
/// That instance will be global.
/// There is a trap for the unwary.
/// The order of global ctors is only defined within a single compilation unit.
/// So, one should not use these interfaces before "main" is reached.
/// This is different than calling these functions when the .dll/.so is linked against.
class AMDDXXModule
{
public:
/// Default name to use for construction.
/// This is usually aticaldd.dll or libaticaldd.so.
static const char* s_DefaultModuleName;
/// Constructor
/// \param module to load.
AMDDXXModule(const std::string& moduleName);
AMDDXXModule();
/// destructor
~AMDDXXModule();
/// Load module.
/// \param[in] name The module name.
/// \return true if successful, false otherwise
bool LoadModule(const std::string& name = s_DefaultModuleName);
/// Unload the caldd shared image.
void UnloadModule();
/// Have we sucessfully loaded the cal module?
/// \returns enumeration value to answer query.
bool IsLoaded() { return m_ModuleLoaded; }
#define X(SYM) Pfn##SYM SYM;
AMDDXX_INTERFACE_TABLE;
#undef X
private:
/// Initialize the internal data
void Initialize();
/// Have we loaded the CAL module?
bool m_ModuleLoaded;
/// Helper.
DynamicLibraryModule m_DynamicLibraryHelper;
};
// Interface to D3DCompiler_xx.dll
#include <D3Dcompiler.h>
#define D3DCOMPILE_INTERFACE_TABLE \
X(D3DCompile) \
X(D3DCompressShaders) \
X(D3DCreateBlob) \
X(D3DDecompressShaders) \
X(D3DDisassemble) \
X(D3DDisassemble10Effect) \
X(D3DGetBlobPart) \
X(D3DGetDebugInfo) \
X(D3DGetInputAndOutputSignatureBlob) \
X(D3DGetInputSignatureBlob) \
X(D3DGetOutputSignatureBlob) \
X(D3DPreprocess) \
X(D3DReflect) \
X(D3DStripShader)
// Missing from the header file.
// X(D3DAssemble)
// X(D3DReturnFailure1)
// X(DebugSetMute)
// pointer prototypes.
// the header file defines some of these, but most are missing.
typedef HRESULT(WINAPI* pD3DGetDebugInfo)
(LPCVOID pSrcData,
SIZE_T SrcDataSize,
ID3DBlob** ppDebugInfo);
typedef HRESULT(WINAPI* pD3DReflect)
(LPCVOID pSrcData,
SIZE_T SrcDataSize,
REFIID pInterface,
void** ppReflector);
typedef HRESULT(WINAPI* pD3DDisassemble10Effect)
(ID3D10Effect* pEffect,
UINT Flags,
ID3DBlob** ppDisassembly);
typedef HRESULT(WINAPI* pD3DGetInputSignatureBlob)
(LPCVOID pSrcData,
SIZE_T SrcDataSize,
ID3DBlob** ppSignatureBlob);
typedef HRESULT(WINAPI* pD3DGetOutputSignatureBlob)
(LPCVOID pSrcData,
SIZE_T SrcDataSize,
ID3DBlob** ppSignatureBlob);
typedef HRESULT(WINAPI* pD3DGetInputAndOutputSignatureBlob)
(LPCVOID pSrcData,
SIZE_T SrcDataSize,
ID3DBlob** ppSignatureBlob);
typedef HRESULT(WINAPI* pD3DStripShader)
(LPCVOID pShaderBytecode,
SIZE_T BytecodeLength,
UINT uStripFlags,
ID3DBlob** ppStrippedBlob);
typedef HRESULT(WINAPI* pD3DGetBlobPart)
(LPCVOID pSrcData,
SIZE_T SrcDataSize,
D3D_BLOB_PART Part,
UINT Flags,
ID3DBlob** ppPart);
typedef HRESULT(WINAPI* pD3DCompressShaders)
(UINT uNumShaders,
D3D_SHADER_DATA* pShaderData,
UINT uFlags,
ID3DBlob** ppCompressedData);
typedef HRESULT(WINAPI* pD3DDecompressShaders)
(__in_bcount(SrcDataSize) LPCVOID pSrcData,
SIZE_T SrcDataSize,
UINT uNumShaders,
UINT uStartIndex,
UINT* pIndices,
UINT uFlags,
ID3DBlob** ppShaders,
UINT* pTotalShaders);
typedef HRESULT(WINAPI* pD3DCreateBlob)
(SIZE_T Size,
ID3DBlob** ppBlob);
/// This class handles the dynamic loading of D3DCompiler_xx.dll
/// \note There will typically be one of these objects.
/// That instance will be global.
/// There is a trap for the unwary.
/// The order of global ctors is only defined within a single compilation unit.
/// So, one should not use these interfaces before "main" is reached.
/// This is different than calling these functions when the .dll/.so is linked against.
class D3DCompileModule
{
public:
/// Default name to use for construction.
/// This is usually aticaldd.dll or libaticaldd.so.
static const char* s_DefaultModuleName;
/// Constructor
/// \param module to load.
D3DCompileModule(const std::string& moduleName);
/// destructor
~D3DCompileModule();
/// Load module.
/// \param[in] name The module name.
/// \param[in] pErrorCode Error code if error occurred loading the module.
/// \return true if successful, false otherwise
bool LoadModule(const std::string& name = s_DefaultModuleName, int* pErrorCode = NULL);
/// Unload the caldd shared image.
void UnloadModule();
/// Have we sucessfully loaded the cal module?
/// \returns enumeration value to answer query.
bool IsLoaded() const { return m_isModuleLoaded; }
#define X(SYM) p##SYM SYM;
D3DCOMPILE_INTERFACE_TABLE;
#undef X
private:
/// Initialize the internal data
void Initialize();
/// Have we loaded the CAL module?
bool m_isModuleLoaded;
/// Helper.
DynamicLibraryModule m_DynamicLibraryHelper;
};
#endif