Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
xoofx committed Jun 29, 2024
1 parent 3a7c1ce commit ce7efcf
Show file tree
Hide file tree
Showing 38 changed files with 248 additions and 246 deletions.
8 changes: 4 additions & 4 deletions src/XenoAtom.Graphics/BackendInfoVulkan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ internal BackendInfoVulkan(VkGraphicsDevice gd)
/// <summary>
/// Gets the underlying VkInstance used by the GraphicsDevice.
/// </summary>
public IntPtr Instance => _gd.Instance.Value.Handle;
public IntPtr Instance => _gd.VkInstance.Value.Handle;

/// <summary>
/// Gets the underlying VkDevice used by the GraphicsDevice.
/// </summary>
public IntPtr Device => _gd.Device.Value.Handle;
public IntPtr Device => _gd.VkDevice.Value.Handle;

/// <summary>
/// Gets the underlying VkPhysicalDevice used by the GraphicsDevice.
/// </summary>
public IntPtr PhysicalDevice => _gd.PhysicalDevice.Value.Handle;
public IntPtr PhysicalDevice => _gd.VkPhysicalDevice.Value.Handle;

/// <summary>
/// Gets the VkQueue which is used by the GraphicsDevice to submit graphics work.
/// </summary>
public IntPtr GraphicsQueue => _gd.GraphicsQueue.Value.Handle;
public IntPtr GraphicsQueue => _gd.VkGraphicsQueue.Value.Handle;

