Merge branch 'master' into skia_text

This commit is contained in:
Emmanuel Hansen 2024-08-23 21:14:23 +00:00 committed by GitHub
commit ee63328733
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 118 additions and 41 deletions

View file

@ -13,7 +13,7 @@
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
<PackageVersion Include="Concentus" Version="2.2.0" />
<PackageVersion Include="DiscordRichPresence" Version="1.2.1.24" />
<PackageVersion Include="DynamicData" Version="9.0.1" />
<PackageVersion Include="DynamicData" Version="9.0.4" />
<PackageVersion Include="FluentAvaloniaUI" Version="2.0.5" />
<PackageVersion Include="GtkSharp.Dependencies" Version="1.1.1" />
<PackageVersion Include="GtkSharp.Dependencies.osx" Version="0.0.5" />

View file

@ -1,6 +1,5 @@
using Ryujinx.Common;
using System;
using System.Numerics;
namespace Ryujinx.Graphics.GAL
{
@ -113,25 +112,6 @@ namespace Ryujinx.Graphics.GAL
return 1;
}
public int GetLevelsClamped()
{
int maxSize = Width;
if (Target != Target.Texture1D &&
Target != Target.Texture1DArray)
{
maxSize = Math.Max(maxSize, Height);
}
if (Target == Target.Texture3D)
{
maxSize = Math.Max(maxSize, Depth);
}
int maxLevels = BitOperations.Log2((uint)maxSize) + 1;
return Math.Min(Levels, maxLevels);
}
private static int GetLevelSize(int size, int level)
{
return Math.Max(1, size >> level);

View file

@ -340,7 +340,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <returns>True if any used entries of the pool might have been modified, false otherwise</returns>
public bool SamplerPoolModified()
{
return SamplerPool.WasModified(ref _samplerPoolSequence);
return SamplerPool != null && SamplerPool.WasModified(ref _samplerPoolSequence);
}
}
@ -516,12 +516,15 @@ namespace Ryujinx.Graphics.Gpu.Image
}
// Check if any of our cached samplers changed on the pool.
foreach ((int samplerId, (Sampler sampler, SamplerDescriptor descriptor)) in SamplerIds)
if (SamplerPool != null)
{
if (SamplerPool.GetCachedItem(samplerId) != sampler ||
(sampler == null && SamplerPool.IsValidId(samplerId) && !SamplerPool.GetDescriptorRef(samplerId).Equals(descriptor)))
foreach ((int samplerId, (Sampler sampler, SamplerDescriptor descriptor)) in SamplerIds)
{
return true;
if (SamplerPool.GetCachedItem(samplerId) != sampler ||
(sampler == null && SamplerPool.IsValidId(samplerId) && !SamplerPool.GetDescriptorRef(samplerId).Equals(descriptor)))
{
return true;
}
}
}
@ -899,13 +902,19 @@ namespace Ryujinx.Graphics.Gpu.Image
}
}
Sampler sampler = samplerPool?.Get(samplerId);
entry.TextureIds[textureId] = (texture, descriptor);
entry.SamplerIds[samplerId] = (sampler, samplerPool?.GetDescriptorRef(samplerId) ?? default);
ITexture hostTexture = texture?.GetTargetTexture(bindingInfo.Target);
ISampler hostSampler = sampler?.GetHostSampler(texture);
ISampler hostSampler = null;
if (!isImage && bindingInfo.Target != Target.TextureBuffer)
{
Sampler sampler = samplerPool?.Get(samplerId);
entry.SamplerIds[samplerId] = (sampler, samplerPool?.GetDescriptorRef(samplerId) ?? default);
hostSampler = sampler?.GetHostSampler(texture);
}
Format format = bindingInfo.Format;

View file

@ -6,6 +6,7 @@ using Ryujinx.Memory.Range;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Numerics;
using System.Threading;
namespace Ryujinx.Graphics.Gpu.Image
@ -490,6 +491,8 @@ namespace Ryujinx.Graphics.Gpu.Image
levels = (maxLod - minLod) + 1;
}
levels = ClampLevels(target, width, height, depthOrLayers, levels);
SwizzleComponent swizzleR = descriptor.UnpackSwizzleR().Convert();
SwizzleComponent swizzleG = descriptor.UnpackSwizzleG().Convert();
SwizzleComponent swizzleB = descriptor.UnpackSwizzleB().Convert();
@ -540,6 +543,34 @@ namespace Ryujinx.Graphics.Gpu.Image
swizzleA);
}
/// <summary>
/// Clamps the amount of mipmap levels to the maximum allowed for the given texture dimensions.
/// </summary>
/// <param name="target">Number of texture dimensions (1D, 2D, 3D, Cube, etc)</param>
/// <param name="width">Width of the texture</param>
/// <param name="height">Height of the texture, ignored for 1D textures</param>
/// <param name="depthOrLayers">Depth of the texture for 3D textures, otherwise ignored</param>
/// <param name="levels">Original amount of mipmap levels</param>
/// <returns>Clamped mipmap levels</returns>
private static int ClampLevels(Target target, int width, int height, int depthOrLayers, int levels)
{
int maxSize = width;
if (target != Target.Texture1D &&
target != Target.Texture1DArray)
{
maxSize = Math.Max(maxSize, height);
}
if (target == Target.Texture3D)
{
maxSize = Math.Max(maxSize, depthOrLayers);
}
int maxLevels = BitOperations.Log2((uint)maxSize) + 1;
return Math.Min(levels, maxLevels);
}
/// <summary>
/// Gets the texture depth-stencil mode, based on the swizzle components of each color channel.
/// The depth-stencil mode is determined based on how the driver sets those parameters.

