Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
GraphicsAdapterFactory.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 using System.Collections.Generic;
5 using SharpDX.DXGI;
6 
7 namespace SiliconStudio.Paradox.Graphics
8 {
9  public static partial class GraphicsAdapterFactory
10  {
11 #if SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP
12  internal static Factory1 NativeFactory;
13 #else
14  internal static Factory2 NativeFactory;
15 #endif
16 
17  /// <summary>
18  /// Initializes all adapters with the specified factory.
19  /// </summary>
20  internal static void InitializeInternal()
21  {
22  staticCollector.Dispose();
23 
24 #if DIRECTX11_1
25  using (var factory = new Factory1())
26  NativeFactory = factory.QueryInterface<Factory2>();
27 #elif SILICONSTUDIO_PLATFORM_WINDOWS_RUNTIME
28  // Maybe this will become default code for everybody if we switch to DX 11.1/11.2 SharpDX dll?
29  NativeFactory = new Factory2();
30 #else
31  NativeFactory = new Factory1();
32 #endif
33 
34  staticCollector.Add(NativeFactory);
35 
36  int countAdapters = NativeFactory.GetAdapterCount1();
37  var adapterList = new List<GraphicsAdapter>();
38  for (int i = 0; i < countAdapters; i++)
39  {
40  var adapter = new GraphicsAdapter(NativeFactory, i);
41  staticCollector.Add(adapter);
42  adapterList.Add(adapter);
43  }
44 
45  defaultAdapter = adapterList.Count > 0 ? adapterList[0] : null;
46  adapters = adapterList.ToArray();
47  }
48 
49  /// <summary>
50  /// Gets the <see cref="Factory1"/> used by all GraphicsAdapter.
51  /// </summary>
52  internal static Factory1 Factory
53  {
54  get
55  {
56  lock (StaticLock)
57  {
58  Initialize();
59  return NativeFactory;
60  }
61  }
62  }
63  }
64 }
65 #endif
SharpDX.DirectWrite.Factory Factory