/// <summary>
/// Gets the queue family index of the graphics VkQueue.
Expand Down
2 changes: 1 addition & 1 deletion src/XenoAtom.Graphics/Buffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace XenoAtom.Graphics
/// The size of a <see cref="DeviceBuffer"/> is fixed upon creation, and resizing is not possible.
/// See <see cref="BufferDescription"/>.
/// </summary>
public abstract class DeviceBuffer : GraphicsDeviceObject, BindableResource, MappableResource
public abstract class DeviceBuffer : GraphicsDeviceObject, IBindableResource, IMappableResource
{
internal DeviceBuffer(GraphicsDevice device) : base(device)
{
Expand Down
4 changes: 2 additions & 2 deletions src/XenoAtom.Graphics/BufferUsage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

namespace XenoAtom.Graphics
{
Expand Down Expand Up @@ -49,7 +49,7 @@ public enum BufferUsage : byte
Dynamic = 1 << 6,
/// <summary>
/// Indicates that a <see cref="DeviceBuffer"/> will be used as a staging Buffer. Staging Buffers can be used to transfer data
/// to-and-from the CPU using <see cref="GraphicsDevice.Map(MappableResource, MapMode)"/>. Staging Buffers can use all
/// to-and-from the CPU using <see cref="GraphicsDevice.Map(IMappableResource, MapMode)"/>. Staging Buffers can use all
/// <see cref="MapMode"/> values.
/// This flag cannot be combined with any other flag.
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions src/XenoAtom.Graphics/DeviceBufferRange.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System;
using System;

namespace XenoAtom.Graphics
{
/// <summary>
/// A <see cref="BindableResource"/> that represents a section of a <see cref="DeviceBuffer"/>. This can be used in place of
/// A <see cref="IBindableResource"/> that represents a section of a <see cref="DeviceBuffer"/>. This can be used in place of
/// a <see cref="DeviceBuffer"/> when creating a <see cref="ResourceSet"/> to make only a subset of the Buffer available to
/// shaders.
/// </summary>
public struct DeviceBufferRange : BindableResource, IEquatable<DeviceBufferRange>
public struct DeviceBufferRange : IBindableResource, IEquatable<DeviceBufferRange>
{
/// <summary>
/// The underlying <see cref="DeviceBuffer"/> that this range refers to.
Expand Down
16 changes: 8 additions & 8 deletions src/XenoAtom.Graphics/GraphicsDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void WaitForIdle()
/// <param name="resource">The <see cref="DeviceBuffer"/> or <see cref="Texture"/> resource to map.</param>
/// <param name="mode">The <see cref="MapMode"/> to use.</param>
/// <returns>A <see cref="MappedResource"/> structure describing the mapped data region.</returns>
public MappedResource Map(MappableResource resource, MapMode mode) => Map(resource, mode, 0);
public MappedResource Map(IMappableResource resource, MapMode mode) => Map(resource, mode, 0);
/// <summary>
/// Maps a <see cref="DeviceBuffer"/> or <see cref="Texture"/> into a CPU-accessible data region.
/// </summary>
Expand All @@ -205,7 +205,7 @@ public void WaitForIdle()
/// <param name="subresource">The subresource to map. Subresources are indexed first by mip slice, then by array layer.
/// For <see cref="DeviceBuffer"/> resources, this parameter must be 0.</param>
/// <returns>A <see cref="MappedResource"/> structure describing the mapped data region.</returns>
public MappedResource Map(MappableResource resource, MapMode mode, uint subresource)
public MappedResource Map(IMappableResource resource, MapMode mode, uint subresource)
{
#if VALIDATE_USAGE
if (resource is DeviceBuffer buffer)
Expand Down Expand Up @@ -248,7 +248,7 @@ public MappedResource Map(MappableResource resource, MapMode mode, uint subresou
/// <param name="mode"></param>
/// <param name="subresource"></param>
/// <returns></returns>
protected abstract MappedResource MapCore(MappableResource resource, MapMode mode, uint subresource);
protected abstract MappedResource MapCore(IMappableResource resource, MapMode mode, uint subresource);

/// <summary>
/// Maps a <see cref="DeviceBuffer"/> or <see cref="Texture"/> into a CPU-accessible data region, and returns a structured
Expand All @@ -258,7 +258,7 @@ public MappedResource Map(MappableResource resource, MapMode mode, uint subresou
/// <param name="mode">The <see cref="MapMode"/> to use.</param>
/// <typeparam name="T">The blittable value type which mapped data is viewed as.</typeparam>
/// <returns>A <see cref="MappedResource"/> structure describing the mapped data region.</returns>
public MappedResourceView<T> Map<T>(MappableResource resource, MapMode mode) where T : unmanaged
public MappedResourceView<T> Map<T>(IMappableResource resource, MapMode mode) where T : unmanaged
=> Map<T>(resource, mode, 0);
/// <summary>
/// Maps a <see cref="DeviceBuffer"/> or <see cref="Texture"/> into a CPU-accessible data region, and returns a structured
Expand All @@ -269,7 +269,7 @@ public MappedResourceView<T> Map<T>(MappableResource resource, MapMode mode) whe
/// <param name="subresource">The subresource to map. Subresources are indexed first by mip slice, then by array layer.</param>
/// <typeparam name="T">The blittable value type which mapped data is viewed as.</typeparam>
/// <returns>A <see cref="MappedResource"/> structure describing the mapped data region.</returns>
public MappedResourceView<T> Map<T>(MappableResource resource, MapMode mode, uint subresource) where T : unmanaged
public MappedResourceView<T> Map<T>(IMappableResource resource, MapMode mode, uint subresource) where T : unmanaged
{
MappedResource mappedResource = Map(resource, mode, subresource);
return new MappedResourceView<T>(mappedResource);
Expand All @@ -280,14 +280,14 @@ public MappedResourceView<T> Map<T>(MappableResource resource, MapMode mode, uin
/// For <see cref="Texture"/> resources, this unmaps the first subresource.
/// </summary>
/// <param name="resource">The resource to unmap.</param>
public void Unmap(MappableResource resource) => Unmap(resource, 0);
public void Unmap(IMappableResource resource) => Unmap(resource, 0);
/// <summary>
/// Invalidates a previously-mapped data region for the given <see cref="DeviceBuffer"/> or <see cref="Texture"/>.
/// </summary>
/// <param name="resource">The resource to unmap.</param>
/// <param name="subresource">The subresource to unmap. Subresources are indexed first by mip slice, then by array layer.
/// For <see cref="DeviceBuffer"/> resources, this parameter must be 0.</param>
public void Unmap(MappableResource resource, uint subresource)
public void Unmap(IMappableResource resource, uint subresource)
{
UnmapCore(resource, subresource);
}
Expand All @@ -296,7 +296,7 @@ public void Unmap(MappableResource resource, uint subresource)
/// </summary>
/// <param name="resource"></param>
/// <param name="subresource"></param>
protected abstract void UnmapCore(MappableResource resource, uint subresource);
protected abstract void UnmapCore(IMappableResource resource, uint subresource);

/// <summary>
/// Updates a portion of a <see cref="Texture"/> resource with new data.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace XenoAtom.Graphics
namespace XenoAtom.Graphics
{
/// <summary>
/// A resource which can be bound in a <see cref="ResourceSet"/> and used in a shader.
/// See <see cref="DeviceBuffer"/>, <see cref="DeviceBufferRange"/>, <see cref="Texture"/>, <see cref="TextureView"/>
/// and <see cref="Sampler"/>.
/// </summary>
public interface BindableResource { }
public interface IBindableResource { }
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace XenoAtom.Graphics
namespace XenoAtom.Graphics
{
/// <summary>
/// A marker interface designating a device resource which can be mapped into CPU-visible memory with
/// <see cref="GraphicsDevice.Map(MappableResource, MapMode, uint)"/>
/// <see cref="GraphicsDevice.Map(IMappableResource, MapMode, uint)"/>
/// </summary>
public interface MappableResource
public interface IMappableResource
{
}
}
6 changes: 3 additions & 3 deletions src/XenoAtom.Graphics/MapMode.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace XenoAtom.Graphics
namespace XenoAtom.Graphics
{
/// <summary>
/// Identifies how a <see cref="MappableResource"/> will be mapped into CPU address space.
/// Identifies how a <see cref="IMappableResource"/> will be mapped into CPU address space.
/// </summary>
public enum MapMode : byte
{
Expand All @@ -12,7 +12,7 @@ public enum MapMode : byte
Read,
/// <summary>
/// A write-only resource mapping. The mapped data region is writable, and will be transferred into the graphics resource
/// when <see cref="GraphicsDevice.Unmap(MappableResource, uint)"/> is called. NOTE: upon mapping a buffer with this
/// when <see cref="GraphicsDevice.Unmap(IMappableResource, uint)"/> is called. NOTE: upon mapping a buffer with this
/// mode, the previous contents of the resource will be erased. This mode can only be used to entirely replace the
/// contents of a resource.
/// </summary>
Expand Down
10 changes: 5 additions & 5 deletions src/XenoAtom.Graphics/MappedResource.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using System;
using System;
using System.Runtime.CompilerServices;

namespace XenoAtom.Graphics
{
/// <summary>
/// A structure describing the layout of a mapped <see cref="MappableResource"/> object.
/// A structure describing the layout of a mapped <see cref="IMappableResource"/> object.
/// </summary>
public struct MappedResource
{
/// <summary>
/// The resource which has been mapped.
/// </summary>
public readonly MappableResource Resource;
public readonly IMappableResource Resource;
/// <summary>
/// Identifies the <see cref="MapMode"/> that was used to map the resource.
/// </summary>
Expand Down Expand Up @@ -41,7 +41,7 @@ public struct MappedResource
public readonly uint DepthPitch;

internal MappedResource(
MappableResource resource,
IMappableResource resource,
MapMode mode,
IntPtr data,
uint sizeInBytes,
Expand All @@ -58,7 +58,7 @@ internal MappedResource(
DepthPitch = depthPitch;
}

internal MappedResource(MappableResource resource, MapMode mode, IntPtr data, uint sizeInBytes)
internal MappedResource(IMappableResource resource, MapMode mode, IntPtr data, uint sizeInBytes)
{
Resource = resource;
Mode = mode;
Expand Down
6 changes: 3 additions & 3 deletions src/XenoAtom.Graphics/MappedResourceCacheKey.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System;
using System;

namespace XenoAtom.Graphics
{
internal struct MappedResourceCacheKey : IEquatable<MappedResourceCacheKey>
{
public readonly MappableResource Resource;
public readonly IMappableResource Resource;
public readonly uint Subresource;

public MappedResourceCacheKey(MappableResource resource, uint subresource)
public MappedResourceCacheKey(IMappableResource resource, uint subresource)
{
Resource = resource;
Subresource = subresource;
Expand Down
4 changes: 2 additions & 2 deletions src/XenoAtom.Graphics/ResourceKind.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace XenoAtom.Graphics
namespace XenoAtom.Graphics
{
/// <summary>
/// The kind of a <see cref="BindableResource"/> object.
/// The kind of a <see cref="IBindableResource"/> object.
/// </summary>
public enum ResourceKind : byte
{
Expand Down
2 changes: 1 addition & 1 deletion src/XenoAtom.Graphics/ResourceLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace XenoAtom.Graphics
{
/// <summary>
/// A device resource which describes the layout and kind of <see cref="BindableResource"/> objects available
/// A device resource which describes the layout and kind of <see cref="IBindableResource"/> objects available
/// to a shader set.
/// See <see cref="ResourceLayoutDescription"/>.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/XenoAtom.Graphics/ResourceLayoutDescription.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System;

namespace XenoAtom.Graphics
{
/// <summary>
/// Describes the layout of <see cref="BindableResource"/> objects for a <see cref="Pipeline"/>.
/// Describes the layout of <see cref="IBindableResource"/> objects for a <see cref="Pipeline"/>.
/// </summary>
public struct ResourceLayoutDescription : IEquatable<ResourceLayoutDescription>
{
Expand Down
4 changes: 2 additions & 2 deletions src/XenoAtom.Graphics/ResourceSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace XenoAtom.Graphics
{
/// <summary>
/// A device resource used to bind a particular set of <see cref="BindableResource"/> objects to a <see cref="CommandList"/>.
/// A device resource used to bind a particular set of <see cref="IBindableResource"/> objects to a <see cref="CommandList"/>.
/// See <see cref="ResourceSetDescription"/>.
/// </summary>
public abstract class ResourceSet : GraphicsDeviceObject
Expand All @@ -19,7 +19,7 @@ internal ResourceSet(GraphicsDevice device, in ResourceSetDescription descriptio

#if VALIDATE_USAGE
internal ResourceLayout Layout { get; }
internal BindableResource[] Resources { get; }
internal IBindableResource[] Resources { get; }
#endif
}
}
10 changes: 5 additions & 5 deletions src/XenoAtom.Graphics/ResourceSetDescription.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

namespace XenoAtom.Graphics
{
Expand All @@ -12,18 +12,18 @@ public struct ResourceSetDescription : IEquatable<ResourceSetDescription>
/// </summary>
public ResourceLayout Layout;
/// <summary>
/// An array of <see cref="BindableResource"/> objects.
/// An array of <see cref="IBindableResource"/> objects.
/// The number and type of resources must match those specified in the <see cref="ResourceLayout"/>.
/// </summary>
public BindableResource[] BoundResources;
public IBindableResource[] BoundResources;

/// <summary>
/// Constructs a new ResourceSetDescription.
/// </summary>
/// <param name="layout">The <see cref="ResourceLayout"/> describing the number and kind of resources used.</param>
/// <param name="boundResources">An array of <see cref="BindableResource"/> objects.
/// <param name="boundResources">An array of <see cref="IBindableResource"/> objects.
/// The number and type of resources must match those specified in the <see cref="ResourceLayout"/>.</param>
public ResourceSetDescription(ResourceLayout layout, params BindableResource[] boundResources)
public ResourceSetDescription(ResourceLayout layout, params IBindableResource[] boundResources)
{
Layout = layout;
BoundResources = boundResources;
Expand Down
2 changes: 1 addition & 1 deletion src/XenoAtom.Graphics/Sampler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace XenoAtom.Graphics
/// A bindable device resource which controls how texture values are sampled within a shader.
/// See <see cref="SamplerDescription"/>.
/// </summary>
public abstract class Sampler : GraphicsDeviceObject, BindableResource
public abstract class Sampler : GraphicsDeviceObject, IBindableResource
{
internal Sampler(GraphicsDevice device) : base(device)
{
Expand Down
2 changes: 1 addition & 1 deletion src/XenoAtom.Graphics/Texture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace XenoAtom.Graphics
/// A device resource used to store arbitrary image data in a specific format.
/// See <see cref="TextureDescription"/>.
/// </summary>
public abstract class Texture : GraphicsDeviceObject, MappableResource, BindableResource
public abstract class Texture : GraphicsDeviceObject, IMappableResource, IBindableResource
{
private readonly object _fullTextureViewLock = new();
private TextureView? _fullTextureView;
Expand Down
4 changes: 2 additions & 2 deletions src/XenoAtom.Graphics/TextureUsage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

namespace XenoAtom.Graphics
{
Expand Down Expand Up @@ -30,7 +30,7 @@ public enum TextureUsage : byte
Cubemap = 1 << 4,
/// <summary>
/// The Texture is used as a read-write staging resource for uploading Texture data.
/// With this flag, a Texture can be mapped using the <see cref="GraphicsDevice.Map(MappableResource, MapMode, uint)"/>
/// With this flag, a Texture can be mapped using the <see cref="GraphicsDevice.Map(IMappableResource, MapMode, uint)"/>
/// method.
/// </summary>
Staging = 1 << 5,
Expand Down
2 changes: 1 addition & 1 deletion src/XenoAtom.Graphics/TextureView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace XenoAtom.Graphics
/// A bindable device resource which provides a shader with access to a sampled <see cref="Texture"/> object.
/// See <see cref="TextureViewDescription"/>.
/// </summary>
public abstract class TextureView : GraphicsDeviceObject, BindableResource
public abstract class TextureView : GraphicsDeviceObject, IBindableResource
{
/// <summary>
/// The target <see cref="Texture"/> object to be sampled via this instance.
Expand Down
6 changes: 3 additions & 3 deletions src/XenoAtom.Graphics/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ internal static T[] ShallowClone<T>(T[] array)
return (T[])array.Clone();
}

public static DeviceBufferRange GetBufferRange(BindableResource resource, uint additionalOffset)
public static DeviceBufferRange GetBufferRange(IBindableResource resource, uint additionalOffset)
{
if (resource is DeviceBufferRange range)
{
Expand All @@ -269,7 +269,7 @@ public static DeviceBufferRange GetBufferRange(BindableResource resource, uint a
}
}

public static bool TryGetDeviceBuffer(BindableResource resource, [NotNullWhen(true)] out DeviceBuffer? buffer)
public static bool TryGetDeviceBuffer(IBindableResource resource, [NotNullWhen(true)] out DeviceBuffer? buffer)
{
if (resource is DeviceBuffer db)
{
Expand All @@ -286,7 +286,7 @@ public static bool TryGetDeviceBuffer(BindableResource resource, [NotNullWhen(tr
return false;
}

internal static TextureView GetTextureView(GraphicsDevice gd, BindableResource resource)
internal static TextureView GetTextureView(GraphicsDevice gd, IBindableResource resource)
{
if (resource is TextureView view)
{
Expand Down
Loading

0 comments on commit ce7efcf

Please sign in to comment.