Code refactoring to texture copies
このコミットが含まれているのは:
1 親
3183771b66
コミット
7e9bd561ca
6ファイル変更
+271
-162
検索条件に一致するファイルはありません
@@ -51,6 +51,11 @@ namespace ComputeSharp.Resources
|
||||
/// </summary>
|
||||
private readonly D3D12_COMMAND_LIST_TYPE d3D12CommandListType;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12_PLACED_SUBRESOURCE_FOOTPRINT"/> description for the current resource.
|
||||
/// </summary>
|
||||
private readonly D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Texture2D{T}"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
@@ -89,6 +94,14 @@ namespace ComputeSharp.Resources
|
||||
? D3D12_COMMAND_LIST_TYPE_COPY
|
||||
: D3D12_COMMAND_LIST_TYPE_COMPUTE;
|
||||
|
||||
GraphicsDevice.D3D12Device->GetCopyableFootprint(
|
||||
DXGIFormatHelper.GetForType<T>(),
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
out this.d3D12PlacedSubresourceFootprint,
|
||||
out _,
|
||||
out _);
|
||||
|
||||
device.RentShaderResourceViewDescriptorHandles(out D3D12CpuDescriptorHandle, out D3D12GpuDescriptorHandle);
|
||||
|
||||
switch (resourceType)
|
||||
@@ -149,7 +162,7 @@ namespace ComputeSharp.Resources
|
||||
DXGIFormatHelper.GetForType<T>(),
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
|
||||
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprintDestination,
|
||||
out ulong rowSizeInBytes,
|
||||
out ulong totalSizeInBytes);
|
||||
|
||||
@@ -163,15 +176,18 @@ namespace ComputeSharp.Resources
|
||||
}
|
||||
|
||||
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
|
||||
d3D12Resource.Get(),
|
||||
&d3D12PlacedSubresourceFootprint,
|
||||
D3D12Resource,
|
||||
(uint)x,
|
||||
(uint)y,
|
||||
0,
|
||||
d3D12ResourceDestination: d3D12Resource.Get(),
|
||||
&d3D12PlacedSubresourceFootprintDestination,
|
||||
destinationX: 0,
|
||||
destinationY: 0,
|
||||
destinationZ: 0,
|
||||
d3D12ResourceSource: D3D12Resource,
|
||||
sourceX: (uint)x,
|
||||
sourceY: (uint)y,
|
||||
sourceZ: 0,
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
1);
|
||||
depth: 1);
|
||||
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
{
|
||||
@@ -189,7 +205,7 @@ namespace ComputeSharp.Resources
|
||||
resource.Pointer,
|
||||
(uint)height,
|
||||
rowSizeInBytes,
|
||||
d3D12PlacedSubresourceFootprint.Footprint.RowPitch,
|
||||
d3D12PlacedSubresourceFootprintDestination.Footprint.RowPitch,
|
||||
destinationPointer);
|
||||
}
|
||||
}
|
||||
@@ -220,14 +236,6 @@ namespace ComputeSharp.Resources
|
||||
Guard.IsLessThanOrEqualTo(x + width, Width, nameof(x));
|
||||
Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y));
|
||||
|
||||
GraphicsDevice.D3D12Device->GetCopyableFootprint(
|
||||
DXGIFormatHelper.GetForType<T>(),
|
||||
(uint)destination.Width,
|
||||
(uint)destination.Height,
|
||||
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
|
||||
out ulong rowSizeInBytes,
|
||||
out ulong totalSizeInBytes);
|
||||
|
||||
using CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType);
|
||||
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
@@ -235,16 +243,22 @@ namespace ComputeSharp.Resources
|
||||
copyCommandList.D3D12GraphicsCommandList->ResourceBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
}
|
||||
|
||||
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
|
||||
destination.D3D12Resource,
|
||||
&d3D12PlacedSubresourceFootprint,
|
||||
D3D12Resource,
|
||||
(uint)x,
|
||||
(uint)y,
|
||||
0,
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
1);
|
||||
fixed (D3D12_PLACED_SUBRESOURCE_FOOTPRINT* d3D12PlacedSubresourceFootprintDestination = &destination.D3D12PlacedSubresourceFootprint)
|
||||
{
|
||||
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
|
||||
d3D12ResourceDestination: destination.D3D12Resource,
|
||||
d3D12PlacedSubresourceFootprintDestination,
|
||||
destinationX: 0,
|
||||
destinationY: 0,
|
||||
destinationZ: 0,
|
||||
d3D12ResourceSource: D3D12Resource,
|
||||
sourceX: (uint)x,
|
||||
sourceY: (uint)y,
|
||||
sourceZ: 0,
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
1);
|
||||
}
|
||||
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
{
|
||||
@@ -281,7 +295,7 @@ namespace ComputeSharp.Resources
|
||||
DXGIFormatHelper.GetForType<T>(),
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
|
||||
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprintSource,
|
||||
out ulong rowSizeInBytes,
|
||||
out ulong totalSizeInBytes);
|
||||
|
||||
@@ -295,7 +309,7 @@ namespace ComputeSharp.Resources
|
||||
resource.Pointer,
|
||||
(uint)height,
|
||||
rowSizeInBytes,
|
||||
d3D12PlacedSubresourceFootprint.Footprint.RowPitch);
|
||||
d3D12PlacedSubresourceFootprintSource.Footprint.RowPitch);
|
||||
}
|
||||
|
||||
using CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType);
|
||||
@@ -306,12 +320,18 @@ namespace ComputeSharp.Resources
|
||||
}
|
||||
|
||||
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
|
||||
D3D12Resource,
|
||||
(uint)x,
|
||||
(uint)y,
|
||||
0,
|
||||
d3D12Resource.Get(),
|
||||
&d3D12PlacedSubresourceFootprint);
|
||||
d3D12ResourceDestination: D3D12Resource,
|
||||
destinationX: (uint)x,
|
||||
destinationY: (uint)y,
|
||||
destinationZ: 0,
|
||||
d3D12ResourceSource: d3D12Resource.Get(),
|
||||
&d3D12PlacedSubresourceFootprintSource,
|
||||
sourceX: 0,
|
||||
sourceY: 0,
|
||||
sourceZ: 0,
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
depth: 1);
|
||||
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
{
|
||||
@@ -347,14 +367,6 @@ namespace ComputeSharp.Resources
|
||||
Guard.IsLessThanOrEqualTo(x + width, Width, nameof(x));
|
||||
Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y));
|
||||
|
||||
GraphicsDevice.D3D12Device->GetCopyableFootprint(
|
||||
DXGIFormatHelper.GetForType<T>(),
|
||||
(uint)source.Width,
|
||||
(uint)source.Height,
|
||||
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
|
||||
out ulong rowSizeInBytes,
|
||||
out ulong totalSizeInBytes);
|
||||
|
||||
using CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType);
|
||||
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
@@ -362,13 +374,22 @@ namespace ComputeSharp.Resources
|
||||
copyCommandList.D3D12GraphicsCommandList->ResourceBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
|
||||
}
|
||||
|
||||
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
|
||||
D3D12Resource,
|
||||
(uint)x,
|
||||
(uint)y,
|
||||
0,
|
||||
source.D3D12Resource,
|
||||
&d3D12PlacedSubresourceFootprint);
|
||||
fixed (D3D12_PLACED_SUBRESOURCE_FOOTPRINT* d3D12PlacedSubresourceFootprintSource = &source.D3D12PlacedSubresourceFootprint)
|
||||
{
|
||||
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
|
||||
d3D12ResourceDestination: D3D12Resource,
|
||||
destinationX: (uint)x,
|
||||
destinationY: (uint)y,
|
||||
destinationZ: 0,
|
||||
d3D12ResourceSource: source.D3D12Resource,
|
||||
d3D12PlacedSubresourceFootprintSource,
|
||||
sourceX: 0,
|
||||
sourceY: 0,
|
||||
sourceZ: 0,
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
depth: 1);
|
||||
}
|
||||
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
{
|
||||
|
||||
@@ -51,6 +51,11 @@ namespace ComputeSharp.Resources
|
||||
/// </summary>
|
||||
private readonly D3D12_COMMAND_LIST_TYPE d3D12CommandListType;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12_PLACED_SUBRESOURCE_FOOTPRINT"/> description for the current resource.
|
||||
/// </summary>
|
||||
private readonly D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Texture3D{T}"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
@@ -93,6 +98,15 @@ namespace ComputeSharp.Resources
|
||||
? D3D12_COMMAND_LIST_TYPE_COPY
|
||||
: D3D12_COMMAND_LIST_TYPE_COMPUTE;
|
||||
|
||||
GraphicsDevice.D3D12Device->GetCopyableFootprint(
|
||||
DXGIFormatHelper.GetForType<T>(),
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
(ushort)depth,
|
||||
out this.d3D12PlacedSubresourceFootprint,
|
||||
out _,
|
||||
out _);
|
||||
|
||||
device.RentShaderResourceViewDescriptorHandles(out D3D12CpuDescriptorHandle, out D3D12GpuDescriptorHandle);
|
||||
|
||||
switch (resourceType)
|
||||
@@ -164,7 +178,7 @@ namespace ComputeSharp.Resources
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
(ushort)depth,
|
||||
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
|
||||
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprintDestination,
|
||||
out ulong rowSizeInBytes,
|
||||
out ulong totalSizeInBytes);
|
||||
|
||||
@@ -178,12 +192,15 @@ namespace ComputeSharp.Resources
|
||||
}
|
||||
|
||||
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
|
||||
d3D12Resource.Get(),
|
||||
&d3D12PlacedSubresourceFootprint,
|
||||
D3D12Resource,
|
||||
(uint)x,
|
||||
(uint)y,
|
||||
(ushort)z,
|
||||
d3D12ResourceDestination: d3D12Resource.Get(),
|
||||
&d3D12PlacedSubresourceFootprintDestination,
|
||||
destinationX: 0,
|
||||
destinationY: 0,
|
||||
destinationZ: 0,
|
||||
d3D12ResourceSource: D3D12Resource,
|
||||
sourceX: (uint)x,
|
||||
sourceY: (uint)y,
|
||||
sourceZ: (ushort)z,
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
(ushort)depth);
|
||||
@@ -205,8 +222,8 @@ namespace ComputeSharp.Resources
|
||||
(uint)height,
|
||||
(uint)depth,
|
||||
rowSizeInBytes,
|
||||
d3D12PlacedSubresourceFootprint.Footprint.RowPitch,
|
||||
d3D12PlacedSubresourceFootprint.Footprint.RowPitch * (uint)height,
|
||||
d3D12PlacedSubresourceFootprintDestination.Footprint.RowPitch,
|
||||
d3D12PlacedSubresourceFootprintDestination.Footprint.RowPitch * (uint)height,
|
||||
destinationPointer);
|
||||
}
|
||||
}
|
||||
@@ -243,15 +260,6 @@ namespace ComputeSharp.Resources
|
||||
Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y));
|
||||
Guard.IsLessThanOrEqualTo(z + depth, Depth, nameof(z));
|
||||
|
||||
GraphicsDevice.D3D12Device->GetCopyableFootprint(
|
||||
DXGIFormatHelper.GetForType<T>(),
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
(ushort)depth,
|
||||
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
|
||||
out ulong rowSizeInBytes,
|
||||
out ulong totalSizeInBytes);
|
||||
|
||||
using CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType);
|
||||
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
@@ -259,16 +267,22 @@ namespace ComputeSharp.Resources
|
||||
copyCommandList.D3D12GraphicsCommandList->ResourceBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
}
|
||||
|
||||
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
|
||||
destination.D3D12Resource,
|
||||
&d3D12PlacedSubresourceFootprint,
|
||||
D3D12Resource,
|
||||
(uint)x,
|
||||
(uint)y,
|
||||
(ushort)z,
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
(ushort)depth);
|
||||
fixed (D3D12_PLACED_SUBRESOURCE_FOOTPRINT* d3D12PlacedSubresourceFootprintDestination = &destination.D3D12PlacedSubresourceFootprint)
|
||||
{
|
||||
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
|
||||
d3D12ResourceDestination: destination.D3D12Resource,
|
||||
d3D12PlacedSubresourceFootprintDestination,
|
||||
destinationX: 0,
|
||||
destinationY: 0,
|
||||
destinationZ: 0,
|
||||
d3D12ResourceSource: D3D12Resource,
|
||||
sourceX: (uint)x,
|
||||
sourceY: (uint)y,
|
||||
sourceZ: (ushort)z,
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
(ushort)depth);
|
||||
}
|
||||
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
{
|
||||
@@ -285,7 +299,7 @@ namespace ComputeSharp.Resources
|
||||
/// <param name="size">The size of the memory area to read data from.</param>
|
||||
/// <param name="x">The horizontal offset in the destination texture.</param>
|
||||
/// <param name="y">The vertical offset in the destination texture.</param>
|
||||
/// <param name="z">The depthwise offseet in the destination texture.</param>
|
||||
/// <param name="z">The depthwise offset in the destination texture.</param>
|
||||
/// <param name="width">The width of the memory area to write to.</param>
|
||||
/// <param name="height">The height of the memory area to write to.</param>
|
||||
/// <param name="depth">The depth of the memory area to write to.</param>
|
||||
@@ -311,7 +325,7 @@ namespace ComputeSharp.Resources
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
(ushort)depth,
|
||||
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
|
||||
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprintSource,
|
||||
out ulong rowSizeInBytes,
|
||||
out ulong totalSizeInBytes);
|
||||
|
||||
@@ -326,8 +340,8 @@ namespace ComputeSharp.Resources
|
||||
(uint)height,
|
||||
(uint)depth,
|
||||
rowSizeInBytes,
|
||||
d3D12PlacedSubresourceFootprint.Footprint.RowPitch,
|
||||
d3D12PlacedSubresourceFootprint.Footprint.RowPitch * (uint)height);
|
||||
d3D12PlacedSubresourceFootprintSource.Footprint.RowPitch,
|
||||
d3D12PlacedSubresourceFootprintSource.Footprint.RowPitch * (uint)height);
|
||||
}
|
||||
|
||||
using CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType);
|
||||
@@ -338,12 +352,18 @@ namespace ComputeSharp.Resources
|
||||
}
|
||||
|
||||
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
|
||||
D3D12Resource,
|
||||
(uint)x,
|
||||
(uint)y,
|
||||
(ushort)z,
|
||||
d3D12Resource.Get(),
|
||||
&d3D12PlacedSubresourceFootprint);
|
||||
d3D12ResourceDestination: D3D12Resource,
|
||||
destinationX: (uint)x,
|
||||
destinationY: (uint)y,
|
||||
destinationZ: (ushort)z,
|
||||
d3D12ResourceSource: d3D12Resource.Get(),
|
||||
&d3D12PlacedSubresourceFootprintSource,
|
||||
sourceX: 0,
|
||||
sourceY: 0,
|
||||
sourceZ: 0,
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
(ushort)depth);
|
||||
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
{
|
||||
@@ -359,7 +379,7 @@ namespace ComputeSharp.Resources
|
||||
/// <param name="source">The input <see cref="UploadTexture3D{T}"/> instance to read data from.</param>
|
||||
/// <param name="x">The horizontal offset in the destination texture.</param>
|
||||
/// <param name="y">The vertical offset in the destination texture.</param>
|
||||
/// <param name="z">The depthwise offseet in the destination texture.</param>
|
||||
/// <param name="z">The depthwise offset in the destination texture.</param>
|
||||
/// <param name="width">The width of the memory area to write to.</param>
|
||||
/// <param name="height">The height of the memory area to write to.</param>
|
||||
/// <param name="depth">The depth of the memory area to write to.</param>
|
||||
@@ -385,15 +405,6 @@ namespace ComputeSharp.Resources
|
||||
Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y));
|
||||
Guard.IsLessThanOrEqualTo(z + depth, Depth, nameof(z));
|
||||
|
||||
GraphicsDevice.D3D12Device->GetCopyableFootprint(
|
||||
DXGIFormatHelper.GetForType<T>(),
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
(ushort)depth,
|
||||
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
|
||||
out ulong rowSizeInBytes,
|
||||
out ulong totalSizeInBytes);
|
||||
|
||||
using CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType);
|
||||
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
@@ -401,13 +412,22 @@ namespace ComputeSharp.Resources
|
||||
copyCommandList.D3D12GraphicsCommandList->ResourceBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
|
||||
}
|
||||
|
||||
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
|
||||
D3D12Resource,
|
||||
(uint)x,
|
||||
(uint)y,
|
||||
(ushort)z,
|
||||
source.D3D12Resource,
|
||||
&d3D12PlacedSubresourceFootprint);
|
||||
fixed (D3D12_PLACED_SUBRESOURCE_FOOTPRINT* d3D12PlacedSubresourceFootprintSource = &source.D3D12PlacedSubresourceFootprint)
|
||||
{
|
||||
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
|
||||
d3D12ResourceDestination: D3D12Resource,
|
||||
destinationX: (uint)x,
|
||||
destinationY: (uint)y,
|
||||
destinationZ: (ushort)z,
|
||||
d3D12ResourceSource: source.D3D12Resource,
|
||||
d3D12PlacedSubresourceFootprintSource,
|
||||
sourceX: 0,
|
||||
sourceY: 0,
|
||||
sourceZ: 0,
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
(ushort)depth);
|
||||
}
|
||||
|
||||
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
|
||||
{
|
||||
|
||||
@@ -29,9 +29,9 @@ namespace ComputeSharp.Resources
|
||||
private readonly T* mappedData;
|
||||
|
||||
/// <summary>
|
||||
/// The stride in bytes for each row within <see cref="mappedData"/>.
|
||||
/// The <see cref="D3D12_PLACED_SUBRESOURCE_FOOTPRINT"/> description for the current resource.
|
||||
/// </summary>
|
||||
private readonly int strideInBytes;
|
||||
private readonly D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="TransferTexture2D{T}"/> instance with the specified parameters.
|
||||
@@ -61,13 +61,12 @@ namespace ComputeSharp.Resources
|
||||
DXGIFormatHelper.GetForType<T>(),
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
|
||||
out ulong rowSizeInBytes,
|
||||
out this.d3D12PlacedSubresourceFootprint,
|
||||
out _,
|
||||
out ulong totalSizeInBytes);
|
||||
|
||||
this.d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(resourceType, allocationMode, totalSizeInBytes, GraphicsDevice.IsCacheCoherentUMA);
|
||||
this.mappedData = (T*)this.d3D12Resource.Get()->Map().Pointer;
|
||||
this.strideInBytes = (int)d3D12PlacedSubresourceFootprint.Footprint.RowPitch;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -90,6 +89,11 @@ namespace ComputeSharp.Resources
|
||||
/// </summary>
|
||||
internal ID3D12Resource* D3D12Resource => this.d3D12Resource;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="D3D12_PLACED_SUBRESOURCE_FOOTPRINT"/> value for the current resource.
|
||||
/// </summary>
|
||||
internal ref readonly D3D12_PLACED_SUBRESOURCE_FOOTPRINT D3D12PlacedSubresourceFootprint => ref this.d3D12PlacedSubresourceFootprint;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public TextureView2D<T> View
|
||||
{
|
||||
@@ -98,7 +102,7 @@ namespace ComputeSharp.Resources
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
|
||||
return new(this.mappedData, Height, Width, this.strideInBytes);
|
||||
return new(this.mappedData, Height, Width, (int)this.d3D12PlacedSubresourceFootprint.Footprint.RowPitch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@ namespace ComputeSharp.Resources
|
||||
private readonly T* mappedData;
|
||||
|
||||
/// <summary>
|
||||
/// The stride in bytes for each row within <see cref="mappedData"/>.
|
||||
/// The <see cref="D3D12_PLACED_SUBRESOURCE_FOOTPRINT"/> description for the current resource.
|
||||
/// </summary>
|
||||
private readonly int strideInBytes;
|
||||
private readonly D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="TransferTexture3D{T}"/> instance with the specified parameters.
|
||||
@@ -65,13 +65,12 @@ namespace ComputeSharp.Resources
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
(ushort)depth,
|
||||
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
|
||||
out ulong rowSizeInBytes,
|
||||
out this.d3D12PlacedSubresourceFootprint,
|
||||
out _,
|
||||
out ulong totalSizeInBytes);
|
||||
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(resourceType, allocationMode, totalSizeInBytes, GraphicsDevice.IsCacheCoherentUMA);
|
||||
this.mappedData = (T*)this.d3D12Resource.Get()->Map().Pointer;
|
||||
this.strideInBytes = (int)d3D12PlacedSubresourceFootprint.Footprint.RowPitch;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -98,6 +97,11 @@ namespace ComputeSharp.Resources
|
||||
/// </summary>
|
||||
internal ID3D12Resource* D3D12Resource => this.d3D12Resource;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="D3D12_PLACED_SUBRESOURCE_FOOTPRINT"/> value for the current resource.
|
||||
/// </summary>
|
||||
internal ref readonly D3D12_PLACED_SUBRESOURCE_FOOTPRINT D3D12PlacedSubresourceFootprint => ref this.d3D12PlacedSubresourceFootprint;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public TextureView3D<T> View
|
||||
{
|
||||
@@ -106,7 +110,7 @@ namespace ComputeSharp.Resources
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
|
||||
return new(this.mappedData, Height, Width, Depth, this.strideInBytes);
|
||||
return new(this.mappedData, Height, Width, Depth, (int)this.d3D12PlacedSubresourceFootprint.Footprint.RowPitch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする