Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
2e43d01d36 | ||
|
7373ec5792 | ||
|
de162a648b | ||
|
131baebe2a | ||
|
187372cbde | ||
|
022d495335 | ||
|
c1372ed775 | ||
|
a16682cfd3 | ||
|
7c53b69c30 |
@@ -1,15 +1,11 @@
|
|||||||
|
using System;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
|
||||||
namespace ARMeilleure.Common
|
namespace ARMeilleure.Common
|
||||||
{
|
{
|
||||||
static class BitUtils
|
static class BitUtils
|
||||||
{
|
{
|
||||||
private static readonly sbyte[] HbsNibbleLut;
|
private static ReadOnlySpan<sbyte> HbsNibbleLut => new sbyte[] { -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3 };
|
||||||
|
|
||||||
static BitUtils()
|
|
||||||
{
|
|
||||||
HbsNibbleLut = new sbyte[] { -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3 };
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long FillWithOnes(int bits)
|
public static long FillWithOnes(int bits)
|
||||||
{
|
{
|
||||||
|
@@ -21,6 +21,7 @@ namespace Ryujinx.Graphics.GAL
|
|||||||
public readonly bool SupportsFragmentShaderOrderingIntel;
|
public readonly bool SupportsFragmentShaderOrderingIntel;
|
||||||
public readonly bool SupportsGeometryShaderPassthrough;
|
public readonly bool SupportsGeometryShaderPassthrough;
|
||||||
public readonly bool SupportsImageLoadFormatted;
|
public readonly bool SupportsImageLoadFormatted;
|
||||||
|
public readonly bool SupportsLayerVertexTessellation;
|
||||||
public readonly bool SupportsMismatchingViewFormat;
|
public readonly bool SupportsMismatchingViewFormat;
|
||||||
public readonly bool SupportsCubemapView;
|
public readonly bool SupportsCubemapView;
|
||||||
public readonly bool SupportsNonConstantTextureOffset;
|
public readonly bool SupportsNonConstantTextureOffset;
|
||||||
@@ -55,6 +56,7 @@ namespace Ryujinx.Graphics.GAL
|
|||||||
bool supportsFragmentShaderOrderingIntel,
|
bool supportsFragmentShaderOrderingIntel,
|
||||||
bool supportsGeometryShaderPassthrough,
|
bool supportsGeometryShaderPassthrough,
|
||||||
bool supportsImageLoadFormatted,
|
bool supportsImageLoadFormatted,
|
||||||
|
bool supportsLayerVertexTessellation,
|
||||||
bool supportsMismatchingViewFormat,
|
bool supportsMismatchingViewFormat,
|
||||||
bool supportsCubemapView,
|
bool supportsCubemapView,
|
||||||
bool supportsNonConstantTextureOffset,
|
bool supportsNonConstantTextureOffset,
|
||||||
@@ -86,6 +88,7 @@ namespace Ryujinx.Graphics.GAL
|
|||||||
SupportsFragmentShaderOrderingIntel = supportsFragmentShaderOrderingIntel;
|
SupportsFragmentShaderOrderingIntel = supportsFragmentShaderOrderingIntel;
|
||||||
SupportsGeometryShaderPassthrough = supportsGeometryShaderPassthrough;
|
SupportsGeometryShaderPassthrough = supportsGeometryShaderPassthrough;
|
||||||
SupportsImageLoadFormatted = supportsImageLoadFormatted;
|
SupportsImageLoadFormatted = supportsImageLoadFormatted;
|
||||||
|
SupportsLayerVertexTessellation = supportsLayerVertexTessellation;
|
||||||
SupportsMismatchingViewFormat = supportsMismatchingViewFormat;
|
SupportsMismatchingViewFormat = supportsMismatchingViewFormat;
|
||||||
SupportsCubemapView = supportsCubemapView;
|
SupportsCubemapView = supportsCubemapView;
|
||||||
SupportsNonConstantTextureOffset = supportsNonConstantTextureOffset;
|
SupportsNonConstantTextureOffset = supportsNonConstantTextureOffset;
|
||||||
|
@@ -67,6 +67,7 @@ namespace Ryujinx.Graphics.Gpu
|
|||||||
|
|
||||||
// Since the memory manager changed, make sure we will get pools from addresses of the new memory manager.
|
// Since the memory manager changed, make sure we will get pools from addresses of the new memory manager.
|
||||||
TextureManager.ReloadPools();
|
TextureManager.ReloadPools();
|
||||||
|
MemoryManager.Physical.BufferCache.QueuePrune();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -77,6 +78,7 @@ namespace Ryujinx.Graphics.Gpu
|
|||||||
private void MemoryUnmappedHandler(object sender, UnmapEventArgs e)
|
private void MemoryUnmappedHandler(object sender, UnmapEventArgs e)
|
||||||
{
|
{
|
||||||
TextureManager.ReloadPools();
|
TextureManager.ReloadPools();
|
||||||
|
MemoryManager.Physical.BufferCache.QueuePrune();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@@ -28,6 +28,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
|
|
||||||
private readonly Dictionary<ulong, BufferCacheEntry> _dirtyCache;
|
private readonly Dictionary<ulong, BufferCacheEntry> _dirtyCache;
|
||||||
private readonly Dictionary<ulong, BufferCacheEntry> _modifiedCache;
|
private readonly Dictionary<ulong, BufferCacheEntry> _modifiedCache;
|
||||||
|
private bool _pruneCaches;
|
||||||
|
|
||||||
public event Action NotifyBuffersModified;
|
public event Action NotifyBuffersModified;
|
||||||
|
|
||||||
@@ -136,6 +137,11 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// <param name="size">Size in bytes of the buffer</param>
|
/// <param name="size">Size in bytes of the buffer</param>
|
||||||
public void ForceDirty(MemoryManager memoryManager, ulong gpuVa, ulong size)
|
public void ForceDirty(MemoryManager memoryManager, ulong gpuVa, ulong size)
|
||||||
{
|
{
|
||||||
|
if (_pruneCaches)
|
||||||
|
{
|
||||||
|
Prune();
|
||||||
|
}
|
||||||
|
|
||||||
if (!_dirtyCache.TryGetValue(gpuVa, out BufferCacheEntry result) ||
|
if (!_dirtyCache.TryGetValue(gpuVa, out BufferCacheEntry result) ||
|
||||||
result.EndGpuAddress < gpuVa + size ||
|
result.EndGpuAddress < gpuVa + size ||
|
||||||
result.UnmappedSequence != result.Buffer.UnmappedSequence)
|
result.UnmappedSequence != result.Buffer.UnmappedSequence)
|
||||||
@@ -158,17 +164,29 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// <returns>True if modified, false otherwise</returns>
|
/// <returns>True if modified, false otherwise</returns>
|
||||||
public bool CheckModified(MemoryManager memoryManager, ulong gpuVa, ulong size, out ulong outAddr)
|
public bool CheckModified(MemoryManager memoryManager, ulong gpuVa, ulong size, out ulong outAddr)
|
||||||
{
|
{
|
||||||
if (!_modifiedCache.TryGetValue(gpuVa, out BufferCacheEntry result) ||
|
if (_pruneCaches)
|
||||||
result.EndGpuAddress < gpuVa + size ||
|
|
||||||
result.UnmappedSequence != result.Buffer.UnmappedSequence)
|
|
||||||
{
|
{
|
||||||
ulong address = TranslateAndCreateBuffer(memoryManager, gpuVa, size);
|
Prune();
|
||||||
result = new BufferCacheEntry(address, gpuVa, GetBuffer(address, size));
|
|
||||||
|
|
||||||
_modifiedCache[gpuVa] = result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
outAddr = result.Address;
|
// Align the address to avoid creating too many entries on the quick lookup dictionary.
|
||||||
|
ulong mask = BufferAlignmentMask;
|
||||||
|
ulong alignedGpuVa = gpuVa & (~mask);
|
||||||
|
ulong alignedEndGpuVa = (gpuVa + size + mask) & (~mask);
|
||||||
|
|
||||||
|
size = alignedEndGpuVa - alignedGpuVa;
|
||||||
|
|
||||||
|
if (!_modifiedCache.TryGetValue(alignedGpuVa, out BufferCacheEntry result) ||
|
||||||
|
result.EndGpuAddress < alignedEndGpuVa ||
|
||||||
|
result.UnmappedSequence != result.Buffer.UnmappedSequence)
|
||||||
|
{
|
||||||
|
ulong address = TranslateAndCreateBuffer(memoryManager, alignedGpuVa, size);
|
||||||
|
result = new BufferCacheEntry(address, alignedGpuVa, GetBuffer(address, size));
|
||||||
|
|
||||||
|
_modifiedCache[alignedGpuVa] = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
outAddr = result.Address | (gpuVa & mask);
|
||||||
|
|
||||||
return result.Buffer.IsModified(result.Address, size);
|
return result.Buffer.IsModified(result.Address, size);
|
||||||
}
|
}
|
||||||
@@ -435,6 +453,54 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Prune any invalid entries from a quick access dictionary.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dictionary">Dictionary to prune</param>
|
||||||
|
/// <param name="toDelete">List used to track entries to delete</param>
|
||||||
|
private void Prune(Dictionary<ulong, BufferCacheEntry> dictionary, ref List<ulong> toDelete)
|
||||||
|
{
|
||||||
|
foreach (var entry in dictionary)
|
||||||
|
{
|
||||||
|
if (entry.Value.UnmappedSequence != entry.Value.Buffer.UnmappedSequence)
|
||||||
|
{
|
||||||
|
(toDelete ??= new()).Add(entry.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toDelete != null)
|
||||||
|
{
|
||||||
|
foreach (ulong entry in toDelete)
|
||||||
|
{
|
||||||
|
dictionary.Remove(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Prune any invalid entries from the quick access dictionaries.
|
||||||
|
/// </summary>
|
||||||
|
private void Prune()
|
||||||
|
{
|
||||||
|
List<ulong> toDelete = null;
|
||||||
|
|
||||||
|
Prune(_dirtyCache, ref toDelete);
|
||||||
|
|
||||||
|
toDelete?.Clear();
|
||||||
|
|
||||||
|
Prune(_modifiedCache, ref toDelete);
|
||||||
|
|
||||||
|
_pruneCaches = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Queues a prune of invalid entries the next time a dictionary cache is accessed.
|
||||||
|
/// </summary>
|
||||||
|
public void QueuePrune()
|
||||||
|
{
|
||||||
|
_pruneCaches = true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Disposes all buffers in the cache.
|
/// Disposes all buffers in the cache.
|
||||||
/// It's an error to use the buffer manager after disposal.
|
/// It's an error to use the buffer manager after disposal.
|
||||||
|
@@ -325,13 +325,15 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
public void ReregisterRanges(Action<ulong, ulong> rangeAction)
|
public void ReregisterRanges(Action<ulong, ulong> rangeAction)
|
||||||
{
|
{
|
||||||
ref var ranges = ref ThreadStaticArray<BufferModifiedRange>.Get();
|
ref var ranges = ref ThreadStaticArray<BufferModifiedRange>.Get();
|
||||||
|
int count;
|
||||||
|
|
||||||
// Range list must be consistent for this operation.
|
// Range list must be consistent for this operation.
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
if (ranges.Length < Count)
|
count = Count;
|
||||||
|
if (ranges.Length < count)
|
||||||
{
|
{
|
||||||
Array.Resize(ref ranges, Count);
|
Array.Resize(ref ranges, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -342,7 +344,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
}
|
}
|
||||||
|
|
||||||
ulong currentSync = _context.SyncNumber;
|
ulong currentSync = _context.SyncNumber;
|
||||||
for (int i = 0; i < Count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
BufferModifiedRange range = ranges[i];
|
BufferModifiedRange range = ranges[i];
|
||||||
if (range.SyncNumber != currentSync)
|
if (range.SyncNumber != currentSync)
|
||||||
|
@@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||||||
private const ushort FileFormatVersionMajor = 1;
|
private const ushort FileFormatVersionMajor = 1;
|
||||||
private const ushort FileFormatVersionMinor = 2;
|
private const ushort FileFormatVersionMinor = 2;
|
||||||
private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor;
|
private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor;
|
||||||
private const uint CodeGenVersion = 3848;
|
private const uint CodeGenVersion = 3866;
|
||||||
|
|
||||||
private const string SharedTocFileName = "shared.toc";
|
private const string SharedTocFileName = "shared.toc";
|
||||||
private const string SharedDataFileName = "shared.data";
|
private const string SharedDataFileName = "shared.data";
|
||||||
|
@@ -636,6 +636,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||||||
CachedShaderStage[] shaders = new CachedShaderStage[guestShaders.Length];
|
CachedShaderStage[] shaders = new CachedShaderStage[guestShaders.Length];
|
||||||
List<ShaderProgram> translatedStages = new List<ShaderProgram>();
|
List<ShaderProgram> translatedStages = new List<ShaderProgram>();
|
||||||
|
|
||||||
|
TranslatorContext previousStage = null;
|
||||||
|
|
||||||
for (int stageIndex = 0; stageIndex < Constants.ShaderStages; stageIndex++)
|
for (int stageIndex = 0; stageIndex < Constants.ShaderStages; stageIndex++)
|
||||||
{
|
{
|
||||||
TranslatorContext currentStage = translatorContexts[stageIndex + 1];
|
TranslatorContext currentStage = translatorContexts[stageIndex + 1];
|
||||||
@@ -668,6 +670,16 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||||||
{
|
{
|
||||||
translatedStages.Add(program);
|
translatedStages.Add(program);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
previousStage = currentStage;
|
||||||
|
}
|
||||||
|
else if (
|
||||||
|
previousStage != null &&
|
||||||
|
previousStage.LayerOutputWritten &&
|
||||||
|
stageIndex == 3 &&
|
||||||
|
!_context.Capabilities.SupportsLayerVertexTessellation)
|
||||||
|
{
|
||||||
|
translatedStages.Add(previousStage.GenerateGeometryPassthrough());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -128,6 +128,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||||||
|
|
||||||
public bool QueryHostSupportsImageLoadFormatted() => _context.Capabilities.SupportsImageLoadFormatted;
|
public bool QueryHostSupportsImageLoadFormatted() => _context.Capabilities.SupportsImageLoadFormatted;
|
||||||
|
|
||||||
|
public bool QueryHostSupportsLayerVertexTessellation() => _context.Capabilities.SupportsLayerVertexTessellation;
|
||||||
|
|
||||||
public bool QueryHostSupportsNonConstantTextureOffset() => _context.Capabilities.SupportsNonConstantTextureOffset;
|
public bool QueryHostSupportsNonConstantTextureOffset() => _context.Capabilities.SupportsNonConstantTextureOffset;
|
||||||
|
|
||||||
public bool QueryHostSupportsShaderBallot() => _context.Capabilities.SupportsShaderBallot;
|
public bool QueryHostSupportsShaderBallot() => _context.Capabilities.SupportsShaderBallot;
|
||||||
|
@@ -356,6 +356,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||||||
CachedShaderStage[] shaders = new CachedShaderStage[Constants.ShaderStages + 1];
|
CachedShaderStage[] shaders = new CachedShaderStage[Constants.ShaderStages + 1];
|
||||||
List<ShaderSource> shaderSources = new List<ShaderSource>();
|
List<ShaderSource> shaderSources = new List<ShaderSource>();
|
||||||
|
|
||||||
|
TranslatorContext previousStage = null;
|
||||||
|
|
||||||
for (int stageIndex = 0; stageIndex < Constants.ShaderStages; stageIndex++)
|
for (int stageIndex = 0; stageIndex < Constants.ShaderStages; stageIndex++)
|
||||||
{
|
{
|
||||||
TranslatorContext currentStage = translatorContexts[stageIndex + 1];
|
TranslatorContext currentStage = translatorContexts[stageIndex + 1];
|
||||||
@@ -392,6 +394,16 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||||||
{
|
{
|
||||||
shaderSources.Add(CreateShaderSource(program));
|
shaderSources.Add(CreateShaderSource(program));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
previousStage = currentStage;
|
||||||
|
}
|
||||||
|
else if (
|
||||||
|
previousStage != null &&
|
||||||
|
previousStage.LayerOutputWritten &&
|
||||||
|
stageIndex == 3 &&
|
||||||
|
!_context.Capabilities.SupportsLayerVertexTessellation)
|
||||||
|
{
|
||||||
|
shaderSources.Add(CreateShaderSource(previousStage.GenerateGeometryPassthrough()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -63,7 +63,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
|||||||
short dqv = dq[0];
|
short dqv = dq[0];
|
||||||
ReadOnlySpan<byte> cat6Prob = (xd.Bd == 12)
|
ReadOnlySpan<byte> cat6Prob = (xd.Bd == 12)
|
||||||
? Luts.Vp9Cat6ProbHigh12
|
? Luts.Vp9Cat6ProbHigh12
|
||||||
: (xd.Bd == 10) ? new ReadOnlySpan<byte>(Luts.Vp9Cat6ProbHigh12).Slice(2) : Luts.Vp9Cat6Prob;
|
: (xd.Bd == 10) ? Luts.Vp9Cat6ProbHigh12.Slice(2) : Luts.Vp9Cat6Prob;
|
||||||
int cat6Bits = (xd.Bd == 12) ? 18 : (xd.Bd == 10) ? 16 : 14;
|
int cat6Bits = (xd.Bd == 12) ? 18 : (xd.Bd == 10) ? 16 : 14;
|
||||||
// Keep value, range, and count as locals. The compiler produces better
|
// Keep value, range, and count as locals. The compiler produces better
|
||||||
// results with the locals than using r directly.
|
// results with the locals than using r directly.
|
||||||
|
@@ -1,14 +1,12 @@
|
|||||||
using Ryujinx.Common.Memory;
|
using Ryujinx.Common.Memory;
|
||||||
using Ryujinx.Graphics.Nvdec.Vp9.Types;
|
using Ryujinx.Graphics.Nvdec.Vp9.Types;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Nvdec.Vp9
|
namespace Ryujinx.Graphics.Nvdec.Vp9
|
||||||
{
|
{
|
||||||
internal static class Luts
|
internal static class Luts
|
||||||
{
|
{
|
||||||
public static readonly byte[] SizeGroupLookup = new byte[]
|
public static ReadOnlySpan<byte> SizeGroupLookup => new byte[] { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3 };
|
||||||
{
|
|
||||||
0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3
|
|
||||||
};
|
|
||||||
|
|
||||||
public static readonly BlockSize[][] SubsizeLookup = new BlockSize[][]
|
public static readonly BlockSize[][] SubsizeLookup = new BlockSize[][]
|
||||||
{
|
{
|
||||||
@@ -1070,18 +1068,18 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
|||||||
-(sbyte)MvClassType.MvClass10,
|
-(sbyte)MvClassType.MvClass10,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static readonly sbyte[] Vp9MvFPTree = new sbyte[] { -0, 2, -1, 4, -2, -3 };
|
public static ReadOnlySpan<sbyte> Vp9MvFPTree => new sbyte[] { -0, 2, -1, 4, -2, -3 };
|
||||||
|
|
||||||
// Entropy
|
// Entropy
|
||||||
|
|
||||||
public static readonly byte[] Vp9Cat1Prob = new byte[] { 159 };
|
public static ReadOnlySpan<byte> Vp9Cat1Prob => new byte[] { 159 };
|
||||||
public static readonly byte[] Vp9Cat2Prob = new byte[] { 165, 145 };
|
public static ReadOnlySpan<byte> Vp9Cat2Prob => new byte[] { 165, 145 };
|
||||||
public static readonly byte[] Vp9Cat3Prob = new byte[] { 173, 148, 140 };
|
public static ReadOnlySpan<byte> Vp9Cat3Prob => new byte[] { 173, 148, 140 };
|
||||||
public static readonly byte[] Vp9Cat4Prob = new byte[] { 176, 155, 140, 135 };
|
public static ReadOnlySpan<byte> Vp9Cat4Prob => new byte[] { 176, 155, 140, 135 };
|
||||||
public static readonly byte[] Vp9Cat5Prob = new byte[] { 180, 157, 141, 134, 130 };
|
public static ReadOnlySpan<byte> Vp9Cat5Prob => new byte[] { 180, 157, 141, 134, 130 };
|
||||||
public static readonly byte[] Vp9Cat6Prob = new byte[] { 254, 254, 254, 252, 249, 243, 230, 196, 177, 153, 140, 133, 130, 129 };
|
public static ReadOnlySpan<byte> Vp9Cat6Prob => new byte[] { 254, 254, 254, 252, 249, 243, 230, 196, 177, 153, 140, 133, 130, 129 };
|
||||||
|
|
||||||
public static readonly byte[] Vp9Cat6ProbHigh12 = new byte[]
|
public static ReadOnlySpan<byte> Vp9Cat6ProbHigh12 => new byte[]
|
||||||
{
|
{
|
||||||
255, 255, 255, 255, 254, 254, 54, 252, 249, 243, 230, 196, 177, 153, 140, 133, 130, 129
|
255, 255, 255, 255, 254, 254, 54, 252, 249, 243, 230, 196, 177, 153, 140, 133, 130, 129
|
||||||
};
|
};
|
||||||
@@ -1131,12 +1129,12 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
|
|||||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly byte[] Vp9CoefbandTrans4X4 = new byte[]
|
private static ReadOnlySpan<byte> Vp9CoefbandTrans4X4 => new byte[]
|
||||||
{
|
{
|
||||||
0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5,
|
0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static byte[] get_band_translate(TxSize txSize)
|
public static ReadOnlySpan<byte> get_band_translate(TxSize txSize)
|
||||||
{
|
{
|
||||||
return txSize == TxSize.Tx4x4 ? Vp9CoefbandTrans4X4 : Vp9CoefbandTrans8X8Plus;
|
return txSize == TxSize.Tx4x4 ? Vp9CoefbandTrans4X4 : Vp9CoefbandTrans8X8Plus;
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
private static readonly Lazy<bool> _supportsQuads = new Lazy<bool>(SupportsQuadsCheck);
|
private static readonly Lazy<bool> _supportsQuads = new Lazy<bool>(SupportsQuadsCheck);
|
||||||
private static readonly Lazy<bool> _supportsSeamlessCubemapPerTexture = new Lazy<bool>(() => HasExtension("GL_ARB_seamless_cubemap_per_texture"));
|
private static readonly Lazy<bool> _supportsSeamlessCubemapPerTexture = new Lazy<bool>(() => HasExtension("GL_ARB_seamless_cubemap_per_texture"));
|
||||||
private static readonly Lazy<bool> _supportsShaderBallot = new Lazy<bool>(() => HasExtension("GL_ARB_shader_ballot"));
|
private static readonly Lazy<bool> _supportsShaderBallot = new Lazy<bool>(() => HasExtension("GL_ARB_shader_ballot"));
|
||||||
|
private static readonly Lazy<bool> _supportsShaderViewportLayerArray = new Lazy<bool>(() => HasExtension("GL_ARB_shader_viewport_layer_array"));
|
||||||
private static readonly Lazy<bool> _supportsTextureCompressionBptc = new Lazy<bool>(() => HasExtension("GL_EXT_texture_compression_bptc"));
|
private static readonly Lazy<bool> _supportsTextureCompressionBptc = new Lazy<bool>(() => HasExtension("GL_EXT_texture_compression_bptc"));
|
||||||
private static readonly Lazy<bool> _supportsTextureCompressionRgtc = new Lazy<bool>(() => HasExtension("GL_EXT_texture_compression_rgtc"));
|
private static readonly Lazy<bool> _supportsTextureCompressionRgtc = new Lazy<bool>(() => HasExtension("GL_EXT_texture_compression_rgtc"));
|
||||||
private static readonly Lazy<bool> _supportsTextureCompressionS3tc = new Lazy<bool>(() => HasExtension("GL_EXT_texture_compression_s3tc"));
|
private static readonly Lazy<bool> _supportsTextureCompressionS3tc = new Lazy<bool>(() => HasExtension("GL_EXT_texture_compression_s3tc"));
|
||||||
@@ -61,6 +62,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
public static bool SupportsQuads => _supportsQuads.Value;
|
public static bool SupportsQuads => _supportsQuads.Value;
|
||||||
public static bool SupportsSeamlessCubemapPerTexture => _supportsSeamlessCubemapPerTexture.Value;
|
public static bool SupportsSeamlessCubemapPerTexture => _supportsSeamlessCubemapPerTexture.Value;
|
||||||
public static bool SupportsShaderBallot => _supportsShaderBallot.Value;
|
public static bool SupportsShaderBallot => _supportsShaderBallot.Value;
|
||||||
|
public static bool SupportsShaderViewportLayerArray => _supportsShaderViewportLayerArray.Value;
|
||||||
public static bool SupportsTextureCompressionBptc => _supportsTextureCompressionBptc.Value;
|
public static bool SupportsTextureCompressionBptc => _supportsTextureCompressionBptc.Value;
|
||||||
public static bool SupportsTextureCompressionRgtc => _supportsTextureCompressionRgtc.Value;
|
public static bool SupportsTextureCompressionRgtc => _supportsTextureCompressionRgtc.Value;
|
||||||
public static bool SupportsTextureCompressionS3tc => _supportsTextureCompressionS3tc.Value;
|
public static bool SupportsTextureCompressionS3tc => _supportsTextureCompressionS3tc.Value;
|
||||||
|
@@ -117,12 +117,13 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
supportsFragmentShaderOrderingIntel: HwCapabilities.SupportsFragmentShaderOrdering,
|
supportsFragmentShaderOrderingIntel: HwCapabilities.SupportsFragmentShaderOrdering,
|
||||||
supportsGeometryShaderPassthrough: HwCapabilities.SupportsGeometryShaderPassthrough,
|
supportsGeometryShaderPassthrough: HwCapabilities.SupportsGeometryShaderPassthrough,
|
||||||
supportsImageLoadFormatted: HwCapabilities.SupportsImageLoadFormatted,
|
supportsImageLoadFormatted: HwCapabilities.SupportsImageLoadFormatted,
|
||||||
|
supportsLayerVertexTessellation: HwCapabilities.SupportsShaderViewportLayerArray,
|
||||||
supportsMismatchingViewFormat: HwCapabilities.SupportsMismatchingViewFormat,
|
supportsMismatchingViewFormat: HwCapabilities.SupportsMismatchingViewFormat,
|
||||||
supportsCubemapView: true,
|
supportsCubemapView: true,
|
||||||
supportsNonConstantTextureOffset: HwCapabilities.SupportsNonConstantTextureOffset,
|
supportsNonConstantTextureOffset: HwCapabilities.SupportsNonConstantTextureOffset,
|
||||||
supportsShaderBallot: HwCapabilities.SupportsShaderBallot,
|
supportsShaderBallot: HwCapabilities.SupportsShaderBallot,
|
||||||
supportsTextureShadowLod: HwCapabilities.SupportsTextureShadowLod,
|
supportsTextureShadowLod: HwCapabilities.SupportsTextureShadowLod,
|
||||||
supportsViewportIndex: true,
|
supportsViewportIndex: HwCapabilities.SupportsShaderViewportLayerArray,
|
||||||
supportsViewportSwizzle: HwCapabilities.SupportsViewportSwizzle,
|
supportsViewportSwizzle: HwCapabilities.SupportsViewportSwizzle,
|
||||||
supportsIndirectParameters: HwCapabilities.SupportsIndirectParameters,
|
supportsIndirectParameters: HwCapabilities.SupportsIndirectParameters,
|
||||||
maximumUniformBuffersPerStage: 13, // TODO: Avoid hardcoding those limits here and get from driver?
|
maximumUniformBuffersPerStage: 13, // TODO: Avoid hardcoding those limits here and get from driver?
|
||||||
|
@@ -1829,7 +1829,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||||||
|
|
||||||
if (texOp.Index < 2 || (type & SamplerType.Mask) == SamplerType.Texture3D)
|
if (texOp.Index < 2 || (type & SamplerType.Mask) == SamplerType.Texture3D)
|
||||||
{
|
{
|
||||||
result = ScalingHelpers.ApplyUnscaling(context, texOp, result, isBindless, isIndexed);
|
result = ScalingHelpers.ApplyUnscaling(context, texOp.WithType(type), result, isBindless, isIndexed);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new OperationResult(AggregateType.S32, result);
|
return new OperationResult(AggregateType.S32, result);
|
||||||
|
@@ -258,6 +258,15 @@ namespace Ryujinx.Graphics.Shader
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Queries host support for writes to Layer from vertex or tessellation shader stages.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True if writes to layer from vertex or tessellation are supported, false otherwise</returns>
|
||||||
|
bool QueryHostSupportsLayerVertexTessellation()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Queries host GPU non-constant texture offset support.
|
/// Queries host GPU non-constant texture offset support.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@@ -278,13 +278,21 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||||||
|
|
||||||
private static int FixedFuncToUserAttribute(ShaderConfig config, int attr, bool isOutput)
|
private static int FixedFuncToUserAttribute(ShaderConfig config, int attr, bool isOutput)
|
||||||
{
|
{
|
||||||
if (attr >= AttributeConsts.FrontColorDiffuseR && attr < AttributeConsts.ClipDistance0)
|
bool supportsLayerFromVertexOrTess = config.GpuAccessor.QueryHostSupportsLayerVertexTessellation();
|
||||||
|
int fixedStartAttr = supportsLayerFromVertexOrTess ? 0 : 1;
|
||||||
|
|
||||||
|
if (attr == AttributeConsts.Layer && config.Stage != ShaderStage.Geometry && !supportsLayerFromVertexOrTess)
|
||||||
{
|
{
|
||||||
attr = FixedFuncToUserAttribute(config, attr, AttributeConsts.FrontColorDiffuseR, 0, isOutput);
|
attr = FixedFuncToUserAttribute(config, attr, AttributeConsts.Layer, 0, isOutput);
|
||||||
|
config.SetLayerOutputAttribute(attr);
|
||||||
|
}
|
||||||
|
else if (attr >= AttributeConsts.FrontColorDiffuseR && attr < AttributeConsts.ClipDistance0)
|
||||||
|
{
|
||||||
|
attr = FixedFuncToUserAttribute(config, attr, AttributeConsts.FrontColorDiffuseR, fixedStartAttr, isOutput);
|
||||||
}
|
}
|
||||||
else if (attr >= AttributeConsts.TexCoordBase && attr < AttributeConsts.TexCoordEnd)
|
else if (attr >= AttributeConsts.TexCoordBase && attr < AttributeConsts.TexCoordEnd)
|
||||||
{
|
{
|
||||||
attr = FixedFuncToUserAttribute(config, attr, AttributeConsts.TexCoordBase, 4, isOutput);
|
attr = FixedFuncToUserAttribute(config, attr, AttributeConsts.TexCoordBase, fixedStartAttr + 4, isOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
return attr;
|
return attr;
|
||||||
|
@@ -27,5 +27,10 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
|
|||||||
CbufSlot = cbufSlot;
|
CbufSlot = cbufSlot;
|
||||||
Handle = handle;
|
Handle = handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AstTextureOperation WithType(SamplerType type)
|
||||||
|
{
|
||||||
|
return new AstTextureOperation(Inst, type, Format, Flags, CbufSlot, Handle, Index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -48,6 +48,9 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||||||
|
|
||||||
public int Cb1DataSize { get; private set; }
|
public int Cb1DataSize { get; private set; }
|
||||||
|
|
||||||
|
public bool LayerOutputWritten { get; private set; }
|
||||||
|
public int LayerOutputAttribute { get; private set; }
|
||||||
|
|
||||||
public bool NextUsesFixedFuncAttributes { get; private set; }
|
public bool NextUsesFixedFuncAttributes { get; private set; }
|
||||||
public int UsedInputAttributes { get; private set; }
|
public int UsedInputAttributes { get; private set; }
|
||||||
public int UsedOutputAttributes { get; private set; }
|
public int UsedOutputAttributes { get; private set; }
|
||||||
@@ -131,6 +134,20 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||||||
_usedImages = new Dictionary<TextureInfo, TextureMeta>();
|
_usedImages = new Dictionary<TextureInfo, TextureMeta>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ShaderConfig(
|
||||||
|
ShaderStage stage,
|
||||||
|
OutputTopology outputTopology,
|
||||||
|
int maxOutputVertices,
|
||||||
|
IGpuAccessor gpuAccessor,
|
||||||
|
TranslationOptions options) : this(gpuAccessor, options)
|
||||||
|
{
|
||||||
|
Stage = stage;
|
||||||
|
ThreadsPerInputPrimitive = 1;
|
||||||
|
OutputTopology = outputTopology;
|
||||||
|
MaxOutputVertices = maxOutputVertices;
|
||||||
|
TransformFeedbackEnabled = gpuAccessor.QueryTransformFeedbackEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
public ShaderConfig(ShaderHeader header, IGpuAccessor gpuAccessor, TranslationOptions options) : this(gpuAccessor, options)
|
public ShaderConfig(ShaderHeader header, IGpuAccessor gpuAccessor, TranslationOptions options) : this(gpuAccessor, options)
|
||||||
{
|
{
|
||||||
Stage = header.Stage;
|
Stage = header.Stage;
|
||||||
@@ -240,6 +257,12 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetLayerOutputAttribute(int attr)
|
||||||
|
{
|
||||||
|
LayerOutputWritten = true;
|
||||||
|
LayerOutputAttribute = attr;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetInputUserAttributeFixedFunc(int index)
|
public void SetInputUserAttributeFixedFunc(int index)
|
||||||
{
|
{
|
||||||
UsedInputAttributes |= 1 << index;
|
UsedInputAttributes |= 1 << index;
|
||||||
@@ -694,5 +717,20 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||||||
{
|
{
|
||||||
return FindDescriptorIndex(GetImageDescriptors(), texOp);
|
return FindDescriptorIndex(GetImageDescriptors(), texOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ShaderProgramInfo CreateProgramInfo()
|
||||||
|
{
|
||||||
|
return new ShaderProgramInfo(
|
||||||
|
GetConstantBufferDescriptors(),
|
||||||
|
GetStorageBufferDescriptors(),
|
||||||
|
GetTextureDescriptors(),
|
||||||
|
GetImageDescriptors(),
|
||||||
|
Stage,
|
||||||
|
UsedFeatures.HasFlag(FeatureFlags.InstanceId),
|
||||||
|
UsedFeatures.HasFlag(FeatureFlags.DrawParameters),
|
||||||
|
UsedFeatures.HasFlag(FeatureFlags.RtLayer),
|
||||||
|
ClipDistancesWritten,
|
||||||
|
OmapTargets);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -79,17 +79,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||||||
|
|
||||||
var sInfo = StructuredProgram.MakeStructuredProgram(funcs, config);
|
var sInfo = StructuredProgram.MakeStructuredProgram(funcs, config);
|
||||||
|
|
||||||
var info = new ShaderProgramInfo(
|
var info = config.CreateProgramInfo();
|
||||||
config.GetConstantBufferDescriptors(),
|
|
||||||
config.GetStorageBufferDescriptors(),
|
|
||||||
config.GetTextureDescriptors(),
|
|
||||||
config.GetImageDescriptors(),
|
|
||||||
config.Stage,
|
|
||||||
config.UsedFeatures.HasFlag(FeatureFlags.InstanceId),
|
|
||||||
config.UsedFeatures.HasFlag(FeatureFlags.DrawParameters),
|
|
||||||
config.UsedFeatures.HasFlag(FeatureFlags.RtLayer),
|
|
||||||
config.ClipDistancesWritten,
|
|
||||||
config.OmapTargets);
|
|
||||||
|
|
||||||
return config.Options.TargetLanguage switch
|
return config.Options.TargetLanguage switch
|
||||||
{
|
{
|
||||||
|
@@ -1,7 +1,12 @@
|
|||||||
using Ryujinx.Graphics.Shader.Decoders;
|
using Ryujinx.Graphics.Shader.CodeGen.Glsl;
|
||||||
|
using Ryujinx.Graphics.Shader.CodeGen.Spirv;
|
||||||
|
using Ryujinx.Graphics.Shader.Decoders;
|
||||||
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
|
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
|
||||||
|
using Ryujinx.Graphics.Shader.StructuredIr;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
|
|
||||||
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
|
using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
|
||||||
using static Ryujinx.Graphics.Shader.Translation.Translator;
|
using static Ryujinx.Graphics.Shader.Translation.Translator;
|
||||||
@@ -18,6 +23,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||||||
public ShaderStage Stage => _config.Stage;
|
public ShaderStage Stage => _config.Stage;
|
||||||
public int Size => _config.Size;
|
public int Size => _config.Size;
|
||||||
public int Cb1DataSize => _config.Cb1DataSize;
|
public int Cb1DataSize => _config.Cb1DataSize;
|
||||||
|
public bool LayerOutputWritten => _config.LayerOutputWritten;
|
||||||
|
|
||||||
public IGpuAccessor GpuAccessor => _config.GpuAccessor;
|
public IGpuAccessor GpuAccessor => _config.GpuAccessor;
|
||||||
|
|
||||||
@@ -149,5 +155,94 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||||||
|
|
||||||
return Translator.Translate(code, _config);
|
return Translator.Translate(code, _config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ShaderProgram GenerateGeometryPassthrough()
|
||||||
|
{
|
||||||
|
int outputAttributesMask = _config.UsedOutputAttributes;
|
||||||
|
int layerOutputAttr = _config.LayerOutputAttribute;
|
||||||
|
|
||||||
|
OutputTopology outputTopology;
|
||||||
|
int maxOutputVertices;
|
||||||
|
|
||||||
|
switch (GpuAccessor.QueryPrimitiveTopology())
|
||||||
|
{
|
||||||
|
case InputTopology.Points:
|
||||||
|
outputTopology = OutputTopology.PointList;
|
||||||
|
maxOutputVertices = 1;
|
||||||
|
break;
|
||||||
|
case InputTopology.Lines:
|
||||||
|
case InputTopology.LinesAdjacency:
|
||||||
|
outputTopology = OutputTopology.LineStrip;
|
||||||
|
maxOutputVertices = 2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
outputTopology = OutputTopology.TriangleStrip;
|
||||||
|
maxOutputVertices = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShaderConfig config = new ShaderConfig(ShaderStage.Geometry, outputTopology, maxOutputVertices, GpuAccessor, _config.Options);
|
||||||
|
|
||||||
|
EmitterContext context = new EmitterContext(default, config, false);
|
||||||
|
|
||||||
|
for (int v = 0; v < maxOutputVertices; v++)
|
||||||
|
{
|
||||||
|
int outAttrsMask = outputAttributesMask;
|
||||||
|
|
||||||
|
while (outAttrsMask != 0)
|
||||||
|
{
|
||||||
|
int attrIndex = BitOperations.TrailingZeroCount(outAttrsMask);
|
||||||
|
|
||||||
|
outAttrsMask &= ~(1 << attrIndex);
|
||||||
|
|
||||||
|
for (int c = 0; c < 4; c++)
|
||||||
|
{
|
||||||
|
int attr = AttributeConsts.UserAttributeBase + attrIndex * 16 + c * 4;
|
||||||
|
|
||||||
|
Operand value = context.LoadAttribute(Const(attr), Const(0), Const(v));
|
||||||
|
|
||||||
|
if (attr == layerOutputAttr)
|
||||||
|
{
|
||||||
|
context.Copy(Attribute(AttributeConsts.Layer), value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context.Copy(Attribute(attr), value);
|
||||||
|
config.SetOutputUserAttribute(attrIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
config.SetInputUserAttribute(attrIndex, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int c = 0; c < 4; c++)
|
||||||
|
{
|
||||||
|
int attr = AttributeConsts.PositionX + c * 4;
|
||||||
|
|
||||||
|
Operand value = context.LoadAttribute(Const(attr), Const(0), Const(v));
|
||||||
|
|
||||||
|
context.Copy(Attribute(attr), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
context.EmitVertex();
|
||||||
|
}
|
||||||
|
|
||||||
|
context.EndPrimitive();
|
||||||
|
|
||||||
|
var operations = context.GetOperations();
|
||||||
|
var cfg = ControlFlowGraph.Create(operations);
|
||||||
|
var function = new Function(cfg.Blocks, "main", false, 0, 0);
|
||||||
|
|
||||||
|
var sInfo = StructuredProgram.MakeStructuredProgram(new[] { function }, config);
|
||||||
|
|
||||||
|
var info = config.CreateProgramInfo();
|
||||||
|
|
||||||
|
return config.Options.TargetLanguage switch
|
||||||
|
{
|
||||||
|
TargetLanguage.Glsl => new ShaderProgram(info, TargetLanguage.Glsl, GlslGenerator.Generate(sInfo, config)),
|
||||||
|
TargetLanguage.Spirv => new ShaderProgram(info, TargetLanguage.Spirv, SpirvGenerator.Generate(sInfo, config)),
|
||||||
|
_ => throw new NotImplementedException(config.Options.TargetLanguage.ToString())
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -210,7 +210,10 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cbs != null && !(_buffer.HasCommandBufferDependency(cbs.Value) && _waitable.IsBufferRangeInUse(cbs.Value.CommandBufferIndex, offset, dataSize)))
|
if (cbs != null &&
|
||||||
|
_gd.PipelineInternal.RenderPassActive &&
|
||||||
|
!(_buffer.HasCommandBufferDependency(cbs.Value) &&
|
||||||
|
_waitable.IsBufferRangeInUse(cbs.Value.CommandBufferIndex, offset, dataSize)))
|
||||||
{
|
{
|
||||||
// If the buffer hasn't been used on the command buffer yet, try to preload the data.
|
// If the buffer hasn't been used on the command buffer yet, try to preload the data.
|
||||||
// This avoids ending and beginning render passes on each buffer data upload.
|
// This avoids ending and beginning render passes on each buffer data upload.
|
||||||
|
@@ -130,6 +130,12 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
1f));
|
1f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
Span<byte> dummyTextureData = stackalloc byte[4];
|
||||||
|
_dummyTexture.SetData(dummyTextureData);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetProgram(ShaderCollection program)
|
public void SetProgram(ShaderCollection program)
|
||||||
{
|
{
|
||||||
_program = program;
|
_program = program;
|
||||||
|
@@ -49,7 +49,6 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
private Auto<DisposableFramebuffer> _framebuffer;
|
private Auto<DisposableFramebuffer> _framebuffer;
|
||||||
private Auto<DisposableRenderPass> _renderPass;
|
private Auto<DisposableRenderPass> _renderPass;
|
||||||
private int _writtenAttachmentCount;
|
private int _writtenAttachmentCount;
|
||||||
private bool _renderPassActive;
|
|
||||||
|
|
||||||
private readonly DescriptorSetUpdater _descriptorSetUpdater;
|
private readonly DescriptorSetUpdater _descriptorSetUpdater;
|
||||||
|
|
||||||
@@ -73,6 +72,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
private PipelineColorBlendAttachmentState[] _storedBlend;
|
private PipelineColorBlendAttachmentState[] _storedBlend;
|
||||||
|
|
||||||
public ulong DrawCount { get; private set; }
|
public ulong DrawCount { get; private set; }
|
||||||
|
public bool RenderPassActive { get; private set; }
|
||||||
|
|
||||||
public unsafe PipelineBase(VulkanRenderer gd, Device device)
|
public unsafe PipelineBase(VulkanRenderer gd, Device device)
|
||||||
{
|
{
|
||||||
@@ -114,6 +114,8 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
|
_descriptorSetUpdater.Initialize();
|
||||||
|
|
||||||
SupportBufferUpdater = new SupportBufferUpdater(Gd);
|
SupportBufferUpdater = new SupportBufferUpdater(Gd);
|
||||||
SupportBufferUpdater.UpdateRenderScale(_renderScale, 0, SupportBuffer.RenderScaleMaxCount);
|
SupportBufferUpdater.UpdateRenderScale(_renderScale, 0, SupportBuffer.RenderScaleMaxCount);
|
||||||
|
|
||||||
@@ -838,6 +840,11 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
stages.CopyTo(_newState.Stages.AsSpan().Slice(0, stages.Length));
|
stages.CopyTo(_newState.Stages.AsSpan().Slice(0, stages.Length));
|
||||||
|
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
|
|
||||||
|
if (_program.IsCompute)
|
||||||
|
{
|
||||||
|
EndRenderPass();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Specialize<T>(in T data) where T : unmanaged
|
public void Specialize<T>(in T data) where T : unmanaged
|
||||||
@@ -1451,7 +1458,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
|
|
||||||
private unsafe void BeginRenderPass()
|
private unsafe void BeginRenderPass()
|
||||||
{
|
{
|
||||||
if (!_renderPassActive)
|
if (!RenderPassActive)
|
||||||
{
|
{
|
||||||
var renderArea = new Rect2D(null, new Extent2D(FramebufferParams.Width, FramebufferParams.Height));
|
var renderArea = new Rect2D(null, new Extent2D(FramebufferParams.Width, FramebufferParams.Height));
|
||||||
var clearValue = new ClearValue();
|
var clearValue = new ClearValue();
|
||||||
@@ -1467,18 +1474,18 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
};
|
};
|
||||||
|
|
||||||
Gd.Api.CmdBeginRenderPass(CommandBuffer, renderPassBeginInfo, SubpassContents.Inline);
|
Gd.Api.CmdBeginRenderPass(CommandBuffer, renderPassBeginInfo, SubpassContents.Inline);
|
||||||
_renderPassActive = true;
|
RenderPassActive = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EndRenderPass()
|
public void EndRenderPass()
|
||||||
{
|
{
|
||||||
if (_renderPassActive)
|
if (RenderPassActive)
|
||||||
{
|
{
|
||||||
PauseTransformFeedbackInternal();
|
PauseTransformFeedbackInternal();
|
||||||
Gd.Api.CmdEndRenderPass(CommandBuffer);
|
Gd.Api.CmdEndRenderPass(CommandBuffer);
|
||||||
SignalRenderPassEnd();
|
SignalRenderPassEnd();
|
||||||
_renderPassActive = false;
|
RenderPassActive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
|
|
||||||
public bool HasMinimalLayout { get; }
|
public bool HasMinimalLayout { get; }
|
||||||
public bool UsePushDescriptors { get; }
|
public bool UsePushDescriptors { get; }
|
||||||
|
public bool IsCompute { get; }
|
||||||
|
|
||||||
public uint Stages { get; }
|
public uint Stages { get; }
|
||||||
|
|
||||||
@@ -47,7 +48,6 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
private VulkanRenderer _gd;
|
private VulkanRenderer _gd;
|
||||||
private Device _device;
|
private Device _device;
|
||||||
private bool _initialized;
|
private bool _initialized;
|
||||||
private bool _isCompute;
|
|
||||||
|
|
||||||
private ProgramPipelineState _state;
|
private ProgramPipelineState _state;
|
||||||
private DisposableRenderPass _dummyRenderPass;
|
private DisposableRenderPass _dummyRenderPass;
|
||||||
@@ -91,7 +91,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
|
|
||||||
if (shader.StageFlags == ShaderStageFlags.ShaderStageComputeBit)
|
if (shader.StageFlags == ShaderStageFlags.ShaderStageComputeBit)
|
||||||
{
|
{
|
||||||
_isCompute = true;
|
IsCompute = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
internalShaders[i] = shader;
|
internalShaders[i] = shader;
|
||||||
@@ -163,7 +163,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_isCompute)
|
if (IsCompute)
|
||||||
{
|
{
|
||||||
CreateBackgroundComputePipeline();
|
CreateBackgroundComputePipeline();
|
||||||
}
|
}
|
||||||
|
@@ -396,6 +396,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
supportsFragmentShaderOrderingIntel: false,
|
supportsFragmentShaderOrderingIntel: false,
|
||||||
supportsGeometryShaderPassthrough: Capabilities.SupportsGeometryShaderPassthrough,
|
supportsGeometryShaderPassthrough: Capabilities.SupportsGeometryShaderPassthrough,
|
||||||
supportsImageLoadFormatted: features2.Features.ShaderStorageImageReadWithoutFormat,
|
supportsImageLoadFormatted: features2.Features.ShaderStorageImageReadWithoutFormat,
|
||||||
|
supportsLayerVertexTessellation: featuresVk12.ShaderOutputLayer,
|
||||||
supportsMismatchingViewFormat: true,
|
supportsMismatchingViewFormat: true,
|
||||||
supportsCubemapView: !IsAmdGcn,
|
supportsCubemapView: !IsAmdGcn,
|
||||||
supportsNonConstantTextureOffset: false,
|
supportsNonConstantTextureOffset: false,
|
||||||
|
@@ -26,8 +26,8 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
|
|||||||
{
|
{
|
||||||
class IApplicationFunctions : IpcService
|
class IApplicationFunctions : IpcService
|
||||||
{
|
{
|
||||||
private ulong _defaultSaveDataSize = 200000000;
|
private long _defaultSaveDataSize = 200000000;
|
||||||
private ulong _defaultJournalSaveDataSize = 200000000;
|
private long _defaultJournalSaveDataSize = 200000000;
|
||||||
|
|
||||||
private KEvent _gpuErrorDetectedSystemEvent;
|
private KEvent _gpuErrorDetectedSystemEvent;
|
||||||
private KEvent _friendInvitationStorageChannelEvent;
|
private KEvent _friendInvitationStorageChannelEvent;
|
||||||
@@ -203,13 +203,13 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
|
|||||||
}
|
}
|
||||||
|
|
||||||
[CommandHipc(25)] // 3.0.0+
|
[CommandHipc(25)] // 3.0.0+
|
||||||
// ExtendSaveData(u8 save_data_type, nn::account::Uid, u64 save_size, u64 journal_size) -> u64 result_code
|
// ExtendSaveData(u8 save_data_type, nn::account::Uid, s64 save_size, s64 journal_size) -> u64 result_code
|
||||||
public ResultCode ExtendSaveData(ServiceCtx context)
|
public ResultCode ExtendSaveData(ServiceCtx context)
|
||||||
{
|
{
|
||||||
SaveDataType saveDataType = (SaveDataType)context.RequestData.ReadUInt64();
|
SaveDataType saveDataType = (SaveDataType)context.RequestData.ReadUInt64();
|
||||||
Uid userId = context.RequestData.ReadStruct<Uid>();
|
Uid userId = context.RequestData.ReadStruct<Uid>();
|
||||||
ulong saveDataSize = context.RequestData.ReadUInt64();
|
long saveDataSize = context.RequestData.ReadInt64();
|
||||||
ulong journalSize = context.RequestData.ReadUInt64();
|
long journalSize = context.RequestData.ReadInt64();
|
||||||
|
|
||||||
// NOTE: Service calls nn::fs::ExtendApplicationSaveData.
|
// NOTE: Service calls nn::fs::ExtendApplicationSaveData.
|
||||||
// Since LibHac currently doesn't support this method, we can stub it for now.
|
// Since LibHac currently doesn't support this method, we can stub it for now.
|
||||||
@@ -225,7 +225,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
|
|||||||
}
|
}
|
||||||
|
|
||||||
[CommandHipc(26)] // 3.0.0+
|
[CommandHipc(26)] // 3.0.0+
|
||||||
// GetSaveDataSize(u8 save_data_type, nn::account::Uid) -> (u64 save_size, u64 journal_size)
|
// GetSaveDataSize(u8 save_data_type, nn::account::Uid) -> (s64 save_size, s64 journal_size)
|
||||||
public ResultCode GetSaveDataSize(ServiceCtx context)
|
public ResultCode GetSaveDataSize(ServiceCtx context)
|
||||||
{
|
{
|
||||||
SaveDataType saveDataType = (SaveDataType)context.RequestData.ReadUInt64();
|
SaveDataType saveDataType = (SaveDataType)context.RequestData.ReadUInt64();
|
||||||
@@ -268,6 +268,23 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
|
|||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CommandHipc(28)] // 11.0.0+
|
||||||
|
// GetSaveDataSizeMax() -> (s64 save_size_max, s64 journal_size_max)
|
||||||
|
public ResultCode GetSaveDataSizeMax(ServiceCtx context)
|
||||||
|
{
|
||||||
|
// NOTE: We are currently using a stub for GetSaveDataSize() which returns the default values.
|
||||||
|
// For this method we shouldn't return anything lower than that, but since we aren't interacting
|
||||||
|
// with fs to get the actual sizes, we return the default values here as well.
|
||||||
|
// This also helps in case ExtendSaveData() has been executed and the default values were modified.
|
||||||
|
|
||||||
|
context.ResponseData.Write(_defaultSaveDataSize);
|
||||||
|
context.ResponseData.Write(_defaultJournalSaveDataSize);
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
||||||
|
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
[CommandHipc(30)]
|
[CommandHipc(30)]
|
||||||
// BeginBlockingHomeButtonShortAndLongPressed()
|
// BeginBlockingHomeButtonShortAndLongPressed()
|
||||||
public ResultCode BeginBlockingHomeButtonShortAndLongPressed(ServiceCtx context)
|
public ResultCode BeginBlockingHomeButtonShortAndLongPressed(ServiceCtx context)
|
||||||
|
@@ -25,6 +25,7 @@ namespace Ryujinx.Memory.Tracking
|
|||||||
|
|
||||||
private int _sequenceNumber;
|
private int _sequenceNumber;
|
||||||
private BitMap _sequenceNumberBitmap;
|
private BitMap _sequenceNumberBitmap;
|
||||||
|
private BitMap _dirtyCheckedBitmap;
|
||||||
private int _uncheckedHandles;
|
private int _uncheckedHandles;
|
||||||
|
|
||||||
public bool Dirty { get; private set; } = true;
|
public bool Dirty { get; private set; } = true;
|
||||||
@@ -36,6 +37,7 @@ namespace Ryujinx.Memory.Tracking
|
|||||||
|
|
||||||
_dirtyBitmap = new ConcurrentBitmap(_handles.Length, true);
|
_dirtyBitmap = new ConcurrentBitmap(_handles.Length, true);
|
||||||
_sequenceNumberBitmap = new BitMap(_handles.Length);
|
_sequenceNumberBitmap = new BitMap(_handles.Length);
|
||||||
|
_dirtyCheckedBitmap = new BitMap(_handles.Length);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
@@ -246,16 +248,18 @@ namespace Ryujinx.Memory.Tracking
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ParseDirtyBits(long dirtyBits, long mask, int index, long[] seqMasks, ref int baseBit, ref int prevHandle, ref ulong rgStart, ref ulong rgSize, Action<ulong, ulong> modifiedAction)
|
private void ParseDirtyBits(long dirtyBits, long mask, int index, long[] seqMasks, long[] checkMasks, ref int baseBit, ref int prevHandle, ref ulong rgStart, ref ulong rgSize, Action<ulong, ulong> modifiedAction)
|
||||||
{
|
{
|
||||||
long seqMask = mask & ~seqMasks[index];
|
long seqMask = mask & ~seqMasks[index];
|
||||||
|
long checkMask = (~dirtyBits) & seqMask;
|
||||||
dirtyBits &= seqMask;
|
dirtyBits &= seqMask;
|
||||||
|
|
||||||
while (dirtyBits != 0)
|
while (dirtyBits != 0)
|
||||||
{
|
{
|
||||||
int bit = BitOperations.TrailingZeroCount(dirtyBits);
|
int bit = BitOperations.TrailingZeroCount(dirtyBits);
|
||||||
|
long bitValue = 1L << bit;
|
||||||
|
|
||||||
dirtyBits &= ~(1L << bit);
|
dirtyBits &= ~bitValue;
|
||||||
|
|
||||||
int handleIndex = baseBit + bit;
|
int handleIndex = baseBit + bit;
|
||||||
|
|
||||||
@@ -273,11 +277,14 @@ namespace Ryujinx.Memory.Tracking
|
|||||||
}
|
}
|
||||||
|
|
||||||
rgSize += handle.Size;
|
rgSize += handle.Size;
|
||||||
handle.Reprotect();
|
handle.Reprotect(false, (checkMasks[index] & bitValue) == 0);
|
||||||
|
|
||||||
|
checkMasks[index] &= ~bitValue;
|
||||||
|
|
||||||
prevHandle = handleIndex;
|
prevHandle = handleIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkMasks[index] |= checkMask;
|
||||||
seqMasks[index] |= mask;
|
seqMasks[index] |= mask;
|
||||||
_uncheckedHandles -= BitOperations.PopCount((ulong)seqMask);
|
_uncheckedHandles -= BitOperations.PopCount((ulong)seqMask);
|
||||||
|
|
||||||
@@ -328,6 +335,7 @@ namespace Ryujinx.Memory.Tracking
|
|||||||
ulong rgSize = 0;
|
ulong rgSize = 0;
|
||||||
|
|
||||||
long[] seqMasks = _sequenceNumberBitmap.Masks;
|
long[] seqMasks = _sequenceNumberBitmap.Masks;
|
||||||
|
long[] checkedMasks = _dirtyCheckedBitmap.Masks;
|
||||||
long[] masks = _dirtyBitmap.Masks;
|
long[] masks = _dirtyBitmap.Masks;
|
||||||
|
|
||||||
int startIndex = startHandle >> ConcurrentBitmap.IntShift;
|
int startIndex = startHandle >> ConcurrentBitmap.IntShift;
|
||||||
@@ -345,20 +353,20 @@ namespace Ryujinx.Memory.Tracking
|
|||||||
|
|
||||||
if (startIndex == endIndex)
|
if (startIndex == endIndex)
|
||||||
{
|
{
|
||||||
ParseDirtyBits(startValue, startMask & endMask, startIndex, seqMasks, ref baseBit, ref prevHandle, ref rgStart, ref rgSize, modifiedAction);
|
ParseDirtyBits(startValue, startMask & endMask, startIndex, seqMasks, checkedMasks, ref baseBit, ref prevHandle, ref rgStart, ref rgSize, modifiedAction);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ParseDirtyBits(startValue, startMask, startIndex, seqMasks, ref baseBit, ref prevHandle, ref rgStart, ref rgSize, modifiedAction);
|
ParseDirtyBits(startValue, startMask, startIndex, seqMasks, checkedMasks, ref baseBit, ref prevHandle, ref rgStart, ref rgSize, modifiedAction);
|
||||||
|
|
||||||
for (int i = startIndex + 1; i < endIndex; i++)
|
for (int i = startIndex + 1; i < endIndex; i++)
|
||||||
{
|
{
|
||||||
ParseDirtyBits(Volatile.Read(ref masks[i]), -1L, i, seqMasks, ref baseBit, ref prevHandle, ref rgStart, ref rgSize, modifiedAction);
|
ParseDirtyBits(Volatile.Read(ref masks[i]), -1L, i, seqMasks, checkedMasks, ref baseBit, ref prevHandle, ref rgStart, ref rgSize, modifiedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
long endValue = Volatile.Read(ref masks[endIndex]);
|
long endValue = Volatile.Read(ref masks[endIndex]);
|
||||||
|
|
||||||
ParseDirtyBits(endValue, endMask, endIndex, seqMasks, ref baseBit, ref prevHandle, ref rgStart, ref rgSize, modifiedAction);
|
ParseDirtyBits(endValue, endMask, endIndex, seqMasks, checkedMasks, ref baseBit, ref prevHandle, ref rgStart, ref rgSize, modifiedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rgSize != 0)
|
if (rgSize != 0)
|
||||||
|
@@ -263,15 +263,15 @@ namespace Ryujinx.Memory.Tracking
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ForceDirty()
|
public void ForceDirty()
|
||||||
{
|
{
|
||||||
_checkCount++;
|
|
||||||
|
|
||||||
Dirty = true;
|
Dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Consume the dirty flag for this handle, and reprotect so it can be set on the next write.
|
/// Consume the dirty flag for this handle, and reprotect so it can be set on the next write.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Reprotect(bool asDirty = false)
|
/// <param name="asDirty">True if the handle should be reprotected as dirty, rather than have it cleared</param>
|
||||||
|
/// <param name="consecutiveCheck">True if this reprotect is the result of consecutive dirty checks</param>
|
||||||
|
public void Reprotect(bool asDirty, bool consecutiveCheck = false)
|
||||||
{
|
{
|
||||||
if (_volatile) return;
|
if (_volatile) return;
|
||||||
|
|
||||||
@@ -296,7 +296,7 @@ namespace Ryujinx.Memory.Tracking
|
|||||||
}
|
}
|
||||||
else if (!asDirty)
|
else if (!asDirty)
|
||||||
{
|
{
|
||||||
if (_checkCount > 0 && _checkCount < CheckCountForInfrequent)
|
if (consecutiveCheck || (_checkCount > 0 && _checkCount < CheckCountForInfrequent))
|
||||||
{
|
{
|
||||||
if (++_volatileCount >= VolatileThreshold && _preAction == null)
|
if (++_volatileCount >= VolatileThreshold && _preAction == null)
|
||||||
{
|
{
|
||||||
@@ -313,6 +313,15 @@ namespace Ryujinx.Memory.Tracking
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Consume the dirty flag for this handle, and reprotect so it can be set on the next write.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="asDirty">True if the handle should be reprotected as dirty, rather than have it cleared</param>
|
||||||
|
public void Reprotect(bool asDirty = false)
|
||||||
|
{
|
||||||
|
Reprotect(asDirty, false);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Register an action to perform when the tracked region is read or written.
|
/// Register an action to perform when the tracked region is read or written.
|
||||||
/// The action is automatically removed after it runs.
|
/// The action is automatically removed after it runs.
|
||||||
|
Reference in New Issue
Block a user