Minor code refactoring

このコミットが含まれているのは:
Sergio Pedri committed 2021-02-05 19:47:35 +01:00
1 親 659b841784
コミット 3183771b66
5ファイル変更
+78 -33

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

+43 -3
ファイルの表示
@@ -457,24 +457,64 @@ namespace ComputeSharp.Graphics.Extensions
/// Gets the layout data for a target resource.
/// </summary>
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> to use to get the layout info.</param>
/// <param name="d3D12ResourceDesc">The <see cref="D3D12_RESOURCE_DESC"/> value for the target resource.</param>
/// <param name="dxgiFormat">The <see cref="DXGI_FORMAT"/> value to use.</param>
/// <param name="width">The width of the texture resource.</param>
/// <param name="height">The height of the texture resource.</param>
/// <param name="d3D12PlacedSubresourceFootprint">The resulting layout info for the resource.</param>
/// <param name="rowSizeInBytes">The size in bytes of each row in the resource.</param>
/// <param name="totalSizeInBytes">The total number of bytes for the resource.</param>
public static void GetCopyableFootprint(
this ref ID3D12Device d3D12Device,
D3D12_RESOURCE_DESC* d3D12ResourceDesc,
DXGI_FORMAT dxgiFormat,
uint width,
uint height,
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
out ulong rowSizeInBytes,
out ulong totalSizeInBytes)
{
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex2D(dxgiFormat, width, height);
ulong a, b;
fixed (D3D12_PLACED_SUBRESOURCE_FOOTPRINT* p = &d3D12PlacedSubresourceFootprint)
{
uint _;
d3D12Device.GetCopyableFootprints(d3D12ResourceDesc, 0, 1, 0, p, &_, &a, &b);
d3D12Device.GetCopyableFootprints(&d3D12ResourceDescription, 0, 1, 0, p, &_, &a, &b);
}
rowSizeInBytes = a;
totalSizeInBytes = b;
}
/// <summary>
/// Gets the layout data for a target resource.
/// </summary>
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> to use to get the layout info.</param>
/// <param name="dxgiFormat">The <see cref="DXGI_FORMAT"/> value to use.</param>
/// <param name="width">The width of the texture resource.</param>
/// <param name="height">The height of the texture resource.</param>
/// <param name="depth">The depth of the texture resource.</param>
/// <param name="d3D12PlacedSubresourceFootprint">The resulting layout info for the resource.</param>
/// <param name="rowSizeInBytes">The size in bytes of each row in the resource.</param>
/// <param name="totalSizeInBytes">The total number of bytes for the resource.</param>
public static void GetCopyableFootprint(
this ref ID3D12Device d3D12Device,
DXGI_FORMAT dxgiFormat,
uint width,
uint height,
ushort depth,
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
out ulong rowSizeInBytes,
out ulong totalSizeInBytes)
{
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex3D(dxgiFormat, width, height, depth);
ulong a, b;
fixed (D3D12_PLACED_SUBRESOURCE_FOOTPRINT* p = &d3D12PlacedSubresourceFootprint)
{
uint _;
d3D12Device.GetCopyableFootprints(&d3D12ResourceDescription, 0, 1, 0, p, &_, &a, &b);
}
rowSizeInBytes = a;
+12 -12
ファイルの表示
@@ -145,10 +145,10 @@ namespace ComputeSharp.Resources
Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y));
Guard.IsGreaterThanOrEqualTo(size, (nint)width * height, nameof(size));
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex2D(DXGIFormatHelper.GetForType<T>(), (ulong)width, (uint)height);
GraphicsDevice.D3D12Device->GetCopyableFootprint(
&d3D12ResourceDescription,
DXGIFormatHelper.GetForType<T>(),
(uint)width,
(uint)height,
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
out ulong rowSizeInBytes,
out ulong totalSizeInBytes);
@@ -220,10 +220,10 @@ namespace ComputeSharp.Resources
Guard.IsLessThanOrEqualTo(x + width, Width, nameof(x));
Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y));
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex2D(DXGIFormatHelper.GetForType<T>(), (ulong)destination.Width, (uint)destination.Height);
GraphicsDevice.D3D12Device->GetCopyableFootprint(
&d3D12ResourceDescription,
DXGIFormatHelper.GetForType<T>(),
(uint)destination.Width,
(uint)destination.Height,
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
out ulong rowSizeInBytes,
out ulong totalSizeInBytes);
@@ -277,10 +277,10 @@ namespace ComputeSharp.Resources
Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y));
Guard.IsGreaterThanOrEqualTo(size, (nint)width * height, nameof(size));
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex2D(DXGIFormatHelper.GetForType<T>(), (ulong)width, (uint)height);
GraphicsDevice.D3D12Device->GetCopyableFootprint(
&d3D12ResourceDescription,
DXGIFormatHelper.GetForType<T>(),
(uint)width,
(uint)height,
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
out ulong rowSizeInBytes,
out ulong totalSizeInBytes);
@@ -347,10 +347,10 @@ namespace ComputeSharp.Resources
Guard.IsLessThanOrEqualTo(x + width, Width, nameof(x));
Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y));
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex2D(DXGIFormatHelper.GetForType<T>(), (ulong)source.Width, (uint)source.Height);
GraphicsDevice.D3D12Device->GetCopyableFootprint(
&d3D12ResourceDescription,
DXGIFormatHelper.GetForType<T>(),
(uint)source.Width,
(uint)source.Height,
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
out ulong rowSizeInBytes,
out ulong totalSizeInBytes);
+16 -12
ファイルの表示
@@ -159,10 +159,11 @@ namespace ComputeSharp.Resources
Guard.IsLessThanOrEqualTo(z + depth, Depth, nameof(z));
Guard.IsGreaterThanOrEqualTo(size, (nint)width * height * depth, nameof(size));
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex3D(DXGIFormatHelper.GetForType<T>(), (ulong)width, (uint)height, (ushort)depth);
GraphicsDevice.D3D12Device->GetCopyableFootprint(
&d3D12ResourceDescription,
DXGIFormatHelper.GetForType<T>(),
(uint)width,
(uint)height,
(ushort)depth,
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
out ulong rowSizeInBytes,
out ulong totalSizeInBytes);
@@ -242,10 +243,11 @@ namespace ComputeSharp.Resources
Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y));
Guard.IsLessThanOrEqualTo(z + depth, Depth, nameof(z));
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex3D(DXGIFormatHelper.GetForType<T>(), (ulong)width, (uint)height, (ushort)depth);
GraphicsDevice.D3D12Device->GetCopyableFootprint(
&d3D12ResourceDescription,
DXGIFormatHelper.GetForType<T>(),
(uint)width,
(uint)height,
(ushort)depth,
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
out ulong rowSizeInBytes,
out ulong totalSizeInBytes);
@@ -304,10 +306,11 @@ namespace ComputeSharp.Resources
Guard.IsLessThanOrEqualTo(z + depth, Depth, nameof(z));
Guard.IsGreaterThanOrEqualTo(size, (nint)width * height * depth, nameof(size));
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex3D(DXGIFormatHelper.GetForType<T>(), (ulong)width, (uint)height, (ushort)depth);
GraphicsDevice.D3D12Device->GetCopyableFootprint(
&d3D12ResourceDescription,
DXGIFormatHelper.GetForType<T>(),
(uint)width,
(uint)height,
(ushort)depth,
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
out ulong rowSizeInBytes,
out ulong totalSizeInBytes);
@@ -382,10 +385,11 @@ namespace ComputeSharp.Resources
Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y));
Guard.IsLessThanOrEqualTo(z + depth, Depth, nameof(z));
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex3D(DXGIFormatHelper.GetForType<T>(), (ulong)width, (uint)height, (ushort)depth);
GraphicsDevice.D3D12Device->GetCopyableFootprint(
&d3D12ResourceDescription,
DXGIFormatHelper.GetForType<T>(),
(uint)width,
(uint)height,
(ushort)depth,
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
out ulong rowSizeInBytes,
out ulong totalSizeInBytes);
+3 -3
ファイルの表示
@@ -57,10 +57,10 @@ namespace ComputeSharp.Resources
Width = width;
Height = height;
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex2D(DXGIFormatHelper.GetForType<T>(), (ulong)width, (uint)height);
GraphicsDevice.D3D12Device->GetCopyableFootprint(
&d3D12ResourceDescription,
DXGIFormatHelper.GetForType<T>(),
(uint)width,
(uint)height,
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
out ulong rowSizeInBytes,
out ulong totalSizeInBytes);
+4 -3
ファイルの表示
@@ -60,10 +60,11 @@ namespace ComputeSharp.Resources
Height = height;
Depth = depth;
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex3D(DXGIFormatHelper.GetForType<T>(), (ulong)width, (uint)height, (ushort)depth);
GraphicsDevice.D3D12Device->GetCopyableFootprint(
&d3D12ResourceDescription,
DXGIFormatHelper.GetForType<T>(),
(uint)width,
(uint)height,
(ushort)depth,
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
out ulong rowSizeInBytes,
out ulong totalSizeInBytes);