Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
GraphicsDeviceFeatures.OpenGL.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_OPENGL
4 // Copyright (c) 2010-2012 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 
24 using System;
25 using System.Collections.Generic;
26 using OpenTK.Graphics;
27 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
28 using OpenTK.Graphics.ES30;
29 #else
30 using OpenTK.Graphics.OpenGL;
31 #endif
32 
33 namespace SiliconStudio.Paradox.Graphics
34 {
35  /// <summary>
36  /// Features supported by a <see cref="GraphicsDevice"/>.
37  /// </summary>
38  /// <remarks>
39  /// This class gives also features for a particular format, using the operator this[dxgiFormat] on this structure.
40  /// </remarks>
41  public partial struct GraphicsDeviceFeatures
42  {
43  internal string Vendor;
44  internal string Renderer;
45  internal IList<string> SupportedExtensions;
46 
47  internal GraphicsDeviceFeatures(GraphicsDevice deviceRoot)
48  {
49  // Find shader model based on OpenGL version (might need to check extensions more carefully)
50  if (deviceRoot.versionMajor > 4)
51  Profile = GraphicsProfile.Level_11_0;
52  else if (deviceRoot.versionMajor > 3 && deviceRoot.versionMinor > 3)
53  Profile = GraphicsProfile.Level_10_0;
54  else
55  Profile = GraphicsProfile.Level_9_1;
56 
57  mapFeaturesPerFormat = new FeaturesPerFormat[256];
58 
59  IsProfiled = false;
60 
61  using (deviceRoot.UseOpenGLCreationContext())
62  {
63  Vendor = GL.GetString(StringName.Vendor);
64  Renderer = GL.GetString(StringName.Renderer);
65 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
66  SupportedExtensions = GL.GetString(StringName.Extensions).Split(' ');
67 #else
68  int numExtensions;
69  GL.GetInteger(GetPName.NumExtensions, out numExtensions);
70  SupportedExtensions = new string[numExtensions];
71  for (int extensionIndex = 0; extensionIndex < numExtensions; ++extensionIndex)
72  {
73  SupportedExtensions[extensionIndex] = GL.GetString(StringName.Extensions, extensionIndex);
74  }
75 #endif
76  }
77 
78 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
79  deviceRoot.HasDepth24 = SupportedExtensions.Contains("GL_OES_depth24");
80  deviceRoot.HasPackedDepthStencilExtension = SupportedExtensions.Contains("GL_OES_packed_depth_stencil");
81  deviceRoot.HasExtTextureFormatBGRA8888 = SupportedExtensions.Contains("GL_EXT_texture_format_BGRA8888")
82  || SupportedExtensions.Contains("GL_APPLE_texture_format_BGRA8888");
83  deviceRoot.HasVAO = SupportedExtensions.Contains("GL_OES_vertex_array_object");
84 #else
85  deviceRoot.HasVAO = true;
86 #endif
87 
88  // Compute shaders available in OpenGL 4.3
89  HasComputeShaders = deviceRoot.versionMajor > 4 && deviceRoot.versionMinor > 3;
90  HasDoublePrecision = SupportedExtensions.Contains("GL_ARB_vertex_attrib_64bit");
91  HasDriverCommandLists = false;
92  HasMultiThreadingConcurrentResources = false;
93 
94  // TODO: Enum supported formats in mapFeaturesPerFormat
95  }
96  }
97 }
98 #endif