mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 20:48:24 +01:00
SOURCE DUMP v1
This commit is contained in:
parent
bd62d51ec9
commit
fb20299e9d
1 changed files with 768360 additions and 0 deletions
|
|
@ -0,0 +1,62 @@
|
|||
using System.Diagnostics;
|
||||
|
||||
namespace Brutal.VulkanApi.Abstractions;
|
||||
|
||||
public static class DebugNameExtensions
|
||||
{
|
||||
private const int MAX_DEBUG_NAME_LENGTH = 256;
|
||||
|
||||
/// <summary>
|
||||
/// Set a debug name for the handle.
|
||||
/// </summary>
|
||||
/// <param name="device">Handle to the device that will assign the name</param>
|
||||
/// <param name="handle">The Vulkan handle we want to assign a name to</param>
|
||||
/// <param name="name">The name to assign to the handle</param>
|
||||
[Conditional("DEBUG")]
|
||||
public static void SetDebugName<T>(this Device device, T handle, string name)
|
||||
where T : IVulkanHandle
|
||||
{
|
||||
if (!device.PhysicalDevice.Instance.IsExtensionEnabled(VK.EXT_DEBUG_UTILS_EXTENSION_NAME))
|
||||
return;
|
||||
|
||||
var bytes = SpanOwner<byte>.Allocate(MAX_DEBUG_NAME_LENGTH);
|
||||
var written = Utf8.GetBytes(name, bytes.Span);
|
||||
bytes.Span[written] = 0;
|
||||
|
||||
device.SetDebugName(handle.VkObjectType, handle.VkHandle, bytes.Span[..written]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set a debug name for the handle.
|
||||
/// </summary>
|
||||
/// <param name="device">Handle to the device that will assign the name</param>
|
||||
/// <param name="handle">The Vulkan handle we want to assign a name to</param>
|
||||
/// <param name="name">The name to assign to the handle</param>
|
||||
[Conditional("DEBUG")]
|
||||
public static void SetDebugName<T>(this Device device, T handle, ReadOnlySpan<byte> name)
|
||||
where T : IVulkanHandle
|
||||
{
|
||||
if (!device.PhysicalDevice.Instance.IsExtensionEnabled(VK.EXT_DEBUG_UTILS_EXTENSION_NAME))
|
||||
return;
|
||||
|
||||
device.SetDebugName(handle.VkObjectType, handle.VkHandle, name);
|
||||
}
|
||||
|
||||
private static unsafe void SetDebugName(
|
||||
this Device device,
|
||||
VkObjectType objectType,
|
||||
nint handle,
|
||||
ReadOnlySpan<byte> name
|
||||
)
|
||||
{
|
||||
fixed (byte* namePtr = name)
|
||||
device.SetDebugUtilsObjectNameEXT(
|
||||
new VkDebugUtilsObjectNameInfoEXT
|
||||
{
|
||||
ObjectType = objectType,
|
||||
ObjectHandle = handle,
|
||||
ObjectName = namePtr,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue