From 78ce4fb4e2535fc47d550bc06069d429f05e7597 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 2 Jan 2021 17:39:32 +0100 Subject: [PATCH] Added more info properties to devices --- src/ComputeSharp.Graphics/GraphicsDevice.cs | 20 ++++++++++++++++--- .../GraphicsDeviceInfo.cs | 20 ++++++++++++++++--- .../ComputeSharp.Tests/InitializationTests.cs | 2 +- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/ComputeSharp.Graphics/GraphicsDevice.cs b/src/ComputeSharp.Graphics/GraphicsDevice.cs index 92503ee7..bfb9e5cd 100644 --- a/src/ComputeSharp.Graphics/GraphicsDevice.cs +++ b/src/ComputeSharp.Graphics/GraphicsDevice.cs @@ -12,6 +12,7 @@ using TerraFX.Interop; using static TerraFX.Interop.D3D12_COMMAND_LIST_TYPE; using static TerraFX.Interop.D3D12_FEATURE; using static TerraFX.Interop.D3D12_FORMAT_SUPPORT1; +using static TerraFX.Interop.DXGI_ADAPTER_FLAG; namespace ComputeSharp.Graphics { @@ -90,7 +91,9 @@ namespace ComputeSharp.Graphics Luid = Luid.FromLUID(dxgiDescription1->AdapterLuid); Name = new string((char*)dxgiDescription1->Description); - MemorySize = dxgiDescription1->DedicatedVideoMemory; + DedicatedMemorySize = dxgiDescription1->DedicatedVideoMemory; + SharedMemorySize = dxgiDescription1->SharedSystemMemory; + IsHardwareAccelerated = (dxgiDescription1->Flags & (uint)DXGI_ADAPTER_FLAG_SOFTWARE) == 0; var d3D12Options1Data = d3D12Device.Get()->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS1); @@ -109,9 +112,20 @@ namespace ComputeSharp.Graphics public string Name { get; } /// - /// Gets the size of the dedicated video memory for the current instance. + /// Gets the size of the dedicated memory for the current device. /// - public nuint MemorySize { get; } + public nuint DedicatedMemorySize { get; } + + /// + /// Gets the size of the shared system memory for the current device. + /// + public nuint SharedMemorySize { get; } + + /// + /// Gets whether or not the current device is hardware accelerated. + /// This value is for software fallback devices. + /// + public bool IsHardwareAccelerated { get; } /// /// Gets the number of total lanes on the current device (eg. CUDA cores on an nVidia GPU). diff --git a/src/ComputeSharp.Graphics/GraphicsDeviceInfo.cs b/src/ComputeSharp.Graphics/GraphicsDeviceInfo.cs index 4ea257dc..ad07c130 100644 --- a/src/ComputeSharp.Graphics/GraphicsDeviceInfo.cs +++ b/src/ComputeSharp.Graphics/GraphicsDeviceInfo.cs @@ -1,4 +1,5 @@ using TerraFX.Interop; +using static TerraFX.Interop.DXGI_ADAPTER_FLAG; namespace ComputeSharp.Graphics { @@ -15,7 +16,9 @@ namespace ComputeSharp.Graphics { Luid = Luid.FromLUID(dxgiDescription1->AdapterLuid); Name = new string((char*)dxgiDescription1->Description); - MemorySize = dxgiDescription1->DedicatedVideoMemory; + DedicatedMemorySize = dxgiDescription1->DedicatedVideoMemory; + SharedMemorySize = dxgiDescription1->SharedSystemMemory; + IsHardwareAccelerated = (dxgiDescription1->Flags & (uint)DXGI_ADAPTER_FLAG_SOFTWARE) == 0; } /// @@ -29,8 +32,19 @@ namespace ComputeSharp.Graphics public string Name { get; } /// - /// Gets the size of the dedicated video memory for the associated device. + /// Gets the size of the dedicated memory for the associated device. /// - public nuint MemorySize { get; } + public nuint DedicatedMemorySize { get; } + + /// + /// Gets the size of the shared system memory for the associated device. + /// + public nuint SharedMemorySize { get; } + + /// + /// Gets whether or not the associated device is hardware accelerated. + /// This value is for software fallback devices. + /// + public bool IsHardwareAccelerated { get; } } } diff --git a/tests/ComputeSharp.Tests/InitializationTests.cs b/tests/ComputeSharp.Tests/InitializationTests.cs index 2e68999f..68c87389 100644 --- a/tests/ComputeSharp.Tests/InitializationTests.cs +++ b/tests/ComputeSharp.Tests/InitializationTests.cs @@ -59,7 +59,7 @@ namespace ComputeSharp.Tests { int i = 0; - foreach (GraphicsDevice device in Gpu.QueryDevices(info => info.MemorySize >= 1024)) + foreach (GraphicsDevice device in Gpu.QueryDevices(info => info.DedicatedMemorySize >= 1024)) { if (i++ == 0) Assert.AreSame(Gpu.Default, device);