Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
8ac53c66b4 | ||
|
0f50de72be | ||
|
df758eddd1 | ||
|
5f32a8ed94 |
@@ -31,7 +31,7 @@
|
||||
<PackageVersion Include="OpenTK.OpenAL" Version="4.7.5" />
|
||||
<PackageVersion Include="OpenTK.Windowing.GraphicsLibraryFramework" Version="4.7.5" />
|
||||
<PackageVersion Include="Ryujinx.Audio.OpenAL.Dependencies" Version="1.21.0.1" />
|
||||
<PackageVersion Include="Ryujinx.Graphics.Nvdec.Dependencies" Version="5.0.1-build12" />
|
||||
<PackageVersion Include="Ryujinx.Graphics.Nvdec.Dependencies" Version="5.0.1-build13" />
|
||||
<PackageVersion Include="Ryujinx.Graphics.Vulkan.Dependencies.MoltenVK" Version="1.2.0" />
|
||||
<PackageVersion Include="Ryujinx.GtkSharp" Version="3.24.24.59-ryujinx" />
|
||||
<PackageVersion Include="Ryujinx.SDL2-CS" Version="2.24.2-build21" />
|
||||
|
@@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||
private const ushort FileFormatVersionMajor = 1;
|
||||
private const ushort FileFormatVersionMinor = 2;
|
||||
private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor;
|
||||
private const uint CodeGenVersion = 4069;
|
||||
private const uint CodeGenVersion = 4106;
|
||||
|
||||
private const string SharedTocFileName = "shared.toc";
|
||||
private const string SharedDataFileName = "shared.data";
|
||||
|
@@ -262,7 +262,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
||||
|
||||
value = (value >> operation.Index * 16) & 0xffff;
|
||||
|
||||
operation.TurnIntoCopy(ConstF(HalfConversion.HalfToSingle(value)));
|
||||
operation.TurnIntoCopy(ConstF((float)BitConverter.UInt16BitsToHalf((ushort)value)));
|
||||
}
|
||||
|
||||
private static void FPNegate(Operation operation)
|
||||
|
@@ -1,47 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
||||
{
|
||||
static class HalfConversion
|
||||
{
|
||||
public static float HalfToSingle(int value)
|
||||
{
|
||||
int mantissa = (value >> 0) & 0x3ff;
|
||||
int exponent = (value >> 10) & 0x1f;
|
||||
int sign = (value >> 15) & 0x1;
|
||||
|
||||
if (exponent == 0x1f)
|
||||
{
|
||||
// NaN or Infinity.
|
||||
mantissa <<= 13;
|
||||
exponent = 0xff;
|
||||
}
|
||||
else if (exponent != 0 || mantissa != 0 )
|
||||
{
|
||||
if (exponent == 0)
|
||||
{
|
||||
// Denormal.
|
||||
int e = -1;
|
||||
int m = mantissa;
|
||||
|
||||
do
|
||||
{
|
||||
e++;
|
||||
m <<= 1;
|
||||
}
|
||||
while ((m & 0x400) == 0);
|
||||
|
||||
mantissa = m & 0x3ff;
|
||||
exponent = e;
|
||||
}
|
||||
|
||||
mantissa <<= 13;
|
||||
exponent = 127 - 15 + exponent;
|
||||
}
|
||||
|
||||
int output = (sign << 31) | (exponent << 23) | mantissa;
|
||||
|
||||
return BitConverter.Int32BitsToSingle(output);
|
||||
}
|
||||
}
|
||||
}
|
@@ -374,7 +374,24 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
api.GetPhysicalDeviceProperties(physicalDevice, out var properties);
|
||||
bool useRobustBufferAccess = VendorUtils.FromId(properties.VendorID) == Vendor.Nvidia;
|
||||
|
||||
var supportedFeatures = api.GetPhysicalDeviceFeature(physicalDevice);
|
||||
PhysicalDeviceFeatures2 features2 = new PhysicalDeviceFeatures2()
|
||||
{
|
||||
SType = StructureType.PhysicalDeviceFeatures2
|
||||
};
|
||||
|
||||
PhysicalDeviceCustomBorderColorFeaturesEXT featuresCustomBorderColorSupported = new PhysicalDeviceCustomBorderColorFeaturesEXT()
|
||||
{
|
||||
SType = StructureType.PhysicalDeviceCustomBorderColorFeaturesExt
|
||||
};
|
||||
|
||||
if (supportedExtensions.Contains("VK_EXT_custom_border_color"))
|
||||
{
|
||||
features2.PNext = &featuresCustomBorderColorSupported;
|
||||
}
|
||||
|
||||
api.GetPhysicalDeviceFeatures2(physicalDevice, &features2);
|
||||
|
||||
var supportedFeatures = features2.Features;
|
||||
|
||||
var features = new PhysicalDeviceFeatures()
|
||||
{
|
||||
@@ -491,6 +508,23 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
pExtendedFeatures = &featuresSubgroupSizeControl;
|
||||
}
|
||||
|
||||
PhysicalDeviceCustomBorderColorFeaturesEXT featuresCustomBorderColor;
|
||||
|
||||
if (supportedExtensions.Contains("VK_EXT_custom_border_color") &&
|
||||
featuresCustomBorderColorSupported.CustomBorderColors &&
|
||||
featuresCustomBorderColorSupported.CustomBorderColorWithoutFormat)
|
||||
{
|
||||
featuresCustomBorderColor = new PhysicalDeviceCustomBorderColorFeaturesEXT()
|
||||
{
|
||||
SType = StructureType.PhysicalDeviceCustomBorderColorFeaturesExt,
|
||||
PNext = pExtendedFeatures,
|
||||
CustomBorderColors = true,
|
||||
CustomBorderColorWithoutFormat = true,
|
||||
};
|
||||
|
||||
pExtendedFeatures = &featuresCustomBorderColor;
|
||||
}
|
||||
|
||||
var enabledExtensions = RequiredExtensions.Union(DesirableExtensions.Intersect(supportedExtensions)).ToArray();
|
||||
|
||||
IntPtr* ppEnabledExtensions = stackalloc IntPtr[enabledExtensions.Length];
|
||||
|
@@ -177,6 +177,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
SType = StructureType.PhysicalDeviceShaderFloat16Int8Features
|
||||
};
|
||||
|
||||
PhysicalDeviceCustomBorderColorFeaturesEXT featuresCustomBorderColor = new PhysicalDeviceCustomBorderColorFeaturesEXT()
|
||||
{
|
||||
SType = StructureType.PhysicalDeviceCustomBorderColorFeaturesExt
|
||||
};
|
||||
|
||||
if (supportedExtensions.Contains("VK_EXT_robustness2"))
|
||||
{
|
||||
features2.PNext = &featuresRobustness2;
|
||||
@@ -188,8 +193,18 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
features2.PNext = &featuresShaderInt8;
|
||||
}
|
||||
|
||||
if (supportedExtensions.Contains("VK_EXT_custom_border_color"))
|
||||
{
|
||||
featuresCustomBorderColor.PNext = features2.PNext;
|
||||
features2.PNext = &featuresCustomBorderColor;
|
||||
}
|
||||
|
||||
Api.GetPhysicalDeviceFeatures2(_physicalDevice, &features2);
|
||||
|
||||
bool customBorderColorSupported = supportedExtensions.Contains("VK_EXT_custom_border_color") &&
|
||||
featuresCustomBorderColor.CustomBorderColors &&
|
||||
featuresCustomBorderColor.CustomBorderColorWithoutFormat;
|
||||
|
||||
ref var properties = ref properties2.Properties;
|
||||
|
||||
SampleCountFlags supportedSampleCounts =
|
||||
@@ -199,7 +214,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
Capabilities = new HardwareCapabilities(
|
||||
supportedExtensions.Contains("VK_EXT_index_type_uint8"),
|
||||
supportedExtensions.Contains("VK_EXT_custom_border_color"),
|
||||
customBorderColorSupported,
|
||||
supportedExtensions.Contains(KhrDrawIndirectCount.ExtensionName),
|
||||
supportedExtensions.Contains("VK_EXT_fragment_shader_interlock"),
|
||||
supportedExtensions.Contains("VK_NV_geometry_shader_passthrough"),
|
||||
|
@@ -18,7 +18,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
|
||||
[Service("sfdnsres")]
|
||||
class IResolver : IpcService
|
||||
{
|
||||
public IResolver(ServiceCtx context) { }
|
||||
public IResolver(ServiceCtx context)
|
||||
{
|
||||
DnsMitmResolver.Instance.ReloadEntries(context);
|
||||
}
|
||||
|
||||
[CommandHipc(0)]
|
||||
// SetDnsAddressesPrivateRequest(u32, buffer<unknown, 5, 0>)
|
||||
@@ -259,6 +262,16 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
// Atmosphère extension for dns_mitm
|
||||
[CommandHipc(65000)]
|
||||
// AtmosphereReloadHostsFile()
|
||||
public ResultCode AtmosphereReloadHostsFile(ServiceCtx context)
|
||||
{
|
||||
DnsMitmResolver.Instance.ReloadEntries(context);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
private static ResultCode GetHostByNameRequestImpl(
|
||||
ServiceCtx context,
|
||||
ulong inputBufferPosition,
|
||||
@@ -321,7 +334,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
|
||||
|
||||
try
|
||||
{
|
||||
hostEntry = Dns.GetHostEntry(targetHost);
|
||||
hostEntry = DnsMitmResolver.Instance.ResolveAddress(targetHost);
|
||||
}
|
||||
catch (SocketException exception)
|
||||
{
|
||||
@@ -537,7 +550,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
|
||||
|
||||
try
|
||||
{
|
||||
hostEntry = Dns.GetHostEntry(targetHost);
|
||||
hostEntry = DnsMitmResolver.Instance.ResolveAddress(targetHost);
|
||||
}
|
||||
catch (SocketException exception)
|
||||
{
|
||||
|
@@ -0,0 +1,106 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.HOS.Services.Sockets.Nsd;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Enumeration;
|
||||
using System.Net;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy
|
||||
{
|
||||
class DnsMitmResolver
|
||||
{
|
||||
private const string HostsFilePath = "/atmosphere/hosts/default.txt";
|
||||
|
||||
private static DnsMitmResolver _instance;
|
||||
public static DnsMitmResolver Instance => _instance ??= new DnsMitmResolver();
|
||||
|
||||
private readonly Dictionary<string, IPAddress> _mitmHostEntries = new();
|
||||
|
||||
public void ReloadEntries(ServiceCtx context)
|
||||
{
|
||||
string sdPath = context.Device.Configuration.VirtualFileSystem.GetSdCardPath();
|
||||
string filePath = context.Device.Configuration.VirtualFileSystem.GetFullPath(sdPath, HostsFilePath);
|
||||
|
||||
_mitmHostEntries.Clear();
|
||||
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
using FileStream fileStream = File.Open(filePath, FileMode.Open, FileAccess.Read);
|
||||
using StreamReader reader = new(fileStream);
|
||||
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
string line = reader.ReadLine();
|
||||
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// Ignore comments and empty lines
|
||||
if (line.StartsWith("#") || line.Trim().Length == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string[] entry = line.Split(new[] { ' ', '\t' }, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
// Hosts file example entry:
|
||||
// 127.0.0.1 localhost loopback
|
||||
|
||||
// 0. Check the size of the array
|
||||
if (entry.Length < 2)
|
||||
{
|
||||
Logger.Warning?.PrintMsg(LogClass.ServiceBsd, $"Invalid entry in hosts file: {line}");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// 1. Parse the address
|
||||
if (!IPAddress.TryParse(entry[0], out IPAddress address))
|
||||
{
|
||||
Logger.Warning?.PrintMsg(LogClass.ServiceBsd, $"Failed to parse IP address in hosts file: {entry[0]}");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// 2. Check for AMS hosts file extension: "%"
|
||||
for (int i = 1; i < entry.Length; i++)
|
||||
{
|
||||
entry[i] = entry[i].Replace("%", IManager.NsdSettings.Environment);
|
||||
}
|
||||
|
||||
// 3. Add hostname to entry dictionary (updating duplicate entries)
|
||||
foreach (string hostname in entry[1..])
|
||||
{
|
||||
_mitmHostEntries[hostname] = address;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IPHostEntry ResolveAddress(string host)
|
||||
{
|
||||
foreach (var hostEntry in _mitmHostEntries)
|
||||
{
|
||||
// Check for AMS hosts file extension: "*"
|
||||
// NOTE: MatchesSimpleExpression also allows "?" as a wildcard
|
||||
if (FileSystemName.MatchesSimpleExpression(hostEntry.Key, host))
|
||||
{
|
||||
Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Redirecting '{host}' to: {hostEntry.Value}");
|
||||
|
||||
return new IPHostEntry
|
||||
{
|
||||
AddressList = new[] { hostEntry.Value },
|
||||
HostName = hostEntry.Key,
|
||||
Aliases = Array.Empty<string>()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// No match has been found, resolve the host using regular dns
|
||||
return Dns.GetHostEntry(host);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user