Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | pmbaty | 1 | |
2 | ////////////////////////////////////////////////////////////////////////////// |
||
3 | // |
||
4 | // Copyright (c) Microsoft Corporation. All rights reserved. |
||
5 | // |
||
6 | // File: D3DX11GPGPU.h |
||
7 | // Content: D3DX11 General Purpose GPU computing algorithms |
||
8 | // |
||
9 | ////////////////////////////////////////////////////////////////////////////// |
||
10 | |||
11 | #ifndef __D3DX11GPGPU_H__ |
||
12 | #define __D3DX11GPGPU_H__ |
||
13 | |||
14 | #include "d3dx11.h" |
||
15 | |||
16 | #ifdef __cplusplus |
||
17 | extern "C" { |
||
18 | #endif //__cplusplus |
||
19 | |||
20 | |||
21 | |||
22 | |||
23 | |||
24 | |||
25 | ////////////////////////////////////////////////////////////////////////////// |
||
26 | |||
27 | typedef enum D3DX11_SCAN_DATA_TYPE |
||
28 | { |
||
29 | D3DX11_SCAN_DATA_TYPE_FLOAT = 1, |
||
30 | D3DX11_SCAN_DATA_TYPE_INT, |
||
31 | D3DX11_SCAN_DATA_TYPE_UINT, |
||
32 | } D3DX11_SCAN_DATA_TYPE; |
||
33 | |||
34 | typedef enum D3DX11_SCAN_OPCODE |
||
35 | { |
||
36 | D3DX11_SCAN_OPCODE_ADD = 1, |
||
37 | D3DX11_SCAN_OPCODE_MIN, |
||
38 | D3DX11_SCAN_OPCODE_MAX, |
||
39 | D3DX11_SCAN_OPCODE_MUL, |
||
40 | D3DX11_SCAN_OPCODE_AND, |
||
41 | D3DX11_SCAN_OPCODE_OR, |
||
42 | D3DX11_SCAN_OPCODE_XOR, |
||
43 | } D3DX11_SCAN_OPCODE; |
||
44 | |||
45 | typedef enum D3DX11_SCAN_DIRECTION |
||
46 | { |
||
47 | D3DX11_SCAN_DIRECTION_FORWARD = 1, |
||
48 | D3DX11_SCAN_DIRECTION_BACKWARD, |
||
49 | } D3DX11_SCAN_DIRECTION; |
||
50 | |||
51 | |||
52 | ////////////////////////////////////////////////////////////////////////////// |
||
53 | // ID3DX11Scan: |
||
54 | ////////////////////////////////////////////////////////////////////////////// |
||
55 | |||
56 | // {5089b68f-e71d-4d38-be8e-f363b95a9405} |
||
57 | DEFINE_GUID(IID_ID3DX11Scan, 0x5089b68f, 0xe71d, 0x4d38, 0xbe, 0x8e, 0xf3, 0x63, 0xb9, 0x5a, 0x94, 0x05); |
||
58 | |||
59 | #undef INTERFACE |
||
60 | #define INTERFACE ID3DX11Scan |
||
61 | |||
62 | DECLARE_INTERFACE_(ID3DX11Scan, IUnknown) |
||
63 | { |
||
64 | // IUnknown |
||
65 | STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; |
||
66 | STDMETHOD_(ULONG, AddRef)(THIS) PURE; |
||
67 | STDMETHOD_(ULONG, Release)(THIS) PURE; |
||
68 | |||
69 | // ID3DX11Scan |
||
70 | |||
71 | STDMETHOD(SetScanDirection)(THIS_ D3DX11_SCAN_DIRECTION Direction) PURE; |
||
72 | |||
73 | //============================================================================= |
||
74 | // Performs an unsegmented scan of a sequence in-place or out-of-place |
||
75 | // ElementType element type |
||
76 | // OpCode binary operation |
||
77 | // Direction scan direction |
||
78 | // ElementScanSize size of scan, in elements |
||
79 | // pSrc input sequence on the device. pSrc==pDst for in-place scans |
||
80 | // pDst output sequence on the device |
||
81 | //============================================================================= |
||
82 | STDMETHOD(Scan)( THIS_ |
||
83 | D3DX11_SCAN_DATA_TYPE ElementType, |
||
84 | D3DX11_SCAN_OPCODE OpCode, |
||
85 | UINT ElementScanSize, |
||
86 | __in ID3D11UnorderedAccessView* pSrc, |
||
87 | __in ID3D11UnorderedAccessView* pDst |
||
88 | ) PURE; |
||
89 | |||
90 | //============================================================================= |
||
91 | // Performs a multiscan of a sequence in-place or out-of-place |
||
92 | // ElementType element type |
||
93 | // OpCode binary operation |
||
94 | // Direction scan direction |
||
95 | // ElementScanSize size of scan, in elements |
||
96 | // ElementScanPitch pitch of the next scan, in elements |
||
97 | // ScanCount number of scans in a multiscan |
||
98 | // pSrc input sequence on the device. pSrc==pDst for in-place scans |
||
99 | // pDst output sequence on the device |
||
100 | //============================================================================= |
||
101 | STDMETHOD(Multiscan)( THIS_ |
||
102 | D3DX11_SCAN_DATA_TYPE ElementType, |
||
103 | D3DX11_SCAN_OPCODE OpCode, |
||
104 | UINT ElementScanSize, |
||
105 | UINT ElementScanPitch, |
||
106 | UINT ScanCount, |
||
107 | __in ID3D11UnorderedAccessView* pSrc, |
||
108 | __in ID3D11UnorderedAccessView* pDst |
||
109 | ) PURE; |
||
110 | }; |
||
111 | |||
112 | |||
113 | //============================================================================= |
||
114 | // Creates a scan context |
||
115 | // pDevice the device context |
||
116 | // MaxElementScanSize maximum single scan size, in elements (FLOAT, UINT, or INT) |
||
117 | // MaxScanCount maximum number of scans in multiscan |
||
118 | // ppScanContext new scan context |
||
119 | //============================================================================= |
||
120 | HRESULT WINAPI D3DX11CreateScan( |
||
121 | __in ID3D11DeviceContext* pDeviceContext, |
||
122 | UINT MaxElementScanSize, |
||
123 | UINT MaxScanCount, |
||
124 | __out ID3DX11Scan** ppScan ); |
||
125 | |||
126 | |||
127 | |||
128 | ////////////////////////////////////////////////////////////////////////////// |
||
129 | // ID3DX11SegmentedScan: |
||
130 | ////////////////////////////////////////////////////////////////////////////// |
||
131 | |||
132 | // {a915128c-d954-4c79-bfe1-64db923194d6} |
||
133 | DEFINE_GUID(IID_ID3DX11SegmentedScan, 0xa915128c, 0xd954, 0x4c79, 0xbf, 0xe1, 0x64, 0xdb, 0x92, 0x31, 0x94, 0xd6); |
||
134 | |||
135 | #undef INTERFACE |
||
136 | #define INTERFACE ID3DX11SegmentedScan |
||
137 | |||
138 | DECLARE_INTERFACE_(ID3DX11SegmentedScan, IUnknown) |
||
139 | { |
||
140 | // IUnknown |
||
141 | STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; |
||
142 | STDMETHOD_(ULONG, AddRef)(THIS) PURE; |
||
143 | STDMETHOD_(ULONG, Release)(THIS) PURE; |
||
144 | |||
145 | // ID3DX11SegmentedScan |
||
146 | |||
147 | STDMETHOD(SetScanDirection)(THIS_ D3DX11_SCAN_DIRECTION Direction) PURE; |
||
148 | |||
149 | //============================================================================= |
||
150 | // Performs a segscan of a sequence in-place or out-of-place |
||
151 | // ElementType element type |
||
152 | // OpCode binary operation |
||
153 | // Direction scan direction |
||
154 | // pSrcElementFlags compact array of bits, one per element of pSrc. A set value |
||
155 | // indicates the start of a new segment. |
||
156 | // ElementScanSize size of scan, in elements |
||
157 | // pSrc input sequence on the device. pSrc==pDst for in-place scans |
||
158 | // pDst output sequence on the device |
||
159 | //============================================================================= |
||
160 | STDMETHOD(SegScan)( THIS_ |
||
161 | D3DX11_SCAN_DATA_TYPE ElementType, |
||
162 | D3DX11_SCAN_OPCODE OpCode, |
||
163 | UINT ElementScanSize, |
||
164 | __in_opt ID3D11UnorderedAccessView* pSrc, |
||
165 | __in ID3D11UnorderedAccessView* pSrcElementFlags, |
||
166 | __in ID3D11UnorderedAccessView* pDst |
||
167 | ) PURE; |
||
168 | }; |
||
169 | |||
170 | |||
171 | //============================================================================= |
||
172 | // Creates a segmented scan context |
||
173 | // pDevice the device context |
||
174 | // MaxElementScanSize maximum single scan size, in elements (FLOAT, UINT, or INT) |
||
175 | // ppScanContext new scan context |
||
176 | //============================================================================= |
||
177 | HRESULT WINAPI D3DX11CreateSegmentedScan( |
||
178 | __in ID3D11DeviceContext* pDeviceContext, |
||
179 | UINT MaxElementScanSize, |
||
180 | __out ID3DX11SegmentedScan** ppScan ); |
||
181 | |||
182 | |||
183 | |||
184 | ////////////////////////////////////////////////////////////////////////////// |
||
185 | |||
186 | #define D3DX11_FFT_MAX_PRECOMPUTE_BUFFERS 4 |
||
187 | #define D3DX11_FFT_MAX_TEMP_BUFFERS 4 |
||
188 | #define D3DX11_FFT_MAX_DIMENSIONS 32 |
||
189 | |||
190 | |||
191 | |||
192 | ////////////////////////////////////////////////////////////////////////////// |
||
193 | // ID3DX11FFT: |
||
194 | ////////////////////////////////////////////////////////////////////////////// |
||
195 | |||
196 | // {b3f7a938-4c93-4310-a675-b30d6de50553} |
||
197 | DEFINE_GUID(IID_ID3DX11FFT, 0xb3f7a938, 0x4c93, 0x4310, 0xa6, 0x75, 0xb3, 0x0d, 0x6d, 0xe5, 0x05, 0x53); |
||
198 | |||
199 | #undef INTERFACE |
||
200 | #define INTERFACE ID3DX11FFT |
||
201 | |||
202 | DECLARE_INTERFACE_(ID3DX11FFT, IUnknown) |
||
203 | { |
||
204 | // IUnknown |
||
205 | STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; |
||
206 | STDMETHOD_(ULONG, AddRef)(THIS) PURE; |
||
207 | STDMETHOD_(ULONG, Release)(THIS) PURE; |
||
208 | |||
209 | // ID3DX11FFT |
||
210 | |||
211 | // scale for forward transform (defaults to 1 if set to 0) |
||
212 | STDMETHOD(SetForwardScale)(THIS_ FLOAT ForwardScale) PURE; |
||
213 | STDMETHOD_(FLOAT, GetForwardScale)(THIS) PURE; |
||
214 | |||
215 | // scale for inverse transform (defaults to 1/N if set to 0, where N is |
||
216 | // the product of the transformed dimension lengths |
||
217 | STDMETHOD(SetInverseScale)(THIS_ FLOAT InverseScale) PURE; |
||
218 | STDMETHOD_(FLOAT, GetInverseScale)(THIS) PURE; |
||
219 | |||
220 | //------------------------------------------------------------------------------ |
||
221 | // Attaches buffers to the context and performs any required precomputation. |
||
222 | // The buffers must be no smaller than the corresponding buffer sizes returned |
||
223 | // by D3DX11CreateFFT*(). Temp buffers may beshared between multiple contexts, |
||
224 | // though care should be taken to concurrently execute multiple FFTs which share |
||
225 | // temp buffers. |
||
226 | // |
||
227 | // NumTempBuffers number of buffers in ppTempBuffers |
||
228 | // ppTempBuffers temp buffers to attach |
||
229 | // NumPrecomputeBuffers number of buffers in ppPrecomputeBufferSizes |
||
230 | // ppPrecomputeBufferSizes buffers to hold precomputed data |
||
231 | STDMETHOD(AttachBuffersAndPrecompute)( THIS_ |
||
232 | __in_range(0,D3DX11_FFT_MAX_TEMP_BUFFERS) UINT NumTempBuffers, |
||
233 | __in_ecount(NumTempBuffers) ID3D11UnorderedAccessView*const* ppTempBuffers, |
||
234 | __in_range(0,D3DX11_FFT_MAX_PRECOMPUTE_BUFFERS) UINT NumPrecomputeBuffers, |
||
235 | __in_ecount(NumPrecomputeBuffers) ID3D11UnorderedAccessView*const* ppPrecomputeBufferSizes ) PURE; |
||
236 | |||
237 | //------------------------------------------------------------------------------ |
||
238 | // Call after buffers have been attached to the context, pInput and *ppOuput can |
||
239 | // be one of the temp buffers. If *ppOutput == NULL, then the computation will ping-pong |
||
240 | // between temp buffers and the last buffer written to is stored at *ppOutput. |
||
241 | // Otherwise, *ppOutput is used as the output buffer (which may incur an extra copy). |
||
242 | // |
||
243 | // The format of complex data is interleaved components, e.g. (Real0, Imag0), |
||
244 | // (Real1, Imag1) ... etc. Data is stored in row major order |
||
245 | // |
||
246 | // pInputBuffer view onto input buffer |
||
247 | // ppOutpuBuffert pointer to view of output buffer |
||
248 | STDMETHOD(ForwardTransform)( THIS_ |
||
249 | __in const ID3D11UnorderedAccessView* pInputBuffer, |
||
250 | __inout ID3D11UnorderedAccessView** ppOutputBuffer ) PURE; |
||
251 | |||
252 | STDMETHOD(InverseTransform)( THIS_ |
||
253 | __in const ID3D11UnorderedAccessView* pInputBuffer, |
||
254 | __inout ID3D11UnorderedAccessView** ppOutputBuffer ) PURE; |
||
255 | }; |
||
256 | |||
257 | |||
258 | ////////////////////////////////////////////////////////////////////////////// |
||
259 | // ID3DX11FFT Creation Routines |
||
260 | ////////////////////////////////////////////////////////////////////////////// |
||
261 | |||
262 | typedef enum D3DX11_FFT_DATA_TYPE |
||
263 | { |
||
264 | D3DX11_FFT_DATA_TYPE_REAL, |
||
265 | D3DX11_FFT_DATA_TYPE_COMPLEX, |
||
266 | } D3DX11_FFT_DATA_TYPE; |
||
267 | |||
268 | typedef enum D3DX11_FFT_DIM_MASK |
||
269 | { |
||
270 | D3DX11_FFT_DIM_MASK_1D = 0x1, |
||
271 | D3DX11_FFT_DIM_MASK_2D = 0x3, |
||
272 | D3DX11_FFT_DIM_MASK_3D = 0x7, |
||
273 | } D3DX11_FFT_DIM_MASK; |
||
274 | |||
275 | typedef struct D3DX11_FFT_DESC |
||
276 | { |
||
277 | UINT NumDimensions; // number of dimensions |
||
278 | UINT ElementLengths[D3DX11_FFT_MAX_DIMENSIONS]; // length of each dimension |
||
279 | UINT DimensionMask; // a bit set for each dimensions to transform |
||
280 | // (see D3DX11_FFT_DIM_MASK for common masks) |
||
281 | D3DX11_FFT_DATA_TYPE Type; // type of the elements in spatial domain |
||
282 | } D3DX11_FFT_DESC; |
||
283 | |||
284 | |||
285 | //------------------------------------------------------------------------------ |
||
286 | // NumTempBufferSizes Number of temporary buffers needed |
||
287 | // pTempBufferSizes Minimum sizes (in FLOATs) of temporary buffers |
||
288 | // NumPrecomputeBufferSizes Number of precompute buffers needed |
||
289 | // pPrecomputeBufferSizes minimum sizes (in FLOATs) for precompute buffers |
||
290 | //------------------------------------------------------------------------------ |
||
291 | |||
292 | typedef struct D3DX11_FFT_BUFFER_INFO |
||
293 | { |
||
294 | __range(0,D3DX11_FFT_MAX_TEMP_BUFFERS) UINT NumTempBufferSizes; |
||
295 | UINT TempBufferFloatSizes[D3DX11_FFT_MAX_TEMP_BUFFERS]; |
||
296 | __range(0,D3DX11_FFT_MAX_PRECOMPUTE_BUFFERS) UINT NumPrecomputeBufferSizes; |
||
297 | UINT PrecomputeBufferFloatSizes[D3DX11_FFT_MAX_PRECOMPUTE_BUFFERS]; |
||
298 | } D3DX11_FFT_BUFFER_INFO; |
||
299 | |||
300 | |||
301 | typedef enum D3DX11_FFT_CREATE_FLAG |
||
302 | { |
||
303 | D3DX11_FFT_CREATE_FLAG_NO_PRECOMPUTE_BUFFERS = 0x01L, // do not precompute values and store into buffers |
||
304 | } D3DX11_FFT_CREATE_FLAG; |
||
305 | |||
306 | |||
307 | //------------------------------------------------------------------------------ |
||
308 | // Creates an ID3DX11FFT COM interface object and returns a pointer to it at *ppFFT. |
||
309 | // The descriptor describes the shape of the data as well as the scaling factors |
||
310 | // that should be used for forward and inverse transforms. |
||
311 | // The FFT computation may require temporaries that act as ping-pong buffers |
||
312 | // and for other purposes. aTempSizes is a list of the sizes required for |
||
313 | // temporaries. Likewise, some data may need to be precomputed and the sizes |
||
314 | // of those sizes are returned in aPrecomputedBufferSizes. |
||
315 | // |
||
316 | // To perform a computation, follow these steps: |
||
317 | // 1) Create the FFT context object |
||
318 | // 2) Precompute (and Attach temp working buffers of at least the required size) |
||
319 | // 3) Call Compute() on some input data |
||
320 | // |
||
321 | // Compute() may be called repeatedly with different inputs and transform |
||
322 | // directions. When finished with the FFT work, release the FFT interface() |
||
323 | // |
||
324 | // Device Direct3DDeviceContext to use in |
||
325 | // pDesc Descriptor for FFT transform in |
||
326 | // Count the number of 1D FFTs to perform in |
||
327 | // Flags See D3DX11_FFT_CREATE_FLAG in |
||
328 | // pBufferInfo Pointer to BUFFER_INFO struct, filled by funciton out |
||
329 | // ppFFT Pointer to returned context pointer out |
||
330 | //------------------------------------------------------------------------------ |
||
331 | |||
332 | HRESULT D3DX11CreateFFT( |
||
333 | ID3D11DeviceContext* pDeviceContext, |
||
334 | __in const D3DX11_FFT_DESC* pDesc, |
||
335 | UINT Flags, |
||
336 | __out D3DX11_FFT_BUFFER_INFO* pBufferInfo, |
||
337 | __out ID3DX11FFT** ppFFT |
||
338 | ); |
||
339 | |||
340 | HRESULT D3DX11CreateFFT1DReal( |
||
341 | ID3D11DeviceContext* pDeviceContext, |
||
342 | UINT X, |
||
343 | UINT Flags, |
||
344 | __out D3DX11_FFT_BUFFER_INFO* pBufferInfo, |
||
345 | __out ID3DX11FFT** ppFFT |
||
346 | ); |
||
347 | HRESULT D3DX11CreateFFT1DComplex( |
||
348 | ID3D11DeviceContext* pDeviceContext, |
||
349 | UINT X, |
||
350 | UINT Flags, |
||
351 | __out D3DX11_FFT_BUFFER_INFO* pBufferInfo, |
||
352 | __out ID3DX11FFT** ppFFT |
||
353 | ); |
||
354 | HRESULT D3DX11CreateFFT2DReal( |
||
355 | ID3D11DeviceContext* pDeviceContext, |
||
356 | UINT X, |
||
357 | UINT Y, |
||
358 | UINT Flags, |
||
359 | __out D3DX11_FFT_BUFFER_INFO* pBufferInfo, |
||
360 | __out ID3DX11FFT** ppFFT |
||
361 | ); |
||
362 | HRESULT D3DX11CreateFFT2DComplex( |
||
363 | ID3D11DeviceContext* pDeviceContext, |
||
364 | UINT X, |
||
365 | UINT Y, |
||
366 | UINT Flags, |
||
367 | __out D3DX11_FFT_BUFFER_INFO* pBufferInfo, |
||
368 | __out ID3DX11FFT** ppFFT |
||
369 | ); |
||
370 | HRESULT D3DX11CreateFFT3DReal( |
||
371 | ID3D11DeviceContext* pDeviceContext, |
||
372 | UINT X, |
||
373 | UINT Y, |
||
374 | UINT Z, |
||
375 | UINT Flags, |
||
376 | __out D3DX11_FFT_BUFFER_INFO* pBufferInfo, |
||
377 | __out ID3DX11FFT** ppFFT |
||
378 | ); |
||
379 | HRESULT D3DX11CreateFFT3DComplex( |
||
380 | ID3D11DeviceContext* pDeviceContext, |
||
381 | UINT X, |
||
382 | UINT Y, |
||
383 | UINT Z, |
||
384 | UINT Flags, |
||
385 | __out D3DX11_FFT_BUFFER_INFO* pBufferInfo, |
||
386 | __out ID3DX11FFT** ppFFT |
||
387 | ); |
||
388 | |||
389 | |||
390 | #ifdef __cplusplus |
||
391 | } |
||
392 | #endif //__cplusplus |
||
393 | |||
394 | #endif //__D3DX11GPGPU_H__ |
||
395 | |||
396 |