Add non shader visible descriptor heap setup
このコミットが含まれているのは:
1 親
2ceb3b83f6
コミット
a9f50c1e46
7ファイル変更
+80
-25
検索条件に一致するファイルはありません
@@ -26,9 +26,14 @@ internal unsafe struct ID3D12DescriptorHandleAllocator : IDisposable
|
||||
private ComPtr<ID3D12DescriptorHeap> d3D12DescriptorHeap;
|
||||
|
||||
/// <summary>
|
||||
/// The array of <see cref="D3D12DescriptorHandlePair"/> items with the available descriptor handles.
|
||||
/// The non shader visible <see cref="ID3D12DescriptorHeap"/> in use for the current <see cref="ID3D12DescriptorHandleAllocator"/> instance.
|
||||
/// </summary>
|
||||
private readonly D3D12DescriptorHandlePair[] d3D12DescriptorHandlePairs;
|
||||
private ComPtr<ID3D12DescriptorHeap> d3D12DescriptorHeapNonShaderVisible;
|
||||
|
||||
/// <summary>
|
||||
/// The array of <see cref="D3D12DescriptorHandleBundle"/> items with the available descriptor handles.
|
||||
/// </summary>
|
||||
private readonly D3D12DescriptorHandleBundle[] d3D12DescriptorHandlePairs;
|
||||
|
||||
/// <summary>
|
||||
/// The head index for the queue.
|
||||
@@ -51,20 +56,23 @@ internal unsafe struct ID3D12DescriptorHandleAllocator : IDisposable
|
||||
/// <param name="device">The <see cref="ID3D12Device"/> instance to use.</param>
|
||||
public ID3D12DescriptorHandleAllocator(ID3D12Device* device)
|
||||
{
|
||||
this.d3D12DescriptorHeap = device->CreateDescriptorHeap(DescriptorsPerHeap);
|
||||
this.d3D12DescriptorHandlePairs = GC.AllocateUninitializedArray<D3D12DescriptorHandlePair>((int)DescriptorsPerHeap);
|
||||
this.d3D12DescriptorHeap = device->CreateDescriptorHeap(DescriptorsPerHeap, isShaderVisible: true);
|
||||
this.d3D12DescriptorHeapNonShaderVisible = device->CreateDescriptorHeap(DescriptorsPerHeap, isShaderVisible: false);
|
||||
this.d3D12DescriptorHandlePairs = GC.AllocateUninitializedArray<D3D12DescriptorHandleBundle>((int)DescriptorsPerHeap);
|
||||
this.head = 0;
|
||||
this.tail = 0;
|
||||
this.size = (int)DescriptorsPerHeap;
|
||||
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle = this.d3D12DescriptorHeap.Get()->GetCPUDescriptorHandleForHeapStart();
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandleNonShaderVisible = this.d3D12DescriptorHeapNonShaderVisible.Get()->GetCPUDescriptorHandleForHeapStart();
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandleStart = this.d3D12DescriptorHeap.Get()->GetGPUDescriptorHandleForHeapStart();
|
||||
uint descriptorIncrementSize = device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
||||
|
||||
for (int i = 0; i < this.d3D12DescriptorHandlePairs.Length; i++)
|
||||
{
|
||||
this.d3D12DescriptorHandlePairs[i] = new D3D12DescriptorHandlePair(
|
||||
this.d3D12DescriptorHandlePairs[i] = new D3D12DescriptorHandleBundle(
|
||||
in d3D12CpuDescriptorHandle,
|
||||
in d3D12CpuDescriptorHandleNonShaderVisible,
|
||||
in d3D12GpuDescriptorHandleStart,
|
||||
i,
|
||||
descriptorIncrementSize);
|
||||
@@ -80,18 +88,21 @@ internal unsafe struct ID3D12DescriptorHandleAllocator : IDisposable
|
||||
/// Rents a new CPU and GPU handle pair to use in a memory buffer.
|
||||
/// </summary>
|
||||
/// <param name="d3D12CpuDescriptorHandle">The resulting <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> value.</param>
|
||||
/// <param name="d3D12CpuDescriptorHandleNonShaderVisible">The resulting non shader visible <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> value.</param>
|
||||
/// <param name="d3D12GpuDescriptorHandle">The resulting <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value.</param>
|
||||
public void Rent(
|
||||
out D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle,
|
||||
out D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandleNonShaderVisible,
|
||||
out D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle)
|
||||
{
|
||||
lock (this.d3D12DescriptorHandlePairs)
|
||||
{
|
||||
Guard.IsGreaterThan(this.size, 0, nameof(size));
|
||||
|
||||
ref readonly D3D12DescriptorHandlePair d3D12DescriptorHandlePair = ref this.d3D12DescriptorHandlePairs[this.head++];
|
||||
ref readonly D3D12DescriptorHandleBundle d3D12DescriptorHandlePair = ref this.d3D12DescriptorHandlePairs[this.head++];
|
||||
|
||||
d3D12CpuDescriptorHandle = d3D12DescriptorHandlePair.D3D12CpuDescriptorHandle;
|
||||
d3D12CpuDescriptorHandleNonShaderVisible = d3D12DescriptorHandlePair.D3D12CpuDescriptorHandleNonShaderVisible;
|
||||
d3D12GpuDescriptorHandle = d3D12DescriptorHandlePair.D3D12GpuDescriptorhandle;
|
||||
|
||||
if (this.head == DescriptorsPerHeap)
|
||||
@@ -107,16 +118,18 @@ internal unsafe struct ID3D12DescriptorHandleAllocator : IDisposable
|
||||
/// Returns a CPU and GPU handle pair for later use.
|
||||
/// </summary>
|
||||
/// <param name="d3D12CpuDescriptorHandle">The returned <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> value.</param>
|
||||
/// <param name="d3D12CpuDescriptorHandleNonShaderVisible">The returned non shader visible <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> value.</param>
|
||||
/// <param name="d3D12GpuDescriptorHandle">The returned <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value.</param>
|
||||
public void Return(
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle,
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandleNonShaderVisible,
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle)
|
||||
{
|
||||
lock (this.d3D12DescriptorHandlePairs)
|
||||
{
|
||||
Guard.IsLessThan(this.size, DescriptorsPerHeap, nameof(size));
|
||||
|
||||
this.d3D12DescriptorHandlePairs[this.tail++] = new D3D12DescriptorHandlePair(d3D12CpuDescriptorHandle, d3D12GpuDescriptorHandle);
|
||||
this.d3D12DescriptorHandlePairs[this.tail++] = new D3D12DescriptorHandleBundle(d3D12CpuDescriptorHandle, d3D12CpuDescriptorHandleNonShaderVisible, d3D12GpuDescriptorHandle);
|
||||
|
||||
if (this.tail == DescriptorsPerHeap)
|
||||
{
|
||||
@@ -134,47 +147,58 @@ internal unsafe struct ID3D12DescriptorHandleAllocator : IDisposable
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A type representing a pair of reusable descriptor handles.
|
||||
/// A type representing a bundle of reusable descriptor handles.
|
||||
/// </summary>
|
||||
private readonly struct D3D12DescriptorHandlePair
|
||||
private readonly struct D3D12DescriptorHandleBundle
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value for the current entry.
|
||||
/// </summary>
|
||||
public readonly D3D12_CPU_DESCRIPTOR_HANDLE D3D12CpuDescriptorHandle;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value for the current entry, non shader visible.
|
||||
/// </summary>
|
||||
public readonly D3D12_CPU_DESCRIPTOR_HANDLE D3D12CpuDescriptorHandleNonShaderVisible;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value for the current entry.
|
||||
/// </summary>
|
||||
public readonly D3D12_GPU_DESCRIPTOR_HANDLE D3D12GpuDescriptorhandle;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="D3D12DescriptorHandlePair"/> instance with the given parameters.
|
||||
/// Creates a new <see cref="D3D12DescriptorHandleBundle"/> instance with the given parameters.
|
||||
/// </summary>
|
||||
/// <param name="d3D12CpuDescriptorHandle">The <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value to wrap.</param>
|
||||
/// <param name="d3D12CpuDescriptorHandleNonShaderVisible">The non shader visible <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value to wrap.</param>
|
||||
/// <param name="d3D12GpuDescriptorHandle">The <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value to wrap.</param>
|
||||
public D3D12DescriptorHandlePair(
|
||||
public D3D12DescriptorHandleBundle(
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle,
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandleNonShaderVisible,
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle)
|
||||
{
|
||||
D3D12CpuDescriptorHandle = d3D12CpuDescriptorHandle;
|
||||
D3D12CpuDescriptorHandleNonShaderVisible = d3D12CpuDescriptorHandleNonShaderVisible;
|
||||
D3D12GpuDescriptorhandle = d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="D3D12DescriptorHandlePair"/> instance with the given parameters.
|
||||
/// Creates a new <see cref="D3D12DescriptorHandleBundle"/> instance with the given parameters.
|
||||
/// </summary>
|
||||
/// <param name="d3D12CpuDescriptorHandleStart">The base <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value.</param>
|
||||
/// <param name="d3D12CpuDescriptorHandleNonShaderVisible">The base non shader visible <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value.</param>
|
||||
/// <param name="d3D12GpuDescriptorHandleStart">The base <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value.</param>
|
||||
/// <param name="offset">The offset for the new pair of handles to compute.</param>
|
||||
/// <param name="descriptorIncrementSize">The increment size for each consecutive handles pair.</param>
|
||||
public D3D12DescriptorHandlePair(
|
||||
public D3D12DescriptorHandleBundle(
|
||||
in D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandleStart,
|
||||
in D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandleNonShaderVisible,
|
||||
in D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandleStart,
|
||||
int offset,
|
||||
uint descriptorIncrementSize)
|
||||
{
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE.InitOffsetted(out D3D12CpuDescriptorHandle, in d3D12CpuDescriptorHandleStart, offset, descriptorIncrementSize);
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE.InitOffsetted(out D3D12CpuDescriptorHandleNonShaderVisible, in d3D12CpuDescriptorHandleNonShaderVisible, offset, descriptorIncrementSize);
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE.InitOffsetted(out D3D12GpuDescriptorhandle, in d3D12GpuDescriptorHandleStart, offset, descriptorIncrementSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,16 +321,17 @@ internal static unsafe class ID3D12DeviceExtensions
|
||||
/// </summary>
|
||||
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> to use to create the descriptor heap.</param>
|
||||
/// <param name="descriptorsCount">The number of descriptors to allocate.</param>
|
||||
/// <param name="isShaderVisible">Whether or not the descriptor heap should be shader visible.</param>
|
||||
/// <returns>A pointer to the newly allocated <see cref="ID3D12DescriptorHeap"/> instance.</returns>
|
||||
/// <exception cref="Exception">Thrown when the creation of the command queue fails.</exception>
|
||||
public static ComPtr<ID3D12DescriptorHeap> CreateDescriptorHeap(this ref ID3D12Device d3D12Device, uint descriptorsCount)
|
||||
public static ComPtr<ID3D12DescriptorHeap> CreateDescriptorHeap(this ref ID3D12Device d3D12Device, uint descriptorsCount, bool isShaderVisible)
|
||||
{
|
||||
using ComPtr<ID3D12DescriptorHeap> d3D12DescriptorHeap = default;
|
||||
|
||||
D3D12_DESCRIPTOR_HEAP_DESC d3D12DescriptorHeapDesc;
|
||||
d3D12DescriptorHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
|
||||
d3D12DescriptorHeapDesc.NumDescriptors = descriptorsCount;
|
||||
d3D12DescriptorHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
|
||||
d3D12DescriptorHeapDesc.Flags = isShaderVisible ? D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE : D3D12_DESCRIPTOR_HEAP_FLAGS.D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
|
||||
d3D12DescriptorHeapDesc.NodeMask = 0;
|
||||
|
||||
d3D12Device.CreateDescriptorHeap(
|
||||
|
||||
@@ -286,18 +286,20 @@ public sealed unsafe partial class GraphicsDevice : NativeObject
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal void RentShaderResourceViewDescriptorHandles(
|
||||
out D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle,
|
||||
out D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandleNonGpuVisible,
|
||||
out D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle)
|
||||
{
|
||||
this.shaderResourceViewDescriptorAllocator.Rent(out d3D12CpuDescriptorHandle, out d3D12GpuDescriptorHandle);
|
||||
this.shaderResourceViewDescriptorAllocator.Rent(out d3D12CpuDescriptorHandle, out d3D12CpuDescriptorHandleNonGpuVisible, out d3D12GpuDescriptorHandle);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID3D12DescriptorHandleAllocator.Return"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal void ReturnShaderResourceViewDescriptorHandles(
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle,
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandleNonGpuVisible,
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle)
|
||||
{
|
||||
this.shaderResourceViewDescriptorAllocator.Return(d3D12CpuDescriptorHandle, d3D12GpuDescriptorHandle);
|
||||
this.shaderResourceViewDescriptorAllocator.Return(d3D12CpuDescriptorHandle, d3D12CpuDescriptorHandleNonGpuVisible, d3D12GpuDescriptorHandle);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID3D12CommandListPool.Rent"/>
|
||||
|
||||
@@ -42,6 +42,11 @@ public unsafe abstract class Buffer<T> : NativeObject
|
||||
/// </summary>
|
||||
private readonly D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle;
|
||||
|
||||
/// <summary>
|
||||
/// The non shader visible <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> instance for the current resource.
|
||||
/// </summary>
|
||||
private readonly D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandleNonShaderVisible;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> instance for the current resource.
|
||||
/// </summary>
|
||||
@@ -95,7 +100,7 @@ public unsafe abstract class Buffer<T> : NativeObject
|
||||
#endif
|
||||
|
||||
device.RegisterAllocatedResource();
|
||||
device.RentShaderResourceViewDescriptorHandles(out this.d3D12CpuDescriptorHandle, out this.d3D12GpuDescriptorHandle);
|
||||
device.RentShaderResourceViewDescriptorHandles(out this.d3D12CpuDescriptorHandle, out this.d3D12CpuDescriptorHandleNonShaderVisible, out this.d3D12GpuDescriptorHandle);
|
||||
|
||||
switch (resourceType)
|
||||
{
|
||||
@@ -107,6 +112,7 @@ public unsafe abstract class Buffer<T> : NativeObject
|
||||
break;
|
||||
case ResourceType.ReadWrite:
|
||||
device.D3D12Device->CreateUnorderedAccessView(this.d3D12Resource.Get(), (uint)length, elementSizeInBytes, this.d3D12CpuDescriptorHandle);
|
||||
device.D3D12Device->CreateUnorderedAccessView(this.d3D12Resource.Get(), (uint)length, elementSizeInBytes, this.d3D12CpuDescriptorHandleNonShaderVisible);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -147,6 +153,11 @@ public unsafe abstract class Buffer<T> : NativeObject
|
||||
/// </summary>
|
||||
internal D3D12_CPU_DESCRIPTOR_HANDLE D3D12CpuDescriptorHandle => this.d3D12CpuDescriptorHandle;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the non shader visible <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> instance for the current resource.
|
||||
/// </summary>
|
||||
internal D3D12_CPU_DESCRIPTOR_HANDLE D3D12CpuDescriptorHandleNonGpuVisible => this.d3D12CpuDescriptorHandleNonShaderVisible;
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Buffer{T}"/> instance and writes them into a target memory area.
|
||||
/// </summary>
|
||||
@@ -208,7 +219,7 @@ public unsafe abstract class Buffer<T> : NativeObject
|
||||
if (GraphicsDevice is GraphicsDevice device)
|
||||
{
|
||||
device.UnregisterAllocatedResource();
|
||||
device.ReturnShaderResourceViewDescriptorHandles(D3D12CpuDescriptorHandle, D3D12GpuDescriptorHandle);
|
||||
device.ReturnShaderResourceViewDescriptorHandles(D3D12CpuDescriptorHandle, this.d3D12CpuDescriptorHandleNonShaderVisible, D3D12GpuDescriptorHandle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -311,7 +311,7 @@ public abstract class StructuredBuffer<T> : Buffer<T>
|
||||
ThrowIfDisposed();
|
||||
ThrowIfDeviceMismatch(device);
|
||||
|
||||
return (D3D12GpuDescriptorHandle, D3D12CpuDescriptorHandle);
|
||||
return (D3D12GpuDescriptorHandle, D3D12CpuDescriptorHandleNonGpuVisible);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="__Internals.GraphicsResourceHelper.IGraphicsResource.ValidateAndGetID3D12Resource(GraphicsDevice)"/>
|
||||
|
||||
@@ -43,6 +43,11 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
|
||||
/// </summary>
|
||||
private readonly D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle;
|
||||
|
||||
/// <summary>
|
||||
/// The non shader visible <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> instance for the current resource.
|
||||
/// </summary>
|
||||
private readonly D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandleNonShaderVisible;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> instance for the current resource.
|
||||
/// </summary>
|
||||
@@ -120,7 +125,7 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
|
||||
out _);
|
||||
|
||||
device.RegisterAllocatedResource();
|
||||
device.RentShaderResourceViewDescriptorHandles(out this.d3D12CpuDescriptorHandle, out this.d3D12GpuDescriptorHandle);
|
||||
device.RentShaderResourceViewDescriptorHandles(out this.d3D12CpuDescriptorHandle, out this.d3D12CpuDescriptorHandleNonShaderVisible, out this.d3D12GpuDescriptorHandle);
|
||||
|
||||
switch (resourceType)
|
||||
{
|
||||
@@ -129,6 +134,7 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
|
||||
break;
|
||||
case ResourceType.ReadWrite:
|
||||
device.D3D12Device->CreateUnorderedAccessView(this.d3D12Resource.Get(), DXGIFormatHelper.GetForType<T>(), D3D12_UAV_DIMENSION_TEXTURE2D, this.d3D12CpuDescriptorHandle);
|
||||
device.D3D12Device->CreateUnorderedAccessView(this.d3D12Resource.Get(), DXGIFormatHelper.GetForType<T>(), D3D12_UAV_DIMENSION_TEXTURE2D, this.d3D12CpuDescriptorHandleNonShaderVisible);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -165,6 +171,11 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
|
||||
/// </summary>
|
||||
internal D3D12_CPU_DESCRIPTOR_HANDLE D3D12CpuDescriptorHandle => this.d3D12CpuDescriptorHandle;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the non shader visible <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> instance for the current resource.
|
||||
/// </summary>
|
||||
internal D3D12_CPU_DESCRIPTOR_HANDLE D3D12CpuDescriptorHandleNonGpuVisible => this.d3D12CpuDescriptorHandleNonShaderVisible;
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target memory area.
|
||||
/// </summary>
|
||||
@@ -546,7 +557,7 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
|
||||
if (GraphicsDevice is GraphicsDevice device)
|
||||
{
|
||||
device.UnregisterAllocatedResource();
|
||||
device.ReturnShaderResourceViewDescriptorHandles(D3D12CpuDescriptorHandle, D3D12GpuDescriptorHandle);
|
||||
device.ReturnShaderResourceViewDescriptorHandles(D3D12CpuDescriptorHandle, this.d3D12CpuDescriptorHandleNonShaderVisible, D3D12GpuDescriptorHandle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -568,7 +579,7 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
|
||||
ThrowIfDisposed();
|
||||
ThrowIfDeviceMismatch(device);
|
||||
|
||||
return (D3D12GpuDescriptorHandle, D3D12CpuDescriptorHandle);
|
||||
return (D3D12GpuDescriptorHandle, D3D12CpuDescriptorHandleNonGpuVisible);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="GraphicsResourceHelper.IGraphicsResource.ValidateAndGetID3D12Resource(GraphicsDevice)"/>
|
||||
|
||||
@@ -43,6 +43,11 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
|
||||
/// </summary>
|
||||
private readonly D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle;
|
||||
|
||||
/// <summary>
|
||||
/// The non shader visible <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> instance for the current resource.
|
||||
/// </summary>
|
||||
private readonly D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandleNonShaderVisible;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> instance for the current resource.
|
||||
/// </summary>
|
||||
@@ -125,7 +130,7 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
|
||||
out _);
|
||||
|
||||
device.RegisterAllocatedResource();
|
||||
device.RentShaderResourceViewDescriptorHandles(out this.d3D12CpuDescriptorHandle, out this.d3D12GpuDescriptorHandle);
|
||||
device.RentShaderResourceViewDescriptorHandles(out this.d3D12CpuDescriptorHandle, out this.d3D12CpuDescriptorHandleNonShaderVisible, out this.d3D12GpuDescriptorHandle);
|
||||
|
||||
switch (resourceType)
|
||||
{
|
||||
@@ -134,6 +139,7 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
|
||||
break;
|
||||
case ResourceType.ReadWrite:
|
||||
device.D3D12Device->CreateUnorderedAccessView(this.d3D12Resource.Get(), DXGIFormatHelper.GetForType<T>(), D3D12_UAV_DIMENSION_TEXTURE3D, this.d3D12CpuDescriptorHandle);
|
||||
device.D3D12Device->CreateUnorderedAccessView(this.d3D12Resource.Get(), DXGIFormatHelper.GetForType<T>(), D3D12_UAV_DIMENSION_TEXTURE3D, this.d3D12CpuDescriptorHandleNonShaderVisible);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -599,7 +605,7 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
|
||||
if (GraphicsDevice is GraphicsDevice device)
|
||||
{
|
||||
device.UnregisterAllocatedResource();
|
||||
device.ReturnShaderResourceViewDescriptorHandles(D3D12CpuDescriptorHandle, D3D12GpuDescriptorHandle);
|
||||
device.ReturnShaderResourceViewDescriptorHandles(D3D12CpuDescriptorHandle, this.d3D12CpuDescriptorHandleNonShaderVisible, D3D12GpuDescriptorHandle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする