Added resource size validation
このコミットが含まれているのは:
1 親
08a6f94453
コミット
04e3dbc316
3ファイル変更
+17
-6
検索条件に一致するファイルはありません
@@ -7,6 +7,7 @@ using ComputeSharp.Graphics.Buffers.Enums;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using TerraFX.Interop;
|
||||
using FX = TerraFX.Interop.Windows;
|
||||
|
||||
namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
{
|
||||
@@ -44,7 +45,15 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
{
|
||||
device.ThrowIfDisposed();
|
||||
|
||||
Guard.IsGreaterThan(length, 0, nameof(length));
|
||||
if (resourceType == ResourceType.Constant)
|
||||
{
|
||||
Guard.IsBetweenOrEqualTo(length, 1, FX.D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT, nameof(length));
|
||||
}
|
||||
else
|
||||
{
|
||||
// The maximum length is set such that the aligned buffer size can't exceed uint.MaxValue
|
||||
Guard.IsBetweenOrEqualTo(length, 1, (uint.MaxValue / elementSizeInBytes) & ~255, nameof(length));
|
||||
}
|
||||
|
||||
SizeInBytes = checked((nint)(length * elementSizeInBytes));
|
||||
GraphicsDevice = device;
|
||||
|
||||
@@ -12,6 +12,7 @@ using static TerraFX.Interop.D3D12_COMMAND_LIST_TYPE;
|
||||
using static TerraFX.Interop.D3D12_RESOURCE_STATES;
|
||||
using static TerraFX.Interop.D3D12_SRV_DIMENSION;
|
||||
using static TerraFX.Interop.D3D12_UAV_DIMENSION;
|
||||
using FX = TerraFX.Interop.Windows;
|
||||
|
||||
namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
{
|
||||
@@ -54,8 +55,8 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
{
|
||||
device.ThrowIfDisposed();
|
||||
|
||||
Guard.IsGreaterThan(width, 0, nameof(width));
|
||||
Guard.IsGreaterThan(height, 0, nameof(height));
|
||||
Guard.IsBetweenOrEqualTo(width, 1, FX.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION, nameof(width));
|
||||
Guard.IsBetweenOrEqualTo(height, 1, FX.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION, nameof(height));
|
||||
|
||||
GraphicsDevice = device;
|
||||
Width = width;
|
||||
|
||||
@@ -12,6 +12,7 @@ using static TerraFX.Interop.D3D12_COMMAND_LIST_TYPE;
|
||||
using static TerraFX.Interop.D3D12_RESOURCE_STATES;
|
||||
using static TerraFX.Interop.D3D12_SRV_DIMENSION;
|
||||
using static TerraFX.Interop.D3D12_UAV_DIMENSION;
|
||||
using FX = TerraFX.Interop.Windows;
|
||||
|
||||
namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
{
|
||||
@@ -55,9 +56,9 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
{
|
||||
device.ThrowIfDisposed();
|
||||
|
||||
Guard.IsGreaterThan(width, 0, nameof(width));
|
||||
Guard.IsGreaterThan(height, 0, nameof(height));
|
||||
Guard.IsBetweenOrEqualTo(depth, 1, ushort.MaxValue, nameof(depth));
|
||||
Guard.IsBetweenOrEqualTo(width, 1, FX.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION, nameof(width));
|
||||
Guard.IsBetweenOrEqualTo(height, 1, FX.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION, nameof(height));
|
||||
Guard.IsBetweenOrEqualTo(depth, 1, FX.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION, nameof(depth));
|
||||
|
||||
GraphicsDevice = device;
|
||||
Width = width;
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする