2024-09-02 01:28:16 +01:00
|
|
|
using Ryujinx.Common.Utilities;
|
2023-12-04 14:17:13 +01:00
|
|
|
using System;
|
2021-04-07 13:19:02 +01:00
|
|
|
|
|
|
|
|
namespace Ryujinx.Common.GraphicsDriver
|
|
|
|
|
{
|
|
|
|
|
public static class DriverUtilities
|
|
|
|
|
{
|
2024-09-02 01:28:16 +01:00
|
|
|
private static void AddMesaFlags(string envVar, string newFlags)
|
|
|
|
|
{
|
|
|
|
|
string existingFlags = Environment.GetEnvironmentVariable(envVar);
|
|
|
|
|
|
|
|
|
|
string flags = existingFlags == null ? newFlags : $"{existingFlags},{newFlags}";
|
|
|
|
|
|
|
|
|
|
OsUtils.SetEnvironmentVariableNoCaching(envVar, flags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void InitDriverConfig(bool oglThreading)
|
|
|
|
|
{
|
|
|
|
|
if (OperatingSystem.IsLinux())
|
|
|
|
|
{
|
|
|
|
|
AddMesaFlags("RADV_DEBUG", "nodcc");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToggleOGLThreading(oglThreading);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-07 13:19:02 +01:00
|
|
|
public static void ToggleOGLThreading(bool enabled)
|
|
|
|
|
{
|
2024-09-02 01:28:16 +01:00
|
|
|
OsUtils.SetEnvironmentVariableNoCaching("mesa_glthread", enabled.ToString().ToLower());
|
|
|
|
|
OsUtils.SetEnvironmentVariableNoCaching("__GL_THREADED_OPTIMIZATIONS", enabled ? "1" : "0");
|
2021-04-07 13:19:02 +01:00
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
NVThreadedOptimization.SetThreadedOptimization(enabled);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
// NVAPI is not available, or couldn't change the application profile.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|