-
Notifications
You must be signed in to change notification settings - Fork 23
/
ID3D10Extensions.h
310 lines (265 loc) · 10.1 KB
/
ID3D10Extensions.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
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
//--------------------------------------------------------------------------------------
// Copyright 2011,2012,2013 Intel Corporation
// All Rights Reserved
//
// Permission is granted to use, copy, distribute and prepare derivative works of this
// software for any purpose and without fee, provided, that the above copyright notice
// and this statement appear in all copies. Intel makes no representations about the
// suitability of this software for any purpose. THIS SOFTWARE IS PROVIDED "AS IS."
// INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, AND ALL LIABILITY,
// INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, FOR THE USE OF THIS SOFTWARE,
// INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY RIGHTS, AND INCLUDING THE
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Intel does not
// assume any responsibility for any errors which may appear in this software nor any
// responsibility to update it.
//--------------------------------------------------------------------------------------
#pragma once
namespace ID3D10
{
/*****************************************************************************\
CONST: EXTENSION_INTERFACE_VERSION
PURPOSE: Version of this header file
\*****************************************************************************/
const UINT EXTENSION_INTERFACE_VERSION_1_0 = 0x00010000;
const UINT EXTENSION_INTERFACE_VERSION = EXTENSION_INTERFACE_VERSION_1_0;
/*****************************************************************************\
CONST: CAPS_EXTENSION_KEY
PURPOSE: KEY to pass to UMD
\*****************************************************************************/
const char CAPS_EXTENSION_KEY[ 16 ] = {
'I','N','T','C',
'E','X','T','N',
'C','A','P','S',
'F','U','N','C' };
/*****************************************************************************\
TYPEDEF: PFND3D10UMDEXT_CHECKEXTENSIONSUPPORT
PURPOSE: Function pointer for shader flag extensions
\*****************************************************************************/
typedef BOOL( APIENTRY* PFND3D10UMDEXT_CHECKEXTENSIONSUPPORT )( UINT );
/*****************************************************************************\
STRUCT: EXTENSION_BASE
PURPOSE: Base data structure for extension initialization data
\*****************************************************************************/
struct EXTENSION_BASE
{
// Input:
char Key[ 16 ]; // CAPS_EXTENSION_KEY
UINT ApplicationVersion; // EXTENSION_INTERFACE_VERSION
};
/*****************************************************************************\
STRUCT: CAPS_EXTENSION_1_0
PURPOSE: Caps data structure
\*****************************************************************************/
struct CAPS_EXTENSION_1_0 : EXTENSION_BASE
{
// Output:
UINT DriverVersion; // EXTENSION_INTERFACE_VERSION
UINT DriverBuildNumber; // BUILD_NUMBER
};
typedef CAPS_EXTENSION_1_0 CAPS_EXTENSION;
#ifndef D3D10_UMD
/*****************************************************************************\
FUNCTION: GetExtensionCaps
PURPOSE: Gets extension caps table from Intel graphics driver
\*****************************************************************************/
inline HRESULT GetExtensionCaps(
ID3D11Device* pd3dDevice,
CAPS_EXTENSION* pCaps )
{
D3D11_BUFFER_DESC desc;
ZeroMemory( &desc, sizeof( desc ) );
desc.ByteWidth = sizeof( CAPS_EXTENSION );
desc.Usage = D3D11_USAGE_STAGING;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
D3D11_SUBRESOURCE_DATA initData;
initData.pSysMem = pCaps;
initData.SysMemPitch = sizeof( CAPS_EXTENSION );
initData.SysMemSlicePitch = 0;
ZeroMemory( pCaps, sizeof( CAPS_EXTENSION ) );
memcpy( pCaps->Key, CAPS_EXTENSION_KEY,
sizeof( pCaps->Key ) );
pCaps->ApplicationVersion = EXTENSION_INTERFACE_VERSION;
ID3D11Buffer* pBuffer = NULL;
HRESULT result = pd3dDevice->CreateBuffer(
&desc,
&initData,
&pBuffer );
if( pBuffer )
pBuffer->Release();
if( S_OK == result )
{
result = ( pCaps->ApplicationVersion <= pCaps->DriverVersion ) ? S_OK : S_FALSE;
}
return result;
};
#endif
/*****************************************************************************\
CONST: RESOURCE_EXTENSION_KEY
PURPOSE: KEY to pass to UMD
\*****************************************************************************/
const char RESOURCE_EXTENSION_KEY[ 16 ] = {
'I','N','T','C',
'E','X','T','N',
'R','E','S','O',
'U','R','C','E' };
/*****************************************************************************\
ENUM: RESOURCE_EXTENSION_TYPE
PURPOSE: Enumeration of supported resource extensions
\*****************************************************************************/
enum RESOURCE_EXTENSION_TYPE
{
RESOURCE_EXTENSION_RESERVED = 0,
// Version 1_0
RESOURCE_EXTENSION_DIRECT_ACCESS = 1,
};
/*****************************************************************************\
ENUM: RESOURCE_EXTENSION_FLAGS
PURPOSE: Enumeration for extra information
\*****************************************************************************/
enum RESOURCE_EXTENSION_FLAGS
{
RESOURCE_EXTENSION_DIRECT_ACCESS_LINEAR_ALLOCATION = 0x1,
};
/*****************************************************************************\
STRUCT: RESOURCE_EXTENSION_1_0
PURPOSE: Resource extension interface structure
\*****************************************************************************/
struct RESOURCE_EXTENSION_1_0 : EXTENSION_BASE
{
// Input:
// Enumeration of the extension
UINT Type; // RESOURCE_EXTENSION_TYPE
// Extension data
UINT Data[ 16 ];
};
typedef RESOURCE_EXTENSION_1_0 RESOURCE_EXTENSION;
/*****************************************************************************\
STRUCT: RESOURCE_DIRECT_ACCESS_MAP_DATA
PURPOSE: Direct Access Resource extension Map structure
\*****************************************************************************/
struct RESOURCE_DIRECT_ACCESS_MAP_DATA
{
void* pBaseAddress;
UINT XOffset;
UINT YOffset;
UINT TileFormat;
UINT Pitch;
UINT Size;
};
#ifndef D3D10_UMD
/*****************************************************************************\
FUNCTION: SetResouceExtension
PURPOSE: Resource extension interface
\*****************************************************************************/
inline HRESULT SetResouceExtension(
ID3D11Device* pd3dDevice,
const RESOURCE_EXTENSION* pExtnDesc )
{
D3D11_BUFFER_DESC desc;
ZeroMemory( &desc, sizeof( desc ) );
desc.ByteWidth = sizeof( RESOURCE_EXTENSION );
desc.Usage = D3D11_USAGE_STAGING;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
D3D11_SUBRESOURCE_DATA initData;
ZeroMemory( &initData, sizeof( initData ) );
initData.pSysMem = pExtnDesc;
initData.SysMemPitch = sizeof( RESOURCE_EXTENSION );
initData.SysMemSlicePitch = 0;
ID3D11Buffer* pBuffer = NULL;
HRESULT result = pd3dDevice->CreateBuffer(
&desc,
&initData,
&pBuffer );
if( pBuffer )
pBuffer->Release();
return result;
}
/*****************************************************************************\
FUNCTION: SetDirectAccessResouceExtension
PURPOSE: Direct Access Resource extension interface
\*****************************************************************************/
inline HRESULT SetDirectAccessResouceExtension(
ID3D11Device* pd3dDevice,
const UINT flags )
{
RESOURCE_EXTENSION extnDesc;
ZeroMemory( &extnDesc, sizeof( extnDesc ) );
memcpy( &extnDesc.Key[ 0 ], RESOURCE_EXTENSION_KEY,
sizeof( extnDesc.Key ) );
extnDesc.ApplicationVersion = EXTENSION_INTERFACE_VERSION;
extnDesc.Type = RESOURCE_EXTENSION_DIRECT_ACCESS;
extnDesc.Data[ 0 ] = flags;
return SetResouceExtension( pd3dDevice, &extnDesc );
}
#endif
/*****************************************************************************\
CONST: STATE_EXTENSION_KEY
PURPOSE: KEY to pass to UMD
\*****************************************************************************/
const char STATE_EXTENSION_KEY[ 16 ] = {
'I','N','T','C',
'E','X','T','N',
'S','T','A','T',
'E','O','B','J' };
/*****************************************************************************\
ENUM: STATE_EXTENSION_TYPE
PURPOSE: Enumeration of supported state extensions
\*****************************************************************************/
enum STATE_EXTENSION_TYPE
{
STATE_EXTENSION_RESERVED = 0,
// Version 1_0
};
/*****************************************************************************\
STRUCT: STATE_EXTENSION_1_0
PURPOSE: UMD extension interface structure
\*****************************************************************************/
struct STATE_EXTENSION_1_0 : EXTENSION_BASE
{
// Input:
// Enumeration of the extension
UINT Type; // STATE_EXTENSION_TYPE
// Extension data
UINT Data[ 16 ];
};
typedef STATE_EXTENSION_1_0 STATE_EXTENSION;
#ifndef D3D10_UMD
/*****************************************************************************\
FUNCTION: SetStateExtension
PURPOSE: State extension interface
\*****************************************************************************/
inline HRESULT SetStateExtension(
ID3D11Device* pd3dDevice,
const STATE_EXTENSION* pExtnDesc )
{
D3D11_BUFFER_DESC desc;
ZeroMemory( &desc, sizeof( desc ) );
desc.ByteWidth = sizeof( STATE_EXTENSION );
desc.Usage = D3D11_USAGE_STAGING;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
D3D11_SUBRESOURCE_DATA initData;
ZeroMemory( &initData, sizeof( initData ) );
initData.pSysMem = pExtnDesc;
initData.SysMemPitch = sizeof( STATE_EXTENSION );
initData.SysMemSlicePitch = 0;
ID3D11Buffer* pBuffer = NULL;
HRESULT result = pd3dDevice->CreateBuffer(
&desc,
&initData,
&pBuffer );
if( pBuffer )
pBuffer->Release();
return result;
}
#endif
/*****************************************************************************\
ENUM: SHADER_EXTENSION_TYPE
PURPOSE: Enumeration of supported shader extensions
\*****************************************************************************/
enum SHADER_EXTENSION_TYPE
{
SHADER_EXTENSION_RESERVED = 0,
// Version 1_0
SHADER_EXTENSION_PIXEL_SHADER_ORDERING = 1,
};
} // namespace ID3D10