2 * Copyright (c) 2007-2010 SlimDX Group
\r
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
5 * of this software and associated documentation files (the "Software"), to deal
\r
6 * in the Software without restriction, including without limitation the rights
\r
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
8 * copies of the Software, and to permit persons to whom the Software is
\r
9 * furnished to do so, subject to the following conditions:
\r
11 * The above copyright notice and this permission notice shall be included in
\r
12 * all copies or substantial portions of the Software.
\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
24 #include "../ComObject.h"
\r
26 #include "../dxgi/Adapter.h"
\r
27 #include "../dxgi/Enums.h"
\r
28 #include "../dxgi/SwapChainDxgi.h"
\r
29 #include "../dxgi/SwapChainDescription.h"
\r
30 #include "../math/Color4.h"
\r
32 #include "Enums11.h"
\r
34 using System::Runtime::InteropServices::OutAttribute;
\r
38 namespace Direct3D11
\r
40 ref class DeviceContext;
\r
41 value class CounterCapabilities;
\r
42 value class CounterMetadata;
\r
45 /// Represents a virtual adapter used to perform rendering and create resources.
\r
47 /// <unmanaged>ID3D11Device</unmanaged>
\r
48 public ref class Device : ComObject
\r
50 COMOBJECT(ID3D11Device, Device);
\r
53 void Initialize( DXGI::Adapter^ adapter, DriverType driverType, DeviceCreationFlags flags, const D3D_FEATURE_LEVEL *featureLevels, int count );
\r
57 /// The maximum number of multisample quality levels supported.
\r
59 literal int MultisampleCountMaximum = D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT;
\r
62 /// Gets the flags used to create the device.
\r
64 property DeviceCreationFlags CreationFlags
\r
66 DeviceCreationFlags get();
\r
70 /// Gets the reason why the device was removed.
\r
72 property Result DeviceRemovedReason
\r
78 /// Gets the feature level of the hardware device.
\r
80 property FeatureLevel FeatureLevel
\r
82 Direct3D11::FeatureLevel get();
\r
86 /// Gets the intrinsic immediate context for the device.
\r
88 property DeviceContext^ ImmediateContext
\r
90 DeviceContext^ get();
\r
94 /// Gets a value indicating whether the current device is using the reference rasterizer.
\r
96 property bool IsReferenceDevice
\r
102 /// Initializes a new instance of the <see cref="Device"/> class using the highest supported feature level.
\r
104 /// <param name="adapter">The video adapter on which the device should be created.</param>
\r
105 Device( DXGI::Adapter^ adapter );
\r
108 /// Initializes a new instance of the <see cref="Device"/> class using the highest supported feature level.
\r
110 /// <param name="adapter">The video adapter on which the device should be created.</param>
\r
111 /// <param name="flags">A list of runtime layers to enable.</param>
\r
112 Device( DXGI::Adapter^ adapter, DeviceCreationFlags flags );
\r
115 /// Initializes a new instance of the <see cref="Device"/> class.
\r
117 /// <param name="adapter">The video adapter on which the device should be created.</param>
\r
118 /// <param name="flags">A list of runtime layers to enable.</param>
\r
119 /// <param name="featureLevels">A list of feature levels which determine the order of feature levels to attempt to create.</param>
\r
120 Device( DXGI::Adapter^ adapter, DeviceCreationFlags flags, ... array<Direct3D11::FeatureLevel>^ featureLevels );
\r
123 /// Initializes a new instance of the <see cref="Device"/> class using the highest supported feature level.
\r
125 /// <param name="driverType">The type of device to create.</param>
\r
126 Device( DriverType driverType );
\r
129 /// Initializes a new instance of the <see cref="Device"/> class using the highest supported feature level.
\r
131 /// <param name="driverType">The type of device to create.</param>
\r
132 /// <param name="flags">A list of runtime layers to enable.</param>
\r
133 Device( DriverType driverType, DeviceCreationFlags flags );
\r
136 /// Initializes a new instance of the <see cref="Device"/> class.
\r
138 /// <param name="driverType">The type of device to create.</param>
\r
139 /// <param name="flags">A list of runtime layers to enable.</param>
\r
140 /// <param name="featureLevels">A list of feature levels which determine the order of feature levels to attempt to create.</param>
\r
141 Device( DriverType driverType, DeviceCreationFlags flags, ... array<Direct3D11::FeatureLevel>^ featureLevels );
\r
144 /// Gets information about the device's performance counters.
\r
146 /// <returns>Information about the device's performance counters.</returns>
\r
147 CounterCapabilities GetCounterCapabilities();
\r
150 /// Gets metadata (name, type, measurement units, et cetera) for a specific counter.
\r
152 /// <param name="counterKind">The type of the counter to retrieve information about.</param>
\r
153 /// <returns>Metadata for the specified counter.</returns>
\r
154 CounterMetadata GetCounterMetadata( CounterKind counterKind );
\r
157 /// Gets information about the supported applications of a specified format.
\r
159 /// <param name="format">The format for which to check support.</param>
\r
160 /// <returns>Flags indicating usage contexts in which the specified format is supported.</returns>
\r
161 FormatSupport CheckFormatSupport( DXGI::Format format );
\r
164 /// Gets information about the supported compute shader applications of a specified format.
\r
166 /// <param name="format">The format for which to check support.</param>
\r
167 /// <returns>Flags indicating usage contexts in which the specified format is supported.</returns>
\r
168 ComputeShaderFormatSupport CheckComputeShaderFormatSupport( DXGI::Format format );
\r
171 /// Checks for hardware support of the specified device feature.
\r
173 /// <returns><c>true</c> if the specified feature is supported; otherwise, <c>false</c>.</returns>
\r
174 bool CheckFeatureSupport( Feature feature );
\r
177 /// Checks the level of hardware multithreading supported by this device.
\r
179 /// <param name="supportsConcurrentResources">When the method completes, contains a value indicating whether resources can be created concurrently on multiple threads while drawing.</param>
\r
180 /// <param name="supportCommandLists">When the method completes, contains a value indicating whether command lists are supported by the current driver.</param>
\r
181 /// <returns>A <see cref="SlimDX::Result"/> object describing the result of the operation.</returns>
\r
182 Result CheckThreadingSupport( [Out] bool% supportsConcurrentResources, [Out] bool% supportCommandLists );
\r
185 /// Gets the number of quality levels supported during multisampling of resources using a specified format.
\r
187 /// <param name="format">The format to check support for.</param>
\r
188 /// <param name="sampleCount">The multisample count for which to check support.</param>
\r
189 /// <returns>The number of quality levels supported. 0 if an error occured or if the format/sampleCount pair is not supported.</returns>
\r
190 int CheckMultisampleQualityLevels( DXGI::Format format, int sampleCount );
\r
193 /// Gives the device access to a shared resource created on a different device.
\r
195 /// <typeparam name="T">The type of the resource.</typeparam>
\r
196 /// <param name="handle">A handle to the shared resource.</param>
\r
197 /// <returns>The new reference to the shared resource.</returns>
\r
198 generic<typename T> where T : ComObject
\r
199 T OpenSharedResource(System::IntPtr handle);
\r
202 /// Switches between the reference rasterizer and a hardware accelerated device.
\r
204 /// <param name="useReferenceRasterizer"><c>true</c> to use the reference rasterizer; <c>false</c> to switch back to a hardware accelerated device.</param>
\r
205 void SwitchToReference(bool useReferenceRasterizer);
\r
208 /// Gets the highest supported hardware feature level of the primary adapter.
\r
210 /// <returns>The highest supported hardware feature level.</returns>
\r
211 static Direct3D11::FeatureLevel GetSupportedFeatureLevel();
\r
214 /// Gets the highest supported hardware feature level of the given adapter.
\r
216 /// <param name="adapter">The adapter for which the feature level is to be retrieved.</param>
\r
217 /// <returns>The highest supported hardware feature level.</returns>
\r
218 static Direct3D11::FeatureLevel GetSupportedFeatureLevel( DXGI::Adapter^ adapter );
\r
221 /// Initializes a new instance of the <see cref="Device"/> class along with a new <see cref="SlimDX::DXGI::SwapChain"/> used for rendering.
\r
223 /// <param name="adapter">The video adapter on which the device should be created.</param>
\r
224 /// <param name="flags">A list of runtime layers to enable.</param>
\r
225 /// <param name="swapChainDescription">Details used to create the swap chain.</param>
\r
226 /// <param name="device">When the method completes, contains the created device instance.</param>
\r
227 /// <param name="swapChain">When the method completes, contains the created swap chain instance.</param>
\r
228 /// <returns>A <see cref="SlimDX::Result"/> object describing the result of the operation.</returns>
\r
229 static Result CreateWithSwapChain( DXGI::Adapter^ adapter, DeviceCreationFlags flags, DXGI::SwapChainDescription swapChainDescription, [Out] Device^ %device, [Out] DXGI::SwapChain^ %swapChain );
\r
232 /// Initializes a new instance of the <see cref="Device"/> class along with a new <see cref="SlimDX::DXGI::SwapChain"/> used for rendering.
\r
234 /// <param name="adapter">The video adapter on which the device should be created.</param>
\r
235 /// <param name="flags">A list of runtime layers to enable.</param>
\r
236 /// <param name="featureLevels">A list of feature levels which determine the order of feature levels to attempt to create.</param>
\r
237 /// <param name="swapChainDescription">Details used to create the swap chain.</param>
\r
238 /// <param name="device">When the method completes, contains the created device instance.</param>
\r
239 /// <param name="swapChain">When the method completes, contains the created swap chain instance.</param>
\r
240 /// <returns>A <see cref="SlimDX::Result"/> object describing the result of the operation.</returns>
\r
241 static Result CreateWithSwapChain( DXGI::Adapter^ adapter, DeviceCreationFlags flags, array<Direct3D11::FeatureLevel>^ featureLevels, DXGI::SwapChainDescription swapChainDescription, [Out] Device^ %device, [Out] DXGI::SwapChain^ %swapChain );
\r
244 /// Initializes a new instance of the <see cref="Device"/> class along with a new <see cref="SlimDX::DXGI::SwapChain"/> used for rendering.
\r
246 /// <param name="driverType">The type of device to create.</param>
\r
247 /// <param name="flags">A list of runtime layers to enable.</param>
\r
248 /// <param name="swapChainDescription">Details used to create the swap chain.</param>
\r
249 /// <param name="device">When the method completes, contains the created device instance.</param>
\r
250 /// <param name="swapChain">When the method completes, contains the created swap chain instance.</param>
\r
251 /// <returns>A <see cref="SlimDX::Result"/> object describing the result of the operation.</returns>
\r
252 static Result CreateWithSwapChain( DriverType driverType, DeviceCreationFlags flags, DXGI::SwapChainDescription swapChainDescription, [Out] Device^ %device, [Out] DXGI::SwapChain^ %swapChain );
\r
255 /// Initializes a new instance of the <see cref="Device"/> class along with a new <see cref="SlimDX::DXGI::SwapChain"/> used for rendering.
\r
257 /// <param name="driverType">The type of device to create.</param>
\r
258 /// <param name="flags">A list of runtime layers to enable.</param>
\r
259 /// <param name="featureLevels">A list of feature levels which determine the order of feature levels to attempt to create.</param>
\r
260 /// <param name="swapChainDescription">Details used to create the swap chain.</param>
\r
261 /// <param name="device">When the method completes, contains the created device instance.</param>
\r
262 /// <param name="swapChain">When the method completes, contains the created swap chain instance.</param>
\r
263 /// <returns>A <see cref="SlimDX::Result"/> object describing the result of the operation.</returns>
\r
264 static Result CreateWithSwapChain( DriverType driverType, DeviceCreationFlags flags, array<Direct3D11::FeatureLevel>^ featureLevels, DXGI::SwapChainDescription swapChainDescription, [Out] Device^ %device, [Out] DXGI::SwapChain^ %swapChain );
\r
267 /// This overload has been deprecated. Use one of the alternatives that does not take both an adapter and a driver type.
\r
269 [System::Obsolete("This method is confusing because only one of the adapter/driverType parameters is valid during the call. Use one of the overloads that explicitly uses the parameter you wish to provide.")]
\r
270 static Result CreateWithSwapChain( DXGI::Adapter^ adapter, DriverType driverType, DeviceCreationFlags flags, DXGI::SwapChainDescription swapChainDescription, [Out] Device^ %device, [Out] DXGI::SwapChain^ %swapChain );
\r
273 /// This overload has been deprecated. Use one of the alternatives that does not take both an adapter and a driver type.
\r
275 [System::Obsolete("This method is confusing because only one of the adapter/driverType parameters is valid during the call. Use one of the overloads that explicitly uses the parameter you wish to provide.")]
\r
276 static Result CreateWithSwapChain( DXGI::Adapter^ adapter, DriverType driverType, DeviceCreationFlags flags, array<Direct3D11::FeatureLevel>^ featureLevels, DXGI::SwapChainDescription swapChainDescription, [Out] Device^ %device, [Out] DXGI::SwapChain^ %swapChain );
\r