Improved DEBUG info on D3D12 objects
このコミットが含まれているのは:
1 親
e4cc915ee0
コミット
b141f0d8c1
9ファイル変更
+36
-39
検索条件に一致するファイルはありません
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Core.Extensions;
|
||||
using ComputeSharp.Graphics.Resources.Interop;
|
||||
@@ -38,5 +39,22 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
{
|
||||
d3D12Resource.Unmap(0, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assigns a name to a given <see cref="ID3D12Resource"/>.
|
||||
/// </summary>
|
||||
/// <param name="d3D12Resource">The target <see cref="ID3D12Resource"/> to map.</param>
|
||||
/// <param name="wrapper">The wrapper object to get the name from.</param>
|
||||
/// <exception cref="Exception">Thrown when the mapping operation fails.</exception>
|
||||
[Conditional("DEBUG")]
|
||||
public static void SetName(this ref ID3D12Resource d3D12Resource, object wrapper)
|
||||
{
|
||||
string name = wrapper.ToString()!;
|
||||
|
||||
fixed (char* p = name)
|
||||
{
|
||||
d3D12Resource.SetName((ushort*)p).Assert();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,8 @@ namespace ComputeSharp.Resources
|
||||
device.D3D12Device->CreateUnorderedAccessView(this.d3D12Resource.Get(), (uint)length, elementSizeInBytes, D3D12CpuDescriptorHandle);
|
||||
break;
|
||||
}
|
||||
|
||||
this.d3D12Resource.Get()->SetName(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -111,6 +111,8 @@ namespace ComputeSharp.Resources
|
||||
device.D3D12Device->CreateUnorderedAccessView(this.d3D12Resource.Get(), DXGIFormatHelper.GetForType<T>(), D3D12_UAV_DIMENSION_TEXTURE2D, D3D12CpuDescriptorHandle);
|
||||
break;
|
||||
}
|
||||
|
||||
this.d3D12Resource.Get()->SetName(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -115,6 +115,8 @@ namespace ComputeSharp.Resources
|
||||
device.D3D12Device->CreateUnorderedAccessView(this.d3D12Resource.Get(), DXGIFormatHelper.GetForType<T>(), D3D12_UAV_DIMENSION_TEXTURE3D, D3D12CpuDescriptorHandle);
|
||||
break;
|
||||
}
|
||||
|
||||
this.d3D12Resource.Get()->SetName(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -48,6 +48,8 @@ namespace ComputeSharp.Resources
|
||||
|
||||
this.d3D12Resource = device.D3D12Device->CreateCommittedResource(resourceType, allocationMode, sizeInBytes, device.IsCacheCoherentUMA);
|
||||
this.mappedData = (T*)this.d3D12Resource.Get()->Map().Pointer;
|
||||
|
||||
this.d3D12Resource.Get()->SetName(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -65,6 +65,8 @@ namespace ComputeSharp.Resources
|
||||
|
||||
this.d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(resourceType, allocationMode, totalSizeInBytes, GraphicsDevice.IsCacheCoherentUMA);
|
||||
this.mappedData = (T*)this.d3D12Resource.Get()->Map().Pointer;
|
||||
|
||||
this.d3D12Resource.Get()->SetName(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -68,6 +68,8 @@ namespace ComputeSharp.Resources
|
||||
|
||||
this.d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(resourceType, allocationMode, totalSizeInBytes, GraphicsDevice.IsCacheCoherentUMA);
|
||||
this.mappedData = (T*)this.d3D12Resource.Get()->Map().Pointer;
|
||||
|
||||
this.d3D12Resource.Get()->SetName(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace ComputeSharp.Tests.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// An helper <see langword="class"/> with methods to process fixed-size buffers.
|
||||
/// </summary>
|
||||
public static class SpanExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// The maximum threshold to validate two <see langword="float"/> values as being equal.
|
||||
/// </summary>
|
||||
private const float FloatThreshold = 0.00001f;
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether or not the two input <see cref="Span{T}"/> instances have the same content.
|
||||
/// </summary>
|
||||
/// <param name="a">The first <see cref="Span{T}"/> to check.</param>
|
||||
/// <param name="b">The second <see cref="Span{T}"/> to check.</param>
|
||||
[Pure]
|
||||
public static bool ContentEquals(this Span<float> a, Span<float> b)
|
||||
{
|
||||
if (a.Length != b.Length) return false;
|
||||
if (a.Length == 0) return true;
|
||||
|
||||
var l = a.Length;
|
||||
ref var ra = ref a.GetPinnableReference();
|
||||
ref var rb = ref b.GetPinnableReference();
|
||||
|
||||
for (var i = 0; i < l; i++)
|
||||
if (Math.Abs(Unsafe.Add(ref ra, i) - Unsafe.Add(ref rb, i)) > FloatThreshold)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,10 @@ namespace ComputeSharp.Tests
|
||||
[AllDevices]
|
||||
public void BokehBlur(Device device)
|
||||
{
|
||||
// Early test to ensure the device is available. This saves time when running the
|
||||
// unit test if the target device is not available, as we skip the preprocessing.
|
||||
_ = device.Get();
|
||||
|
||||
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging");
|
||||
|
||||
using var original = Image.Load<ImageSharpRgba32>(Path.Combine(path, "city.jpg"));
|
||||
@@ -42,6 +46,8 @@ namespace ComputeSharp.Tests
|
||||
[AllDevices]
|
||||
public void GaussianBlur(Device device)
|
||||
{
|
||||
_ = device.Get();
|
||||
|
||||
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging");
|
||||
|
||||
using var original = Image.Load<ImageSharpRgba32>(Path.Combine(path, "city.jpg"));
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする