Compare commits

...

6 Commits

Author SHA1 Message Date
riperiperi
b3f0978869 Vulkan: Flush command buffers for queries less aggressively (#4387)
The AutoFlushCounter would flush command buffers on any attachment change (write mask or bindings change) if there was a pending query. This is to get query results as soon as possible for draw skips, but it's assuming that a full occlusion query _pass_ happened, that we want to flush it's data before getting onto draws, rather than the queries being randomly interspersed throughout a pass that also draws.

Xenoblade 2 repeatedly switches between performing a samples passed query and outputting to a render target on each draw, and flips the write mask to do so. Flushing the command buffer every 2 draws isn't ideal, so it's best that we only do this if the pattern matches the large block style of occlusion query.

This change makes this flush only happen after a few consecutive query reports. "Consecutive" is interrupted by attachment changes or command buffer flush.

This doesn't really solve the issue where it resets more queries than it uses, it just stops the game doing it as often. I'm not sure of the best way to do that. The cost of resetting could probably be reduced by using query pools with more than one element and resetting in bulk.
2023-02-09 02:03:41 +01:00
Ac_K
f614d2c435 bug_report.yml hotfix 2023-02-09 02:02:00 +01:00
Ac_K
40c9416097 Misc: Update issues form (#4383) 2023-02-09 00:52:43 +00:00
dependabot[bot]
618c8edc79 nuget: bump System.IdentityModel.Tokens.Jwt from 6.26.0 to 6.26.1 (#4384)
Bumps [System.IdentityModel.Tokens.Jwt](https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet) from 6.26.0 to 6.26.1.
- [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/6.26.0...v6.26.1)

---
updated-dependencies:
- dependency-name: System.IdentityModel.Tokens.Jwt
  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>
2023-02-08 22:51:07 +01:00
Berkan Diler
99fc4fa61b Replace BitConverter.ToString(bytes).Replace("-", "") with Convert.ToHexString(bytes) (#4382) 2023-02-08 14:54:58 +01:00
gdkchan
f6d5499a16 Fix some Vulkan validation errors (#4357) 2023-02-08 14:34:22 +01:00
14 changed files with 86 additions and 63 deletions

View File

@@ -1,13 +1,8 @@
name: Bug Report
description: File a bug report
title: "[Bug] <title>"
labels: bug
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please search to see if an issue already exists for the bug you encountered.
options:
- label: I have searched the existing issues
required: true
- type: textarea
id: issue
attributes:
@@ -53,17 +48,43 @@ body:
- *(e.g. 1.1.1)*
validations:
required: false
- type: textarea
id: environment
- type: input
id: cpu
attributes:
label: Environment?
value: |
- ##### CPU: *(e.g. i7-6700)*
- ##### GPU: *(e.g. NVIDIA RTX 2070)*
- ##### RAM: *(e.g. 16GB)*
- Applied Mods: [ Yes (Which ones) / No ]
label: CPU
placeholder: |
- *(e.g. i7-6700)*
validations:
required: true
required: false
- type: input
id: gpu
attributes:
label: GPU
placeholder: |
- *(e.g. NVIDIA RTX 2070)*
validations:
required: false
- type: input
id: ram
attributes:
label: RAM
placeholder: |
- *(e.g. 16GB)*
validations:
required: false
- type: checkboxes
attributes:
label: Applied Mods?
options:
- label: "Yes"
required: false
- type: textarea
id: mods
attributes:
label: List of applied mods
placeholder: You can list applied mods here.
validations:
required: false
- type: textarea
id: additional-context
attributes:
@@ -72,4 +93,4 @@ body:
- Additional info about your environment:
- Any other information relevant to your issue.
validations:
required: false
required: false

View File

@@ -1,13 +1,7 @@
name: Feature Request
description: Suggest a new feature for Ryujinx.
title: "[Feature Request] <title>"
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please search to see if an issue already exists for the feature you are requesting.
options:
- label: I have searched the existing issues
required: true
- type: textarea
id: overview
attributes:

View File

@@ -1,13 +1,8 @@
name: Missing CPU Instruction
description: CPU Instruction is missing in Ryujinx.
title: "[CPU] <title>"
labels: [cpu, not-implemented]
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please search for existing missing CPU instruction
options:
- label: I have searched the existing issues
required: true
- type: textarea
id: instruction
attributes:

View File

@@ -1,13 +1,7 @@
name: Missing Service Call
description: Service call is missing in Ryujinx.
labels: not-implemented
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please search for an [existing missing service call issue](https://github.com/Ryujinx/Ryujinx/issues) first.
options:
- label: I have searched the existing issues
required: true
- type: textarea
id: instruction
attributes:

View File

@@ -44,7 +44,7 @@
<PackageVersion Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta11" />
<PackageVersion Include="SPB" Version="0.0.4-build28" />
<PackageVersion Include="System.Drawing.Common" Version="7.0.0" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="6.26.0" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="6.26.1" />
<PackageVersion Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
<PackageVersion Include="System.Management" Version="7.0.0" />
<PackageVersion Include="System.Net.NameResolution" Version="4.3.0" />

View File

@@ -10,11 +10,13 @@ namespace Ryujinx.Graphics.Vulkan
private readonly static long FramebufferFlushTimer = Stopwatch.Frequency / 1000;
private const int MinDrawCountForFlush = 10;
private const int MinConsecutiveQueryForFlush = 10;
private const int InitialQueryCountForFlush = 32;
private long _lastFlush;
private ulong _lastDrawCount;
private bool _hasPendingQuery;
private int _consecutiveQueries;
private int _queryCount;
private int[] _queryCountHistory = new int[3];
@@ -27,11 +29,13 @@ namespace Ryujinx.Graphics.Vulkan
_lastDrawCount = drawCount;
_hasPendingQuery = false;
_consecutiveQueries = 0;
}
public bool RegisterPendingQuery()
{
_hasPendingQuery = true;
_consecutiveQueries++;
_remainingQueries--;
_queryCountHistory[_queryCountHistoryIndex]++;
@@ -65,15 +69,18 @@ namespace Ryujinx.Graphics.Vulkan
return _hasPendingQuery;
}
public bool ShouldFlush(ulong drawCount)
public bool ShouldFlushAttachmentChange(ulong drawCount)
{
_queryCount = 0;
if (_hasPendingQuery)
// Flush when there's an attachment change out of a large block of queries.
if (_consecutiveQueries > MinConsecutiveQueryForFlush)
{
return true;
}
_consecutiveQueries = 0;
long draws = (long)(drawCount - _lastDrawCount);
if (draws < MinDrawCountForFlush)

View File

@@ -27,6 +27,7 @@ namespace Ryujinx.Graphics.Vulkan
int attachmentCount = 0;
int colorCount = 0;
int maxColorAttachmentIndex = -1;
for (int i = 0; i < state.AttachmentEnable.Length; i++)
{
@@ -36,6 +37,7 @@ namespace Ryujinx.Graphics.Vulkan
attachmentIndices[attachmentCount++] = i;
colorCount++;
maxColorAttachmentIndex = i;
}
}
@@ -73,12 +75,11 @@ namespace Ryujinx.Graphics.Vulkan
if (colorAttachmentsCount != 0)
{
int maxAttachmentIndex = Constants.MaxRenderTargets - 1;
subpass.ColorAttachmentCount = (uint)maxAttachmentIndex + 1;
subpass.ColorAttachmentCount = (uint)maxColorAttachmentIndex + 1;
subpass.PColorAttachments = &attachmentReferences[0];
// Fill with VK_ATTACHMENT_UNUSED to cover any gaps.
for (int i = 0; i <= maxAttachmentIndex; i++)
for (int i = 0; i <= maxColorAttachmentIndex; i++)
{
subpass.PColorAttachments[i] = new AttachmentReference(Vk.AttachmentUnused, ImageLayout.Undefined);
}

View File

@@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Vulkan
{
private const ulong MinByteWeightForFlush = 256 * 1024 * 1024; // MiB
private readonly List<QueryPool> _activeQueries;
private readonly List<(QueryPool, bool)> _activeQueries;
private CounterQueueEvent _activeConditionalRender;
private readonly List<BufferedQuery> _pendingQueryCopies;
@@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Vulkan
public PipelineFull(VulkanRenderer gd, Device device) : base(gd, device)
{
_activeQueries = new List<QueryPool>();
_activeQueries = new List<(QueryPool, bool)>();
_pendingQueryCopies = new();
CommandBuffer = (Cbs = gd.CommandBufferPool.Rent()).CommandBuffer;
@@ -202,7 +202,7 @@ namespace Ryujinx.Graphics.Vulkan
AutoFlush.RegisterFlush(DrawCount);
EndRenderPass();
foreach (var queryPool in _activeQueries)
foreach ((var queryPool, _) in _activeQueries)
{
Gd.Api.CmdEndQuery(CommandBuffer, queryPool, 0);
}
@@ -220,10 +220,12 @@ namespace Ryujinx.Graphics.Vulkan
// Restore per-command buffer state.
foreach (var queryPool in _activeQueries)
foreach ((var queryPool, var isOcclusion) in _activeQueries)
{
bool isPrecise = Gd.Capabilities.SupportsPreciseOcclusionQueries && isOcclusion;
Gd.Api.CmdResetQueryPool(CommandBuffer, queryPool, 0, 1);
Gd.Api.CmdBeginQuery(CommandBuffer, queryPool, 0, Gd.Capabilities.SupportsPreciseOcclusionQueries ? QueryControlFlags.PreciseBit : 0);
Gd.Api.CmdBeginQuery(CommandBuffer, queryPool, 0, isPrecise ? QueryControlFlags.PreciseBit : 0);
}
Gd.ResetCounterPool();
@@ -231,7 +233,7 @@ namespace Ryujinx.Graphics.Vulkan
Restore();
}
public void BeginQuery(BufferedQuery query, QueryPool pool, bool needsReset, bool fromSamplePool)
public void BeginQuery(BufferedQuery query, QueryPool pool, bool needsReset, bool isOcclusion, bool fromSamplePool)
{
if (needsReset)
{
@@ -247,16 +249,24 @@ namespace Ryujinx.Graphics.Vulkan
}
}
Gd.Api.CmdBeginQuery(CommandBuffer, pool, 0, Gd.Capabilities.SupportsPreciseOcclusionQueries ? QueryControlFlags.PreciseBit : 0);
bool isPrecise = Gd.Capabilities.SupportsPreciseOcclusionQueries && isOcclusion;
Gd.Api.CmdBeginQuery(CommandBuffer, pool, 0, isPrecise ? QueryControlFlags.PreciseBit : 0);
_activeQueries.Add(pool);
_activeQueries.Add((pool, isOcclusion));
}
public void EndQuery(QueryPool pool)
{
Gd.Api.CmdEndQuery(CommandBuffer, pool, 0);
_activeQueries.Remove(pool);
for (int i = 0; i < _activeQueries.Count; i++)
{
if (_activeQueries[i].Item1.Handle == pool.Handle)
{
_activeQueries.RemoveAt(i);
break;
}
}
}
public void CopyQueryResults(BufferedQuery query)
@@ -271,7 +281,7 @@ namespace Ryujinx.Graphics.Vulkan
protected override void SignalAttachmentChange()
{
if (AutoFlush.ShouldFlush(DrawCount))
if (AutoFlush.ShouldFlushAttachmentChange(DrawCount))
{
FlushCommandsImpl();
}

View File

@@ -100,7 +100,8 @@ namespace Ryujinx.Graphics.Vulkan.Queries
if (_isSupported)
{
bool needsReset = resetSequence == null || _resetSequence == null || resetSequence.Value != _resetSequence.Value;
_pipeline.BeginQuery(this, _queryPool, needsReset, _type == CounterType.SamplesPassed && resetSequence != null);
bool isOcclusion = _type == CounterType.SamplesPassed;
_pipeline.BeginQuery(this, _queryPool, needsReset, isOcclusion, isOcclusion && resetSequence != null);
}
_resetSequence = null;
}

View File

@@ -90,7 +90,7 @@ namespace Ryujinx.Graphics.Vulkan
var componentMapping = new ComponentMapping(swizzleR, swizzleG, swizzleB, swizzleA);
var aspectFlags = info.Format.ConvertAspectFlags(info.DepthStencilMode);
var aspectFlagsDepth = info.Format.ConvertAspectFlags(DepthStencilMode.Depth);
var aspectFlagsDepth = info.Format.ConvertAspectFlags();
var subresourceRange = new ImageSubresourceRange(aspectFlags, (uint)firstLevel, levels, (uint)firstLayer, layers);
var subresourceRangeDepth = new ImageSubresourceRange(aspectFlagsDepth, (uint)firstLevel, levels, (uint)firstLayer, layers);

View File

@@ -229,7 +229,7 @@ namespace Ryujinx.HLE.FileSystem
continue;
}
string ncaId = BitConverter.ToString(cnmt.ContentEntries[0].NcaId).Replace("-", "").ToLower();
string ncaId = Convert.ToHexString(cnmt.ContentEntries[0].NcaId).ToLower();
AddAocItem(cnmt.TitleId, containerPath, $"{ncaId}.nca", true);
}

View File

@@ -696,8 +696,8 @@ namespace Ryujinx.HLE.HOS
var buildIds = programs.Select(p => p switch
{
NsoExecutable nso => BitConverter.ToString(nso.BuildId.ItemsRo.ToArray()).Replace("-", "").TrimEnd('0'),
NroExecutable nro => BitConverter.ToString(nro.Header.BuildId).Replace("-", "").TrimEnd('0'),
NsoExecutable nso => Convert.ToHexString(nso.BuildId.ItemsRo.ToArray()).TrimEnd('0'),
NroExecutable nro => Convert.ToHexString(nro.Header.BuildId).TrimEnd('0'),
_ => string.Empty
}).ToList();

View File

@@ -51,11 +51,11 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
var payload = new JwtPayload
{
{ "sub", BitConverter.ToString(rawUserId).Replace("-", "").ToLower() },
{ "sub", Convert.ToHexString(rawUserId).ToLower() },
{ "aud", "ed9e2f05d286f7b8" },
{ "di", BitConverter.ToString(deviceId).Replace("-", "").ToLower() },
{ "di", Convert.ToHexString(deviceId).ToLower() },
{ "sn", "XAW10000000000" },
{ "bs:did", BitConverter.ToString(deviceAccountId).Replace("-", "").ToLower() },
{ "bs:did", Convert.ToHexString(deviceAccountId).ToLower() },
{ "iss", "https://e0d67c509fb203858ebcb2fe3f88c2aa.baas.nintendo.com" },
{ "typ", "id_token" },
{ "iat", DateTimeOffset.UtcNow.ToUnixTimeSeconds() },

View File

@@ -101,7 +101,7 @@ namespace Ryujinx.HLE.HOS.Services.Caps
};
// NOTE: The hex hash is a HMAC-SHA256 (first 32 bytes) using a hardcoded secret key over the titleId, we can simulate it by hashing the titleId instead.
string hash = BitConverter.ToString(SHA256.HashData(BitConverter.GetBytes(titleId))).Replace("-", "").Remove(0x20);
string hash = Convert.ToHexString(SHA256.HashData(BitConverter.GetBytes(titleId))).Remove(0x20);
string folderPath = Path.Combine(_sdCardPath, "Nintendo", "Album", currentDateTime.Year.ToString("00"), currentDateTime.Month.ToString("00"), currentDateTime.Day.ToString("00"));
string filePath = GenerateFilePath(folderPath, applicationAlbumEntry, currentDateTime, hash);