From c0db9ca81b0382a134349226cd43e497a029352e Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 18 Nov 2020 12:53:41 +0100 Subject: [PATCH] Added GraphicsDeviceInfo type --- src/ComputeSharp.Graphics/GraphicsDevice.cs | 4 +-- .../GraphicsDeviceInfo.cs | 36 +++++++++++++++++++ src/ComputeSharp.Graphics/Luid.cs | 2 +- 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 src/ComputeSharp.Graphics/GraphicsDeviceInfo.cs diff --git a/src/ComputeSharp.Graphics/GraphicsDevice.cs b/src/ComputeSharp.Graphics/GraphicsDevice.cs index 58d5fb97..0bff46cb 100644 --- a/src/ComputeSharp.Graphics/GraphicsDevice.cs +++ b/src/ComputeSharp.Graphics/GraphicsDevice.cs @@ -67,8 +67,8 @@ namespace ComputeSharp.Graphics /// /// Creates a new instance for the input . /// - /// The to use for the new instance. - /// The available info for the new instance. + /// The to use for the new instance. + /// The available info for the new instance. internal GraphicsDevice(ComPtr d3d12device, DXGI_ADAPTER_DESC1* dxgiDescription1) { this.d3D12Device = d3d12device; diff --git a/src/ComputeSharp.Graphics/GraphicsDeviceInfo.cs b/src/ComputeSharp.Graphics/GraphicsDeviceInfo.cs new file mode 100644 index 00000000..7ec594d3 --- /dev/null +++ b/src/ComputeSharp.Graphics/GraphicsDeviceInfo.cs @@ -0,0 +1,36 @@ +using TerraFX.Interop; + +namespace ComputeSharp.Graphics +{ + /// + /// A type containing info on a given DX12.0 device that can be used. + /// + public readonly struct GraphicsDeviceInfo + { + /// + /// Creates a new instance with the specified parameters. + /// + /// The available info for the associate device. + internal unsafe GraphicsDeviceInfo(DXGI_ADAPTER_DESC1* dxgiDescription1) + { + Luid = *(Luid*)&dxgiDescription1->AdapterLuid; + Name = new string((char*)dxgiDescription1->Description); + MemorySize = dxgiDescription1->DedicatedVideoMemory; + } + + /// + /// Gets the locally unique identifier for the current device. + /// + public Luid Luid { get; } + + /// + /// Gets the name of the associated device. + /// + public string Name { get; } + + /// + /// Gets the size of the dedicated video memory for the associated device. + /// + public nuint MemorySize { get; } + } +} diff --git a/src/ComputeSharp.Graphics/Luid.cs b/src/ComputeSharp.Graphics/Luid.cs index 7123b1b3..568884b9 100644 --- a/src/ComputeSharp.Graphics/Luid.cs +++ b/src/ComputeSharp.Graphics/Luid.cs @@ -2,7 +2,7 @@ using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; -namespace ComputeSharp +namespace ComputeSharp.Graphics { /// /// A locally unique identifier for a graphics device.