From 341a23e65e9bcdd0bf75cb10fc2f83cc7b230225 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 9 Feb 2021 18:59:57 +0100 Subject: [PATCH] Minor code tweaks, reduced texture object sizes --- .../Resources/Abstract/Texture2D{T}.cs | 6 ++---- .../Resources/Abstract/Texture3D{T}.cs | 9 +++------ .../Resources/Abstract/TransferTexture2D{T}.cs | 6 ++---- .../Resources/Abstract/TransferTexture3D{T}.cs | 9 +++------ 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/ComputeSharp.Graphics/Resources/Abstract/Texture2D{T}.cs b/src/ComputeSharp.Graphics/Resources/Abstract/Texture2D{T}.cs index 80825945..02385adb 100644 --- a/src/ComputeSharp.Graphics/Resources/Abstract/Texture2D{T}.cs +++ b/src/ComputeSharp.Graphics/Resources/Abstract/Texture2D{T}.cs @@ -78,8 +78,6 @@ namespace ComputeSharp.Resources } GraphicsDevice = device; - Width = width; - Height = height; this.d3D12Resource = device.D3D12Device->CreateCommittedResource( resourceType, @@ -123,12 +121,12 @@ namespace ComputeSharp.Resources /// /// Gets the width of the current texture. /// - public int Width { get; } + public int Width => (int)this.d3D12PlacedSubresourceFootprint.Footprint.Width; /// /// Gets the height of the current texture. /// - public int Height { get; } + public int Height => (int)this.d3D12PlacedSubresourceFootprint.Footprint.Height; /// /// Gets the instance currently mapped. diff --git a/src/ComputeSharp.Graphics/Resources/Abstract/Texture3D{T}.cs b/src/ComputeSharp.Graphics/Resources/Abstract/Texture3D{T}.cs index 34dfe533..7b2d1af9 100644 --- a/src/ComputeSharp.Graphics/Resources/Abstract/Texture3D{T}.cs +++ b/src/ComputeSharp.Graphics/Resources/Abstract/Texture3D{T}.cs @@ -80,9 +80,6 @@ namespace ComputeSharp.Resources } GraphicsDevice = device; - Width = width; - Height = height; - Depth = depth; this.d3D12Resource = device.D3D12Device->CreateCommittedResource( resourceType, @@ -128,17 +125,17 @@ namespace ComputeSharp.Resources /// /// Gets the width of the current texture. /// - public int Width { get; } + public int Width => (int)this.d3D12PlacedSubresourceFootprint.Footprint.Width; /// /// Gets the height of the current texture. /// - public int Height { get; } + public int Height => (int)this.d3D12PlacedSubresourceFootprint.Footprint.Height; /// /// Gets the depth of the current texture. /// - public int Depth { get; } + public int Depth => (int)this.d3D12PlacedSubresourceFootprint.Footprint.Depth; /// /// Gets the instance currently mapped. diff --git a/src/ComputeSharp.Graphics/Resources/Abstract/TransferTexture2D{T}.cs b/src/ComputeSharp.Graphics/Resources/Abstract/TransferTexture2D{T}.cs index 8d825c03..41807c7e 100644 --- a/src/ComputeSharp.Graphics/Resources/Abstract/TransferTexture2D{T}.cs +++ b/src/ComputeSharp.Graphics/Resources/Abstract/TransferTexture2D{T}.cs @@ -54,8 +54,6 @@ namespace ComputeSharp.Resources } GraphicsDevice = device; - Width = width; - Height = height; GraphicsDevice.D3D12Device->GetCopyableFootprint( DXGIFormatHelper.GetForType(), @@ -77,12 +75,12 @@ namespace ComputeSharp.Resources /// /// Gets the width of the current texture. /// - public int Width { get; } + public int Width => (int)this.d3D12PlacedSubresourceFootprint.Footprint.Width; /// /// Gets the height of the current texture. /// - public int Height { get; } + public int Height => (int)this.d3D12PlacedSubresourceFootprint.Footprint.Height; /// /// Gets the instance currently mapped. diff --git a/src/ComputeSharp.Graphics/Resources/Abstract/TransferTexture3D{T}.cs b/src/ComputeSharp.Graphics/Resources/Abstract/TransferTexture3D{T}.cs index c16364a5..e26a4e54 100644 --- a/src/ComputeSharp.Graphics/Resources/Abstract/TransferTexture3D{T}.cs +++ b/src/ComputeSharp.Graphics/Resources/Abstract/TransferTexture3D{T}.cs @@ -56,9 +56,6 @@ namespace ComputeSharp.Resources } GraphicsDevice = device; - Width = width; - Height = height; - Depth = depth; GraphicsDevice.D3D12Device->GetCopyableFootprint( DXGIFormatHelper.GetForType(), @@ -81,16 +78,16 @@ namespace ComputeSharp.Resources /// /// Gets the width of the current texture. /// - public int Width { get; } + public int Width => (int)this.d3D12PlacedSubresourceFootprint.Footprint.Width; /// /// Gets the height of the current texture. /// - public int Height { get; } + public int Height => (int)this.d3D12PlacedSubresourceFootprint.Footprint.Height; /// /// Gets the depth of the current texture. /// - public int Depth { get; } + public int Depth => (int)this.d3D12PlacedSubresourceFootprint.Footprint.Depth; /// /// Gets the instance currently mapped.