diff --git a/src/ComputeSharp/Graphics/Commands/Interop/ID3D12DescriptorHandleAllocator.cs b/src/ComputeSharp/Graphics/Commands/Interop/ID3D12DescriptorHandleAllocator.cs index 3c869ad8..5591aba3 100644 --- a/src/ComputeSharp/Graphics/Commands/Interop/ID3D12DescriptorHandleAllocator.cs +++ b/src/ComputeSharp/Graphics/Commands/Interop/ID3D12DescriptorHandleAllocator.cs @@ -94,7 +94,10 @@ internal unsafe struct ID3D12DescriptorHandleAllocator : IDisposable { lock (this.d3D12DescriptorHandlePairs) { - Guard.IsGreaterThan(this.size, 0, nameof(size)); + if (this.size <= 0) + { + ThrowHelper.ThrowInvalidOperationException("There are no descriptor handles left in the pool."); + } d3D12ResourceDescriptorHandles = this.d3D12DescriptorHandlePairs[this.head++]; @@ -115,7 +118,10 @@ internal unsafe struct ID3D12DescriptorHandleAllocator : IDisposable { lock (this.d3D12DescriptorHandlePairs) { - Guard.IsLessThan(this.size, DescriptorsPerHeap, nameof(size)); + if (this.size >= DescriptorsPerHeap) + { + ThrowHelper.ThrowInvalidOperationException("The pool of descriptor heaps is already full."); + } this.d3D12DescriptorHandlePairs[this.tail++] = d3D12ResourceDescriptorHandles;