From 705b47c0eeb5f1d50cf23cb5d732554a4881264f Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 2 Dec 2020 20:25:54 +0100 Subject: [PATCH] Minor code tweaks, rearranged height/width --- .../Buffers/Abstract/Texture2D{T}.cs | 28 +++++++++++++------ .../Extensions/ID3D12DeviceExtensions.cs | 6 ++-- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/ComputeSharp.Graphics/Buffers/Abstract/Texture2D{T}.cs b/src/ComputeSharp.Graphics/Buffers/Abstract/Texture2D{T}.cs index 7313a9a7..1b25acfa 100644 --- a/src/ComputeSharp.Graphics/Buffers/Abstract/Texture2D{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/Abstract/Texture2D{T}.cs @@ -27,22 +27,24 @@ namespace ComputeSharp.Graphics.Buffers.Abstract internal readonly D3D12_GPU_DESCRIPTOR_HANDLE D3D12GpuDescriptorHandle; /// - /// Creates a new instance with the specified parameters. + /// Creates a new instance with the specified parameters. /// - /// The associated with the current instance. - /// The number of items to store in the current buffer. - /// The size in bytes of each buffer item (including padding, if any). - /// The buffer type for the current buffer. - private protected Texture2D(GraphicsDevice device, int height, int width, TextureType textureType) + /// The associated with the current instance. + /// The height of the texture. + /// The width of the texture. + /// The texture type for the current texture. + private protected Texture2D(GraphicsDevice device, int width, int height, TextureType textureType) { device.ThrowIfDisposed(); - Guard.IsGreaterThanOrEqualTo(height, 0, nameof(height)); Guard.IsGreaterThanOrEqualTo(width, 0, nameof(width)); + Guard.IsGreaterThanOrEqualTo(height, 0, nameof(height)); GraphicsDevice = device; + Width = width; + Height = height; - this.d3D12Resource = device.D3D12Device->CreateCommittedResource(textureType, DXGIFormatHelper.GetForType(), (uint)height, (uint)width); + this.d3D12Resource = device.D3D12Device->CreateCommittedResource(textureType, DXGIFormatHelper.GetForType(), (uint)width, (uint)height); device.AllocateShaderResourceViewDescriptorHandles(out D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle, out D3D12GpuDescriptorHandle); @@ -62,6 +64,16 @@ namespace ComputeSharp.Graphics.Buffers.Abstract /// public GraphicsDevice GraphicsDevice { get; } + /// + /// Gets the width of the current texture. + /// + public int Width { get; } + + /// + /// Gets the height of the current texture. + /// + public int Height { get; } + /// /// Gets the instance currently mapped. /// diff --git a/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs b/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs index e98ffde8..5928347e 100644 --- a/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs +++ b/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs @@ -147,15 +147,15 @@ namespace ComputeSharp.Graphics.Extensions /// The instance in use. /// The texture type currently in use. /// The value to use. - /// The height of the texture resource. /// The width of the texture resource. + /// The height of the texture resource. /// An reference for the current texture. public static ComPtr CreateCommittedResource( this ref ID3D12Device d3D12Device, TextureType textureType, DXGI_FORMAT dxgiFormat, - uint height, - uint width) + uint width, + uint height) { D3D12_RESOURCE_FLAGS d3D12ResourceFlags = textureType switch {