diff --git a/src/DirectX12GameEngine.Graphics/Buffer.cs b/src/DirectX12GameEngine.Graphics/Buffer.cs
index 8fe4b741..8b9ee87b 100644
--- a/src/DirectX12GameEngine.Graphics/Buffer.cs
+++ b/src/DirectX12GameEngine.Graphics/Buffer.cs
@@ -1,16 +1,13 @@
using System;
using System.Runtime.CompilerServices;
using DirectX12GameEngine.Core;
+using DirectX12GameEngine.Graphics.Primitives.Abstract;
using SharpDX.Direct3D12;
namespace DirectX12GameEngine.Graphics
{
public partial class Buffer : GraphicsResource
{
- public Buffer()
- {
- }
-
protected Buffer(GraphicsDevice device) : base(device)
{
}
diff --git a/src/DirectX12GameEngine.Graphics/CommandList.cs b/src/DirectX12GameEngine.Graphics/CommandList.cs
index cc7c597a..699ea89b 100644
--- a/src/DirectX12GameEngine.Graphics/CommandList.cs
+++ b/src/DirectX12GameEngine.Graphics/CommandList.cs
@@ -1,4 +1,5 @@
using System;
+using DirectX12GameEngine.Graphics.Primitives.Abstract;
using SharpDX.Direct3D12;
namespace DirectX12GameEngine.Graphics
diff --git a/src/DirectX12GameEngine.Graphics/GraphicsResource.cs b/src/DirectX12GameEngine.Graphics/GraphicsResource.cs
deleted file mode 100644
index 3ea86e7c..00000000
--- a/src/DirectX12GameEngine.Graphics/GraphicsResource.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using SharpDX.Direct3D12;
-
-namespace DirectX12GameEngine.Graphics
-{
- public abstract class GraphicsResource : IDisposable
- {
- protected GraphicsResource()
- {
- }
-
- protected GraphicsResource(GraphicsDevice device)
- {
- AttachToGraphicsDevice(device);
- }
-
-#nullable disable
- public GraphicsDevice GraphicsDevice { get; private set; }
-#nullable restore
-
- public IntPtr MappedResource { get; private set; }
-
-#nullable disable
- protected internal Resource NativeResource { get; set; }
-#nullable restore
-
- protected internal CpuDescriptorHandle NativeCpuDescriptorHandle { get; protected set; }
-
- protected internal GpuDescriptorHandle NativeGpuDescriptorHandle { get; protected set; }
-
- public void AttachToGraphicsDevice(GraphicsDevice device)
- {
- GraphicsDevice = device;
- }
-
- public virtual void Dispose()
- {
- NativeResource.Dispose();
- }
-
- public IntPtr Map(int subresource)
- {
- IntPtr mappedResource = NativeResource.Map(subresource);
- MappedResource = mappedResource;
- return mappedResource;
- }
-
- public void Unmap(int subresource)
- {
- NativeResource.Unmap(subresource);
- MappedResource = IntPtr.Zero;
- }
- }
-}
diff --git a/src/DirectX12GameEngine.Graphics/Primitives/Abstract/GraphicsResource.cs b/src/DirectX12GameEngine.Graphics/Primitives/Abstract/GraphicsResource.cs
new file mode 100644
index 00000000..61a0d1eb
--- /dev/null
+++ b/src/DirectX12GameEngine.Graphics/Primitives/Abstract/GraphicsResource.cs
@@ -0,0 +1,70 @@
+using System;
+using SharpDX.Direct3D12;
+
+namespace DirectX12GameEngine.Graphics.Primitives.Abstract
+{
+ ///
+ /// An abstract that represents a graphics resource object
+ ///
+ public abstract class GraphicsResource : IDisposable
+ {
+ ///
+ /// Creates a new instance with the specified parameters
+ ///
+ /// The associated with the current instance
+ protected GraphicsResource(GraphicsDevice device)
+ {
+ GraphicsDevice = device;
+ }
+
+ ///
+ /// Gets the associated with the current instance
+ ///
+ public GraphicsDevice GraphicsDevice { get; }
+
+ ///
+ /// Gets the associated to the currently mapped resource
+ ///
+ public IntPtr MappedResource { get; private set; }
+
+ ///
+ /// Gets the object currently mapped
+ ///
+ protected internal Resource? NativeResource { get; set; }
+
+ ///
+ /// Gets the instance for the current resource
+ ///
+ protected internal CpuDescriptorHandle NativeCpuDescriptorHandle { get; protected set; }
+
+ ///
+ /// Gets the instance for the current resource
+ ///
+ protected internal GpuDescriptorHandle NativeGpuDescriptorHandle { get; protected set; }
+
+ ///
+ /// Maps the current resource to a specified subresource
+ ///
+ /// The index of the target subresource to map
+ /// An for the newly mapped resource
+ public IntPtr Map(int subresource)
+ {
+ IntPtr mappedResource = NativeResource?.Map(subresource) ?? throw new InvalidOperationException("Missing resource");
+ MappedResource = mappedResource;
+ return mappedResource;
+ }
+
+ ///
+ /// Unmaps a subresource specified by a given index
+ ///
+ /// The index of the subresource to unmap
+ public void Unmap(int subresource)
+ {
+ NativeResource?.Unmap(subresource);
+ MappedResource = IntPtr.Zero;
+ }
+
+ ///
+ public virtual void Dispose() => NativeResource?.Dispose();
+ }
+}