Compare commits

...

4 Commits

Author SHA1 Message Date
dependabot[bot]
4b7802e0f8 nuget: bump Microsoft.IdentityModel.JsonWebTokens from 7.3.0 to 7.4.0
Bumps [Microsoft.IdentityModel.JsonWebTokens](https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet) from 7.3.0 to 7.4.0.
- [Release notes](https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/releases)
- [Changelog](https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/blob/dev/CHANGELOG.md)
- [Commits](https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/compare/7.3.0...v7.4.0)

---
updated-dependencies:
- dependency-name: Microsoft.IdentityModel.JsonWebTokens
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-28 16:48:11 +00:00
gdkchan
87f238be60 Change packed aliasing formats to UInt (#6358) 2024-02-24 19:02:20 -03:00
dependabot[bot]
4d0dbbfae2 nuget: bump System.Drawing.Common from 8.0.1 to 8.0.2 (#6308)
Bumps [System.Drawing.Common](https://github.com/dotnet/winforms) from 8.0.1 to 8.0.2.
- [Release notes](https://github.com/dotnet/winforms/releases)
- [Changelog](https://github.com/dotnet/winforms/blob/main/docs/release-activity.md)
- [Commits](https://github.com/dotnet/winforms/compare/v8.0.1...v8.0.2)

---
updated-dependencies:
- dependency-name: System.Drawing.Common
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-24 01:17:24 +01:00
jhorv
08384ee5a8 IPC code gen improvements (#6352)
* HipcGenerator: skip do-nothing call to MemoryMarshal.Cast<byte, byte>() in generated code

* HipcGenerator: fix method name typos

* HipcGenerator: make generated methods use stackalloc for `isBufferMapAlias` bool array

* HipcGenerator: make generated GetCommandHandlers() method return a FrozenDictionary<int, CommandHandler>

* HipcGenerator: return `FrozenDictionary<,>.Empty` when there are no command implementations, otherwise create `FrozenDictionary` from a `IEnumerable<KeyValuePair<,>>`` instead of a `Dictionary<,>``
2024-02-23 21:12:24 -03:00
4 changed files with 59 additions and 47 deletions

View File

@@ -20,7 +20,7 @@
<PackageVersion Include="LibHac" Version="0.19.0" /> <PackageVersion Include="LibHac" Version="0.19.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" /> <PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" /> <PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.3.0" /> <PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.4.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" /> <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.0" /> <PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.0" />
<PackageVersion Include="MsgPack.Cli" Version="1.0.1" /> <PackageVersion Include="MsgPack.Cli" Version="1.0.1" />
@@ -45,7 +45,7 @@
<PackageVersion Include="SixLabors.ImageSharp" Version="1.0.4" /> <PackageVersion Include="SixLabors.ImageSharp" Version="1.0.4" />
<PackageVersion Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta11" /> <PackageVersion Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta11" />
<PackageVersion Include="SPB" Version="0.0.4-build32" /> <PackageVersion Include="SPB" Version="0.0.4-build32" />
<PackageVersion Include="System.Drawing.Common" Version="8.0.1" /> <PackageVersion Include="System.Drawing.Common" Version="8.0.2" />
<PackageVersion Include="System.IO.Hashing" Version="8.0.0" /> <PackageVersion Include="System.IO.Hashing" Version="8.0.0" />
<PackageVersion Include="System.Management" Version="8.0.0" /> <PackageVersion Include="System.Management" Version="8.0.0" />
<PackageVersion Include="UnicornEngine.Unicorn" Version="2.0.2-rc1-fb78016" /> <PackageVersion Include="UnicornEngine.Unicorn" Version="2.0.2-rc1-fb78016" />

View File

@@ -674,9 +674,9 @@ namespace Ryujinx.Graphics.Gpu.Image
{ {
1 => new FormatInfo(Format.R8Unorm, 1, 1, 1, 1), 1 => new FormatInfo(Format.R8Unorm, 1, 1, 1, 1),
2 => new FormatInfo(Format.R16Unorm, 1, 1, 2, 1), 2 => new FormatInfo(Format.R16Unorm, 1, 1, 2, 1),
4 => new FormatInfo(Format.R32Float, 1, 1, 4, 1), 4 => new FormatInfo(Format.R32Uint, 1, 1, 4, 1),
8 => new FormatInfo(Format.R32G32Float, 1, 1, 8, 2), 8 => new FormatInfo(Format.R32G32Uint, 1, 1, 8, 2),
16 => new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16, 4), 16 => new FormatInfo(Format.R32G32B32A32Uint, 1, 1, 16, 4),
_ => format, _ => format,
}; };
} }

View File

@@ -74,6 +74,7 @@ namespace Ryujinx.Horizon.Generators.Hipc
generator.AppendLine("using Ryujinx.Horizon.Sdk.Sf.Cmif;"); generator.AppendLine("using Ryujinx.Horizon.Sdk.Sf.Cmif;");
generator.AppendLine("using Ryujinx.Horizon.Sdk.Sf.Hipc;"); generator.AppendLine("using Ryujinx.Horizon.Sdk.Sf.Hipc;");
generator.AppendLine("using System;"); generator.AppendLine("using System;");
generator.AppendLine("using System.Collections.Frozen;");
generator.AppendLine("using System.Collections.Generic;"); generator.AppendLine("using System.Collections.Generic;");
generator.AppendLine("using System.Runtime.CompilerServices;"); generator.AppendLine("using System.Runtime.CompilerServices;");
generator.AppendLine("using System.Runtime.InteropServices;"); generator.AppendLine("using System.Runtime.InteropServices;");
@@ -115,17 +116,24 @@ namespace Ryujinx.Horizon.Generators.Hipc
private static void GenerateMethodTable(CodeGenerator generator, Compilation compilation, CommandInterface commandInterface) private static void GenerateMethodTable(CodeGenerator generator, Compilation compilation, CommandInterface commandInterface)
{ {
generator.EnterScope($"public IReadOnlyDictionary<int, CommandHandler> GetCommandHandlers()"); generator.EnterScope($"public IReadOnlyDictionary<int, CommandHandler> GetCommandHandlers()");
generator.EnterScope($"return new Dictionary<int, CommandHandler>()");
if (commandInterface.CommandImplementations.Count == 0)
{
generator.AppendLine("return FrozenDictionary<int, CommandHandler>.Empty;");
}
else
{
generator.EnterScope($"return FrozenDictionary.ToFrozenDictionary(new []");
foreach (var method in commandInterface.CommandImplementations) foreach (var method in commandInterface.CommandImplementations)
{ {
foreach (var commandId in GetAttributeAguments(compilation, method, TypeCommandAttribute, 0)) foreach (var commandId in GetAttributeArguments(compilation, method, TypeCommandAttribute, 0))
{ {
string[] args = new string[method.ParameterList.Parameters.Count]; string[] args = new string[method.ParameterList.Parameters.Count];
if (args.Length == 0) if (args.Length == 0)
{ {
generator.AppendLine($"{{ {commandId}, new CommandHandler({method.Identifier.Text}, Array.Empty<CommandArg>()) }},"); generator.AppendLine($"KeyValuePair.Create({commandId}, new CommandHandler({method.Identifier.Text}, Array.Empty<CommandArg>())),");
} }
else else
{ {
@@ -140,8 +148,8 @@ namespace Ryujinx.Horizon.Generators.Hipc
if (argType == CommandArgType.Buffer) if (argType == CommandArgType.Buffer)
{ {
string bufferFlags = GetFirstAttributeAgument(compilation, parameter, TypeBufferAttribute, 0); string bufferFlags = GetFirstAttributeArgument(compilation, parameter, TypeBufferAttribute, 0);
string bufferFixedSize = GetFirstAttributeAgument(compilation, parameter, TypeBufferAttribute, 1); string bufferFixedSize = GetFirstAttributeArgument(compilation, parameter, TypeBufferAttribute, 1);
if (bufferFixedSize != null) if (bufferFixedSize != null)
{ {
@@ -166,16 +174,18 @@ namespace Ryujinx.Horizon.Generators.Hipc
args[index++] = arg; args[index++] = arg;
} }
generator.AppendLine($"{{ {commandId}, new CommandHandler({method.Identifier.Text}, {string.Join(", ", args)}) }},"); generator.AppendLine($"KeyValuePair.Create({commandId}, new CommandHandler({method.Identifier.Text}, {string.Join(", ", args)})),");
} }
} }
} }
generator.LeaveScope(";"); generator.LeaveScope(");");
}
generator.LeaveScope(); generator.LeaveScope();
} }
private static IEnumerable<string> GetAttributeAguments(Compilation compilation, SyntaxNode syntaxNode, string attributeName, int argIndex) private static IEnumerable<string> GetAttributeArguments(Compilation compilation, SyntaxNode syntaxNode, string attributeName, int argIndex)
{ {
ISymbol symbol = compilation.GetSemanticModel(syntaxNode.SyntaxTree).GetDeclaredSymbol(syntaxNode); ISymbol symbol = compilation.GetSemanticModel(syntaxNode.SyntaxTree).GetDeclaredSymbol(syntaxNode);
@@ -188,9 +198,9 @@ namespace Ryujinx.Horizon.Generators.Hipc
} }
} }
private static string GetFirstAttributeAgument(Compilation compilation, SyntaxNode syntaxNode, string attributeName, int argIndex) private static string GetFirstAttributeArgument(Compilation compilation, SyntaxNode syntaxNode, string attributeName, int argIndex)
{ {
return GetAttributeAguments(compilation, syntaxNode, attributeName, argIndex).FirstOrDefault(); return GetAttributeArguments(compilation, syntaxNode, attributeName, argIndex).FirstOrDefault();
} }
private static void GenerateMethod(CodeGenerator generator, Compilation compilation, MethodDeclarationSyntax method) private static void GenerateMethod(CodeGenerator generator, Compilation compilation, MethodDeclarationSyntax method)
@@ -233,7 +243,7 @@ namespace Ryujinx.Horizon.Generators.Hipc
if (buffersCount != 0) if (buffersCount != 0)
{ {
generator.AppendLine($"bool[] {IsBufferMapAliasVariableName} = new bool[{method.ParameterList.Parameters.Count}];"); generator.AppendLine($"Span<bool> {IsBufferMapAliasVariableName} = stackalloc bool[{method.ParameterList.Parameters.Count}];");
generator.AppendLine(); generator.AppendLine();
generator.AppendLine($"{ResultVariableName} = processor.ProcessBuffers(ref context, {IsBufferMapAliasVariableName}, runtimeMetadata);"); generator.AppendLine($"{ResultVariableName} = processor.ProcessBuffers(ref context, {IsBufferMapAliasVariableName}, runtimeMetadata);");
@@ -719,7 +729,9 @@ namespace Ryujinx.Horizon.Generators.Hipc
private static string GenerateSpanCast(string targetType, string input) private static string GenerateSpanCast(string targetType, string input)
{ {
return $"MemoryMarshal.Cast<byte, {targetType}>({input})"; return targetType == "byte"
? input
: $"MemoryMarshal.Cast<byte, {targetType}>({input})";
} }
private static bool HasAttribute(Compilation compilation, ParameterSyntax parameterSyntax, string fullAttributeName) private static bool HasAttribute(Compilation compilation, ParameterSyntax parameterSyntax, string fullAttributeName)

View File

@@ -127,7 +127,7 @@ namespace Ryujinx.Horizon.Sdk.Sf
return _bufferRanges[argIndex]; return _bufferRanges[argIndex];
} }
public Result ProcessBuffers(ref ServiceDispatchContext context, bool[] isBufferMapAlias, ServerMessageRuntimeMetadata runtimeMetadata) public Result ProcessBuffers(ref ServiceDispatchContext context, scoped Span<bool> isBufferMapAlias, ServerMessageRuntimeMetadata runtimeMetadata)
{ {
bool mapAliasBuffersValid = true; bool mapAliasBuffersValid = true;
@@ -246,7 +246,7 @@ namespace Ryujinx.Horizon.Sdk.Sf
return mode == HipcBufferMode.Normal; return mode == HipcBufferMode.Normal;
} }
public void SetOutBuffers(HipcMessageData response, bool[] isBufferMapAlias) public void SetOutBuffers(HipcMessageData response, ReadOnlySpan<bool> isBufferMapAlias)
{ {
int recvPointerIndex = 0; int recvPointerIndex = 0;