Compare commits
31 Commits
Author | SHA1 | Date | |
---|---|---|---|
2de78a2d55 | |||
b29ded1d60 | |||
9860bfb2cd | |||
f6ada8d169 | |||
42d31f646d | |||
07fc3ded68 | |||
fd01259d2b | |||
7ffe7f8442 | |||
2b2ce68f07 | |||
bc53d00463 | |||
bddb2a1483 | |||
e3bacfa774 | |||
7c2f07d124 | |||
ede5b3c324 | |||
df5be5812f | |||
bc392e55df | |||
fffc3ed193 | |||
7d160e98fd | |||
bf96bc84a8 | |||
91e4caaa69 | |||
efbd29463d | |||
7608cb37ab | |||
d604e98227 | |||
58907e2c29 | |||
649d372f7d | |||
f9a538bb0f | |||
f92921a6d1 | |||
32d21ddf17 | |||
82f90704a0 | |||
f978d3726a | |||
6f28c4abad |
@ -46,7 +46,7 @@
|
||||
<PackageVersion Include="System.Drawing.Common" Version="7.0.0" />
|
||||
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="6.31.0" />
|
||||
<PackageVersion Include="System.IO.Hashing" Version="7.0.0" />
|
||||
<PackageVersion Include="System.Management" Version="7.0.1" />
|
||||
<PackageVersion Include="System.Management" Version="7.0.2" />
|
||||
<PackageVersion Include="UnicornEngine.Unicorn" Version="2.0.2-rc1-fb78016" />
|
||||
<PackageVersion Include="XamlNameReferenceGenerator" Version="1.6.1" />
|
||||
</ItemGroup>
|
||||
|
@ -39,10 +39,15 @@
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2018 - 2022 Ryujinx Team and Contributors.</string>
|
||||
<string>Copyright © 2018 - 2023 Ryujinx Team and Contributors.</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.games</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>11.0</string>
|
||||
<key>LSEnvironment</key>
|
||||
<dict>
|
||||
<key>COMPlus_DefaultStackSize</key>
|
||||
<string>200000</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@ -13,7 +13,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
enum OpCode32SimdSelMode : int
|
||||
enum OpCode32SimdSelMode
|
||||
{
|
||||
Eq = 0,
|
||||
Vs,
|
||||
|
@ -228,7 +228,6 @@ namespace ARMeilleure.Instructions
|
||||
|
||||
switch (context.Fpcr.GetRoundingMode())
|
||||
{
|
||||
default:
|
||||
case FPRoundingMode.ToNearest:
|
||||
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
||||
overflowToInf = true;
|
||||
@ -248,6 +247,9 @@ namespace ARMeilleure.Instructions
|
||||
roundUp = false;
|
||||
overflowToInf = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentException($"Invalid rounding mode \"{context.Fpcr.GetRoundingMode()}\".");
|
||||
}
|
||||
|
||||
if (roundUp)
|
||||
@ -412,7 +414,6 @@ namespace ARMeilleure.Instructions
|
||||
|
||||
switch (context.Fpcr.GetRoundingMode())
|
||||
{
|
||||
default:
|
||||
case FPRoundingMode.ToNearest:
|
||||
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
||||
overflowToInf = true;
|
||||
@ -432,6 +433,9 @@ namespace ARMeilleure.Instructions
|
||||
roundUp = false;
|
||||
overflowToInf = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentException($"Invalid rounding mode \"{context.Fpcr.GetRoundingMode()}\".");
|
||||
}
|
||||
|
||||
if (roundUp)
|
||||
@ -585,7 +589,6 @@ namespace ARMeilleure.Instructions
|
||||
|
||||
switch (context.Fpcr.GetRoundingMode())
|
||||
{
|
||||
default:
|
||||
case FPRoundingMode.ToNearest:
|
||||
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
||||
overflowToInf = true;
|
||||
@ -605,6 +608,9 @@ namespace ARMeilleure.Instructions
|
||||
roundUp = false;
|
||||
overflowToInf = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentException($"Invalid rounding mode \"{context.Fpcr.GetRoundingMode()}\".");
|
||||
}
|
||||
|
||||
if (roundUp)
|
||||
@ -1433,11 +1439,24 @@ namespace ARMeilleure.Instructions
|
||||
|
||||
switch (fpcr.GetRoundingMode())
|
||||
{
|
||||
case FPRoundingMode.ToNearest:
|
||||
overflowToInf = true;
|
||||
break;
|
||||
|
||||
case FPRoundingMode.TowardsPlusInfinity:
|
||||
overflowToInf = !sign;
|
||||
break;
|
||||
|
||||
case FPRoundingMode.TowardsMinusInfinity:
|
||||
overflowToInf = sign;
|
||||
break;
|
||||
|
||||
case FPRoundingMode.TowardsZero:
|
||||
overflowToInf = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
case FPRoundingMode.ToNearest: overflowToInf = true; break;
|
||||
case FPRoundingMode.TowardsPlusInfinity: overflowToInf = !sign; break;
|
||||
case FPRoundingMode.TowardsMinusInfinity: overflowToInf = sign; break;
|
||||
case FPRoundingMode.TowardsZero: overflowToInf = false; break;
|
||||
throw new ArgumentException($"Invalid rounding mode \"{fpcr.GetRoundingMode()}\".");
|
||||
}
|
||||
|
||||
result = overflowToInf ? FPInfinity(sign) : FPMaxNormal(sign);
|
||||
@ -2845,11 +2864,24 @@ namespace ARMeilleure.Instructions
|
||||
|
||||
switch (fpcr.GetRoundingMode())
|
||||
{
|
||||
case FPRoundingMode.ToNearest:
|
||||
overflowToInf = true;
|
||||
break;
|
||||
|
||||
case FPRoundingMode.TowardsPlusInfinity:
|
||||
overflowToInf = !sign;
|
||||
break;
|
||||
|
||||
case FPRoundingMode.TowardsMinusInfinity:
|
||||
overflowToInf = sign;
|
||||
break;
|
||||
|
||||
case FPRoundingMode.TowardsZero:
|
||||
overflowToInf = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
case FPRoundingMode.ToNearest: overflowToInf = true; break;
|
||||
case FPRoundingMode.TowardsPlusInfinity: overflowToInf = !sign; break;
|
||||
case FPRoundingMode.TowardsMinusInfinity: overflowToInf = sign; break;
|
||||
case FPRoundingMode.TowardsZero: overflowToInf = false; break;
|
||||
throw new ArgumentException($"Invalid rounding mode \"{fpcr.GetRoundingMode()}\".");
|
||||
}
|
||||
|
||||
result = overflowToInf ? FPInfinity(sign) : FPMaxNormal(sign);
|
||||
|
@ -6,9 +6,9 @@ namespace ARMeilleure.Memory
|
||||
{
|
||||
IntPtr Pointer { get; }
|
||||
|
||||
bool Commit(ulong offset, ulong size);
|
||||
void Commit(ulong offset, ulong size);
|
||||
|
||||
void MapAsRx(ulong offset, ulong size);
|
||||
void MapAsRwx(ulong offset, ulong size);
|
||||
}
|
||||
}
|
||||
}
|
@ -78,7 +78,7 @@ namespace ARMeilleure.Signal
|
||||
private static IntPtr _signalHandlerPtr;
|
||||
private static IntPtr _signalHandlerHandle;
|
||||
|
||||
private static readonly object _lock = new object();
|
||||
private static readonly object _lock = new();
|
||||
private static bool _initialized;
|
||||
|
||||
static NativeSignalHandler()
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace ARMeilleure.State
|
||||
{
|
||||
enum ExecutionMode : int
|
||||
enum ExecutionMode
|
||||
{
|
||||
Aarch32Arm = 0,
|
||||
Aarch32Thumb = 1,
|
||||
|
@ -13,8 +13,8 @@ namespace ARMeilleure.State
|
||||
// _e0 & _e1 could be marked as readonly, however they are not readonly because we modify them through the Unsafe
|
||||
// APIs. This also means that one should be careful when changing the layout of this struct.
|
||||
|
||||
private ulong _e0;
|
||||
private ulong _e1;
|
||||
private readonly ulong _e0;
|
||||
private readonly ulong _e1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a new <see cref="V128"/> with all bits set to zero.
|
||||
|
@ -2,6 +2,7 @@ using ARMeilleure.CodeGen;
|
||||
using ARMeilleure.CodeGen.Unwinding;
|
||||
using ARMeilleure.Memory;
|
||||
using ARMeilleure.Native;
|
||||
using Ryujinx.Memory;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@ -12,8 +13,8 @@ namespace ARMeilleure.Translation.Cache
|
||||
{
|
||||
static partial class JitCache
|
||||
{
|
||||
private const int PageSize = 4 * 1024;
|
||||
private const int PageMask = PageSize - 1;
|
||||
private static readonly int PageSize = (int)MemoryBlock.GetPageSize();
|
||||
private static readonly int PageMask = PageSize - 1;
|
||||
|
||||
private const int CodeAlignment = 4; // Bytes.
|
||||
private const int CacheSize = 2047 * 1024 * 1024;
|
||||
@ -25,7 +26,7 @@ namespace ARMeilleure.Translation.Cache
|
||||
|
||||
private static readonly List<CacheEntry> _cacheEntries = new List<CacheEntry>();
|
||||
|
||||
private static readonly object _lock = new object();
|
||||
private static readonly object _lock = new();
|
||||
private static bool _initialized;
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
|
@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
||||
private readonly ManualResetEvent _pauseEvent;
|
||||
private readonly ConcurrentDictionary<OpenALHardwareDeviceSession, byte> _sessions;
|
||||
private bool _stillRunning;
|
||||
private Thread _updaterThread;
|
||||
private readonly Thread _updaterThread;
|
||||
|
||||
public OpenALHardwareDeviceDriver()
|
||||
{
|
||||
@ -73,7 +73,7 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
||||
throw new ArgumentException($"{channelCount}");
|
||||
}
|
||||
|
||||
OpenALHardwareDeviceSession session = new OpenALHardwareDeviceSession(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
|
||||
OpenALHardwareDeviceSession session = new(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
|
||||
|
||||
_sessions.TryAdd(session, 0);
|
||||
|
||||
@ -123,6 +123,7 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
|
@ -10,14 +10,14 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
||||
{
|
||||
class OpenALHardwareDeviceSession : HardwareDeviceSessionOutputBase
|
||||
{
|
||||
private OpenALHardwareDeviceDriver _driver;
|
||||
private int _sourceId;
|
||||
private ALFormat _targetFormat;
|
||||
private readonly OpenALHardwareDeviceDriver _driver;
|
||||
private readonly int _sourceId;
|
||||
private readonly ALFormat _targetFormat;
|
||||
private bool _isActive;
|
||||
private Queue<OpenALAudioBuffer> _queuedBuffers;
|
||||
private readonly Queue<OpenALAudioBuffer> _queuedBuffers;
|
||||
private ulong _playedSampleCount;
|
||||
|
||||
private object _lock = new object();
|
||||
private readonly object _lock = new();
|
||||
|
||||
public OpenALHardwareDeviceSession(OpenALHardwareDeviceDriver driver, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount, float requestedVolume) : base(memoryManager, requestedSampleFormat, requestedSampleRate, requestedChannelCount)
|
||||
{
|
||||
@ -32,23 +32,17 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
||||
|
||||
private ALFormat GetALFormat()
|
||||
{
|
||||
switch (RequestedSampleFormat)
|
||||
return RequestedSampleFormat switch
|
||||
{
|
||||
case SampleFormat.PcmInt16:
|
||||
switch (RequestedChannelCount)
|
||||
{
|
||||
case 1:
|
||||
return ALFormat.Mono16;
|
||||
case 2:
|
||||
return ALFormat.Stereo16;
|
||||
case 6:
|
||||
return ALFormat.Multi51Chn16Ext;
|
||||
default:
|
||||
throw new NotImplementedException($"Unsupported channel config {RequestedChannelCount}");
|
||||
}
|
||||
default:
|
||||
throw new NotImplementedException($"Unsupported sample format {RequestedSampleFormat}");
|
||||
}
|
||||
SampleFormat.PcmInt16 => RequestedChannelCount switch
|
||||
{
|
||||
1 => ALFormat.Mono16,
|
||||
2 => ALFormat.Stereo16,
|
||||
6 => ALFormat.Multi51Chn16Ext,
|
||||
_ => throw new NotImplementedException($"Unsupported channel config {RequestedChannelCount}"),
|
||||
},
|
||||
_ => throw new NotImplementedException($"Unsupported sample format {RequestedSampleFormat}"),
|
||||
};
|
||||
}
|
||||
|
||||
public override void PrepareToClose() { }
|
||||
@ -69,7 +63,7 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
OpenALAudioBuffer driverBuffer = new OpenALAudioBuffer
|
||||
OpenALAudioBuffer driverBuffer = new()
|
||||
{
|
||||
DriverIdentifier = buffer.DataPointer,
|
||||
BufferId = AL.GenBuffer(),
|
||||
|
@ -19,12 +19,14 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||
private readonly ManualResetEvent _pauseEvent;
|
||||
private readonly ConcurrentDictionary<SDL2HardwareDeviceSession, byte> _sessions;
|
||||
|
||||
private bool _supportSurroundConfiguration;
|
||||
private readonly bool _supportSurroundConfiguration;
|
||||
|
||||
// TODO: Add this to SDL2-CS
|
||||
// NOTE: We use a DllImport here because of marshaling issue for spec.
|
||||
#pragma warning disable SYSLIB1054
|
||||
[DllImport("SDL2")]
|
||||
private static extern int SDL_GetDefaultAudioInfo(IntPtr name, out SDL_AudioSpec spec, int isCapture);
|
||||
#pragma warning restore SYSLIB1054
|
||||
|
||||
public SDL2HardwareDeviceDriver()
|
||||
{
|
||||
@ -90,7 +92,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||
throw new NotImplementedException("Input direction is currently not implemented on SDL2 backend!");
|
||||
}
|
||||
|
||||
SDL2HardwareDeviceSession session = new SDL2HardwareDeviceSession(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
|
||||
SDL2HardwareDeviceSession session = new(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
|
||||
|
||||
_sessions.TryAdd(session, 0);
|
||||
|
||||
@ -135,8 +137,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||
|
||||
if (device == 0)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application,
|
||||
$"SDL2 open audio device initialization failed with error \"{SDL_GetError()}\"");
|
||||
Logger.Error?.Print(LogClass.Application, $"SDL2 open audio device initialization failed with error \"{SDL_GetError()}\"");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -156,6 +157,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
|
@ -12,19 +12,19 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||
{
|
||||
class SDL2HardwareDeviceSession : HardwareDeviceSessionOutputBase
|
||||
{
|
||||
private SDL2HardwareDeviceDriver _driver;
|
||||
private ConcurrentQueue<SDL2AudioBuffer> _queuedBuffers;
|
||||
private DynamicRingBuffer _ringBuffer;
|
||||
private readonly SDL2HardwareDeviceDriver _driver;
|
||||
private readonly ConcurrentQueue<SDL2AudioBuffer> _queuedBuffers;
|
||||
private readonly DynamicRingBuffer _ringBuffer;
|
||||
private ulong _playedSampleCount;
|
||||
private ManualResetEvent _updateRequiredEvent;
|
||||
private readonly ManualResetEvent _updateRequiredEvent;
|
||||
private uint _outputStream;
|
||||
private bool _hasSetupError;
|
||||
private SDL_AudioCallback _callbackDelegate;
|
||||
private int _bytesPerFrame;
|
||||
private readonly SDL_AudioCallback _callbackDelegate;
|
||||
private readonly int _bytesPerFrame;
|
||||
private uint _sampleCount;
|
||||
private bool _started;
|
||||
private float _volume;
|
||||
private ushort _nativeSampleFormat;
|
||||
private readonly ushort _nativeSampleFormat;
|
||||
|
||||
public SDL2HardwareDeviceSession(SDL2HardwareDeviceDriver driver, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount, float requestedVolume) : base(memoryManager, requestedSampleFormat, requestedSampleRate, requestedChannelCount)
|
||||
{
|
||||
@ -72,7 +72,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||
|
||||
private unsafe void Update(IntPtr userdata, IntPtr stream, int streamLength)
|
||||
{
|
||||
Span<byte> streamSpan = new Span<byte>((void*)stream, streamLength);
|
||||
Span<byte> streamSpan = new((void*)stream, streamLength);
|
||||
|
||||
int maxFrameCount = (int)GetSampleCount(streamLength);
|
||||
int bufferedFrames = _ringBuffer.Length / _bytesPerFrame;
|
||||
@ -82,7 +82,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||
if (frameCount == 0)
|
||||
{
|
||||
// SDL2 left the responsibility to the user to clear the buffer.
|
||||
streamSpan.Fill(0);
|
||||
streamSpan.Clear();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -96,7 +96,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||
IntPtr pStreamSrc = (IntPtr)p;
|
||||
|
||||
// Zero the dest buffer
|
||||
streamSpan.Fill(0);
|
||||
streamSpan.Clear();
|
||||
|
||||
// Apply volume to written data
|
||||
SDL_MixAudioFormat(stream, pStreamSrc, _nativeSampleFormat, (uint)samples.Length, (int)(_volume * SDL_MIX_MAXVOLUME));
|
||||
@ -151,7 +151,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||
|
||||
if (_outputStream != 0)
|
||||
{
|
||||
SDL2AudioBuffer driverBuffer = new SDL2AudioBuffer(buffer.DataPointer, GetSampleCount(buffer));
|
||||
SDL2AudioBuffer driverBuffer = new(buffer.DataPointer, GetSampleCount(buffer));
|
||||
|
||||
_ringBuffer.Write(buffer.Data, 0, buffer.Data.Length);
|
||||
|
||||
|
@ -10,19 +10,19 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
||||
private const string LibraryName = "libsoundio";
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public unsafe delegate void OnDeviceChangeNativeDelegate(IntPtr ctx);
|
||||
public delegate void OnDeviceChangeNativeDelegate(IntPtr ctx);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public unsafe delegate void OnBackendDisconnectedDelegate(IntPtr ctx, SoundIoError err);
|
||||
public delegate void OnBackendDisconnectedDelegate(IntPtr ctx, SoundIoError err);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public unsafe delegate void OnEventsSignalDelegate(IntPtr ctx);
|
||||
public delegate void OnEventsSignalDelegate(IntPtr ctx);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public unsafe delegate void EmitRtPrioWarningDelegate();
|
||||
public delegate void EmitRtPrioWarningDelegate();
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public unsafe delegate void JackCallbackDelegate(IntPtr msg);
|
||||
public delegate void JackCallbackDelegate(IntPtr msg);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct SoundIoStruct
|
||||
@ -110,69 +110,69 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
||||
}
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
public static partial IntPtr soundio_create();
|
||||
internal static partial IntPtr soundio_create();
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
public static partial SoundIoError soundio_connect(IntPtr ctx);
|
||||
internal static partial SoundIoError soundio_connect(IntPtr ctx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
public static partial void soundio_disconnect(IntPtr ctx);
|
||||
internal static partial void soundio_disconnect(IntPtr ctx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
public static partial void soundio_flush_events(IntPtr ctx);
|
||||
internal static partial void soundio_flush_events(IntPtr ctx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
public static partial int soundio_output_device_count(IntPtr ctx);
|
||||
internal static partial int soundio_output_device_count(IntPtr ctx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
public static partial int soundio_default_output_device_index(IntPtr ctx);
|
||||
internal static partial int soundio_default_output_device_index(IntPtr ctx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
public static partial IntPtr soundio_get_output_device(IntPtr ctx, int index);
|
||||
internal static partial IntPtr soundio_get_output_device(IntPtr ctx, int index);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static partial bool soundio_device_supports_format(IntPtr devCtx, SoundIoFormat format);
|
||||
internal static partial bool soundio_device_supports_format(IntPtr devCtx, SoundIoFormat format);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static partial bool soundio_device_supports_layout(IntPtr devCtx, IntPtr layout);
|
||||
internal static partial bool soundio_device_supports_layout(IntPtr devCtx, IntPtr layout);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static partial bool soundio_device_supports_sample_rate(IntPtr devCtx, int sampleRate);
|
||||
internal static partial bool soundio_device_supports_sample_rate(IntPtr devCtx, int sampleRate);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
public static partial IntPtr soundio_outstream_create(IntPtr devCtx);
|
||||
internal static partial IntPtr soundio_outstream_create(IntPtr devCtx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
public static partial SoundIoError soundio_outstream_open(IntPtr outStreamCtx);
|
||||
internal static partial SoundIoError soundio_outstream_open(IntPtr outStreamCtx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
public static partial SoundIoError soundio_outstream_start(IntPtr outStreamCtx);
|
||||
internal static partial SoundIoError soundio_outstream_start(IntPtr outStreamCtx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
public static partial SoundIoError soundio_outstream_begin_write(IntPtr outStreamCtx, IntPtr areas, IntPtr frameCount);
|
||||
internal static partial SoundIoError soundio_outstream_begin_write(IntPtr outStreamCtx, IntPtr areas, IntPtr frameCount);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
public static partial SoundIoError soundio_outstream_end_write(IntPtr outStreamCtx);
|
||||
internal static partial SoundIoError soundio_outstream_end_write(IntPtr outStreamCtx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
public static partial SoundIoError soundio_outstream_pause(IntPtr devCtx, [MarshalAs(UnmanagedType.Bool)] bool pause);
|
||||
internal static partial SoundIoError soundio_outstream_pause(IntPtr devCtx, [MarshalAs(UnmanagedType.Bool)] bool pause);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
public static partial SoundIoError soundio_outstream_set_volume(IntPtr devCtx, double volume);
|
||||
internal static partial SoundIoError soundio_outstream_set_volume(IntPtr devCtx, double volume);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
public static partial void soundio_outstream_destroy(IntPtr streamCtx);
|
||||
internal static partial void soundio_outstream_destroy(IntPtr streamCtx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
public static partial void soundio_destroy(IntPtr ctx);
|
||||
internal static partial void soundio_destroy(IntPtr ctx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
public static partial IntPtr soundio_channel_layout_get_default(int channelCount);
|
||||
internal static partial IntPtr soundio_channel_layout_get_default(int channelCount);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
public static partial IntPtr soundio_strerror(SoundIoError err);
|
||||
internal static partial IntPtr soundio_strerror(SoundIoError err);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace Ryujinx.Audio.Backends.SoundIo.Native
|
||||
{
|
||||
public enum SoundIoBackend : int
|
||||
public enum SoundIoBackend
|
||||
{
|
||||
None = 0,
|
||||
Jack = 1,
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
@ -141,7 +141,7 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
||||
throw new NotImplementedException("Input direction is currently not implemented on SoundIO backend!");
|
||||
}
|
||||
|
||||
SoundIoHardwareDeviceSession session = new SoundIoHardwareDeviceSession(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
|
||||
SoundIoHardwareDeviceSession session = new(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
|
||||
|
||||
_sessions.TryAdd(session, 0);
|
||||
|
||||
@ -162,7 +162,7 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
||||
SampleFormat.PcmInt24 => SoundIoFormat.S24LE,
|
||||
SampleFormat.PcmInt32 => SoundIoFormat.S32LE,
|
||||
SampleFormat.PcmFloat => SoundIoFormat.Float32LE,
|
||||
_ => throw new ArgumentException ($"Unsupported sample format {format}"),
|
||||
_ => throw new ArgumentException($"Unsupported sample format {format}"),
|
||||
};
|
||||
}
|
||||
|
||||
@ -202,6 +202,8 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
||||
{
|
||||
Dispose(true);
|
||||
|
@ -12,12 +12,12 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
||||
{
|
||||
class SoundIoHardwareDeviceSession : HardwareDeviceSessionOutputBase
|
||||
{
|
||||
private SoundIoHardwareDeviceDriver _driver;
|
||||
private ConcurrentQueue<SoundIoAudioBuffer> _queuedBuffers;
|
||||
private readonly SoundIoHardwareDeviceDriver _driver;
|
||||
private readonly ConcurrentQueue<SoundIoAudioBuffer> _queuedBuffers;
|
||||
private SoundIoOutStreamContext _outputStream;
|
||||
private DynamicRingBuffer _ringBuffer;
|
||||
private readonly DynamicRingBuffer _ringBuffer;
|
||||
private ulong _playedSampleCount;
|
||||
private ManualResetEvent _updateRequiredEvent;
|
||||
private readonly ManualResetEvent _updateRequiredEvent;
|
||||
private int _disposeState;
|
||||
|
||||
public SoundIoHardwareDeviceSession(SoundIoHardwareDeviceDriver driver, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount, float requestedVolume) : base(memoryManager, requestedSampleFormat, requestedSampleRate, requestedChannelCount)
|
||||
@ -54,7 +54,7 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
||||
|
||||
public override void QueueBuffer(AudioBuffer buffer)
|
||||
{
|
||||
SoundIoAudioBuffer driverBuffer = new SoundIoAudioBuffer(buffer.DataPointer, GetSampleCount(buffer));
|
||||
SoundIoAudioBuffer driverBuffer = new(buffer.DataPointer, GetSampleCount(buffer));
|
||||
|
||||
_ringBuffer.Write(buffer.Data, 0, buffer.Data.Length);
|
||||
|
||||
@ -81,7 +81,7 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
||||
_driver.FlushContextEvents();
|
||||
}
|
||||
|
||||
public override void UnregisterBuffer(AudioBuffer buffer) {}
|
||||
public override void UnregisterBuffer(AudioBuffer buffer) { }
|
||||
|
||||
public override bool WasBufferFullyConsumed(AudioBuffer buffer)
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ namespace Ryujinx.Audio
|
||||
/// <summary>
|
||||
/// Lock used to control the waiters registration.
|
||||
/// </summary>
|
||||
private object _lock = new object();
|
||||
private readonly object _lock = new();
|
||||
|
||||
/// <summary>
|
||||
/// Events signaled when the driver played audio buffers.
|
||||
|
@ -10,7 +10,7 @@ namespace Ryujinx.Audio.Backends.Common
|
||||
{
|
||||
private const int RingBufferAlignment = 2048;
|
||||
|
||||
private object _lock = new object();
|
||||
private readonly object _lock = new();
|
||||
|
||||
private byte[] _buffer;
|
||||
private int _size;
|
||||
|
@ -164,7 +164,7 @@ namespace Ryujinx.Audio
|
||||
/// <summary>
|
||||
/// The default coefficients used for standard 5.1 surround to stereo downmixing.
|
||||
/// </summary>
|
||||
public static float[] DefaultSurroundToStereoCoefficients = new float[4]
|
||||
public static readonly float[] DefaultSurroundToStereoCoefficients = new float[4]
|
||||
{
|
||||
1.0f,
|
||||
0.707f,
|
||||
|
@ -14,12 +14,12 @@ namespace Ryujinx.Audio.Input
|
||||
/// </summary>
|
||||
public class AudioInputManager : IDisposable
|
||||
{
|
||||
private object _lock = new object();
|
||||
private readonly object _lock = new();
|
||||
|
||||
/// <summary>
|
||||
/// Lock used for session allocation.
|
||||
/// </summary>
|
||||
private object _sessionLock = new object();
|
||||
private readonly object _sessionLock = new();
|
||||
|
||||
/// <summary>
|
||||
/// The session ids allocation table.
|
||||
|
@ -48,7 +48,7 @@ namespace Ryujinx.Audio.Input
|
||||
/// <summary>
|
||||
/// The lock of the parent.
|
||||
/// </summary>
|
||||
private object _parentLock;
|
||||
private readonly object _parentLock;
|
||||
|
||||
/// <summary>
|
||||
/// The dispose state.
|
||||
|
@ -14,12 +14,12 @@ namespace Ryujinx.Audio.Output
|
||||
/// </summary>
|
||||
public class AudioOutputManager : IDisposable
|
||||
{
|
||||
private object _lock = new object();
|
||||
private readonly object _lock = new();
|
||||
|
||||
/// <summary>
|
||||
/// Lock used for session allocation.
|
||||
/// </summary>
|
||||
private object _sessionLock = new object();
|
||||
private readonly object _sessionLock = new();
|
||||
|
||||
/// <summary>
|
||||
/// The session ids allocation table.
|
||||
|
@ -48,7 +48,7 @@ namespace Ryujinx.Audio.Output
|
||||
/// <summary>
|
||||
/// THe lock of the parent.
|
||||
/// </summary>
|
||||
private object _parentLock;
|
||||
private readonly object _parentLock;
|
||||
|
||||
/// <summary>
|
||||
/// The dispose state.
|
||||
|
@ -26,7 +26,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
public class AudioRenderSystem : IDisposable
|
||||
{
|
||||
private object _lock = new object();
|
||||
private readonly object _lock = new();
|
||||
|
||||
private AudioRendererRenderingDevice _renderingDevice;
|
||||
private AudioRendererExecutionMode _executionMode;
|
||||
|
@ -19,12 +19,12 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <summary>
|
||||
/// Lock used for session allocation.
|
||||
/// </summary>
|
||||
private object _sessionLock = new object();
|
||||
private readonly object _sessionLock = new();
|
||||
|
||||
/// <summary>
|
||||
/// Lock used to control the <see cref="AudioProcessor"/> running state.
|
||||
/// </summary>
|
||||
private object _audioProcessorLock = new object();
|
||||
private readonly object _audioProcessorLock = new();
|
||||
|
||||
/// <summary>
|
||||
/// The session ids allocation table.
|
||||
|
@ -16,7 +16,7 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
|
||||
/// <summary>
|
||||
/// Global lock of the object.
|
||||
/// </summary>
|
||||
private object Lock = new object();
|
||||
private readonly object Lock = new();
|
||||
|
||||
/// <summary>
|
||||
/// The upsamplers instances.
|
||||
|
@ -134,7 +134,7 @@ namespace Ryujinx.Ava
|
||||
_inputManager = inputManager;
|
||||
_accountManager = accountManager;
|
||||
_userChannelPersistence = userChannelPersistence;
|
||||
_renderingThread = new Thread(RenderLoop, 1 * 1024 * 1024) { Name = "GUI.RenderThread" };
|
||||
_renderingThread = new Thread(RenderLoop) { Name = "GUI.RenderThread" };
|
||||
_lastCursorMoveTime = Stopwatch.GetTimestamp();
|
||||
_glLogLevel = ConfigurationState.Instance.Logger.GraphicsDebugLevel;
|
||||
_topLevel = topLevel;
|
||||
|
@ -264,7 +264,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
private void SelectLastScannedAmiibo()
|
||||
{
|
||||
AmiiboApi scanned = _amiiboList.FirstOrDefault(amiibo => amiibo.GetId() == LastScannedAmiiboId);
|
||||
AmiiboApi scanned = _amiiboList.Find(amiibo => amiibo.GetId() == LastScannedAmiiboId);
|
||||
|
||||
SeriesSelectedIndex = AmiiboSeries.IndexOf(scanned.AmiiboSeries);
|
||||
AmiiboSelectedIndex = AmiiboList.IndexOf(scanned);
|
||||
@ -325,7 +325,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
AmiiboApi selected = _amiibos[_amiiboSelectedIndex];
|
||||
|
||||
string imageUrl = _amiiboList.FirstOrDefault(amiibo => amiibo.Equals(selected)).Image;
|
||||
string imageUrl = _amiiboList.Find(amiibo => amiibo.Equals(selected)).Image;
|
||||
|
||||
string usageString = "";
|
||||
|
||||
|
@ -7,7 +7,7 @@ namespace Ryujinx.Common.Configuration.Hid
|
||||
// This enum was duplicated from Ryujinx.HLE.HOS.Services.Hid.PlayerIndex and should be kept identical
|
||||
[Flags]
|
||||
[JsonConverter(typeof(TypedStringEnumConverter<ControllerType>))]
|
||||
public enum ControllerType : int
|
||||
public enum ControllerType
|
||||
{
|
||||
None,
|
||||
ProController = 1 << 0,
|
||||
|
@ -5,7 +5,7 @@ namespace Ryujinx.Common.Configuration.Hid
|
||||
{
|
||||
// This enum was duplicated from Ryujinx.HLE.HOS.Services.Hid.PlayerIndex and should be kept identical
|
||||
[JsonConverter(typeof(TypedStringEnumConverter<PlayerIndex>))]
|
||||
public enum PlayerIndex : int
|
||||
public enum PlayerIndex
|
||||
{
|
||||
Player1 = 0,
|
||||
Player2 = 1,
|
||||
|
@ -5,7 +5,7 @@ using System;
|
||||
|
||||
namespace Ryujinx.Cpu
|
||||
{
|
||||
class AddressSpace : IDisposable
|
||||
public class AddressSpace : IDisposable
|
||||
{
|
||||
private const ulong PageSize = 0x1000;
|
||||
|
||||
@ -154,7 +154,9 @@ namespace Ryujinx.Cpu
|
||||
public MemoryBlock Base { get; }
|
||||
public MemoryBlock Mirror { get; }
|
||||
|
||||
public AddressSpace(MemoryBlock backingMemory, ulong asSize, bool supports4KBPages)
|
||||
public ulong AddressSpaceSize { get; }
|
||||
|
||||
public AddressSpace(MemoryBlock backingMemory, MemoryBlock baseMemory, MemoryBlock mirrorMemory, ulong addressSpaceSize, bool supports4KBPages)
|
||||
{
|
||||
if (!supports4KBPages)
|
||||
{
|
||||
@ -163,17 +165,48 @@ namespace Ryujinx.Cpu
|
||||
_privateTree = new IntrusiveRedBlackTree<PrivateMapping>();
|
||||
_treeLock = new object();
|
||||
|
||||
_mappingTree.Add(new Mapping(0UL, asSize, MappingType.None));
|
||||
_privateTree.Add(new PrivateMapping(0UL, asSize, default));
|
||||
_mappingTree.Add(new Mapping(0UL, addressSpaceSize, MappingType.None));
|
||||
_privateTree.Add(new PrivateMapping(0UL, addressSpaceSize, default));
|
||||
}
|
||||
|
||||
_backingMemory = backingMemory;
|
||||
_supports4KBPages = supports4KBPages;
|
||||
|
||||
Base = baseMemory;
|
||||
Mirror = mirrorMemory;
|
||||
AddressSpaceSize = addressSpaceSize;
|
||||
}
|
||||
|
||||
public static bool TryCreate(MemoryBlock backingMemory, ulong asSize, bool supports4KBPages, out AddressSpace addressSpace)
|
||||
{
|
||||
addressSpace = null;
|
||||
|
||||
MemoryAllocationFlags asFlags = MemoryAllocationFlags.Reserve | MemoryAllocationFlags.ViewCompatible;
|
||||
|
||||
Base = new MemoryBlock(asSize, asFlags);
|
||||
Mirror = new MemoryBlock(asSize, asFlags);
|
||||
ulong minAddressSpaceSize = Math.Min(asSize, 1UL << 36);
|
||||
|
||||
// Attempt to create the address space with expected size or try to reduce it until it succeed.
|
||||
for (ulong addressSpaceSize = asSize; addressSpaceSize >= minAddressSpaceSize; addressSpaceSize >>= 1)
|
||||
{
|
||||
MemoryBlock baseMemory = null;
|
||||
MemoryBlock mirrorMemory = null;
|
||||
|
||||
try
|
||||
{
|
||||
baseMemory = new MemoryBlock(addressSpaceSize, asFlags);
|
||||
mirrorMemory = new MemoryBlock(addressSpaceSize, asFlags);
|
||||
addressSpace = new AddressSpace(backingMemory, baseMemory, mirrorMemory, addressSpaceSize, supports4KBPages);
|
||||
|
||||
break;
|
||||
}
|
||||
catch (SystemException)
|
||||
{
|
||||
baseMemory?.Dispose();
|
||||
mirrorMemory?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return addressSpace != null;
|
||||
}
|
||||
|
||||
public void Map(ulong va, ulong pa, ulong size, MemoryMapFlags flags)
|
||||
|
@ -15,10 +15,10 @@ namespace Ryujinx.Cpu.Jit
|
||||
_impl = new MemoryBlock(size, flags);
|
||||
}
|
||||
|
||||
public bool Commit(ulong offset, ulong size) => _impl.Commit(offset, size);
|
||||
public void Commit(ulong offset, ulong size) => _impl.Commit(offset, size);
|
||||
public void MapAsRx(ulong offset, ulong size) => _impl.Reprotect(offset, size, MemoryPermission.ReadAndExecute);
|
||||
public void MapAsRwx(ulong offset, ulong size) => _impl.Reprotect(offset, size, MemoryPermission.ReadWriteExecute);
|
||||
|
||||
public void Dispose() => _impl.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
@ -38,7 +38,8 @@ namespace Ryujinx.Cpu.Jit
|
||||
private readonly bool _unsafeMode;
|
||||
|
||||
private readonly AddressSpace _addressSpace;
|
||||
private readonly ulong _addressSpaceSize;
|
||||
|
||||
public ulong AddressSpaceSize { get; }
|
||||
|
||||
private readonly PageTable<ulong> _pageTable;
|
||||
|
||||
@ -62,21 +63,21 @@ namespace Ryujinx.Cpu.Jit
|
||||
/// <summary>
|
||||
/// Creates a new instance of the host mapped memory manager.
|
||||
/// </summary>
|
||||
/// <param name="backingMemory">Physical backing memory where virtual memory will be mapped to</param>
|
||||
/// <param name="addressSpaceSize">Size of the address space</param>
|
||||
/// <param name="addressSpace">Address space instance to use</param>
|
||||
/// <param name="unsafeMode">True if unmanaged access should not be masked (unsafe), false otherwise.</param>
|
||||
/// <param name="invalidAccessHandler">Optional function to handle invalid memory accesses</param>
|
||||
public MemoryManagerHostMapped(MemoryBlock backingMemory, ulong addressSpaceSize, bool unsafeMode, InvalidAccessHandler invalidAccessHandler = null)
|
||||
public MemoryManagerHostMapped(AddressSpace addressSpace, bool unsafeMode, InvalidAccessHandler invalidAccessHandler)
|
||||
{
|
||||
_addressSpace = addressSpace;
|
||||
_pageTable = new PageTable<ulong>();
|
||||
_invalidAccessHandler = invalidAccessHandler;
|
||||
_unsafeMode = unsafeMode;
|
||||
_addressSpaceSize = addressSpaceSize;
|
||||
AddressSpaceSize = addressSpace.AddressSpaceSize;
|
||||
|
||||
ulong asSize = PageSize;
|
||||
int asBits = PageBits;
|
||||
|
||||
while (asSize < addressSpaceSize)
|
||||
while (asSize < AddressSpaceSize)
|
||||
{
|
||||
asSize <<= 1;
|
||||
asBits++;
|
||||
@ -86,8 +87,6 @@ namespace Ryujinx.Cpu.Jit
|
||||
|
||||
_pageBitmap = new ulong[1 << (AddressSpaceBits - (PageBits + PageToPteShift))];
|
||||
|
||||
_addressSpace = new AddressSpace(backingMemory, asSize, Supports4KBPages);
|
||||
|
||||
Tracking = new MemoryTracking(this, (int)MemoryBlock.GetPageSize(), invalidAccessHandler);
|
||||
_memoryEh = new MemoryEhMeilleure(_addressSpace.Base, _addressSpace.Mirror, Tracking);
|
||||
}
|
||||
@ -99,7 +98,7 @@ namespace Ryujinx.Cpu.Jit
|
||||
/// <returns>True if the virtual address is part of the addressable space</returns>
|
||||
private bool ValidateAddress(ulong va)
|
||||
{
|
||||
return va < _addressSpaceSize;
|
||||
return va < AddressSpaceSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -111,7 +110,7 @@ namespace Ryujinx.Cpu.Jit
|
||||
private bool ValidateAddressAndSize(ulong va, ulong size)
|
||||
{
|
||||
ulong endVa = va + size;
|
||||
return endVa >= va && endVa >= size && endVa <= _addressSpaceSize;
|
||||
return endVa >= va && endVa >= size && endVa <= AddressSpaceSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Device
|
||||
|
||||
public TState State;
|
||||
|
||||
private uint Size => (uint)(Unsafe.SizeOf<TState>() + RegisterSize - 1) / RegisterSize;
|
||||
private static uint Size => (uint)(Unsafe.SizeOf<TState>() + RegisterSize - 1) / RegisterSize;
|
||||
|
||||
private readonly Func<int>[] _readCallbacks;
|
||||
private readonly Action<int>[] _writeCallbacks;
|
||||
|
@ -56,7 +56,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading
|
||||
private int _refConsumerPtr;
|
||||
|
||||
private Action _interruptAction;
|
||||
private object _interruptLock = new();
|
||||
private readonly object _interruptLock = new();
|
||||
|
||||
public event EventHandler<ScreenCaptureImageInfo> ScreenCaptured;
|
||||
|
||||
|
@ -512,7 +512,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
/// <returns>True if at least one of the handles is dirty</returns>
|
||||
private bool CheckDirty()
|
||||
{
|
||||
return Handles.Any(handle => handle.Dirty);
|
||||
return Array.Exists(Handles, handle => handle.Dirty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -78,7 +78,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
private List<BufferMigration> _sources;
|
||||
private BufferMigration _migrationTarget;
|
||||
|
||||
private object _lock = new object();
|
||||
private readonly object _lock = new();
|
||||
|
||||
/// <summary>
|
||||
/// Whether the modified range list has any entries or not.
|
||||
@ -125,7 +125,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
BufferModifiedRange overlap = overlaps[i];
|
||||
|
||||
|
||||
if (overlap.Address > address)
|
||||
{
|
||||
// The start of the remaining region is uncovered by this overlap. Call the action for it.
|
||||
|
@ -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 = 5080;
|
||||
private const uint CodeGenVersion = 5311;
|
||||
|
||||
private const string SharedTocFileName = "shared.toc";
|
||||
private const string SharedDataFileName = "shared.data";
|
||||
|
@ -12,8 +12,8 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg
|
||||
private readonly AVCodec_decode _decodeFrame;
|
||||
private static readonly FFmpegApi.av_log_set_callback_callback _logFunc;
|
||||
private readonly AVCodec* _codec;
|
||||
private AVPacket* _packet;
|
||||
private AVCodecContext* _context;
|
||||
private readonly AVPacket* _packet;
|
||||
private readonly AVCodecContext* _context;
|
||||
|
||||
public FFmpegContext(AVCodecID codecId)
|
||||
{
|
||||
@ -164,7 +164,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg
|
||||
FFmpegApi.av_packet_free(ppPacket);
|
||||
}
|
||||
|
||||
FFmpegApi.avcodec_close(_context);
|
||||
_ = FFmpegApi.avcodec_close(_context);
|
||||
|
||||
fixed (AVCodecContext** ppContext = &_context)
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.H264
|
||||
|
||||
private readonly byte[] _workBuffer = new byte[WorkBufferSize];
|
||||
|
||||
private FFmpegContext _context = new FFmpegContext(AVCodecID.AV_CODEC_ID_H264);
|
||||
private FFmpegContext _context = new(AVCodecID.AV_CODEC_ID_H264);
|
||||
|
||||
private int _oldOutputWidth;
|
||||
private int _oldOutputHeight;
|
||||
@ -46,7 +46,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.H264
|
||||
byte[] output = new byte[data.Length + prep.Length];
|
||||
|
||||
prep.CopyTo(output);
|
||||
data.CopyTo(new Span<byte>(output).Slice(prep.Length));
|
||||
data.CopyTo(new Span<byte>(output)[prep.Length..]);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@ -84,9 +84,9 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.H264
|
||||
Flush();
|
||||
}
|
||||
|
||||
public Span<byte> AsSpan()
|
||||
public readonly Span<byte> AsSpan()
|
||||
{
|
||||
return new Span<byte>(_workBuffer).Slice(0, _offset);
|
||||
return new Span<byte>(_workBuffer)[.._offset];
|
||||
}
|
||||
|
||||
public void WriteU(uint value, int valueSize) => WriteBits((int)value, valueSize);
|
||||
@ -118,4 +118,4 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.H264
|
||||
WriteBits((int)value, size - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.H264
|
||||
{
|
||||
public static Span<byte> Reconstruct(ref H264PictureInfo pictureInfo, byte[] workBuffer)
|
||||
{
|
||||
H264BitStreamWriter writer = new H264BitStreamWriter(workBuffer);
|
||||
H264BitStreamWriter writer = new(workBuffer);
|
||||
|
||||
// Sequence Parameter Set.
|
||||
writer.WriteU(1, 24);
|
||||
|
@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
{
|
||||
struct AVCodec
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public unsafe byte* Name;
|
||||
public unsafe byte* LongName;
|
||||
public int Type;
|
||||
|
@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
{
|
||||
struct AVCodec501
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public unsafe byte* Name;
|
||||
public unsafe byte* LongName;
|
||||
public int Type;
|
||||
|
@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
{
|
||||
struct AVCodecContext
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public unsafe IntPtr AvClass;
|
||||
public int LogLevelOffset;
|
||||
public int CodecType;
|
||||
|
@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
{
|
||||
struct AVFrame
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public Array8<IntPtr> Data;
|
||||
public Array8<int> LineSize;
|
||||
public IntPtr ExtendedData;
|
||||
|
@ -1,26 +1,24 @@
|
||||
using System;
|
||||
|
||||
using AVBufferRef = System.IntPtr;
|
||||
using AVBufferRef = System.IntPtr;
|
||||
|
||||
namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
{
|
||||
struct AVPacket
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
public unsafe AVBufferRef *Buf;
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public unsafe AVBufferRef* Buf;
|
||||
public long Pts;
|
||||
public long Dts;
|
||||
public unsafe byte* Data;
|
||||
public int Size;
|
||||
public int StreamIndex;
|
||||
public int Flags;
|
||||
public IntPtr SizeData;
|
||||
public AVBufferRef SizeData;
|
||||
public int SizeDataElems;
|
||||
public long Duration;
|
||||
public long Position;
|
||||
public IntPtr Opaque;
|
||||
public unsafe AVBufferRef *OpaqueRef;
|
||||
public AVBufferRef Opaque;
|
||||
public unsafe AVBufferRef* OpaqueRef;
|
||||
public AVRational TimeBase;
|
||||
#pragma warning restore CS0649
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
{
|
||||
struct FFCodec<T> where T: struct
|
||||
struct FFCodec<T> where T : struct
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public T Base;
|
||||
public int CapsInternalOrCbType;
|
||||
public int PrivDataSize;
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
{
|
||||
struct FFCodecLegacy<T> where T: struct
|
||||
struct FFCodecLegacy<T> where T : struct
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public T Base;
|
||||
public uint CapsInternalOrCbType;
|
||||
public int PrivDataSize;
|
||||
|
@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
public const string AvCodecLibraryName = "avcodec";
|
||||
public const string AvUtilLibraryName = "avutil";
|
||||
|
||||
private static readonly Dictionary<string, (int, int)> _librariesWhitelist = new Dictionary<string, (int, int)>
|
||||
private static readonly Dictionary<string, (int, int)> _librariesWhitelist = new()
|
||||
{
|
||||
{ AvCodecLibraryName, (58, 59) },
|
||||
{ AvUtilLibraryName, (56, 57) }
|
||||
@ -61,9 +61,8 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
{
|
||||
NativeLibrary.SetDllImportResolver(typeof(FFmpegApi).Assembly, (name, assembly, path) =>
|
||||
{
|
||||
IntPtr handle;
|
||||
|
||||
if (name == AvUtilLibraryName && TryLoadWhitelistedLibrary(AvUtilLibraryName, assembly, path, out handle))
|
||||
if (name == AvUtilLibraryName && TryLoadWhitelistedLibrary(AvUtilLibraryName, assembly, path, out nint handle))
|
||||
{
|
||||
return handle;
|
||||
}
|
||||
@ -106,7 +105,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
internal static unsafe partial AVCodecContext* avcodec_alloc_context3(AVCodec* codec);
|
||||
|
||||
[LibraryImport(AvCodecLibraryName)]
|
||||
internal static unsafe partial int avcodec_open2(AVCodecContext* avctx, AVCodec* codec, void **options);
|
||||
internal static unsafe partial int avcodec_open2(AVCodecContext* avctx, AVCodec* codec, void** options);
|
||||
|
||||
[LibraryImport(AvCodecLibraryName)]
|
||||
internal static unsafe partial int avcodec_close(AVCodecContext* avctx);
|
||||
|
@ -11,9 +11,9 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg
|
||||
public int RequestedWidth { get; }
|
||||
public int RequestedHeight { get; }
|
||||
|
||||
public Plane YPlane => new Plane((IntPtr)Frame->Data[0], Stride * Height);
|
||||
public Plane UPlane => new Plane((IntPtr)Frame->Data[1], UvStride * UvHeight);
|
||||
public Plane VPlane => new Plane((IntPtr)Frame->Data[2], UvStride * UvHeight);
|
||||
public Plane YPlane => new((IntPtr)Frame->Data[0], Stride * Height);
|
||||
public Plane UPlane => new((IntPtr)Frame->Data[1], UvStride * UvHeight);
|
||||
public Plane VPlane => new((IntPtr)Frame->Data[2], UvStride * UvHeight);
|
||||
|
||||
public FrameField Field => Frame->InterlacedFrame != 0 ? FrameField.Interlaced : FrameField.Progressive;
|
||||
|
||||
|
@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Vp8
|
||||
{
|
||||
public bool IsHardwareAccelerated => false;
|
||||
|
||||
private readonly FFmpegContext _context = new FFmpegContext(AVCodecID.AV_CODEC_ID_VP8);
|
||||
private readonly FFmpegContext _context = new(AVCodecID.AV_CODEC_ID_VP8);
|
||||
|
||||
public ISurface CreateSurface(int width, int height)
|
||||
{
|
||||
@ -43,11 +43,11 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Vp8
|
||||
frame[9] = (byte)((pictureInfo.FrameHeight >> 8) & 0x3F);
|
||||
}
|
||||
|
||||
bitstream.CopyTo(new Span<byte>(frame).Slice(uncompHeaderSize));
|
||||
bitstream.CopyTo(new Span<byte>(frame)[uncompHeaderSize..]);
|
||||
|
||||
return _context.DecodeFrame(outSurf, frame) == 0;
|
||||
}
|
||||
|
||||
public void Dispose() => _context.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,12 +17,12 @@ namespace Ryujinx.Graphics.Nvdec
|
||||
|
||||
ReadOnlySpan<byte> bitstream = rm.Gmm.DeviceGetSpan(state.SetInBufBaseOffset, (int)pictureInfo.BitstreamSize);
|
||||
|
||||
int width = (int)pictureInfo.PicWidthInMbs * MbSizeInPixels;
|
||||
int width = (int)pictureInfo.PicWidthInMbs * MbSizeInPixels;
|
||||
int height = (int)pictureInfo.PicHeightInMbs * MbSizeInPixels;
|
||||
|
||||
int surfaceIndex = (int)pictureInfo.OutputSurfaceIndex;
|
||||
|
||||
uint lumaOffset = state.SetPictureLumaOffset[surfaceIndex];
|
||||
uint lumaOffset = state.SetPictureLumaOffset[surfaceIndex];
|
||||
uint chromaOffset = state.SetPictureChromaOffset[surfaceIndex];
|
||||
|
||||
Decoder decoder = context.GetH264Decoder();
|
||||
@ -36,7 +36,7 @@ namespace Ryujinx.Graphics.Nvdec
|
||||
SurfaceWriter.Write(
|
||||
rm.Gmm,
|
||||
outputSurface,
|
||||
lumaOffset + pictureInfo.LumaFrameOffset,
|
||||
lumaOffset + pictureInfo.LumaFrameOffset,
|
||||
chromaOffset + pictureInfo.ChromaFrameOffset);
|
||||
}
|
||||
else
|
||||
@ -44,9 +44,9 @@ namespace Ryujinx.Graphics.Nvdec
|
||||
SurfaceWriter.WriteInterlaced(
|
||||
rm.Gmm,
|
||||
outputSurface,
|
||||
lumaOffset + pictureInfo.LumaTopFieldOffset,
|
||||
lumaOffset + pictureInfo.LumaTopFieldOffset,
|
||||
chromaOffset + pictureInfo.ChromaTopFieldOffset,
|
||||
lumaOffset + pictureInfo.LumaBottomFieldOffset,
|
||||
lumaOffset + pictureInfo.LumaBottomFieldOffset,
|
||||
chromaOffset + pictureInfo.ChromaBottomFieldOffset);
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ namespace Ryujinx.Graphics.Nvdec.Image
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
OffsetCalculator calc = new OffsetCalculator(width, height, 0, false, 2, 2);
|
||||
OffsetCalculator calc = new(width, height, 0, false, 2, 2);
|
||||
|
||||
if (Sse2.IsSupported)
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ namespace Ryujinx.Graphics.Nvdec.Image
|
||||
|
||||
WriteLuma(
|
||||
lumaBottom.Memory.Span,
|
||||
surface.YPlane.AsSpan().Slice(surface.Stride),
|
||||
surface.YPlane.AsSpan()[surface.Stride..],
|
||||
surface.Stride * 2,
|
||||
surface.Width,
|
||||
surface.Height / 2);
|
||||
@ -80,8 +80,8 @@ namespace Ryujinx.Graphics.Nvdec.Image
|
||||
|
||||
WriteChroma(
|
||||
chromaBottom.Memory.Span,
|
||||
surface.UPlane.AsSpan().Slice(surface.UvStride),
|
||||
surface.VPlane.AsSpan().Slice(surface.UvStride),
|
||||
surface.UPlane.AsSpan()[surface.UvStride..],
|
||||
surface.VPlane.AsSpan()[surface.UvStride..],
|
||||
surface.UvStride * 2,
|
||||
surface.UvWidth,
|
||||
surface.UvHeight / 2);
|
||||
@ -100,7 +100,7 @@ namespace Ryujinx.Graphics.Nvdec.Image
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
OffsetCalculator calc = new OffsetCalculator(width, height, 0, false, 2, 2);
|
||||
OffsetCalculator calc = new(width, height, 0, false, 2, 2);
|
||||
|
||||
if (Sse2.IsSupported)
|
||||
{
|
||||
|
@ -26,4 +26,4 @@ namespace Ryujinx.Graphics.Nvdec
|
||||
_vp8Decoder = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Nvdec
|
||||
private readonly DeviceState<NvdecRegisters> _state;
|
||||
|
||||
private long _currentId;
|
||||
private ConcurrentDictionary<long, NvdecDecoderContext> _contexts;
|
||||
private readonly ConcurrentDictionary<long, NvdecDecoderContext> _contexts;
|
||||
private NvdecDecoderContext _currentContext;
|
||||
|
||||
public NvdecDevice(MemoryManager gmm)
|
||||
|
@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Nvdec
|
||||
{
|
||||
struct NvdecRegisters
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public Array64<uint> Reserved0;
|
||||
public uint Nop;
|
||||
public Array63<uint> Reserved104;
|
||||
|
@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Nvdec
|
||||
{
|
||||
struct NvdecStatus
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public uint MbsCorrectlyDecoded;
|
||||
public uint MbsInError;
|
||||
public uint Reserved;
|
||||
@ -13,4 +13,4 @@ namespace Ryujinx.Graphics.Nvdec
|
||||
public uint SliceHeaderErrorCode;
|
||||
#pragma warning restore CS0649
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,9 @@ namespace Ryujinx.Graphics.Nvdec.Types.H264
|
||||
{
|
||||
struct PictureInfo
|
||||
{
|
||||
#pragma warning disable CS0169, CS0649
|
||||
#pragma warning disable IDE0051, CS0169, CS0649 // Remove unused private member
|
||||
Array18<uint> Unknown0;
|
||||
#pragma warning restore IDE0051
|
||||
public uint BitstreamSize;
|
||||
public uint NumSlices;
|
||||
public uint Unknown50;
|
||||
@ -50,24 +51,24 @@ namespace Ryujinx.Graphics.Nvdec.Types.H264
|
||||
public Array10<uint> Unknown2D4;
|
||||
#pragma warning restore CS0169, CS0649
|
||||
|
||||
public bool MbAdaptiveFrameFieldFlag => (Flags & (1 << 0)) != 0;
|
||||
public bool Direct8x8InferenceFlag => (Flags & (1 << 1)) != 0;
|
||||
public bool WeightedPredFlag => (Flags & (1 << 2)) != 0;
|
||||
public bool ConstrainedIntraPredFlag => (Flags & (1 << 3)) != 0;
|
||||
public bool IsReference => (Flags & (1 << 4)) != 0;
|
||||
public bool FieldPicFlag => (Flags & (1 << 5)) != 0;
|
||||
public bool BottomFieldFlag => (Flags & (1 << 6)) != 0;
|
||||
public uint Log2MaxFrameNumMinus4 => (uint)(Flags >> 8) & 0xf;
|
||||
public ushort ChromaFormatIdc => (ushort)((Flags >> 12) & 3);
|
||||
public uint PicOrderCntType => (uint)(Flags >> 14) & 3;
|
||||
public int PicInitQpMinus26 => ExtractSx(Flags, 16, 6);
|
||||
public int ChromaQpIndexOffset => ExtractSx(Flags, 22, 5);
|
||||
public int SecondChromaQpIndexOffset => ExtractSx(Flags, 27, 5);
|
||||
public uint WeightedBipredIdc => (uint)(Flags >> 32) & 3;
|
||||
public uint OutputSurfaceIndex => (uint)(Flags >> 34) & 0x7f;
|
||||
public uint ColIndex => (uint)(Flags >> 41) & 0x1f;
|
||||
public ushort FrameNum => (ushort)(Flags >> 46);
|
||||
public bool QpprimeYZeroTransformBypassFlag => (Flags2 & (1 << 1)) != 0;
|
||||
public readonly bool MbAdaptiveFrameFieldFlag => (Flags & (1 << 0)) != 0;
|
||||
public readonly bool Direct8x8InferenceFlag => (Flags & (1 << 1)) != 0;
|
||||
public readonly bool WeightedPredFlag => (Flags & (1 << 2)) != 0;
|
||||
public readonly bool ConstrainedIntraPredFlag => (Flags & (1 << 3)) != 0;
|
||||
public readonly bool IsReference => (Flags & (1 << 4)) != 0;
|
||||
public readonly bool FieldPicFlag => (Flags & (1 << 5)) != 0;
|
||||
public readonly bool BottomFieldFlag => (Flags & (1 << 6)) != 0;
|
||||
public readonly uint Log2MaxFrameNumMinus4 => (uint)(Flags >> 8) & 0xf;
|
||||
public readonly ushort ChromaFormatIdc => (ushort)((Flags >> 12) & 3);
|
||||
public readonly uint PicOrderCntType => (uint)(Flags >> 14) & 3;
|
||||
public readonly int PicInitQpMinus26 => ExtractSx(Flags, 16, 6);
|
||||
public readonly int ChromaQpIndexOffset => ExtractSx(Flags, 22, 5);
|
||||
public readonly int SecondChromaQpIndexOffset => ExtractSx(Flags, 27, 5);
|
||||
public readonly uint WeightedBipredIdc => (uint)(Flags >> 32) & 3;
|
||||
public readonly uint OutputSurfaceIndex => (uint)(Flags >> 34) & 0x7f;
|
||||
public readonly uint ColIndex => (uint)(Flags >> 41) & 0x1f;
|
||||
public readonly ushort FrameNum => (ushort)(Flags >> 46);
|
||||
public readonly bool QpprimeYZeroTransformBypassFlag => (Flags2 & (1 << 1)) != 0;
|
||||
|
||||
private static int ExtractSx(ulong packed, int lsb, int length)
|
||||
{
|
||||
|
@ -4,12 +4,12 @@ namespace Ryujinx.Graphics.Nvdec.Types.H264
|
||||
{
|
||||
struct ReferenceFrame
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public uint Flags;
|
||||
public Array2<uint> FieldOrderCnt;
|
||||
public uint FrameNum;
|
||||
#pragma warning restore CS0649
|
||||
|
||||
public uint OutputSurfaceIndex => (uint)Flags & 0x7f;
|
||||
public readonly uint OutputSurfaceIndex => (uint)Flags & 0x7f;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Nvdec.Types.Vp8
|
||||
{
|
||||
struct PictureInfo
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public Array13<uint> Unknown0;
|
||||
public uint GpTimerTimeoutValue;
|
||||
public ushort FrameWidth;
|
||||
|
@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Nvdec.Types.Vp9
|
||||
{
|
||||
struct EntropyProbs
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public Array10<Array10<Array8<byte>>> KfYModeProbE0ToE7;
|
||||
public Array10<Array10<byte>> KfYModeProbE8;
|
||||
public Array3<byte> Padding384;
|
||||
|
@ -2,7 +2,7 @@
|
||||
{
|
||||
struct FrameSize
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public ushort Width;
|
||||
public ushort Height;
|
||||
public ushort LumaPitch;
|
||||
|
@ -2,7 +2,7 @@
|
||||
{
|
||||
struct FrameStats
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public uint Unknown0;
|
||||
public uint Unknown4;
|
||||
public uint Pass2CycleCount;
|
||||
|
@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Nvdec.Types.Vp9
|
||||
{
|
||||
struct LoopFilter
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public byte ModeRefDeltaEnabled;
|
||||
public Array4<sbyte> RefDeltas;
|
||||
public Array2<sbyte> ModeDeltas;
|
||||
|
@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Nvdec.Types.Vp9
|
||||
{
|
||||
struct PictureInfo
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public Array12<uint> Unknown0;
|
||||
public uint BitstreamSize;
|
||||
public uint IsEncrypted;
|
||||
@ -44,7 +44,7 @@ namespace Ryujinx.Graphics.Nvdec.Types.Vp9
|
||||
public uint UnknownFC;
|
||||
#pragma warning restore CS0649
|
||||
|
||||
public uint BitDepth => (SurfaceParams >> 1) & 0xf;
|
||||
public readonly uint BitDepth => (SurfaceParams >> 1) & 0xf;
|
||||
|
||||
public Vp9PictureInfo Convert()
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Nvdec.Types.Vp9
|
||||
{
|
||||
struct Segmentation
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public byte Enabled;
|
||||
public byte UpdateMap;
|
||||
public byte TemporalUpdate;
|
||||
|
@ -30,4 +30,4 @@ namespace Ryujinx.Graphics.Nvdec
|
||||
rm.Cache.Put(outputSurface);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Nvdec
|
||||
{
|
||||
static class Vp9Decoder
|
||||
{
|
||||
private static Decoder _decoder = new Decoder();
|
||||
private static readonly Decoder _decoder = new();
|
||||
|
||||
public unsafe static void Decode(ResourceManager rm, ref NvdecRegisters state)
|
||||
{
|
||||
@ -25,9 +25,9 @@ namespace Ryujinx.Graphics.Nvdec
|
||||
return rm.Cache.Get(_decoder, lumaOffset, chromaOffset, size.Width, size.Height);
|
||||
}
|
||||
|
||||
ISurface lastSurface = Rent(state.SetPictureLumaOffset[0], state.SetPictureChromaOffset[0], pictureInfo.LastFrameSize);
|
||||
ISurface goldenSurface = Rent(state.SetPictureLumaOffset[1], state.SetPictureChromaOffset[1], pictureInfo.GoldenFrameSize);
|
||||
ISurface altSurface = Rent(state.SetPictureLumaOffset[2], state.SetPictureChromaOffset[2], pictureInfo.AltFrameSize);
|
||||
ISurface lastSurface = Rent(state.SetPictureLumaOffset[0], state.SetPictureChromaOffset[0], pictureInfo.LastFrameSize);
|
||||
ISurface goldenSurface = Rent(state.SetPictureLumaOffset[1], state.SetPictureChromaOffset[1], pictureInfo.GoldenFrameSize);
|
||||
ISurface altSurface = Rent(state.SetPictureLumaOffset[2], state.SetPictureChromaOffset[2], pictureInfo.AltFrameSize);
|
||||
ISurface currentSurface = Rent(state.SetPictureLumaOffset[3], state.SetPictureChromaOffset[3], pictureInfo.CurrentFrameSize);
|
||||
|
||||
Vp9PictureInfo info = pictureInfo.Convert();
|
||||
@ -54,7 +54,7 @@ namespace Ryujinx.Graphics.Nvdec
|
||||
|
||||
Span<Vp9MvRef> mvsOut = MemoryMarshal.Cast<byte, Vp9MvRef>(mvsRegion.Memory.Span);
|
||||
|
||||
uint lumaOffset = state.SetPictureLumaOffset[3];
|
||||
uint lumaOffset = state.SetPictureLumaOffset[3];
|
||||
uint chromaOffset = state.SetPictureChromaOffset[3];
|
||||
|
||||
if (_decoder.Decode(ref info, currentSurface, bitstream, mvsIn, mvsOut))
|
||||
|
@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries
|
||||
private ulong _accumulatedCounter;
|
||||
private int _waiterCount;
|
||||
|
||||
private object _lock = new object();
|
||||
private readonly object _lock = new();
|
||||
|
||||
private Queue<BufferedQuery> _queryPool;
|
||||
private AutoResetEvent _queuedEvent = new AutoResetEvent(false);
|
||||
|
@ -24,7 +24,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries
|
||||
private bool _hostAccessReserved = false;
|
||||
private int _refCount = 1; // Starts with a reference from the counter queue.
|
||||
|
||||
private object _lock = new object();
|
||||
private readonly object _lock = new();
|
||||
private ulong _result = ulong.MaxValue;
|
||||
private double _divisor = 1f;
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||
{
|
||||
private const int DisposedLiveFrames = 2;
|
||||
|
||||
private readonly object _lock = new object();
|
||||
private readonly object _lock = new();
|
||||
private readonly Dictionary<TextureCreateInfo, List<DisposedTexture>> _textures = new Dictionary<TextureCreateInfo, List<DisposedTexture>>();
|
||||
|
||||
/// <summary>
|
||||
|
@ -71,40 +71,10 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||
context.AppendLine($"const int {DefaultNames.UndefinedName} = 0;");
|
||||
context.AppendLine();
|
||||
|
||||
if (context.Config.Stage == ShaderStage.Compute)
|
||||
{
|
||||
int localMemorySize = BitUtils.DivRoundUp(context.Config.GpuAccessor.QueryComputeLocalMemorySize(), 4);
|
||||
|
||||
if (localMemorySize != 0)
|
||||
{
|
||||
string localMemorySizeStr = NumberFormatter.FormatInt(localMemorySize);
|
||||
|
||||
context.AppendLine($"uint {DefaultNames.LocalMemoryName}[{localMemorySizeStr}];");
|
||||
context.AppendLine();
|
||||
}
|
||||
|
||||
int sharedMemorySize = BitUtils.DivRoundUp(context.Config.GpuAccessor.QueryComputeSharedMemorySize(), 4);
|
||||
|
||||
if (sharedMemorySize != 0)
|
||||
{
|
||||
string sharedMemorySizeStr = NumberFormatter.FormatInt(sharedMemorySize);
|
||||
|
||||
context.AppendLine($"shared uint {DefaultNames.SharedMemoryName}[{sharedMemorySizeStr}];");
|
||||
context.AppendLine();
|
||||
}
|
||||
}
|
||||
else if (context.Config.LocalMemorySize != 0)
|
||||
{
|
||||
int localMemorySize = BitUtils.DivRoundUp(context.Config.LocalMemorySize, 4);
|
||||
|
||||
string localMemorySizeStr = NumberFormatter.FormatInt(localMemorySize);
|
||||
|
||||
context.AppendLine($"uint {DefaultNames.LocalMemoryName}[{localMemorySizeStr}];");
|
||||
context.AppendLine();
|
||||
}
|
||||
|
||||
DeclareConstantBuffers(context, context.Config.Properties.ConstantBuffers.Values);
|
||||
DeclareStorageBuffers(context, context.Config.Properties.StorageBuffers.Values);
|
||||
DeclareMemories(context, context.Config.Properties.LocalMemories.Values, isShared: false);
|
||||
DeclareMemories(context, context.Config.Properties.SharedMemories.Values, isShared: true);
|
||||
|
||||
var textureDescriptors = context.Config.GetTextureDescriptors();
|
||||
if (textureDescriptors.Length != 0)
|
||||
@ -238,11 +208,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||
context.AppendLine();
|
||||
}
|
||||
|
||||
if ((info.HelperFunctionsMask & HelperFunctionsMask.AtomicMinMaxS32Shared) != 0)
|
||||
{
|
||||
AppendHelperFunction(context, "Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/AtomicMinMaxS32Shared.glsl");
|
||||
}
|
||||
|
||||
if ((info.HelperFunctionsMask & HelperFunctionsMask.MultiplyHighS32) != 0)
|
||||
{
|
||||
AppendHelperFunction(context, "Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/MultiplyHighS32.glsl");
|
||||
@ -273,11 +238,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||
AppendHelperFunction(context, "Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/ShuffleXor.glsl");
|
||||
}
|
||||
|
||||
if ((info.HelperFunctionsMask & HelperFunctionsMask.StoreSharedSmallInt) != 0)
|
||||
{
|
||||
AppendHelperFunction(context, "Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/StoreSharedSmallInt.glsl");
|
||||
}
|
||||
|
||||
if ((info.HelperFunctionsMask & HelperFunctionsMask.SwizzleAdd) != 0)
|
||||
{
|
||||
AppendHelperFunction(context, "Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/SwizzleAdd.glsl");
|
||||
@ -358,7 +318,14 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||
_ => "std430"
|
||||
};
|
||||
|
||||
context.AppendLine($"layout (binding = {buffer.Binding}, {layout}) {declType} _{buffer.Name}");
|
||||
string set = string.Empty;
|
||||
|
||||
if (context.Config.Options.TargetApi == TargetApi.Vulkan)
|
||||
{
|
||||
set = $"set = {buffer.Set}, ";
|
||||
}
|
||||
|
||||
context.AppendLine($"layout ({set}binding = {buffer.Binding}, {layout}) {declType} _{buffer.Name}");
|
||||
context.EnterScope();
|
||||
|
||||
foreach (StructureField field in buffer.Type.Fields)
|
||||
@ -391,6 +358,27 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||
}
|
||||
}
|
||||
|
||||
private static void DeclareMemories(CodeGenContext context, IEnumerable<MemoryDefinition> memories, bool isShared)
|
||||
{
|
||||
string prefix = isShared ? "shared " : string.Empty;
|
||||
|
||||
foreach (MemoryDefinition memory in memories)
|
||||
{
|
||||
string typeName = GetVarTypeName(context, memory.Type & ~AggregateType.Array);
|
||||
|
||||
if (memory.ArrayLength > 0)
|
||||
{
|
||||
string arraySize = memory.ArrayLength.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
context.AppendLine($"{prefix}{typeName} {memory.Name}[{arraySize}];");
|
||||
}
|
||||
else
|
||||
{
|
||||
context.AppendLine($"{prefix}{typeName} {memory.Name}[];");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void DeclareSamplers(CodeGenContext context, TextureDescriptor[] descriptors)
|
||||
{
|
||||
int arraySize = 0;
|
||||
@ -717,7 +705,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||
string code = EmbeddedResources.ReadAllText(filename);
|
||||
|
||||
code = code.Replace("\t", CodeGenContext.Tab);
|
||||
code = code.Replace("$SHARED_MEM$", DefaultNames.SharedMemoryName);
|
||||
|
||||
if (context.Config.GpuAccessor.QueryHostSupportsShaderBallot())
|
||||
{
|
||||
|
@ -11,9 +11,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||
public const string IAttributePrefix = "in_attr";
|
||||
public const string OAttributePrefix = "out_attr";
|
||||
|
||||
public const string LocalMemoryName = "local_mem";
|
||||
public const string SharedMemoryName = "shared_mem";
|
||||
|
||||
public const string ArgumentNamePrefix = "a";
|
||||
|
||||
public const string UndefinedName = "undef";
|
||||
|
@ -1,21 +0,0 @@
|
||||
int Helper_AtomicMaxS32(int offset, int value)
|
||||
{
|
||||
uint oldValue, newValue;
|
||||
do
|
||||
{
|
||||
oldValue = $SHARED_MEM$[offset];
|
||||
newValue = uint(max(int(oldValue), value));
|
||||
} while (atomicCompSwap($SHARED_MEM$[offset], oldValue, newValue) != oldValue);
|
||||
return int(oldValue);
|
||||
}
|
||||
|
||||
int Helper_AtomicMinS32(int offset, int value)
|
||||
{
|
||||
uint oldValue, newValue;
|
||||
do
|
||||
{
|
||||
oldValue = $SHARED_MEM$[offset];
|
||||
newValue = uint(min(int(oldValue), value));
|
||||
} while (atomicCompSwap($SHARED_MEM$[offset], oldValue, newValue) != oldValue);
|
||||
return int(oldValue);
|
||||
}
|
@ -2,9 +2,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||
{
|
||||
static class HelperFunctionNames
|
||||
{
|
||||
public static string AtomicMaxS32 = "Helper_AtomicMaxS32";
|
||||
public static string AtomicMinS32 = "Helper_AtomicMinS32";
|
||||
|
||||
public static string MultiplyHighS32 = "Helper_MultiplyHighS32";
|
||||
public static string MultiplyHighU32 = "Helper_MultiplyHighU32";
|
||||
|
||||
@ -13,10 +10,5 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||
public static string ShuffleUp = "Helper_ShuffleUp";
|
||||
public static string ShuffleXor = "Helper_ShuffleXor";
|
||||
public static string SwizzleAdd = "Helper_SwizzleAdd";
|
||||
|
||||
public static string StoreShared16 = "Helper_StoreShared16";
|
||||
public static string StoreShared8 = "Helper_StoreShared8";
|
||||
public static string StoreStorage16 = "Helper_StoreStorage16";
|
||||
public static string StoreStorage8 = "Helper_StoreStorage8";
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
void Helper_StoreShared16(int offset, uint value)
|
||||
{
|
||||
int wordOffset = offset >> 2;
|
||||
int bitOffset = (offset & 3) * 8;
|
||||
uint oldValue, newValue;
|
||||
do
|
||||
{
|
||||
oldValue = $SHARED_MEM$[wordOffset];
|
||||
newValue = bitfieldInsert(oldValue, value, bitOffset, 16);
|
||||
} while (atomicCompSwap($SHARED_MEM$[wordOffset], oldValue, newValue) != oldValue);
|
||||
}
|
||||
|
||||
void Helper_StoreShared8(int offset, uint value)
|
||||
{
|
||||
int wordOffset = offset >> 2;
|
||||
int bitOffset = (offset & 3) * 8;
|
||||
uint oldValue, newValue;
|
||||
do
|
||||
{
|
||||
oldValue = $SHARED_MEM$[wordOffset];
|
||||
newValue = bitfieldInsert(oldValue, value, bitOffset, 8);
|
||||
} while (atomicCompSwap($SHARED_MEM$[wordOffset], oldValue, newValue) != oldValue);
|
||||
}
|
@ -68,7 +68,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||
|
||||
string args = string.Empty;
|
||||
|
||||
if (atomic && operation.StorageKind == StorageKind.StorageBuffer)
|
||||
if (atomic && (operation.StorageKind == StorageKind.StorageBuffer || operation.StorageKind == StorageKind.SharedMemory))
|
||||
{
|
||||
args = GenerateLoadOrStore(context, operation, isStore: false);
|
||||
|
||||
@ -81,23 +81,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||
args += ", " + GetSoureExpr(context, operation.GetSource(argIndex), dstType);
|
||||
}
|
||||
}
|
||||
else if (atomic && operation.StorageKind == StorageKind.SharedMemory)
|
||||
{
|
||||
args = LoadShared(context, operation);
|
||||
|
||||
// For shared memory access, the second argument is unused and should be ignored.
|
||||
// It is there to make both storage and shared access have the same number of arguments.
|
||||
// For storage, both inputs are consumed when the argument index is 0, so we should skip it here.
|
||||
|
||||
for (int argIndex = 2; argIndex < arity; argIndex++)
|
||||
{
|
||||
args += ", ";
|
||||
|
||||
AggregateType dstType = GetSrcVarType(inst, argIndex);
|
||||
|
||||
args += GetSoureExpr(context, operation.GetSource(argIndex), dstType);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int argIndex = 0; argIndex < arity; argIndex++)
|
||||
@ -179,12 +162,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||
case Instruction.Load:
|
||||
return Load(context, operation);
|
||||
|
||||
case Instruction.LoadLocal:
|
||||
return LoadLocal(context, operation);
|
||||
|
||||
case Instruction.LoadShared:
|
||||
return LoadShared(context, operation);
|
||||
|
||||
case Instruction.Lod:
|
||||
return Lod(context, operation);
|
||||
|
||||
@ -200,18 +177,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||
case Instruction.Store:
|
||||
return Store(context, operation);
|
||||
|
||||
case Instruction.StoreLocal:
|
||||
return StoreLocal(context, operation);
|
||||
|
||||
case Instruction.StoreShared:
|
||||
return StoreShared(context, operation);
|
||||
|
||||
case Instruction.StoreShared16:
|
||||
return StoreShared16(context, operation);
|
||||
|
||||
case Instruction.StoreShared8:
|
||||
return StoreShared8(context, operation);
|
||||
|
||||
case Instruction.TextureSample:
|
||||
return TextureSample(context, operation);
|
||||
|
||||
|
@ -17,9 +17,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||
Add(Instruction.AtomicAdd, InstType.AtomicBinary, "atomicAdd");
|
||||
Add(Instruction.AtomicAnd, InstType.AtomicBinary, "atomicAnd");
|
||||
Add(Instruction.AtomicCompareAndSwap, InstType.AtomicTernary, "atomicCompSwap");
|
||||
Add(Instruction.AtomicMaxS32, InstType.CallTernary, HelperFunctionNames.AtomicMaxS32);
|
||||
Add(Instruction.AtomicMaxU32, InstType.AtomicBinary, "atomicMax");
|
||||
Add(Instruction.AtomicMinS32, InstType.CallTernary, HelperFunctionNames.AtomicMinS32);
|
||||
Add(Instruction.AtomicMinU32, InstType.AtomicBinary, "atomicMin");
|
||||
Add(Instruction.AtomicOr, InstType.AtomicBinary, "atomicOr");
|
||||
Add(Instruction.AtomicSwap, InstType.AtomicBinary, "atomicExchange");
|
||||
@ -83,8 +81,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||
Add(Instruction.ImageAtomic, InstType.Special);
|
||||
Add(Instruction.IsNan, InstType.CallUnary, "isnan");
|
||||
Add(Instruction.Load, InstType.Special);
|
||||
Add(Instruction.LoadLocal, InstType.Special);
|
||||
Add(Instruction.LoadShared, InstType.Special);
|
||||
Add(Instruction.Lod, InstType.Special);
|
||||
Add(Instruction.LogarithmB2, InstType.CallUnary, "log2");
|
||||
Add(Instruction.LogicalAnd, InstType.OpBinaryCom, "&&", 9);
|
||||
@ -118,10 +114,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||
Add(Instruction.Sine, InstType.CallUnary, "sin");
|
||||
Add(Instruction.SquareRoot, InstType.CallUnary, "sqrt");
|
||||
Add(Instruction.Store, InstType.Special);
|
||||
Add(Instruction.StoreLocal, InstType.Special);
|
||||
Add(Instruction.StoreShared, InstType.Special);
|
||||
Add(Instruction.StoreShared16, InstType.Special);
|
||||
Add(Instruction.StoreShared8, InstType.Special);
|
||||
Add(Instruction.Subtract, InstType.OpBinary, "-", 2);
|
||||
Add(Instruction.SwizzleAdd, InstType.CallTernary, HelperFunctionNames.SwizzleAdd);
|
||||
Add(Instruction.TextureSample, InstType.Special);
|
||||
|
@ -191,25 +191,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||
return GenerateLoadOrStore(context, operation, isStore: false);
|
||||
}
|
||||
|
||||
public static string LoadLocal(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
return LoadLocalOrShared(context, operation, DefaultNames.LocalMemoryName);
|
||||
}
|
||||
|
||||
public static string LoadShared(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
return LoadLocalOrShared(context, operation, DefaultNames.SharedMemoryName);
|
||||
}
|
||||
|
||||
private static string LoadLocalOrShared(CodeGenContext context, AstOperation operation, string arrayName)
|
||||
{
|
||||
IAstNode src1 = operation.GetSource(0);
|
||||
|
||||
string offsetExpr = GetSoureExpr(context, src1, GetSrcVarType(operation.Inst, 0));
|
||||
|
||||
return $"{arrayName}[{offsetExpr}]";
|
||||
}
|
||||
|
||||
public static string Lod(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
AstTextureOperation texOp = (AstTextureOperation)operation;
|
||||
@ -263,58 +244,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||
return GenerateLoadOrStore(context, operation, isStore: true);
|
||||
}
|
||||
|
||||
public static string StoreLocal(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
return StoreLocalOrShared(context, operation, DefaultNames.LocalMemoryName);
|
||||
}
|
||||
|
||||
public static string StoreShared(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
return StoreLocalOrShared(context, operation, DefaultNames.SharedMemoryName);
|
||||
}
|
||||
|
||||
private static string StoreLocalOrShared(CodeGenContext context, AstOperation operation, string arrayName)
|
||||
{
|
||||
IAstNode src1 = operation.GetSource(0);
|
||||
IAstNode src2 = operation.GetSource(1);
|
||||
|
||||
string offsetExpr = GetSoureExpr(context, src1, GetSrcVarType(operation.Inst, 0));
|
||||
|
||||
AggregateType srcType = OperandManager.GetNodeDestType(context, src2);
|
||||
|
||||
string src = TypeConversion.ReinterpretCast(context, src2, srcType, AggregateType.U32);
|
||||
|
||||
return $"{arrayName}[{offsetExpr}] = {src}";
|
||||
}
|
||||
|
||||
public static string StoreShared16(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
IAstNode src1 = operation.GetSource(0);
|
||||
IAstNode src2 = operation.GetSource(1);
|
||||
|
||||
string offsetExpr = GetSoureExpr(context, src1, GetSrcVarType(operation.Inst, 0));
|
||||
|
||||
AggregateType srcType = OperandManager.GetNodeDestType(context, src2);
|
||||
|
||||
string src = TypeConversion.ReinterpretCast(context, src2, srcType, AggregateType.U32);
|
||||
|
||||
return $"{HelperFunctionNames.StoreShared16}({offsetExpr}, {src})";
|
||||
}
|
||||
|
||||
public static string StoreShared8(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
IAstNode src1 = operation.GetSource(0);
|
||||
IAstNode src2 = operation.GetSource(1);
|
||||
|
||||
string offsetExpr = GetSoureExpr(context, src1, GetSrcVarType(operation.Inst, 0));
|
||||
|
||||
AggregateType srcType = OperandManager.GetNodeDestType(context, src2);
|
||||
|
||||
string src = TypeConversion.ReinterpretCast(context, src2, srcType, AggregateType.U32);
|
||||
|
||||
return $"{HelperFunctionNames.StoreShared8}({offsetExpr}, {src})";
|
||||
}
|
||||
|
||||
public static string TextureSample(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
AstTextureOperation texOp = (AstTextureOperation)operation;
|
||||
@ -675,6 +604,21 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||
varType = field.Type;
|
||||
break;
|
||||
|
||||
case StorageKind.LocalMemory:
|
||||
case StorageKind.SharedMemory:
|
||||
if (!(operation.GetSource(srcIndex++) is AstOperand bindingId) || bindingId.Type != OperandType.Constant)
|
||||
{
|
||||
throw new InvalidOperationException($"First input of {operation.Inst} with {storageKind} storage must be a constant operand.");
|
||||
}
|
||||
|
||||
MemoryDefinition memory = storageKind == StorageKind.LocalMemory
|
||||
? context.Config.Properties.LocalMemories[bindingId.Value]
|
||||
: context.Config.Properties.SharedMemories[bindingId.Value];
|
||||
|
||||
varName = memory.Name;
|
||||
varType = memory.Type;
|
||||
break;
|
||||
|
||||
case StorageKind.Input:
|
||||
case StorageKind.InputPerPatch:
|
||||
case StorageKind.Output:
|
||||
|
@ -113,7 +113,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||
|
||||
if (node is AstOperation operation)
|
||||
{
|
||||
if (operation.Inst == Instruction.Load)
|
||||
if (operation.Inst == Instruction.Load || operation.Inst.IsAtomic())
|
||||
{
|
||||
switch (operation.StorageKind)
|
||||
{
|
||||
@ -136,6 +136,19 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||
|
||||
return field.Type & AggregateType.ElementTypeMask;
|
||||
|
||||
case StorageKind.LocalMemory:
|
||||
case StorageKind.SharedMemory:
|
||||
if (!(operation.GetSource(0) is AstOperand bindingId) || bindingId.Type != OperandType.Constant)
|
||||
{
|
||||
throw new InvalidOperationException($"First input of {operation.Inst} with {operation.StorageKind} storage must be a constant operand.");
|
||||
}
|
||||
|
||||
MemoryDefinition memory = operation.StorageKind == StorageKind.LocalMemory
|
||||
? context.Config.Properties.LocalMemories[bindingId.Value]
|
||||
: context.Config.Properties.SharedMemories[bindingId.Value];
|
||||
|
||||
return memory.Type & AggregateType.ElementTypeMask;
|
||||
|
||||
case StorageKind.Input:
|
||||
case StorageKind.InputPerPatch:
|
||||
case StorageKind.Output:
|
||||
|
@ -25,8 +25,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
|
||||
public Dictionary<int, Instruction> ConstantBuffers { get; } = new Dictionary<int, Instruction>();
|
||||
public Dictionary<int, Instruction> StorageBuffers { get; } = new Dictionary<int, Instruction>();
|
||||
public Instruction LocalMemory { get; set; }
|
||||
public Instruction SharedMemory { get; set; }
|
||||
public Dictionary<int, Instruction> LocalMemories { get; } = new Dictionary<int, Instruction>();
|
||||
public Dictionary<int, Instruction> SharedMemories { get; } = new Dictionary<int, Instruction>();
|
||||
public Dictionary<TextureMeta, SamplerType> SamplersTypes { get; } = new Dictionary<TextureMeta, SamplerType>();
|
||||
public Dictionary<TextureMeta, (Instruction, Instruction, Instruction)> Samplers { get; } = new Dictionary<TextureMeta, (Instruction, Instruction, Instruction)>();
|
||||
public Dictionary<TextureMeta, (Instruction, Instruction)> Images { get; } = new Dictionary<TextureMeta, (Instruction, Instruction)>();
|
||||
@ -35,7 +35,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
public Dictionary<IoDefinition, Instruction> InputsPerPatch { get; } = new Dictionary<IoDefinition, Instruction>();
|
||||
public Dictionary<IoDefinition, Instruction> OutputsPerPatch { get; } = new Dictionary<IoDefinition, Instruction>();
|
||||
|
||||
public Instruction CoordTemp { get; set; }
|
||||
public StructuredFunction CurrentFunction { get; set; }
|
||||
private readonly Dictionary<AstOperand, Instruction> _locals = new Dictionary<AstOperand, Instruction>();
|
||||
private readonly Dictionary<int, Instruction[]> _localForArgs = new Dictionary<int, Instruction[]>();
|
||||
|
@ -6,7 +6,6 @@ using Spv.Generator;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using static Spv.Specification;
|
||||
using SpvInstruction = Spv.Generator.Instruction;
|
||||
@ -44,13 +43,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
context.AddLocalVariable(spvLocal);
|
||||
context.DeclareLocal(local, spvLocal);
|
||||
}
|
||||
|
||||
var ivector2Type = context.TypeVector(context.TypeS32(), 2);
|
||||
var coordTempPointerType = context.TypePointer(StorageClass.Function, ivector2Type);
|
||||
var coordTemp = context.Variable(coordTempPointerType, StorageClass.Function);
|
||||
|
||||
context.AddLocalVariable(coordTemp);
|
||||
context.CoordTemp = coordTemp;
|
||||
}
|
||||
|
||||
public static void DeclareLocalForArgs(CodeGenContext context, List<StructuredFunction> functions)
|
||||
@ -77,54 +69,30 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
|
||||
public static void DeclareAll(CodeGenContext context, StructuredProgramInfo info)
|
||||
{
|
||||
if (context.Config.Stage == ShaderStage.Compute)
|
||||
{
|
||||
int localMemorySize = BitUtils.DivRoundUp(context.Config.GpuAccessor.QueryComputeLocalMemorySize(), 4);
|
||||
|
||||
if (localMemorySize != 0)
|
||||
{
|
||||
DeclareLocalMemory(context, localMemorySize);
|
||||
}
|
||||
|
||||
int sharedMemorySize = BitUtils.DivRoundUp(context.Config.GpuAccessor.QueryComputeSharedMemorySize(), 4);
|
||||
|
||||
if (sharedMemorySize != 0)
|
||||
{
|
||||
DeclareSharedMemory(context, sharedMemorySize);
|
||||
}
|
||||
}
|
||||
else if (context.Config.LocalMemorySize != 0)
|
||||
{
|
||||
int localMemorySize = BitUtils.DivRoundUp(context.Config.LocalMemorySize, 4);
|
||||
DeclareLocalMemory(context, localMemorySize);
|
||||
}
|
||||
|
||||
DeclareConstantBuffers(context, context.Config.Properties.ConstantBuffers.Values);
|
||||
DeclareStorageBuffers(context, context.Config.Properties.StorageBuffers.Values);
|
||||
DeclareMemories(context, context.Config.Properties.LocalMemories, context.LocalMemories, StorageClass.Private);
|
||||
DeclareMemories(context, context.Config.Properties.SharedMemories, context.SharedMemories, StorageClass.Workgroup);
|
||||
DeclareSamplers(context, context.Config.GetTextureDescriptors());
|
||||
DeclareImages(context, context.Config.GetImageDescriptors());
|
||||
DeclareInputsAndOutputs(context, info);
|
||||
}
|
||||
|
||||
private static void DeclareLocalMemory(CodeGenContext context, int size)
|
||||
private static void DeclareMemories(
|
||||
CodeGenContext context,
|
||||
IReadOnlyDictionary<int, MemoryDefinition> memories,
|
||||
Dictionary<int, SpvInstruction> dict,
|
||||
StorageClass storage)
|
||||
{
|
||||
context.LocalMemory = DeclareMemory(context, StorageClass.Private, size);
|
||||
}
|
||||
foreach ((int id, MemoryDefinition memory) in memories)
|
||||
{
|
||||
var pointerType = context.TypePointer(storage, context.GetType(memory.Type, memory.ArrayLength));
|
||||
var variable = context.Variable(pointerType, storage);
|
||||
|
||||
private static void DeclareSharedMemory(CodeGenContext context, int size)
|
||||
{
|
||||
context.SharedMemory = DeclareMemory(context, StorageClass.Workgroup, size);
|
||||
}
|
||||
context.AddGlobalVariable(variable);
|
||||
|
||||
private static SpvInstruction DeclareMemory(CodeGenContext context, StorageClass storage, int size)
|
||||
{
|
||||
var arrayType = context.TypeArray(context.TypeU32(), context.Constant(context.TypeU32(), size));
|
||||
var pointerType = context.TypePointer(storage, arrayType);
|
||||
var variable = context.Variable(pointerType, storage);
|
||||
|
||||
context.AddGlobalVariable(variable);
|
||||
|
||||
return variable;
|
||||
dict.Add(id, variable);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DeclareConstantBuffers(CodeGenContext context, IEnumerable<BufferDefinition> buffers)
|
||||
|
@ -97,8 +97,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
Add(Instruction.ImageStore, GenerateImageStore);
|
||||
Add(Instruction.IsNan, GenerateIsNan);
|
||||
Add(Instruction.Load, GenerateLoad);
|
||||
Add(Instruction.LoadLocal, GenerateLoadLocal);
|
||||
Add(Instruction.LoadShared, GenerateLoadShared);
|
||||
Add(Instruction.Lod, GenerateLod);
|
||||
Add(Instruction.LogarithmB2, GenerateLogarithmB2);
|
||||
Add(Instruction.LogicalAnd, GenerateLogicalAnd);
|
||||
@ -132,10 +130,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
Add(Instruction.Sine, GenerateSine);
|
||||
Add(Instruction.SquareRoot, GenerateSquareRoot);
|
||||
Add(Instruction.Store, GenerateStore);
|
||||
Add(Instruction.StoreLocal, GenerateStoreLocal);
|
||||
Add(Instruction.StoreShared, GenerateStoreShared);
|
||||
Add(Instruction.StoreShared16, GenerateStoreShared16);
|
||||
Add(Instruction.StoreShared8, GenerateStoreShared8);
|
||||
Add(Instruction.Subtract, GenerateSubtract);
|
||||
Add(Instruction.SwizzleAdd, GenerateSwizzleAdd);
|
||||
Add(Instruction.TextureSample, GenerateTextureSample);
|
||||
@ -871,30 +865,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
return GenerateLoadOrStore(context, operation, isStore: false);
|
||||
}
|
||||
|
||||
private static OperationResult GenerateLoadLocal(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
return GenerateLoadLocalOrShared(context, operation, StorageClass.Private, context.LocalMemory);
|
||||
}
|
||||
|
||||
private static OperationResult GenerateLoadShared(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
return GenerateLoadLocalOrShared(context, operation, StorageClass.Workgroup, context.SharedMemory);
|
||||
}
|
||||
|
||||
private static OperationResult GenerateLoadLocalOrShared(
|
||||
CodeGenContext context,
|
||||
AstOperation operation,
|
||||
StorageClass storageClass,
|
||||
SpvInstruction memory)
|
||||
{
|
||||
var offset = context.Get(AggregateType.S32, operation.GetSource(0));
|
||||
|
||||
var elemPointer = context.AccessChain(context.TypePointer(storageClass, context.TypeU32()), memory, offset);
|
||||
var value = context.Load(context.TypeU32(), elemPointer);
|
||||
|
||||
return new OperationResult(AggregateType.U32, value);
|
||||
}
|
||||
|
||||
private static OperationResult GenerateLod(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
AstTextureOperation texOp = (AstTextureOperation)operation;
|
||||
@ -1268,45 +1238,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
return GenerateLoadOrStore(context, operation, isStore: true);
|
||||
}
|
||||
|
||||
private static OperationResult GenerateStoreLocal(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
return GenerateStoreLocalOrShared(context, operation, StorageClass.Private, context.LocalMemory);
|
||||
}
|
||||
|
||||
private static OperationResult GenerateStoreShared(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
return GenerateStoreLocalOrShared(context, operation, StorageClass.Workgroup, context.SharedMemory);
|
||||
}
|
||||
|
||||
private static OperationResult GenerateStoreLocalOrShared(
|
||||
CodeGenContext context,
|
||||
AstOperation operation,
|
||||
StorageClass storageClass,
|
||||
SpvInstruction memory)
|
||||
{
|
||||
var offset = context.Get(AggregateType.S32, operation.GetSource(0));
|
||||
var value = context.Get(AggregateType.U32, operation.GetSource(1));
|
||||
|
||||
var elemPointer = context.AccessChain(context.TypePointer(storageClass, context.TypeU32()), memory, offset);
|
||||
context.Store(elemPointer, value);
|
||||
|
||||
return OperationResult.Invalid;
|
||||
}
|
||||
|
||||
private static OperationResult GenerateStoreShared16(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
GenerateStoreSharedSmallInt(context, operation, 16);
|
||||
|
||||
return OperationResult.Invalid;
|
||||
}
|
||||
|
||||
private static OperationResult GenerateStoreShared8(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
GenerateStoreSharedSmallInt(context, operation, 8);
|
||||
|
||||
return OperationResult.Invalid;
|
||||
}
|
||||
|
||||
private static OperationResult GenerateSubtract(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
return GenerateBinary(context, operation, context.Delegates.FSub, context.Delegates.ISub);
|
||||
@ -1827,55 +1758,27 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
AstOperation operation,
|
||||
Func<SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction> emitU)
|
||||
{
|
||||
var value = context.GetU32(operation.GetSource(operation.SourcesCount - 1));
|
||||
SpvInstruction elemPointer = GetStoragePointer(context, operation, out AggregateType varType);
|
||||
|
||||
SpvInstruction elemPointer;
|
||||
|
||||
if (operation.StorageKind == StorageKind.StorageBuffer)
|
||||
{
|
||||
elemPointer = GetStoragePointer(context, operation, out _);
|
||||
}
|
||||
else if (operation.StorageKind == StorageKind.SharedMemory)
|
||||
{
|
||||
var offset = context.GetU32(operation.GetSource(0));
|
||||
elemPointer = context.AccessChain(context.TypePointer(StorageClass.Workgroup, context.TypeU32()), context.SharedMemory, offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException($"Invalid storage kind \"{operation.StorageKind}\".");
|
||||
}
|
||||
var value = context.Get(varType, operation.GetSource(operation.SourcesCount - 1));
|
||||
|
||||
var one = context.Constant(context.TypeU32(), 1);
|
||||
var zero = context.Constant(context.TypeU32(), 0);
|
||||
|
||||
return new OperationResult(AggregateType.U32, emitU(context.TypeU32(), elemPointer, one, zero, value));
|
||||
return new OperationResult(varType, emitU(context.GetType(varType), elemPointer, one, zero, value));
|
||||
}
|
||||
|
||||
private static OperationResult GenerateAtomicMemoryCas(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var value0 = context.GetU32(operation.GetSource(operation.SourcesCount - 2));
|
||||
var value1 = context.GetU32(operation.GetSource(operation.SourcesCount - 1));
|
||||
SpvInstruction elemPointer = GetStoragePointer(context, operation, out AggregateType varType);
|
||||
|
||||
SpvInstruction elemPointer;
|
||||
|
||||
if (operation.StorageKind == StorageKind.StorageBuffer)
|
||||
{
|
||||
elemPointer = GetStoragePointer(context, operation, out _);
|
||||
}
|
||||
else if (operation.StorageKind == StorageKind.SharedMemory)
|
||||
{
|
||||
var offset = context.GetU32(operation.GetSource(0));
|
||||
elemPointer = context.AccessChain(context.TypePointer(StorageClass.Workgroup, context.TypeU32()), context.SharedMemory, offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException($"Invalid storage kind \"{operation.StorageKind}\".");
|
||||
}
|
||||
var value0 = context.Get(varType, operation.GetSource(operation.SourcesCount - 2));
|
||||
var value1 = context.Get(varType, operation.GetSource(operation.SourcesCount - 1));
|
||||
|
||||
var one = context.Constant(context.TypeU32(), 1);
|
||||
var zero = context.Constant(context.TypeU32(), 0);
|
||||
|
||||
return new OperationResult(AggregateType.U32, context.AtomicCompareExchange(context.TypeU32(), elemPointer, one, zero, zero, value1, value0));
|
||||
return new OperationResult(varType, context.AtomicCompareExchange(context.GetType(varType), elemPointer, one, zero, zero, value1, value0));
|
||||
}
|
||||
|
||||
private static OperationResult GenerateLoadOrStore(CodeGenContext context, AstOperation operation, bool isStore)
|
||||
@ -1928,6 +1831,27 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
: context.StorageBuffers[bindingIndex.Value];
|
||||
break;
|
||||
|
||||
case StorageKind.LocalMemory:
|
||||
case StorageKind.SharedMemory:
|
||||
if (!(operation.GetSource(srcIndex++) is AstOperand bindingId) || bindingId.Type != OperandType.Constant)
|
||||
{
|
||||
throw new InvalidOperationException($"First input of {operation.Inst} with {storageKind} storage must be a constant operand.");
|
||||
}
|
||||
|
||||
if (storageKind == StorageKind.LocalMemory)
|
||||
{
|
||||
storageClass = StorageClass.Private;
|
||||
varType = context.Config.Properties.LocalMemories[bindingId.Value].Type & AggregateType.ElementTypeMask;
|
||||
baseObj = context.LocalMemories[bindingId.Value];
|
||||
}
|
||||
else
|
||||
{
|
||||
storageClass = StorageClass.Workgroup;
|
||||
varType = context.Config.Properties.SharedMemories[bindingId.Value].Type & AggregateType.ElementTypeMask;
|
||||
baseObj = context.SharedMemories[bindingId.Value];
|
||||
}
|
||||
break;
|
||||
|
||||
case StorageKind.Input:
|
||||
case StorageKind.InputPerPatch:
|
||||
case StorageKind.Output:
|
||||
@ -2048,50 +1972,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||
return context.Load(context.GetType(varType), context.Inputs[ioDefinition]);
|
||||
}
|
||||
|
||||
private static void GenerateStoreSharedSmallInt(CodeGenContext context, AstOperation operation, int bitSize)
|
||||
{
|
||||
var offset = context.Get(AggregateType.U32, operation.GetSource(0));
|
||||
var value = context.Get(AggregateType.U32, operation.GetSource(1));
|
||||
|
||||
var wordOffset = context.ShiftRightLogical(context.TypeU32(), offset, context.Constant(context.TypeU32(), 2));
|
||||
var bitOffset = context.BitwiseAnd(context.TypeU32(), offset, context.Constant(context.TypeU32(), 3));
|
||||
bitOffset = context.ShiftLeftLogical(context.TypeU32(), bitOffset, context.Constant(context.TypeU32(), 3));
|
||||
|
||||
var memory = context.SharedMemory;
|
||||
|
||||
var elemPointer = context.AccessChain(context.TypePointer(StorageClass.Workgroup, context.TypeU32()), memory, wordOffset);
|
||||
|
||||
GenerateStoreSmallInt(context, elemPointer, bitOffset, value, bitSize);
|
||||
}
|
||||
|
||||
private static void GenerateStoreSmallInt(
|
||||
CodeGenContext context,
|
||||
SpvInstruction elemPointer,
|
||||
SpvInstruction bitOffset,
|
||||
SpvInstruction value,
|
||||
int bitSize)
|
||||
{
|
||||
var loopStart = context.Label();
|
||||
var loopEnd = context.Label();
|
||||
|
||||
context.Branch(loopStart);
|
||||
context.AddLabel(loopStart);
|
||||
|
||||
var oldValue = context.Load(context.TypeU32(), elemPointer);
|
||||
var newValue = context.BitFieldInsert(context.TypeU32(), oldValue, value, bitOffset, context.Constant(context.TypeU32(), bitSize));
|
||||
|
||||
var one = context.Constant(context.TypeU32(), 1);
|
||||
var zero = context.Constant(context.TypeU32(), 0);
|
||||
|
||||
var result = context.AtomicCompareExchange(context.TypeU32(), elemPointer, one, zero, zero, newValue, oldValue);
|
||||
var failed = context.INotEqual(context.TypeBool(), result, oldValue);
|
||||
|
||||
context.LoopMerge(loopEnd, loopStart, LoopControlMask.MaskNone);
|
||||
context.BranchConditional(failed, loopStart, loopEnd);
|
||||
|
||||
context.AddLabel(loopEnd);
|
||||
}
|
||||
|
||||
private static OperationResult GetZeroOperationResult(
|
||||
CodeGenContext context,
|
||||
AstTextureOperation texOp,
|
||||
|
@ -247,6 +247,17 @@ namespace Ryujinx.Graphics.Shader.Decoders
|
||||
{
|
||||
block.AddPushOp(op);
|
||||
}
|
||||
else if (op.Name == InstName.Ldl || op.Name == InstName.Stl)
|
||||
{
|
||||
config.SetUsedFeature(FeatureFlags.LocalMemory);
|
||||
}
|
||||
else if (op.Name == InstName.Atoms ||
|
||||
op.Name == InstName.AtomsCas ||
|
||||
op.Name == InstName.Lds ||
|
||||
op.Name == InstName.Sts)
|
||||
{
|
||||
config.SetUsedFeature(FeatureFlags.SharedMemory);
|
||||
}
|
||||
|
||||
block.OpCodes.Add(op);
|
||||
|
||||
|
@ -166,7 +166,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
{
|
||||
// gl_FrontFacing sometimes has incorrect (flipped) values depending how it is accessed on Intel GPUs.
|
||||
// This weird trick makes it behave.
|
||||
res = context.ICompareLess(context.INegate(context.IConvertS32ToFP32(res)), Const(0));
|
||||
res = context.ICompareLess(context.INegate(context.FP32ConvertToS32(context.ConditionalSelect(res, ConstF(1f), ConstF(0f)))), Const(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,12 +10,6 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
{
|
||||
static partial class InstEmit
|
||||
{
|
||||
private enum MemoryRegion
|
||||
{
|
||||
Local,
|
||||
Shared
|
||||
}
|
||||
|
||||
public static void Atom(EmitterContext context)
|
||||
{
|
||||
InstAtom op = context.GetOp<InstAtom>();
|
||||
@ -33,6 +27,12 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
|
||||
public static void Atoms(EmitterContext context)
|
||||
{
|
||||
if (context.Config.Stage != ShaderStage.Compute)
|
||||
{
|
||||
context.Config.GpuAccessor.Log($"Atoms instruction is not valid on \"{context.Config.Stage}\" stage.");
|
||||
return;
|
||||
}
|
||||
|
||||
InstAtoms op = context.GetOp<InstAtoms>();
|
||||
|
||||
Operand offset = context.ShiftRightU32(GetSrcReg(context, op.SrcA), Const(2));
|
||||
@ -51,7 +51,8 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
_ => AtomSize.U32
|
||||
};
|
||||
|
||||
Operand res = EmitAtomicOp(context, StorageKind.SharedMemory, op.AtomOp, size, offset, Const(0), value);
|
||||
Operand id = Const(context.Config.ResourceManager.SharedMemoryId);
|
||||
Operand res = EmitAtomicOp(context, StorageKind.SharedMemory, op.AtomOp, size, id, offset, value);
|
||||
|
||||
context.Copy(GetDest(op.Dest), res);
|
||||
}
|
||||
@ -114,14 +115,20 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
{
|
||||
InstLdl op = context.GetOp<InstLdl>();
|
||||
|
||||
EmitLoad(context, MemoryRegion.Local, op.LsSize, GetSrcReg(context, op.SrcA), op.Dest, Imm24ToSInt(op.Imm24));
|
||||
EmitLoad(context, StorageKind.LocalMemory, op.LsSize, GetSrcReg(context, op.SrcA), op.Dest, Imm24ToSInt(op.Imm24));
|
||||
}
|
||||
|
||||
public static void Lds(EmitterContext context)
|
||||
{
|
||||
if (context.Config.Stage != ShaderStage.Compute)
|
||||
{
|
||||
context.Config.GpuAccessor.Log($"Lds instruction is not valid on \"{context.Config.Stage}\" stage.");
|
||||
return;
|
||||
}
|
||||
|
||||
InstLds op = context.GetOp<InstLds>();
|
||||
|
||||
EmitLoad(context, MemoryRegion.Shared, op.LsSize, GetSrcReg(context, op.SrcA), op.Dest, Imm24ToSInt(op.Imm24));
|
||||
EmitLoad(context, StorageKind.SharedMemory, op.LsSize, GetSrcReg(context, op.SrcA), op.Dest, Imm24ToSInt(op.Imm24));
|
||||
}
|
||||
|
||||
public static void Red(EmitterContext context)
|
||||
@ -144,14 +151,20 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
{
|
||||
InstStl op = context.GetOp<InstStl>();
|
||||
|
||||
EmitStore(context, MemoryRegion.Local, op.LsSize, GetSrcReg(context, op.SrcA), op.Dest, Imm24ToSInt(op.Imm24));
|
||||
EmitStore(context, StorageKind.LocalMemory, op.LsSize, GetSrcReg(context, op.SrcA), op.Dest, Imm24ToSInt(op.Imm24));
|
||||
}
|
||||
|
||||
public static void Sts(EmitterContext context)
|
||||
{
|
||||
if (context.Config.Stage != ShaderStage.Compute)
|
||||
{
|
||||
context.Config.GpuAccessor.Log($"Sts instruction is not valid on \"{context.Config.Stage}\" stage.");
|
||||
return;
|
||||
}
|
||||
|
||||
InstSts op = context.GetOp<InstSts>();
|
||||
|
||||
EmitStore(context, MemoryRegion.Shared, op.LsSize, GetSrcReg(context, op.SrcA), op.Dest, Imm24ToSInt(op.Imm24));
|
||||
EmitStore(context, StorageKind.SharedMemory, op.LsSize, GetSrcReg(context, op.SrcA), op.Dest, Imm24ToSInt(op.Imm24));
|
||||
}
|
||||
|
||||
private static Operand EmitLoadConstant(EmitterContext context, Operand slot, Operand offset)
|
||||
@ -192,8 +205,8 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
StorageKind storageKind,
|
||||
AtomOp op,
|
||||
AtomSize type,
|
||||
Operand addrLow,
|
||||
Operand addrHigh,
|
||||
Operand e0,
|
||||
Operand e1,
|
||||
Operand value)
|
||||
{
|
||||
Operand res = Const(0);
|
||||
@ -203,7 +216,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
case AtomOp.Add:
|
||||
if (type == AtomSize.S32 || type == AtomSize.U32)
|
||||
{
|
||||
res = context.AtomicAdd(storageKind, addrLow, addrHigh, value);
|
||||
res = context.AtomicAdd(storageKind, e0, e1, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -213,7 +226,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
case AtomOp.And:
|
||||
if (type == AtomSize.S32 || type == AtomSize.U32)
|
||||
{
|
||||
res = context.AtomicAnd(storageKind, addrLow, addrHigh, value);
|
||||
res = context.AtomicAnd(storageKind, e0, e1, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -223,7 +236,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
case AtomOp.Xor:
|
||||
if (type == AtomSize.S32 || type == AtomSize.U32)
|
||||
{
|
||||
res = context.AtomicXor(storageKind, addrLow, addrHigh, value);
|
||||
res = context.AtomicXor(storageKind, e0, e1, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -233,7 +246,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
case AtomOp.Or:
|
||||
if (type == AtomSize.S32 || type == AtomSize.U32)
|
||||
{
|
||||
res = context.AtomicOr(storageKind, addrLow, addrHigh, value);
|
||||
res = context.AtomicOr(storageKind, e0, e1, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -243,11 +256,11 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
case AtomOp.Max:
|
||||
if (type == AtomSize.S32)
|
||||
{
|
||||
res = context.AtomicMaxS32(storageKind, addrLow, addrHigh, value);
|
||||
res = context.AtomicMaxS32(storageKind, e0, e1, value);
|
||||
}
|
||||
else if (type == AtomSize.U32)
|
||||
{
|
||||
res = context.AtomicMaxU32(storageKind, addrLow, addrHigh, value);
|
||||
res = context.AtomicMaxU32(storageKind, e0, e1, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -257,11 +270,11 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
case AtomOp.Min:
|
||||
if (type == AtomSize.S32)
|
||||
{
|
||||
res = context.AtomicMinS32(storageKind, addrLow, addrHigh, value);
|
||||
res = context.AtomicMinS32(storageKind, e0, e1, value);
|
||||
}
|
||||
else if (type == AtomSize.U32)
|
||||
{
|
||||
res = context.AtomicMinU32(storageKind, addrLow, addrHigh, value);
|
||||
res = context.AtomicMinU32(storageKind, e0, e1, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -275,7 +288,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
|
||||
private static void EmitLoad(
|
||||
EmitterContext context,
|
||||
MemoryRegion region,
|
||||
StorageKind storageKind,
|
||||
LsSize2 size,
|
||||
Operand srcA,
|
||||
int rd,
|
||||
@ -287,19 +300,19 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
return;
|
||||
}
|
||||
|
||||
int id = storageKind == StorageKind.LocalMemory
|
||||
? context.Config.ResourceManager.LocalMemoryId
|
||||
: context.Config.ResourceManager.SharedMemoryId;
|
||||
bool isSmallInt = size < LsSize2.B32;
|
||||
|
||||
int count = 1;
|
||||
|
||||
switch (size)
|
||||
int count = size switch
|
||||
{
|
||||
case LsSize2.B64: count = 2; break;
|
||||
case LsSize2.B128: count = 4; break;
|
||||
}
|
||||
LsSize2.B64 => 2,
|
||||
LsSize2.B128 => 4,
|
||||
_ => 1
|
||||
};
|
||||
|
||||
Operand baseOffset = context.IAdd(srcA, Const(offset));
|
||||
Operand wordOffset = context.ShiftRightU32(baseOffset, Const(2)); // Word offset = byte offset / 4 (one word = 4 bytes).
|
||||
Operand bitOffset = GetBitOffset(context, baseOffset);
|
||||
Operand baseOffset = context.Copy(srcA);
|
||||
|
||||
for (int index = 0; index < count; index++)
|
||||
{
|
||||
@ -310,14 +323,10 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
break;
|
||||
}
|
||||
|
||||
Operand elemOffset = context.IAdd(wordOffset, Const(index));
|
||||
Operand value = null;
|
||||
|
||||
switch (region)
|
||||
{
|
||||
case MemoryRegion.Local: value = context.LoadLocal(elemOffset); break;
|
||||
case MemoryRegion.Shared: value = context.LoadShared(elemOffset); break;
|
||||
}
|
||||
Operand byteOffset = context.IAdd(baseOffset, Const(offset + index * 4));
|
||||
Operand wordOffset = context.ShiftRightU32(byteOffset, Const(2)); // Word offset = byte offset / 4 (one word = 4 bytes).
|
||||
Operand bitOffset = GetBitOffset(context, byteOffset);
|
||||
Operand value = context.Load(storageKind, id, wordOffset);
|
||||
|
||||
if (isSmallInt)
|
||||
{
|
||||
@ -360,7 +369,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
|
||||
private static void EmitStore(
|
||||
EmitterContext context,
|
||||
MemoryRegion region,
|
||||
StorageKind storageKind,
|
||||
LsSize2 size,
|
||||
Operand srcA,
|
||||
int rd,
|
||||
@ -372,52 +381,54 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
return;
|
||||
}
|
||||
|
||||
int id = storageKind == StorageKind.LocalMemory
|
||||
? context.Config.ResourceManager.LocalMemoryId
|
||||
: context.Config.ResourceManager.SharedMemoryId;
|
||||
bool isSmallInt = size < LsSize2.B32;
|
||||
|
||||
int count = 1;
|
||||
|
||||
switch (size)
|
||||
int count = size switch
|
||||
{
|
||||
case LsSize2.B64: count = 2; break;
|
||||
case LsSize2.B128: count = 4; break;
|
||||
}
|
||||
LsSize2.B64 => 2,
|
||||
LsSize2.B128 => 4,
|
||||
_ => 1
|
||||
};
|
||||
|
||||
Operand baseOffset = context.IAdd(srcA, Const(offset));
|
||||
Operand wordOffset = context.ShiftRightU32(baseOffset, Const(2));
|
||||
Operand bitOffset = GetBitOffset(context, baseOffset);
|
||||
Operand baseOffset = context.Copy(srcA);
|
||||
|
||||
for (int index = 0; index < count; index++)
|
||||
{
|
||||
bool isRz = rd + index >= RegisterConsts.RegisterZeroIndex;
|
||||
|
||||
Operand value = Register(isRz ? rd : rd + index, RegisterType.Gpr);
|
||||
Operand elemOffset = context.IAdd(wordOffset, Const(index));
|
||||
Operand byteOffset = context.IAdd(baseOffset, Const(offset + index * 4));
|
||||
Operand wordOffset = context.ShiftRightU32(byteOffset, Const(2));
|
||||
Operand bitOffset = GetBitOffset(context, byteOffset);
|
||||
|
||||
if (isSmallInt && region == MemoryRegion.Local)
|
||||
if (isSmallInt && storageKind == StorageKind.LocalMemory)
|
||||
{
|
||||
Operand word = context.LoadLocal(elemOffset);
|
||||
Operand word = context.Load(storageKind, id, wordOffset);
|
||||
|
||||
value = InsertSmallInt(context, (LsSize)size, bitOffset, word, value);
|
||||
}
|
||||
|
||||
if (region == MemoryRegion.Local)
|
||||
if (storageKind == StorageKind.LocalMemory)
|
||||
{
|
||||
context.StoreLocal(elemOffset, value);
|
||||
context.Store(storageKind, id, wordOffset, value);
|
||||
}
|
||||
else if (region == MemoryRegion.Shared)
|
||||
else if (storageKind == StorageKind.SharedMemory)
|
||||
{
|
||||
switch (size)
|
||||
{
|
||||
case LsSize2.U8:
|
||||
case LsSize2.S8:
|
||||
context.StoreShared8(baseOffset, value);
|
||||
context.Store(StorageKind.SharedMemory8, id, byteOffset, value);
|
||||
break;
|
||||
case LsSize2.U16:
|
||||
case LsSize2.S16:
|
||||
context.StoreShared16(baseOffset, value);
|
||||
context.Store(StorageKind.SharedMemory16, id, byteOffset, value);
|
||||
break;
|
||||
default:
|
||||
context.StoreShared(elemOffset, value);
|
||||
context.Store(storageKind, id, wordOffset, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -79,8 +79,6 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
|
||||
ImageAtomic,
|
||||
IsNan,
|
||||
Load,
|
||||
LoadLocal,
|
||||
LoadShared,
|
||||
Lod,
|
||||
LogarithmB2,
|
||||
LogicalAnd,
|
||||
@ -115,10 +113,6 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
|
||||
Sine,
|
||||
SquareRoot,
|
||||
Store,
|
||||
StoreLocal,
|
||||
StoreShared,
|
||||
StoreShared16,
|
||||
StoreShared8,
|
||||
Subtract,
|
||||
SwizzleAdd,
|
||||
TextureSample,
|
||||
|
@ -11,12 +11,13 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
|
||||
StorageBuffer,
|
||||
LocalMemory,
|
||||
SharedMemory,
|
||||
SharedMemory8, // TODO: Remove this and store type as a field on the Operation class itself.
|
||||
SharedMemory16, // TODO: Remove this and store type as a field on the Operation class itself.
|
||||
GlobalMemory,
|
||||
// TODO: Remove those and store type as a field on the Operation class itself.
|
||||
GlobalMemoryS8,
|
||||
GlobalMemoryS16,
|
||||
GlobalMemoryU8,
|
||||
GlobalMemoryU16
|
||||
GlobalMemoryS8, // TODO: Remove this and store type as a field on the Operation class itself.
|
||||
GlobalMemoryS16, // TODO: Remove this and store type as a field on the Operation class itself.
|
||||
GlobalMemoryU8, // TODO: Remove this and store type as a field on the Operation class itself.
|
||||
GlobalMemoryU16 // TODO: Remove this and store type as a field on the Operation class itself.
|
||||
}
|
||||
|
||||
static class StorageKindExtensions
|
||||
|
@ -10,14 +10,12 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="CodeGen\Glsl\HelperFunctions\AtomicMinMaxS32Shared.glsl" />
|
||||
<EmbeddedResource Include="CodeGen\Glsl\HelperFunctions\MultiplyHighS32.glsl" />
|
||||
<EmbeddedResource Include="CodeGen\Glsl\HelperFunctions\MultiplyHighU32.glsl" />
|
||||
<EmbeddedResource Include="CodeGen\Glsl\HelperFunctions\Shuffle.glsl" />
|
||||
<EmbeddedResource Include="CodeGen\Glsl\HelperFunctions\ShuffleDown.glsl" />
|
||||
<EmbeddedResource Include="CodeGen\Glsl\HelperFunctions\ShuffleUp.glsl" />
|
||||
<EmbeddedResource Include="CodeGen\Glsl\HelperFunctions\ShuffleXor.glsl" />
|
||||
<EmbeddedResource Include="CodeGen\Glsl\HelperFunctions\StoreSharedSmallInt.glsl" />
|
||||
<EmbeddedResource Include="CodeGen\Glsl\HelperFunctions\SwizzleAdd.glsl" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -5,15 +5,13 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
|
||||
[Flags]
|
||||
enum HelperFunctionsMask
|
||||
{
|
||||
AtomicMinMaxS32Shared = 1 << 0,
|
||||
MultiplyHighS32 = 1 << 2,
|
||||
MultiplyHighU32 = 1 << 3,
|
||||
Shuffle = 1 << 4,
|
||||
ShuffleDown = 1 << 5,
|
||||
ShuffleUp = 1 << 6,
|
||||
ShuffleXor = 1 << 7,
|
||||
StoreSharedSmallInt = 1 << 8,
|
||||
SwizzleAdd = 1 << 10,
|
||||
FSI = 1 << 11
|
||||
MultiplyHighS32 = 1 << 2,
|
||||
MultiplyHighU32 = 1 << 3,
|
||||
Shuffle = 1 << 4,
|
||||
ShuffleDown = 1 << 5,
|
||||
ShuffleUp = 1 << 6,
|
||||
ShuffleXor = 1 << 7,
|
||||
SwizzleAdd = 1 << 10,
|
||||
FSI = 1 << 11
|
||||
}
|
||||
}
|
@ -90,8 +90,6 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
|
||||
Add(Instruction.ImageAtomic, AggregateType.S32);
|
||||
Add(Instruction.IsNan, AggregateType.Bool, AggregateType.Scalar);
|
||||
Add(Instruction.Load, AggregateType.FP32);
|
||||
Add(Instruction.LoadLocal, AggregateType.U32, AggregateType.S32);
|
||||
Add(Instruction.LoadShared, AggregateType.U32, AggregateType.S32);
|
||||
Add(Instruction.Lod, AggregateType.FP32);
|
||||
Add(Instruction.LogarithmB2, AggregateType.Scalar, AggregateType.Scalar);
|
||||
Add(Instruction.LogicalAnd, AggregateType.Bool, AggregateType.Bool, AggregateType.Bool);
|
||||
@ -121,10 +119,6 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
|
||||
Add(Instruction.Sine, AggregateType.Scalar, AggregateType.Scalar);
|
||||
Add(Instruction.SquareRoot, AggregateType.Scalar, AggregateType.Scalar);
|
||||
Add(Instruction.Store, AggregateType.Void);
|
||||
Add(Instruction.StoreLocal, AggregateType.Void, AggregateType.S32, AggregateType.U32);
|
||||
Add(Instruction.StoreShared, AggregateType.Void, AggregateType.S32, AggregateType.U32);
|
||||
Add(Instruction.StoreShared16, AggregateType.Void, AggregateType.S32, AggregateType.U32);
|
||||
Add(Instruction.StoreShared8, AggregateType.Void, AggregateType.S32, AggregateType.U32);
|
||||
Add(Instruction.Subtract, AggregateType.Scalar, AggregateType.Scalar, AggregateType.Scalar);
|
||||
Add(Instruction.SwizzleAdd, AggregateType.FP32, AggregateType.FP32, AggregateType.FP32, AggregateType.S32);
|
||||
Add(Instruction.TextureSample, AggregateType.FP32);
|
||||
|
18
src/Ryujinx.Graphics.Shader/StructuredIr/MemoryDefinition.cs
Normal file
18
src/Ryujinx.Graphics.Shader/StructuredIr/MemoryDefinition.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using Ryujinx.Graphics.Shader.Translation;
|
||||
|
||||
namespace Ryujinx.Graphics.Shader.StructuredIr
|
||||
{
|
||||
readonly struct MemoryDefinition
|
||||
{
|
||||
public string Name { get; }
|
||||
public AggregateType Type { get; }
|
||||
public int ArrayLength { get; }
|
||||
|
||||
public MemoryDefinition(string name, AggregateType type, int arrayLength = 1)
|
||||
{
|
||||
Name = name;
|
||||
Type = type;
|
||||
ArrayLength = arrayLength;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,14 +6,20 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
|
||||
{
|
||||
private readonly Dictionary<int, BufferDefinition> _constantBuffers;
|
||||
private readonly Dictionary<int, BufferDefinition> _storageBuffers;
|
||||
private readonly Dictionary<int, MemoryDefinition> _localMemories;
|
||||
private readonly Dictionary<int, MemoryDefinition> _sharedMemories;
|
||||
|
||||
public IReadOnlyDictionary<int, BufferDefinition> ConstantBuffers => _constantBuffers;
|
||||
public IReadOnlyDictionary<int, BufferDefinition> StorageBuffers => _storageBuffers;
|
||||
public IReadOnlyDictionary<int, MemoryDefinition> LocalMemories => _localMemories;
|
||||
public IReadOnlyDictionary<int, MemoryDefinition> SharedMemories => _sharedMemories;
|
||||
|
||||
public ShaderProperties()
|
||||
{
|
||||
_constantBuffers = new Dictionary<int, BufferDefinition>();
|
||||
_storageBuffers = new Dictionary<int, BufferDefinition>();
|
||||
_localMemories = new Dictionary<int, MemoryDefinition>();
|
||||
_sharedMemories = new Dictionary<int, MemoryDefinition>();
|
||||
}
|
||||
|
||||
public void AddConstantBuffer(int binding, BufferDefinition definition)
|
||||
@ -25,5 +31,21 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
|
||||
{
|
||||
_storageBuffers[binding] = definition;
|
||||
}
|
||||
|
||||
public int AddLocalMemory(MemoryDefinition definition)
|
||||
{
|
||||
int id = _localMemories.Count;
|
||||
_localMemories.Add(id, definition);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public int AddSharedMemory(MemoryDefinition definition)
|
||||
{
|
||||
int id = _sharedMemories.Count;
|
||||
_sharedMemories.Add(id, definition);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
@ -274,13 +274,6 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
|
||||
// decide which helper functions are needed on the final generated code.
|
||||
switch (operation.Inst)
|
||||
{
|
||||
case Instruction.AtomicMaxS32:
|
||||
case Instruction.AtomicMinS32:
|
||||
if (operation.StorageKind == StorageKind.SharedMemory)
|
||||
{
|
||||
context.Info.HelperFunctionsMask |= HelperFunctionsMask.AtomicMinMaxS32Shared;
|
||||
}
|
||||
break;
|
||||
case Instruction.MultiplyHighS32:
|
||||
context.Info.HelperFunctionsMask |= HelperFunctionsMask.MultiplyHighS32;
|
||||
break;
|
||||
@ -299,10 +292,6 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
|
||||
case Instruction.ShuffleXor:
|
||||
context.Info.HelperFunctionsMask |= HelperFunctionsMask.ShuffleXor;
|
||||
break;
|
||||
case Instruction.StoreShared16:
|
||||
case Instruction.StoreShared8:
|
||||
context.Info.HelperFunctionsMask |= HelperFunctionsMask.StoreSharedSmallInt;
|
||||
break;
|
||||
case Instruction.SwizzleAdd:
|
||||
context.Info.HelperFunctionsMask |= HelperFunctionsMask.SwizzleAdd;
|
||||
break;
|
||||
|
@ -67,6 +67,11 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
return context.Add(Instruction.AtomicAnd, storageKind, Local(), Const(binding), e0, e1, value);
|
||||
}
|
||||
|
||||
public static Operand AtomicCompareAndSwap(this EmitterContext context, StorageKind storageKind, int binding, Operand e0, Operand compare, Operand value)
|
||||
{
|
||||
return context.Add(Instruction.AtomicCompareAndSwap, storageKind, Local(), Const(binding), e0, compare, value);
|
||||
}
|
||||
|
||||
public static Operand AtomicCompareAndSwap(this EmitterContext context, StorageKind storageKind, int binding, Operand e0, Operand e1, Operand compare, Operand value)
|
||||
{
|
||||
return context.Add(Instruction.AtomicCompareAndSwap, storageKind, Local(), Const(binding), e0, e1, compare, value);
|
||||
@ -661,16 +666,6 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
: context.Load(storageKind, (int)ioVariable, arrayIndex, elemIndex);
|
||||
}
|
||||
|
||||
public static Operand LoadLocal(this EmitterContext context, Operand a)
|
||||
{
|
||||
return context.Add(Instruction.LoadLocal, Local(), a);
|
||||
}
|
||||
|
||||
public static Operand LoadShared(this EmitterContext context, Operand a)
|
||||
{
|
||||
return context.Add(Instruction.LoadShared, Local(), a);
|
||||
}
|
||||
|
||||
public static Operand MemoryBarrier(this EmitterContext context)
|
||||
{
|
||||
return context.Add(Instruction.MemoryBarrier);
|
||||
@ -753,6 +748,11 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
return context.Add(Instruction.Store, storageKind, null, e0, e1, value);
|
||||
}
|
||||
|
||||
public static Operand Store(this EmitterContext context, StorageKind storageKind, int binding, Operand e0, Operand value)
|
||||
{
|
||||
return context.Add(Instruction.Store, storageKind, null, Const(binding), e0, value);
|
||||
}
|
||||
|
||||
public static Operand Store(this EmitterContext context, StorageKind storageKind, int binding, Operand e0, Operand e1, Operand value)
|
||||
{
|
||||
return context.Add(Instruction.Store, storageKind, null, Const(binding), e0, e1, value);
|
||||
@ -797,26 +797,6 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
: context.Add(Instruction.Store, storageKind, null, Const((int)ioVariable), arrayIndex, elemIndex, value);
|
||||
}
|
||||
|
||||
public static Operand StoreLocal(this EmitterContext context, Operand a, Operand b)
|
||||
{
|
||||
return context.Add(Instruction.StoreLocal, null, a, b);
|
||||
}
|
||||
|
||||
public static Operand StoreShared(this EmitterContext context, Operand a, Operand b)
|
||||
{
|
||||
return context.Add(Instruction.StoreShared, null, a, b);
|
||||
}
|
||||
|
||||
public static Operand StoreShared16(this EmitterContext context, Operand a, Operand b)
|
||||
{
|
||||
return context.Add(Instruction.StoreShared16, null, a, b);
|
||||
}
|
||||
|
||||
public static Operand StoreShared8(this EmitterContext context, Operand a, Operand b)
|
||||
{
|
||||
return context.Add(Instruction.StoreShared8, null, a, b);
|
||||
}
|
||||
|
||||
public static Operand UnpackDouble2x32High(this EmitterContext context, Operand a)
|
||||
{
|
||||
return UnpackDouble2x32(context, a, 1);
|
||||
|
@ -21,6 +21,8 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
RtLayer = 1 << 5,
|
||||
IaIndexing = 1 << 7,
|
||||
OaIndexing = 1 << 8,
|
||||
FixedFuncAttr = 1 << 9
|
||||
FixedFuncAttr = 1 << 9,
|
||||
LocalMemory = 1 << 10,
|
||||
SharedMemory = 1 << 11
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user