Added INativeGraphicsAdapter
This commit is contained in:
parent
4381ef7c82
commit
32b43c2a82
@ -449,6 +449,7 @@
|
|||||||
<Compile Include="NonXNA\PreloadAttribute.cs" />
|
<Compile Include="NonXNA\PreloadAttribute.cs" />
|
||||||
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
|
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
|
||||||
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
|
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
|
||||||
|
<Compile Include="NonXNA\RenderSystem\INativeGraphicsAdapter.cs" />
|
||||||
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
|
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
|
||||||
<Compile Include="NonXNA\RenderSystem\INativeEffectAnnotation.cs" />
|
<Compile Include="NonXNA\RenderSystem\INativeEffectAnnotation.cs" />
|
||||||
<Compile Include="NonXNA\RenderSystem\VertexTypeHelper.cs" />
|
<Compile Include="NonXNA\RenderSystem\VertexTypeHelper.cs" />
|
||||||
|
@ -11,12 +11,25 @@ using ANX.Framework.NonXNA.Development;
|
|||||||
|
|
||||||
namespace ANX.Framework.Graphics
|
namespace ANX.Framework.Graphics
|
||||||
{
|
{
|
||||||
[PercentageComplete(50)]
|
[PercentageComplete(100)]
|
||||||
[Developer("Glatzemann")]
|
[Developer("Glatzemann, KorsarNek")]
|
||||||
[TestState(TestStateAttribute.TestState.Untested)]
|
[TestState(TestStateAttribute.TestState.Untested)]
|
||||||
public sealed class GraphicsAdapter
|
public sealed class GraphicsAdapter
|
||||||
{
|
{
|
||||||
public static ReadOnlyCollection<GraphicsAdapter> Adapters { get; private set; }
|
private static ReadOnlyCollection<GraphicsAdapter> _adapters;
|
||||||
|
|
||||||
|
public static ReadOnlyCollection<GraphicsAdapter> Adapters
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_adapters == null)
|
||||||
|
{
|
||||||
|
var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
|
||||||
|
_adapters = new ReadOnlyCollection<GraphicsAdapter>(creator.GetAdapterList().Select((x) => new GraphicsAdapter(x)).ToArray());
|
||||||
|
}
|
||||||
|
return _adapters;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static GraphicsAdapter DefaultAdapter
|
public static GraphicsAdapter DefaultAdapter
|
||||||
{
|
{
|
||||||
@ -24,49 +37,100 @@ namespace ANX.Framework.Graphics
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static bool UseNullDevice { get; set; }
|
public static bool UseNullDevice { get; set; }
|
||||||
public static bool UseReferenceDevice { get; set; }
|
public static bool UseReferenceDevice { get; set; }
|
||||||
public int DeviceId { get; set; }
|
|
||||||
public string DeviceName { get; set; }
|
|
||||||
public bool IsDefaultAdapter { get; set; }
|
|
||||||
public int Revision { get; set; }
|
|
||||||
public int SubSystemId { get; set; }
|
|
||||||
public int VendorId { get; set; }
|
|
||||||
public string Description { get; set; }
|
|
||||||
public DisplayMode CurrentDisplayMode { get; set; }
|
|
||||||
public DisplayModeCollection SupportedDisplayModes { get; set; }
|
|
||||||
public IntPtr MonitorHandle { get; set; }
|
|
||||||
|
|
||||||
public bool IsWideScreen
|
private INativeGraphicsAdapter nativeAdapter;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static GraphicsAdapter()
|
#region Public
|
||||||
{
|
public int DeviceId
|
||||||
var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
|
{
|
||||||
Adapters = new ReadOnlyCollection<GraphicsAdapter>(creator.GetAdapterList());
|
get { return nativeAdapter.DeviceId; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string DeviceName
|
||||||
|
{
|
||||||
|
get { return nativeAdapter.DeviceName; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsDefaultAdapter
|
||||||
|
{
|
||||||
|
get { return nativeAdapter.IsDefaultAdapter; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Revision
|
||||||
|
{
|
||||||
|
get { return nativeAdapter.Revision; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int SubSystemId
|
||||||
|
{
|
||||||
|
get { return nativeAdapter.SubSystemId; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int VendorId
|
||||||
|
{
|
||||||
|
get { return nativeAdapter.VendorId; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get { return nativeAdapter.Description; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public DisplayMode CurrentDisplayMode
|
||||||
|
{
|
||||||
|
get { return nativeAdapter.CurrentDisplayMode; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public DisplayModeCollection SupportedDisplayModes
|
||||||
|
{
|
||||||
|
get { return nativeAdapter.SupportedDisplayModes; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntPtr MonitorHandle
|
||||||
|
{
|
||||||
|
get { return nativeAdapter.MonitorHandle; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsWideScreen
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.CurrentDisplayMode.AspectRatio > (16 / 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
internal INativeGraphicsAdapter NativeAdapter
|
||||||
|
{
|
||||||
|
get { return nativeAdapter; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal GraphicsAdapter(INativeGraphicsAdapter nativeAdapter)
|
||||||
|
{
|
||||||
|
if (nativeAdapter == null)
|
||||||
|
throw new ArgumentNullException("nativeAdapter");
|
||||||
|
|
||||||
|
this.nativeAdapter = nativeAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsProfileSupported(GraphicsProfile graphicsProfile)
|
public bool IsProfileSupported(GraphicsProfile graphicsProfile)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return nativeAdapter.IsProfileSupported(graphicsProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool QueryBackBufferFormat(GraphicsProfile graphicsProfile, SurfaceFormat format, DepthFormat depthFormat,
|
public bool QueryBackBufferFormat(GraphicsProfile graphicsProfile, SurfaceFormat format, DepthFormat depthFormat,
|
||||||
int multiSampleCount, out SurfaceFormat selectedFormat, out DepthFormat selectedDepthFormat,
|
int multiSampleCount, out SurfaceFormat selectedFormat, out DepthFormat selectedDepthFormat,
|
||||||
out int selectedMultiSampleCount)
|
out int selectedMultiSampleCount)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return nativeAdapter.QueryBackBufferFormat(graphicsProfile, format, depthFormat, multiSampleCount, out selectedFormat, out selectedDepthFormat, out selectedMultiSampleCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool QueryRenderTargetFormat(GraphicsProfile graphicsProfile, SurfaceFormat format, DepthFormat depthFormat,
|
public bool QueryRenderTargetFormat(GraphicsProfile graphicsProfile, SurfaceFormat format, DepthFormat depthFormat,
|
||||||
int multiSampleCount, out SurfaceFormat selectedFormat, out DepthFormat selectedDepthFormat,
|
int multiSampleCount, out SurfaceFormat selectedFormat, out DepthFormat selectedDepthFormat,
|
||||||
out int selectedMultiSampleCount)
|
out int selectedMultiSampleCount)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return nativeAdapter.QueryRenderTargetFormat(graphicsProfile, format, depthFormat, multiSampleCount, out selectedFormat, out selectedDepthFormat, out selectedMultiSampleCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
35
ANX.Framework/NonXNA/RenderSystem/INativeGraphicsAdapter.cs
Normal file
35
ANX.Framework/NonXNA/RenderSystem/INativeGraphicsAdapter.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#region Using Statements
|
||||||
|
using ANX.Framework.Graphics;
|
||||||
|
using System;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// This file is part of the ANX.Framework created by the
|
||||||
|
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||||
|
// For details see: http://anxframework.codeplex.com/license
|
||||||
|
|
||||||
|
namespace ANX.Framework.NonXNA
|
||||||
|
{
|
||||||
|
public interface INativeGraphicsAdapter
|
||||||
|
{
|
||||||
|
IntPtr MonitorHandle { get; }
|
||||||
|
bool IsDefaultAdapter { get; }
|
||||||
|
int Revision { get; }
|
||||||
|
int SubSystemId { get; }
|
||||||
|
int DeviceId { get; }
|
||||||
|
int VendorId { get; }
|
||||||
|
string DeviceName { get; }
|
||||||
|
string Description { get; }
|
||||||
|
DisplayMode CurrentDisplayMode { get; }
|
||||||
|
DisplayModeCollection SupportedDisplayModes { get; }
|
||||||
|
|
||||||
|
bool IsProfileSupported(GraphicsProfile graphicsProfile);
|
||||||
|
|
||||||
|
bool QueryBackBufferFormat(GraphicsProfile graphicsProfile, SurfaceFormat format, DepthFormat depthFormat,
|
||||||
|
int multiSampleCount, out SurfaceFormat selectedFormat, out DepthFormat selectedDepthFormat,
|
||||||
|
out int selectedMultiSampleCount);
|
||||||
|
|
||||||
|
bool QueryRenderTargetFormat(GraphicsProfile graphicsProfile, SurfaceFormat format, DepthFormat depthFormat,
|
||||||
|
int multiSampleCount, out SurfaceFormat selectedFormat, out DepthFormat selectedDepthFormat,
|
||||||
|
out int selectedMultiSampleCount);
|
||||||
|
}
|
||||||
|
}
|
@ -47,7 +47,7 @@ namespace ANX.Framework.NonXNA
|
|||||||
byte[] GetShaderByteCode(PreDefinedShader type);
|
byte[] GetShaderByteCode(PreDefinedShader type);
|
||||||
EffectSourceLanguage GetStockShaderSourceLanguage { get; }
|
EffectSourceLanguage GetStockShaderSourceLanguage { get; }
|
||||||
|
|
||||||
ReadOnlyCollection<GraphicsAdapter> GetAdapterList();
|
ReadOnlyCollection<INativeGraphicsAdapter> GetAdapterList();
|
||||||
|
|
||||||
void SetTextureSampler(int index, Texture value);
|
void SetTextureSampler(int index, Texture value);
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="BlendStateGL3.cs" />
|
<Compile Include="BlendStateGL3.cs" />
|
||||||
<Compile Include="Creator.cs" />
|
<Compile Include="Creator.cs" />
|
||||||
|
<Compile Include="GraphicsAdapterGL3.cs" />
|
||||||
<Compile Include="Helpers\DatatypesMapping.cs" />
|
<Compile Include="Helpers\DatatypesMapping.cs" />
|
||||||
<Compile Include="DepthStencilStateGL3.cs" />
|
<Compile Include="DepthStencilStateGL3.cs" />
|
||||||
<Compile Include="EffectGL3.cs" />
|
<Compile Include="EffectGL3.cs" />
|
||||||
|
@ -262,48 +262,31 @@ namespace ANX.RenderSystem.GL3
|
|||||||
/// Get a list of available graphics adapter information.
|
/// Get a list of available graphics adapter information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>List of graphics adapters.</returns>
|
/// <returns>List of graphics adapters.</returns>
|
||||||
public ReadOnlyCollection<GraphicsAdapter> GetAdapterList()
|
public ReadOnlyCollection<INativeGraphicsAdapter> GetAdapterList()
|
||||||
{
|
{
|
||||||
AddInSystemFactory.Instance.PreventSystemChange(AddInType.RenderSystem);
|
AddInSystemFactory.Instance.PreventSystemChange(AddInType.RenderSystem);
|
||||||
|
|
||||||
var result = new List<GraphicsAdapter>();
|
var result = new List<INativeGraphicsAdapter>();
|
||||||
foreach (DisplayDevice device in DisplayDevice.AvailableDisplays)
|
foreach (DisplayDevice device in DisplayDevice.AvailableDisplays)
|
||||||
{
|
{
|
||||||
var resultingModes = new List<DisplayMode>();
|
var resultingModes = new List<DisplayMode>();
|
||||||
foreach (string format in Enum.GetNames(typeof(SurfaceFormat)))
|
foreach (string format in Enum.GetNames(typeof(SurfaceFormat)))
|
||||||
{
|
{
|
||||||
SurfaceFormat surfaceFormat = (SurfaceFormat)Enum.Parse(typeof(SurfaceFormat), format);
|
SurfaceFormat surfaceFormat = (SurfaceFormat)Enum.Parse(typeof(SurfaceFormat), format);
|
||||||
|
|
||||||
// TODO: device.BitsPerPixel
|
// TODO: device.BitsPerPixel
|
||||||
if (surfaceFormat != SurfaceFormat.Color)//adapter.Supports(surfaceFormat) == false)
|
if (surfaceFormat != SurfaceFormat.Color)//adapter.Supports(surfaceFormat) == false)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach (DisplayResolution res in device.AvailableResolutions)
|
var newAdapter = new GraphicsAdapterGL3(device, SurfaceFormat.Color);
|
||||||
resultingModes.Add(new DisplayMode(res.Width, res.Height, surfaceFormat));
|
|
||||||
}
|
|
||||||
|
|
||||||
DisplayDevice dev = DisplayDevice.GetDisplay(DisplayIndex.Default);
|
result.Add(newAdapter);
|
||||||
|
}
|
||||||
|
|
||||||
var newAdapter = new GraphicsAdapter
|
return new ReadOnlyCollection<INativeGraphicsAdapter>(result);
|
||||||
{
|
|
||||||
SupportedDisplayModes = new DisplayModeCollection(resultingModes),
|
|
||||||
IsDefaultAdapter = device.IsPrimary,
|
|
||||||
|
|
||||||
// TODO:
|
|
||||||
DeviceId = 0,
|
|
||||||
DeviceName = "",
|
|
||||||
Revision = 0,
|
|
||||||
SubSystemId = 0,
|
|
||||||
VendorId = 0,
|
|
||||||
CurrentDisplayMode = new DisplayMode(dev.Width, dev.Height, SurfaceFormat.Color)
|
|
||||||
};
|
|
||||||
|
|
||||||
result.Add(newAdapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ReadOnlyCollection<GraphicsAdapter>(result);
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
102
RenderSystems/ANX.Framework.GL3/GraphicsAdapterGL3.cs
Normal file
102
RenderSystems/ANX.Framework.GL3/GraphicsAdapterGL3.cs
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
using ANX.Framework.Graphics;
|
||||||
|
using ANX.Framework.NonXNA;
|
||||||
|
using OpenTK;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ANX.RenderSystem.GL3
|
||||||
|
{
|
||||||
|
public class GraphicsAdapterGL3 : INativeGraphicsAdapter
|
||||||
|
{
|
||||||
|
SurfaceFormat surfaceFormat;
|
||||||
|
|
||||||
|
public IntPtr MonitorHandle
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsDefaultAdapter
|
||||||
|
{
|
||||||
|
get { return this.DisplayDevice.IsPrimary; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Revision
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int SubSystemId
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int DeviceId
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int VendorId
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string DeviceName
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public DisplayDevice DisplayDevice
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GraphicsAdapterGL3(DisplayDevice device, SurfaceFormat surfaceFormat)
|
||||||
|
{
|
||||||
|
this.DisplayDevice = device;
|
||||||
|
this.surfaceFormat = surfaceFormat;
|
||||||
|
|
||||||
|
List<DisplayMode> modes = new List<DisplayMode>();
|
||||||
|
foreach (DisplayResolution res in device.AvailableResolutions)
|
||||||
|
modes.Add(new DisplayMode(res.Width, res.Height, surfaceFormat));
|
||||||
|
|
||||||
|
this.SupportedDisplayModes = new DisplayModeCollection(modes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Framework.Graphics.DisplayMode CurrentDisplayMode
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new DisplayMode(this.DisplayDevice.Width, this.DisplayDevice.Height, surfaceFormat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Framework.Graphics.DisplayModeCollection SupportedDisplayModes
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsProfileSupported(Framework.Graphics.GraphicsProfile graphicsProfile)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool QueryBackBufferFormat(Framework.Graphics.GraphicsProfile graphicsProfile, Framework.Graphics.SurfaceFormat format, Framework.Graphics.DepthFormat depthFormat, int multiSampleCount, out Framework.Graphics.SurfaceFormat selectedFormat, out Framework.Graphics.DepthFormat selectedDepthFormat, out int selectedMultiSampleCount)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool QueryRenderTargetFormat(Framework.Graphics.GraphicsProfile graphicsProfile, Framework.Graphics.SurfaceFormat format, Framework.Graphics.DepthFormat depthFormat, int multiSampleCount, out Framework.Graphics.SurfaceFormat selectedFormat, out Framework.Graphics.DepthFormat selectedDepthFormat, out int selectedMultiSampleCount)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,155 @@
|
|||||||
|
using System;
|
||||||
|
using SharpDX.D3DCompiler;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using ANX.Framework.Graphics;
|
||||||
|
using ANX.Framework.NonXNA;
|
||||||
|
using SharpDX.DXGI;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
#if DX10
|
||||||
|
using Dx = SharpDX.Direct3D10;
|
||||||
|
#elif DX11
|
||||||
|
using Dx = SharpDX.Direct3D11;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// This file is part of the ANX.Framework created by the
|
||||||
|
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||||
|
// For details see: http://anxframework.codeplex.com/license
|
||||||
|
|
||||||
|
#if DX10
|
||||||
|
namespace ANX.RenderSystem.Windows.DX10
|
||||||
|
#elif DX11
|
||||||
|
namespace ANX.RenderSystem.Windows.DX11
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
public partial class DirectXGraphicsAdapter : INativeGraphicsAdapter
|
||||||
|
{
|
||||||
|
Output _output;
|
||||||
|
Adapter _adapter;
|
||||||
|
bool _isDefaultAdapter;
|
||||||
|
|
||||||
|
#region Public
|
||||||
|
public IntPtr MonitorHandle
|
||||||
|
{
|
||||||
|
get { return _output.Description.MonitorHandle; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsDefaultAdapter
|
||||||
|
{
|
||||||
|
get { return _isDefaultAdapter; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Revision
|
||||||
|
{
|
||||||
|
get { return _adapter.Description.Revision; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int SubSystemId
|
||||||
|
{
|
||||||
|
get { return _adapter.Description.SubsystemId; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int DeviceId
|
||||||
|
{
|
||||||
|
get { return _adapter.Description.DeviceId; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int VendorId
|
||||||
|
{
|
||||||
|
get { return _adapter.Description.VendorId; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string DeviceName
|
||||||
|
{
|
||||||
|
get { return _output.Description.DeviceName; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get { return _adapter.Description.Description; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public DisplayMode CurrentDisplayMode
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
//Display mode can change when changing resolutions.
|
||||||
|
//The output description will be automatically updated it seems, we only have the return the correct display mode.
|
||||||
|
return new DisplayMode(_output.Description.DesktopBounds.Width, _output.Description.DesktopBounds.Height, SurfaceFormat.Color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DisplayModeCollection SupportedDisplayModes
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Output Output
|
||||||
|
{
|
||||||
|
get { return _output; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Adapter Adapter
|
||||||
|
{
|
||||||
|
get { return _adapter; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModeDescription CurrentModeDescription
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _output.GetDisplayModeList(Format.R8G8B8A8_UNorm, DisplayModeEnumerationFlags.Interlaced).Where(
|
||||||
|
(x) =>
|
||||||
|
{
|
||||||
|
var bounds = _output.Description.DesktopBounds;
|
||||||
|
return x.Width == bounds.Width && x.Height == bounds.Height; //TODO: Check refreshRate too.
|
||||||
|
}).FirstOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
public DirectXGraphicsAdapter(Adapter adapter, Output output, bool isDefaultAdapter)
|
||||||
|
{
|
||||||
|
this._adapter = adapter;
|
||||||
|
this._output = output;
|
||||||
|
this._isDefaultAdapter = isDefaultAdapter;
|
||||||
|
|
||||||
|
List<DisplayMode> supportedModes = new List<DisplayMode>();
|
||||||
|
var modeList = output.GetDisplayModeList(Format.R8G8B8A8_UNorm, DisplayModeEnumerationFlags.Interlaced);
|
||||||
|
foreach (ModeDescription modeDescription in modeList)
|
||||||
|
{
|
||||||
|
var displayMode = new DisplayMode(modeDescription.Width, modeDescription.Height, DxFormatConverter.Translate(modeDescription.Format));
|
||||||
|
supportedModes.Add(displayMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.SupportedDisplayModes = new DisplayModeCollection(supportedModes);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public ModeDescription GetClosestMatchingMode(Dx.Device device, int width, int height)
|
||||||
|
{
|
||||||
|
ModeDescription closestMatch;
|
||||||
|
_output.GetClosestMatchingMode(device, new ModeDescription(width, height, new Rational(0, 0), Format.R8G8B8A8_UNorm), out closestMatch);
|
||||||
|
|
||||||
|
return closestMatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsProfileSupported(GraphicsProfile graphicsProfile)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool QueryBackBufferFormat(GraphicsProfile graphicsProfile, SurfaceFormat format, DepthFormat depthFormat, int multiSampleCount, out SurfaceFormat selectedFormat, out DepthFormat selectedDepthFormat, out int selectedMultiSampleCount)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool QueryRenderTargetFormat(GraphicsProfile graphicsProfile, SurfaceFormat format, DepthFormat depthFormat, int multiSampleCount, out SurfaceFormat selectedFormat, out DepthFormat selectedDepthFormat, out int selectedMultiSampleCount)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -66,6 +66,9 @@
|
|||||||
<Compile Include="..\ANX.RenderSystem.DX.SharedSources\ResourceMapping.cs">
|
<Compile Include="..\ANX.RenderSystem.DX.SharedSources\ResourceMapping.cs">
|
||||||
<Link>ResourceMapping.cs</Link>
|
<Link>ResourceMapping.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\ANX.RenderSystem.DX.SharedSources\SharedGraphicsAdapter.cs">
|
||||||
|
<Link>SharedGraphicsAdapter.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="BlendState_DX10.cs" />
|
<Compile Include="BlendState_DX10.cs" />
|
||||||
<Compile Include="Buffer.cs" />
|
<Compile Include="Buffer.cs" />
|
||||||
<Compile Include="Creator.cs" />
|
<Compile Include="Creator.cs" />
|
||||||
|
@ -182,56 +182,27 @@ namespace ANX.RenderSystem.Windows.DX10
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region GetAdapterList
|
#region GetAdapterList
|
||||||
public ReadOnlyCollection<GraphicsAdapter> GetAdapterList()
|
public ReadOnlyCollection<INativeGraphicsAdapter> GetAdapterList()
|
||||||
{
|
{
|
||||||
PreventSystemChange();
|
PreventSystemChange();
|
||||||
|
|
||||||
var adapterList = new List<GraphicsAdapter>();
|
var adapterList = new List<INativeGraphicsAdapter>();
|
||||||
var resultingModes = new List<DisplayMode>();
|
bool firstOutput = true;
|
||||||
|
|
||||||
using (Factory factory = new Factory())
|
using (Factory factory = new Factory())
|
||||||
{
|
{
|
||||||
for (int i = 0; i < factory.GetAdapterCount(); i++)
|
foreach (Adapter adapter in factory.Adapters)
|
||||||
{
|
{
|
||||||
using (Adapter adapter = factory.GetAdapter(i))
|
foreach (Output output in adapter.Outputs)
|
||||||
{
|
{
|
||||||
var ga = new GraphicsAdapter();
|
//By definition, the first returned output is always the default adapter.
|
||||||
ga.Description = adapter.Description.Description;
|
adapterList.Add(new DirectXGraphicsAdapter(adapter, output, firstOutput));
|
||||||
ga.DeviceId = adapter.Description.DeviceId;
|
firstOutput = false;
|
||||||
ga.DeviceName = adapter.Description.Description;
|
|
||||||
ga.IsDefaultAdapter = i == 0; //TODO: how to set default adapter?
|
|
||||||
//ga.IsWideScreen = ;
|
|
||||||
ga.Revision = adapter.Description.Revision;
|
|
||||||
ga.SubSystemId = adapter.Description.SubsystemId;
|
|
||||||
ga.VendorId = adapter.Description.VendorId;
|
|
||||||
|
|
||||||
resultingModes.Clear();
|
|
||||||
|
|
||||||
if (adapter.Outputs.Length >= 1)
|
|
||||||
{
|
|
||||||
using (Output adapterOutput = adapter.Outputs[0])
|
|
||||||
{
|
|
||||||
var modeList = adapterOutput.GetDisplayModeList(Format.R8G8B8A8_UNorm, DisplayModeEnumerationFlags.Interlaced);
|
|
||||||
|
|
||||||
foreach (ModeDescription modeDescription in modeList)
|
|
||||||
{
|
|
||||||
var displayMode = new DisplayMode(modeDescription.Width, modeDescription.Height, DxFormatConverter.Translate(modeDescription.Format));
|
|
||||||
resultingModes.Add(displayMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
ga.CurrentDisplayMode = new DisplayMode(adapterOutput.Description.DesktopBounds.Width, adapterOutput.Description.DesktopBounds.Height, SurfaceFormat.Color);
|
|
||||||
ga.MonitorHandle = adapterOutput.Description.MonitorHandle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ga.SupportedDisplayModes = new DisplayModeCollection(resultingModes);
|
|
||||||
|
|
||||||
adapterList.Add(ga);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ReadOnlyCollection<GraphicsAdapter>(adapterList);
|
return new ReadOnlyCollection<INativeGraphicsAdapter>(adapterList);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -79,6 +79,9 @@
|
|||||||
<Compile Include="..\ANX.RenderSystem.DX.SharedSources\ResourceMapping.cs">
|
<Compile Include="..\ANX.RenderSystem.DX.SharedSources\ResourceMapping.cs">
|
||||||
<Link>ResourceMapping.cs</Link>
|
<Link>ResourceMapping.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\ANX.RenderSystem.DX.SharedSources\SharedGraphicsAdapter.cs">
|
||||||
|
<Link>SharedGraphicsAdapter.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="BlendState_DX11.cs" />
|
<Compile Include="BlendState_DX11.cs" />
|
||||||
<Compile Include="Buffer.cs" />
|
<Compile Include="Buffer.cs" />
|
||||||
<Compile Include="Creator.cs" />
|
<Compile Include="Creator.cs" />
|
||||||
|
@ -187,56 +187,27 @@ namespace ANX.RenderSystem.Windows.DX11
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region GetAdapterList
|
#region GetAdapterList
|
||||||
public ReadOnlyCollection<GraphicsAdapter> GetAdapterList()
|
public ReadOnlyCollection<INativeGraphicsAdapter> GetAdapterList()
|
||||||
{
|
{
|
||||||
PreventSystemChange();
|
PreventSystemChange();
|
||||||
|
|
||||||
var adapterList = new List<GraphicsAdapter>();
|
var adapterList = new List<INativeGraphicsAdapter>();
|
||||||
var resultingModes = new List<DisplayMode>();
|
bool firstOutput = true;
|
||||||
|
|
||||||
using (Factory factory = new Factory())
|
using (Factory factory = new Factory())
|
||||||
{
|
{
|
||||||
for (int i = 0; i < factory.GetAdapterCount(); i++)
|
foreach (Adapter adapter in factory.Adapters)
|
||||||
{
|
{
|
||||||
using (Adapter adapter = factory.GetAdapter(i))
|
foreach (Output output in adapter.Outputs)
|
||||||
{
|
{
|
||||||
GraphicsAdapter ga = new GraphicsAdapter();
|
//By definition, the first returned output is always the default adapter.
|
||||||
ga.Description = adapter.Description.Description;
|
adapterList.Add(new DirectXGraphicsAdapter(adapter, output, firstOutput));
|
||||||
ga.DeviceId = adapter.Description.DeviceId;
|
firstOutput = false;
|
||||||
ga.DeviceName = adapter.Description.Description;
|
|
||||||
ga.IsDefaultAdapter = i == 0; //TODO: how to set default adapter?
|
|
||||||
//ga.IsWideScreen = ;
|
|
||||||
ga.Revision = adapter.Description.Revision;
|
|
||||||
ga.SubSystemId = adapter.Description.SubsystemId;
|
|
||||||
ga.VendorId = adapter.Description.VendorId;
|
|
||||||
|
|
||||||
resultingModes.Clear();
|
|
||||||
|
|
||||||
if (adapter.Outputs.Length >= 1)
|
|
||||||
{
|
|
||||||
using (Output adapterOutput = adapter.Outputs[0])
|
|
||||||
{
|
|
||||||
var modeList = adapterOutput.GetDisplayModeList(Format.R8G8B8A8_UNorm, DisplayModeEnumerationFlags.Interlaced);
|
|
||||||
|
|
||||||
foreach (ModeDescription modeDescription in modeList)
|
|
||||||
{
|
|
||||||
var displayMode = new DisplayMode(modeDescription.Width, modeDescription.Height, DxFormatConverter.Translate(modeDescription.Format));
|
|
||||||
resultingModes.Add(displayMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
ga.CurrentDisplayMode = new DisplayMode(adapterOutput.Description.DesktopBounds.Width, adapterOutput.Description.DesktopBounds.Height, SurfaceFormat.Color);
|
|
||||||
ga.MonitorHandle = adapterOutput.Description.MonitorHandle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ga.SupportedDisplayModes = new DisplayModeCollection(resultingModes);
|
|
||||||
|
|
||||||
adapterList.Add(ga);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new System.Collections.ObjectModel.ReadOnlyCollection<GraphicsAdapter>(adapterList);
|
return new ReadOnlyCollection<INativeGraphicsAdapter>(adapterList);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user