View file

@ -48,7 +48,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
internalFormat = (SizedInternalFormat)format.PixelInternalFormat;
}
int levels = Info.GetLevelsClamped();
int levels = Info.Levels;
switch (Info.Target)
{

View file

@ -51,7 +51,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
pixelInternalFormat = format.PixelInternalFormat;
}
int levels = Info.GetLevelsClamped();
int levels = Info.Levels;
GL.TextureView(
Handle,
@ -267,7 +267,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
public unsafe PinnedSpan<byte> GetData()
{
int size = 0;
int levels = Info.GetLevelsClamped();
int levels = Info.Levels;
for (int level = 0; level < levels; level++)
{
@ -426,7 +426,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
faces = 6;
}
int levels = Info.GetLevelsClamped();
int levels = Info.Levels;
for (int level = 0; level < levels; level++)
{
@ -716,7 +716,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
int width = Info.Width;
int height = Info.Height;
int depth = Info.Depth;
int levels = Info.GetLevelsClamped();
int levels = Info.Levels;
int offset = 0;

View file

@ -95,7 +95,7 @@ namespace Ryujinx.Graphics.Vulkan
{
_cachedCommandBufferIndex = -1;
_storages = null;
SetDirty(_gd);
SetDirty(_gd, isImage: true);
}
public void QueueWriteToReadBarriers(CommandBufferScoped cbs, PipelineStageFlags stageFlags)

View file

@ -14,13 +14,20 @@ namespace Ryujinx.Graphics.Vulkan
private int _bindCount;
protected void SetDirty(VulkanRenderer gd)
protected void SetDirty(VulkanRenderer gd, bool isImage)
{
ReleaseDescriptorSet();
if (_bindCount != 0)
{
gd.PipelineInternal.ForceTextureDirty();
if (isImage)
{
gd.PipelineInternal.ForceImageDirty();
}
else
{
gd.PipelineInternal.ForceTextureDirty();
}
}
}

View file

@ -104,7 +104,7 @@ namespace Ryujinx.Graphics.Vulkan
{
_cachedCommandBufferIndex = -1;
_storages = null;
SetDirty(_gd);
SetDirty(_gd, isImage: false);
}
public void QueueWriteToReadBarriers(CommandBufferScoped cbs, PipelineStageFlags stageFlags)

View file

@ -40,5 +40,12 @@ namespace Ryujinx.HLE.HOS.Services.Nim
return ResultCode.Success;
}
[CommandCmif(5)] // 17.0.0+
// CreateServerInterface2(pid, handle<unknown>, u64) -> object<nn::ec::IshopServiceAccessServer>
public ResultCode CreateServerInterface2(ServiceCtx context)
{
return CreateServerInterface(context);
}
}
}

View file

@ -0,0 +1,43 @@
using Ryujinx.UI.App.Common;
using System;
namespace Ryujinx.Ava.UI.ViewModels
{
/// <summary>
/// Implements a custom comparer which is used for sorting titles by favorite on a UI.
/// Returns a sorted list of favorites in alphabetical order, followed by all non-favorites sorted alphabetical.
/// </summary>
public readonly struct AppListFavoriteComparable : IComparable
{
/// <summary>
/// The application data being compared.
/// </summary>
private readonly ApplicationData app;
/// <summary>
/// Constructs a new <see cref="AppListFavoriteComparable"/> with the specified application data.
/// </summary>
/// <param name="app">The app data being compared.</param>
public AppListFavoriteComparable(ApplicationData app)
{
ArgumentNullException.ThrowIfNull(app, nameof(app));
this.app = app;
}
/// <inheritdoc/>
public readonly int CompareTo(object o)
{
if (o is AppListFavoriteComparable other)
{
if (app.Favorite == other.app.Favorite)
{
return string.Compare(app.Name, other.app.Name, StringComparison.OrdinalIgnoreCase);
}
return app.Favorite ? -1 : 1;
}
throw new InvalidCastException($"Cannot cast {o.GetType()} to {nameof(AppListFavoriteComparable)}");
}
}
}

View file

@ -965,8 +965,8 @@ namespace Ryujinx.Ava.UI.ViewModels
: SortExpressionComparer<ApplicationData>.Descending(app => app.FileSize),
ApplicationSort.Path => IsAscending ? SortExpressionComparer<ApplicationData>.Ascending(app => app.Path)
: SortExpressionComparer<ApplicationData>.Descending(app => app.Path),
ApplicationSort.Favorite => !IsAscending ? SortExpressionComparer<ApplicationData>.Ascending(app => app.Favorite)
: SortExpressionComparer<ApplicationData>.Descending(app => app.Favorite),
ApplicationSort.Favorite => IsAscending ? SortExpressionComparer<ApplicationData>.Ascending(app => new AppListFavoriteComparable(app))
: SortExpressionComparer<ApplicationData>.Descending(app => new AppListFavoriteComparable(app)),
_ => null,
#pragma warning restore IDE0055
};