mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-13 14:19:12 +00:00
Vulkan: Add CommandBufferLabelScope
This commit is contained in:
parent
e2cfe6fe44
commit
9d1d564993
3 changed files with 90 additions and 0 deletions
79
src/Ryujinx.Graphics.Vulkan/LabelScope.cs
Normal file
79
src/Ryujinx.Graphics.Vulkan/LabelScope.cs
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
using Ryujinx.Graphics.GAL;
|
||||||
|
using Silk.NET.Vulkan;
|
||||||
|
using Silk.NET.Vulkan.Extensions.EXT;
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Ryujinx.Graphics.Vulkan
|
||||||
|
{
|
||||||
|
public interface ILabelScope : IDisposable
|
||||||
|
{
|
||||||
|
void InsertLabel(string labelName, ColorF labelColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ILabelScopePrivate : ILabelScope
|
||||||
|
{
|
||||||
|
void BeginLabel(string scopeName, ColorF scopeColor);
|
||||||
|
void EndLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class CommandBufferLabelScope : ILabelScopePrivate
|
||||||
|
{
|
||||||
|
private CommandBuffer _commandBuffer;
|
||||||
|
|
||||||
|
private readonly ExtDebugUtils _debugUtils;
|
||||||
|
|
||||||
|
public unsafe CommandBufferLabelScope(ExtDebugUtils debugUtils, CommandBuffer commandBuffer, string scopeName, ColorF scopeColor)
|
||||||
|
{
|
||||||
|
_debugUtils = debugUtils;
|
||||||
|
_commandBuffer = commandBuffer;
|
||||||
|
|
||||||
|
BeginLabel(scopeName, scopeColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe void InsertLabel(string labelName, ColorF labelColor)
|
||||||
|
{
|
||||||
|
IntPtr pLabelName = Marshal.StringToHGlobalAnsi(labelName);
|
||||||
|
|
||||||
|
DebugUtilsLabelEXT label = CreateLabel(pLabelName, labelColor);
|
||||||
|
_debugUtils.CmdInsertDebugUtilsLabel(_commandBuffer, label);
|
||||||
|
|
||||||
|
Marshal.FreeHGlobal(pLabelName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe void BeginLabel(string scopeName, ColorF scopeColor)
|
||||||
|
{
|
||||||
|
IntPtr pScopeName = Marshal.StringToHGlobalAnsi(scopeName);
|
||||||
|
|
||||||
|
DebugUtilsLabelEXT label = CreateLabel(pScopeName, scopeColor);
|
||||||
|
_debugUtils.CmdBeginDebugUtilsLabel(_commandBuffer, label);
|
||||||
|
|
||||||
|
Marshal.FreeHGlobal(pScopeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe void EndLabel()
|
||||||
|
{
|
||||||
|
_debugUtils.CmdEndDebugUtilsLabel(_commandBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static unsafe DebugUtilsLabelEXT CreateLabel(IntPtr scopeName, ColorF scopeColor)
|
||||||
|
{
|
||||||
|
DebugUtilsLabelEXT label = new DebugUtilsLabelEXT
|
||||||
|
{
|
||||||
|
SType = StructureType.DebugUtilsLabelExt,
|
||||||
|
PLabelName = (byte*)scopeName
|
||||||
|
};
|
||||||
|
label.Color[0] = scopeColor.Red;
|
||||||
|
label.Color[1] = scopeColor.Green;
|
||||||
|
label.Color[2] = scopeColor.Blue;
|
||||||
|
label.Color[3] = scopeColor.Alpha;
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
EndLabel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
using Ryujinx.Common.Configuration;
|
using Ryujinx.Common.Configuration;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.Common.Utilities;
|
using Ryujinx.Common.Utilities;
|
||||||
|
using Ryujinx.Graphics.GAL;
|
||||||
using Silk.NET.Vulkan;
|
using Silk.NET.Vulkan;
|
||||||
using Silk.NET.Vulkan.Extensions.EXT;
|
using Silk.NET.Vulkan.Extensions.EXT;
|
||||||
using System;
|
using System;
|
||||||
|
@ -33,6 +34,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ILabelScope CreateLabelScope(CommandBuffer commandBuffer, string scopeName, ColorF scopeColor)
|
||||||
|
{
|
||||||
|
return new CommandBufferLabelScope(_debugUtils, commandBuffer, scopeName, scopeColor);
|
||||||
|
}
|
||||||
|
|
||||||
private Result TryInitialize(out DebugUtilsMessengerEXT? debugUtilsMessengerHandle)
|
private Result TryInitialize(out DebugUtilsMessengerEXT? debugUtilsMessengerHandle)
|
||||||
{
|
{
|
||||||
debugUtilsMessengerHandle = null;
|
debugUtilsMessengerHandle = null;
|
||||||
|
|
|
@ -396,6 +396,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ILabelScope CreateLabelScope(CommandBuffer commandBuffer, string scopeName, ColorF scopeColor)
|
||||||
|
{
|
||||||
|
return _debugMessenger.CreateLabelScope(commandBuffer, scopeName, scopeColor);
|
||||||
|
}
|
||||||
|
|
||||||
public BufferHandle CreateBuffer(int size, BufferAccess access)
|
public BufferHandle CreateBuffer(int size, BufferAccess access)
|
||||||
{
|
{
|
||||||
return BufferManager.CreateWithHandle(this, size, access.Convert(), default, access == BufferAccess.Stream);
|
return BufferManager.CreateWithHandle(this, size, access.Convert(), default, access == BufferAccess.Stream);
|
||||||
|
|
Loading…
Reference in a new issue