未割当ディスクリプタの返却を無視するよう修正

このコミットが含まれているのは:
routersys committed 2026-07-17 08:27:05 +09:00
1 親 27880c60b8
コミット 902d1a50a3
2ファイル変更
+29 -1

検索条件に一致するファイルはありません

+8 -1
ファイルの表示
@@ -108,6 +108,13 @@ internal unsafe struct ID3D12DescriptorHandleAllocator : IDisposable
/// <param name="d3D12ResourceDescriptorHandles">The returned <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> value.</param>
public void Return(in ID3D12ResourceDescriptorHandles d3D12ResourceDescriptorHandles)
{
if (d3D12ResourceDescriptorHandles.D3D12CpuDescriptorHandle.ptr == 0 &&
d3D12ResourceDescriptorHandles.D3D12GpuDescriptorHandle.ptr == 0 &&
d3D12ResourceDescriptorHandles.D3D12CpuDescriptorHandleNonShaderVisible.ptr == 0)
{
return;
}
lock (this.d3D12DescriptorHandlePairs)
{
default(InvalidOperationException).ThrowIf(this.size >= DescriptorsPerHeap);
@@ -129,4 +136,4 @@ internal unsafe struct ID3D12DescriptorHandleAllocator : IDisposable
this.d3D12DescriptorHeap.Dispose();
this.d3D12DescriptorHeapNonShaderVisible.Dispose();
}
}
}
+21
ファイルの表示
@@ -2,6 +2,7 @@ using System;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using ComputeSharp.Graphics.Commands.Interop;
using ComputeSharp.Interop;
using ComputeSharp.Tests.Attributes;
using ComputeSharp.Tests.Extensions;
@@ -16,6 +17,26 @@ public unsafe partial class InteropServicesTests
[DllImport("kernel32", ExactSpelling = true)]
private static extern int CloseHandle(nint hObject);
[CombinatorialTestMethod]
[AllDevices]
public void DescriptorHandleAllocator_DefaultReturnIsIgnoredAndDuplicateReturnThrows(Device device)
{
ID3D12DescriptorHandleAllocator allocator = new(device.Get().D3D12Device);
try
{
allocator.Return(default);
allocator.Rent(out ID3D12ResourceDescriptorHandles handles);
allocator.Return(in handles);
Assert.ThrowsExactly<InvalidOperationException>(() => allocator.Return(in handles));
}
finally
{
allocator.Dispose();
}
}
[CombinatorialTestMethod]
[AllDevices]
public void SharedReadWriteTexture2D_ComputeShaderRoundTrip(Device device)