mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-01-11 20:10:30 +00:00
use RenderDocVersion enum for MinimumRequired instead of System.Version,
additionally added .NET 10 extension properties instead of helper methods in RenderDoc
This commit is contained in:
parent
0c1338b7d3
commit
82ab8132f6
3 changed files with 44 additions and 15 deletions
|
|
@ -3,7 +3,7 @@ using System.Runtime.CompilerServices;
|
|||
|
||||
namespace Ryujinx.Graphics.RenderDocApi
|
||||
{
|
||||
public static class Helpers
|
||||
public static partial class Helpers
|
||||
{
|
||||
extension(Vk api)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.RenderDocApi
|
|||
/// Set the minimum version of the API you require.
|
||||
/// </summary>
|
||||
/// <remarks>Set this before you do anything else with the RenderDoc API, including <see cref="IsAvailable"/>.</remarks>
|
||||
public static Version MinimumRequired { get; set; } = new Version(1, 0, 0);
|
||||
public static RenderDocVersion MinimumRequired { get; set; } = RenderDocVersion.Version_1_0_0;
|
||||
|
||||
/// <summary>
|
||||
/// Set to true to assert versions.
|
||||
|
|
@ -417,7 +417,8 @@ namespace Ryujinx.Graphics.RenderDocApi
|
|||
/// Reload the internal RenderDoc API structure. Useful for manually refreshing <see cref="Api"/> while using process injection.
|
||||
/// </summary>
|
||||
/// <param name="ignoreAlreadyLoaded">Ignores the existing API function structure and overwrites it with a re-request.</param>
|
||||
public static void ReloadApi(bool ignoreAlreadyLoaded = false)
|
||||
/// <param name="requiredVersion">The version of the RenderDoc API required by your application.</param>
|
||||
public static void ReloadApi(bool ignoreAlreadyLoaded = false, RenderDocVersion? requiredVersion = null)
|
||||
{
|
||||
if (_loaded && !ignoreAlreadyLoaded)
|
||||
return;
|
||||
|
|
@ -428,11 +429,14 @@ namespace Ryujinx.Graphics.RenderDocApi
|
|||
if (_loaded && !ignoreAlreadyLoaded)
|
||||
return;
|
||||
|
||||
if (requiredVersion.HasValue)
|
||||
MinimumRequired = requiredVersion.Value;
|
||||
|
||||
_loaded = true;
|
||||
_api = GetApi(SystemVersionToRenderdocVersion(MinimumRequired));
|
||||
_api = GetApi(MinimumRequired);
|
||||
|
||||
if (_api != null)
|
||||
AssertAtLeast(MinimumRequired.Major, MinimumRequired.Minor, MinimumRequired.Build);
|
||||
AssertAtLeast(MinimumRequired);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -475,6 +479,12 @@ namespace Ryujinx.Graphics.RenderDocApi
|
|||
return null;
|
||||
}
|
||||
|
||||
private static void AssertAtLeast(RenderDocVersion rdv, [CallerMemberName] string callee = "")
|
||||
{
|
||||
Version ver = rdv.SystemVersion;
|
||||
AssertAtLeast(ver.Major, ver.Minor, ver.Build, callee);
|
||||
}
|
||||
|
||||
private static void AssertAtLeast(int major, int minor, int patch = 0, [CallerMemberName] string callee = "")
|
||||
{
|
||||
if (!AssertVersionEnabled)
|
||||
|
|
@ -502,15 +512,6 @@ namespace Ryujinx.Graphics.RenderDocApi
|
|||
$"This API was introduced in RenderdocAPI {minVersion}. Current API version is {Version}.");
|
||||
}
|
||||
|
||||
private static Version RenderdocVersionToSystemVersion(RenderDocVersion version)
|
||||
{
|
||||
int i = (int)version;
|
||||
return new Version(i / 10000, (i % 10000) / 100, i % 100);
|
||||
}
|
||||
|
||||
private static RenderDocVersion SystemVersionToRenderdocVersion(Version version) =>
|
||||
(RenderDocVersion)(version.Major * 10000 + version.Minor * 100 + version.Build);
|
||||
|
||||
private static byte[] ToNullTerminatedByteArray(this string str, Encoding? encoding = null)
|
||||
{
|
||||
encoding ??= Encoding.UTF8;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.RenderDocApi
|
||||
{
|
||||
internal enum RenderDocVersion : int
|
||||
public enum RenderDocVersion
|
||||
{
|
||||
Version_1_0_0 = 10000,
|
||||
Version_1_0_1 = 10001,
|
||||
|
|
@ -16,4 +18,30 @@ namespace Ryujinx.Graphics.RenderDocApi
|
|||
Version_1_5_0 = 10500,
|
||||
Version_1_6_0 = 10600,
|
||||
}
|
||||
|
||||
public static partial class Helpers
|
||||
{
|
||||
extension(RenderDocVersion rdv)
|
||||
{
|
||||
public Version SystemVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
int i = (int)rdv;
|
||||
return new (i / 10000, (i % 10000) / 100, i % 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension(Version sv)
|
||||
{
|
||||
public RenderDocVersion RenderDocVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return (RenderDocVersion)(sv.Major * 10000 + sv.Minor * 100 + sv.Build);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue