OSDN Git Service

#32713 初コミット。SVNrev567時点での、ファイルはbranch/140707(ReBuild XGVersion)から移行したもの。
[dtxmaniaxg-verk/dtxmaniaxg-verk-git.git] / SlimDXc_Jun2010(VC++2008) / source / direct3d10 / Device10.h
1 /*
2 * Copyright (c) 2007-2010 SlimDX Group
3
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22 #pragma once
23
24 #include "../ComObject.h"
25
26 #include "../dxgi/Adapter.h"
27 #include "../dxgi/Enums.h"
28 #include "../dxgi/SwapChainDxgi.h"
29 #include "../dxgi/SwapChainDescription.h"
30 #include "../math/Color4.h"
31
32 #include "Enums.h"
33
34 using System::Runtime::InteropServices::OutAttribute;
35
36 namespace SlimDX
37 {
38         ref class DataBox;
39         
40         namespace Direct3D10
41         {
42                 ref class Buffer;
43                 ref class DepthStencilView;
44                 ref class GeometryShaderWrapper;
45                 ref class InputAssemblerWrapper;
46                 ref class InputLayout;
47                 ref class OutputMergerWrapper;
48                 ref class Predicate;
49                 ref class RasterizerWrapper;
50                 ref class RenderTargetView;
51                 ref class Resource;
52                 ref class PixelShaderWrapper;
53                 ref class ShaderResourceView;
54                 ref class StreamOutputWrapper;
55                 ref class VertexShaderWrapper;
56                 value class CounterCapabilities;
57                 value class CounterDescription;
58                 value class CounterMetadata;
59                 value class RenderTargetViewDescription;
60                 value class ResourceRegion;
61
62                 /// <summary>
63                 /// A virtual adapter for performing rendering.
64                 /// </summary>
65                 /// <unmanaged>ID3D10Device</unmanaged>
66                 public ref class Device : ComObject
67                 {
68                         COMOBJECT_CUSTOM(ID3D10Device, Device);
69                 
70                 private:
71                         InputAssemblerWrapper^ m_InputAssembler;
72                         OutputMergerWrapper^ m_OutputMerger;
73                         StreamOutputWrapper^ m_StreamOutput;
74                         RasterizerWrapper^ m_Rasterizer;
75                         VertexShaderWrapper^ m_VertexShader;
76                         PixelShaderWrapper^ m_PixelShader;
77                         GeometryShaderWrapper^ m_GeometryShader;
78
79                 protected:
80                         //no-op ctor for use by Device1
81                         Device() { }
82
83                         void InitializeSubclasses();
84
85                 public:
86                         /// <summary>
87                         /// The maximum number of multisample quality levels supported.
88                         /// </summary>
89                         literal int MultisampleCountMaximum = D3D10_MAX_MULTISAMPLE_SAMPLE_COUNT;
90                         
91                         /// <summary>
92                         /// Gets the device's input assembler interface.
93                         /// </summary>
94                         property InputAssemblerWrapper^ InputAssembler
95                         {
96                                 InputAssemblerWrapper^ get();
97                         }
98
99                         /// <summary>
100                         /// Gets the device's output merger interface.
101                         /// </summary>
102                         property OutputMergerWrapper^ OutputMerger
103                         {
104                                 OutputMergerWrapper^ get();
105                         }
106
107                         /// <summary>
108                         /// Gets the device's stream output interface.
109                         /// </summary>
110                         property StreamOutputWrapper^ StreamOutput
111                         {
112                                 StreamOutputWrapper^ get();
113                         }
114
115                         /// <summary>
116                         /// Gets the device's rasterizer interface.
117                         /// </summary>
118                         property RasterizerWrapper^ Rasterizer
119                         {
120                                 RasterizerWrapper^ get();
121                         }
122
123                         /// <summary>
124                         /// Gets the device's vertex shader interface.
125                         /// </summary>
126                         property VertexShaderWrapper^ VertexShader
127                         {
128                                 VertexShaderWrapper^ get();
129                         }
130
131                         /// <summary>
132                         /// Gets the device's pixel shader interface.
133                         /// </summary>
134                         property PixelShaderWrapper^ PixelShader
135                         {
136                                 PixelShaderWrapper^ get();
137                         }
138
139                         /// <summary>
140                         /// Gets the device's geometry shader interface.
141                         /// </summary>
142                         property GeometryShaderWrapper^ GeometryShader
143                         {
144                                 GeometryShaderWrapper^ get();
145                         }
146                         
147                         /// <summary>
148                         /// Gets the device's creation flags.
149                         /// </summary>
150                         property DeviceCreationFlags CreationFlags
151                         {
152                                 DeviceCreationFlags get();
153                         }
154
155                         property Result DeviceRemovedReason
156                         {
157                                 Result get();
158                         }
159                         
160                         /// <summary>
161                         /// Constructs a new Device object.
162                         /// </summary>
163                         /// <param name="flags">Flags that indicate which device API layers to enable.</param>
164                         Device( DeviceCreationFlags flags );
165
166                         /// <summary>
167                         /// Constructs a new Device object.
168                         /// </summary>
169                         /// <param name="driverType">The device driver type.</param>
170                         /// <param name="flags">Flags that indicate which device API layers to enable.</param>
171                         Device( DriverType driverType, DeviceCreationFlags flags );
172
173                         /// <summary>
174                         /// Constructs a new Device object.
175                         /// </summary>
176                         /// <param name="adapter">The display adapter to associate the device with when creating a hardware device.</param>
177                         /// <param name="driverType">The device driver type.</param>
178                         /// <param name="flags">Flags that indicate which device API layers to enable.</param>
179                         Device( DXGI::Adapter^ adapter, DriverType driverType, DeviceCreationFlags flags );
180
181                         /// <summary>
182                         /// Gets information about the device's performance counters.
183                         /// </summary>
184                         /// <returns>Information about the device's performance counters.</returns>
185                         CounterCapabilities GetCounterCapabilities();
186
187                         /// <summary>
188                         /// Gets metadata (name, type, measurement units, et cetera) for a specific counter.
189                         /// </summary>
190                         /// <param name="description">The description of the counter to retrieve information about.</param>
191                         /// <returns>Metadata for the specified counter.</returns>
192                         CounterMetadata GetCounterMetadata( CounterDescription description );
193                         
194                         /// <summary>
195                         /// Gets information about the supported applications of a specified format.
196                         /// </summary>
197                         /// <param name="format">The format to check support for.</param>
198                         /// <returns>FormatSupport flags indicating usage contexts in which the specified format is supported.</returns>
199                         FormatSupport CheckFormatSupport( DXGI::Format format );
200
201                         /// <summary>
202                         /// Gets the number of quality levels supported during multisampling of resources using a specified format.
203                         /// </summary>
204                         /// <param name="format">The format to check support for.</param>
205                         /// <param name="sampleCount">The multisample count to check support for.</param>
206                         /// <returns>The number of quality levels supported. 0 if an error occured
207                         /// or if the format/samplecount pair is not supported.</returns>
208                         int CheckMultisampleQualityLevels( DXGI::Format format, int sampleCount );
209
210                         /// <summary>
211                         /// Gives the device access to a shared resource created on a different device.
212                         /// </summary>
213                         /// <typeparam name="T">The type of the resource.</typeparam>
214                         /// <param name="handle">A handle to the shared resource.</param>
215                         /// <returns>The new reference to the shared resource.</returns>
216                         generic<typename T> where T : ComObject
217                         T OpenSharedResource(System::IntPtr handle);
218                         
219                         /// <summary>
220                         /// Clears the specified depth-stencil resource.
221                         /// </summary>
222                         /// <param name="view">The view of the resource to clear.</param>
223                         /// <param name="flags">Flags indicating which parts of the resource to clear.</param>
224                         /// <param name="depth">The depth value to clear to, if applicable.</param>
225                         /// <param name="stencil">The stencil value to clear to, if applicable.</param>
226                         void ClearDepthStencilView( DepthStencilView^ view, DepthStencilClearFlags flags, float depth, System::Byte stencil );
227                         
228                         /// <summary>
229                         /// Clears the specified render target resource.
230                         /// </summary>
231                         /// <param name="view">The view of the resource to clear.</param>
232                         /// <param name="color">The color to clear to.</param>
233                         void ClearRenderTargetView( RenderTargetView^ view, Color4 color );
234
235                         /// <summary>
236                         /// Restores all device state to defaults.
237                         /// </summary>
238                         void ClearState();
239                         
240                         /// <summary>
241                         /// Clears all resource bindings from the device.
242                         /// </summary>
243                         /// <returns>A <see cref="SlimDX::Result"/> object describing the result of the operation.</returns>
244                         Result ClearAllObjects();
245                         
246                         /// <summary>
247                         /// Copies resource data using the GPU.
248                         /// </summary>
249                         /// <param name="source">The source resource.</param>
250                         /// <param name="destination">The destination resource.</param>
251                         void CopyResource( Resource^ source, Resource^ destination );
252
253                         /// <summary>
254                         /// Copies a portion of a resource's data using the GPU.
255                         /// </summary>
256                         /// <param name="source">The source resource.</param>
257                         /// <param name="sourceSubresource">The source subresource.</param>
258                         /// <param name="region">The source region.</param>
259                         /// <param name="destination">The destination resource.</param>
260                         /// <param name="destinationSubresource">The destination subresource.</param>
261                         /// <param name="x">The X offset between the source region origin and the destination location.</param>
262                         /// <param name="y">The Y offset between the source region origin and the destination location.</param>
263                         /// <param name="z">The Z offset between the source region origin and the destination location.</param>
264                         void CopySubresourceRegion( Resource^ source, int sourceSubresource, ResourceRegion region, Resource^ destination, int destinationSubresource, int x, int y, int z );
265                         
266                         /// <summary>
267                         /// Copies a multisampled resource into a non-multisampled resource.
268                         /// </summary>
269                         /// <param name="source">The source resource.</param>
270                         /// <param name="sourceSubresource">The source subresource.</param>
271                         /// <param name="destination">The destination resource.</param>
272                         /// <param name="destinationSubresource">The destination subresource.</param>
273                         /// <param name="format">The format that indicates how the multisampled resource will be resolved.</param>
274                         void ResolveSubresource( Resource^ source, int sourceSubresource, Resource^ destination, int destinationSubresource, DXGI::Format format );
275                         
276                         /// <summary>
277                         /// Copies data from the CPU to to a non-mappable subresource region.
278                         /// </summary>
279                         /// <param name="source">The source data.</param>
280                         /// <param name="resource">The destination resource.</param>
281                         /// <param name="subresource">The destination subresource.</param>
282                         void UpdateSubresource( DataBox^ source, Resource^ resource, int subresource );
283
284                         /// <summary>
285                         /// Copies data from the CPU to to a non-mappable subresource region.
286                         /// </summary>
287                         /// <param name="source">The source data.</param>
288                         /// <param name="resource">The destination resource.</param>
289                         /// <param name="subresource">The destination subresource.</param>
290                         /// <param name="region">The destination region within the resource.</param>
291                         void UpdateSubresource( DataBox^ source, Resource^ resource, int subresource, ResourceRegion region );
292
293                         /// <summary>
294                         /// Renders non-indexed, non-instanced primitive data.
295                         /// </summary>
296                         /// <param name="vertexCount">The number of vertices to use.</param>
297                         /// <param name="startVertexLocation">The index of the first vertex.</param>
298                         void Draw( int vertexCount, int startVertexLocation );
299
300                         /// <summary>
301                         /// Renders non-indexed, instanced primitive data.
302                         /// </summary>
303                         /// <param name="vertexCountPerInstance">The number of vertices to use per index.</param>
304                         /// <param name="instanceCount">The number of instances to render.</param>
305                         /// <param name="startVertexLocation">The index of the first vertex.</param>
306                         /// <param name="startInstanceLocation">The index of the first instance.</param>
307                         void DrawInstanced( int vertexCountPerInstance, int instanceCount, int startVertexLocation, int startInstanceLocation );
308                         
309                         /// <summary>
310                         /// Renders indexed, non-instanced primitive data.
311                         /// </summary>
312                         /// <param name="indexCount">The number of indices to use.</param>
313                         /// <param name="startIndexLocation">The index of the first index.</param>
314                         /// <param name="baseVertexLocation">The index of the first vertex.</param>
315                         void DrawIndexed( int indexCount, int startIndexLocation, int baseVertexLocation );
316
317                         /// <summary>
318                         /// Renders indexed, instanced primitive data.
319                         /// </summary>
320                         /// <param name="indexCountPerInstance">The number of indices to use per index.</param>
321                         /// <param name="instanceCount">The number of instances to render.</param>
322                         /// <param name="startIndexLocation">The index of the first index.</param>
323                         /// <param name="baseVertexLocation">The index of the first vertex.</param>
324                         /// <param name="startInstanceLocation">The index of the first instance.</param>
325                         void DrawIndexedInstanced( int indexCountPerInstance, int instanceCount, int startIndexLocation, int baseVertexLocation, int startInstanceLocation );
326                         
327                         /// <summary>
328                         /// Renders primitive data of an unknown size that was created by a geometry shader.
329                         /// </summary>
330                         void DrawAuto();
331
332                         /// <summary>
333                         /// Sends queued commands in the command buffer to the GPU.
334                         /// </summary>
335                         void Flush();
336                         
337                         /// <summary>
338                         /// Generates mipmaps for the specified shader resource.
339                         /// </summary>
340                         /// <param name="view">A view of the resource to generate mipmaps for.</param>
341                         void GenerateMips( ShaderResourceView^ view );
342
343                         void GetPredication( [Out] Predicate^ %predicate, [Out] bool %predicateValue ); 
344                         
345                         /// <summary>
346                         /// Sets a rendering predicate.
347                         /// </summary>
348                         /// <param name="predicate">The predicate to set.</param>
349                         /// <param name="predicateValue">If true, rendering will be affected when the predicate's conditions are met. Otherwise,
350                         /// rendering will be affected when the predicate's conditions are not met.</param>
351                         void SetPredication( Predicate^ predicate, bool predicateValue );
352                         
353                         /// <summary>
354                         /// Creates a new device and swap chain.
355                         /// </summary>
356                         /// <param name="adapter">The display adapter to associate the device with when creating a hardware device.</param>
357                         /// <param name="driverType">The device driver type.</param>
358                         /// <param name="flags">Flags that indicate which device API layers to enable.</param>
359                         /// <param name="swapChainDescription">Swap chain properties.</param>
360                         /// <param name="device">The newly-created device.</param>
361                         /// <param name="swapChain">The newly-created swap chain.</param>
362                         /// <returns>A result code.</returns>
363                         static Result CreateWithSwapChain( DXGI::Adapter^ adapter, DriverType driverType, DeviceCreationFlags flags, DXGI::SwapChainDescription swapChainDescription, [Out] Device^ %device, [Out] DXGI::SwapChain^ %swapChain );
364                 };
365         }
366 };