Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
GraphicsAdapter.Direct3D.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_DIRECT3D
4 // Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 // THE SOFTWARE.
23 using System;
24 using System.Collections.Generic;
25 using System.Resources;
26 using SharpDX.Direct3D;
27 using SharpDX.Direct3D11;
28 using SharpDX.DXGI;
29 using SharpDX;
30 using SiliconStudio.Core;
31 
32 using ComponentBase = SiliconStudio.Core.ComponentBase;
34 
35 namespace SiliconStudio.Paradox.Graphics
36 {
37  /// <summary>
38  /// Provides methods to retrieve and manipulate graphics adapters. This is the equivalent to <see cref="Adapter1"/>.
39  /// </summary>
40  /// <msdn-id>ff471329</msdn-id>
41  /// <unmanaged>IDXGIAdapter1</unmanaged>
42  /// <unmanaged-short>IDXGIAdapter1</unmanaged-short>
43  public partial class GraphicsAdapter
44  {
45  private readonly Adapter1 adapter;
46  private readonly int adapterOrdinal;
47  private readonly AdapterDescription1 description;
48 
49  /// <summary>
50  /// Initializes a new instance of the <see cref="GraphicsAdapter" /> class.
51  /// </summary>
52  /// <param name="defaultFactory">The default factory.</param>
53  /// <param name="adapterOrdinal">The adapter ordinal.</param>
54  internal GraphicsAdapter(Factory1 defaultFactory, int adapterOrdinal)
55  {
56  this.adapterOrdinal = adapterOrdinal;
57  adapter = defaultFactory.GetAdapter1(adapterOrdinal).DisposeBy(this);
58  description = adapter.Description1;
59  //var nativeOutputs = adapter.Outputs;
60 
61  var count = adapter.GetOutputCount();
62  outputs = new GraphicsOutput[count];
63  for (var i = 0; i < outputs.Length; i++)
64  outputs[i] = new GraphicsOutput(this, i).DisposeBy(this);
65  }
66 
67  /// <summary>
68  /// Gets the description of this adapter.
69  /// </summary>
70  /// <value>The description.</value>
71  public string Description
72  {
73  get
74  {
75  return description.Description;
76  }
77  }
78 
79  /// <summary>
80  /// Gets or sets the vendor identifier.
81  /// </summary>
82  /// <value>
83  /// The vendor identifier.
84  /// </value>
85  public int VendorId
86  {
87  get { return description.VendorId; }
88  }
89 
90  /// <summary>
91  /// Determines if this instance of GraphicsAdapter is the default adapter.
92  /// </summary>
93  public bool IsDefaultAdapter
94  {
95  get
96  {
97  return adapterOrdinal == 0;
98  }
99  }
100 
101  internal Adapter1 NativeAdapter
102  {
103  get
104  {
105  return adapter;
106  }
107  }
108 
109  /// <summary>
110  /// Tests to see if the adapter supports the requested profile.
111  /// </summary>
112  /// <param name="graphicsProfile">The graphics profile.</param>
113  /// <returns>true if the profile is supported</returns>
114  public bool IsProfileSupported(GraphicsProfile graphicsProfile)
115  {
116  return SharpDX.Direct3D11.Device.IsSupportedFeatureLevel(this.NativeAdapter, (SharpDX.Direct3D.FeatureLevel)graphicsProfile);
117  }
118  }
119 }
120 #endif
Base class for a framework component.
_In_ size_t count
Definition: DirectXTexP.h:174
SiliconStudio.Core.Utilities Utilities
Definition: Texture.cs:29
GraphicsProfile
Identifies the set of supported devices for the demo based on device capabilities.