diff --git a/src/ARMeilleure/Translation/Delegates.cs b/src/ARMeilleure/Translation/Delegates.cs index 9877c57b1..37f5e35d6 100644 --- a/src/ARMeilleure/Translation/Delegates.cs +++ b/src/ARMeilleure/Translation/Delegates.cs @@ -58,7 +58,7 @@ namespace ARMeilleure.Translation private static string GetKey(MethodInfo info) { - return $"{info.DeclaringType.Name}.{info.Name}"; + return $"{info.DeclaringType?.Name}.{info.Name}"; } private static readonly SortedList _delegates; diff --git a/src/ARMeilleure/Translation/IntervalTree.cs b/src/ARMeilleure/Translation/IntervalTree.cs index 2fa431a8b..c1737765c 100644 --- a/src/ARMeilleure/Translation/IntervalTree.cs +++ b/src/ARMeilleure/Translation/IntervalTree.cs @@ -316,13 +316,16 @@ namespace ARMeilleure.Translation { _root = newNode; } - else if (start.CompareTo(parent.Start) < 0) + else if (parent != null && start.CompareTo(parent.Start) < 0) { parent.Left = newNode; } else { - parent.Right = newNode; + if (parent != null) + { + parent.Right = newNode; + } } PropagateIncrease(newNode); diff --git a/src/Ryujinx.Graphics.GAL/ResourceLayout.cs b/src/Ryujinx.Graphics.GAL/ResourceLayout.cs index b7464ee12..91f74e907 100644 --- a/src/Ryujinx.Graphics.GAL/ResourceLayout.cs +++ b/src/Ryujinx.Graphics.GAL/ResourceLayout.cs @@ -147,7 +147,7 @@ namespace Ryujinx.Graphics.GAL return false; } - if (Descriptors != null) + if (Descriptors != null && other.Descriptors != null) { if (Descriptors.Count != other.Descriptors.Count) { diff --git a/src/Ryujinx.Graphics.Vulkan/BufferMirrorRangeList.cs b/src/Ryujinx.Graphics.Vulkan/BufferMirrorRangeList.cs index 5ce75dc6c..e6521e4d3 100644 --- a/src/Ryujinx.Graphics.Vulkan/BufferMirrorRangeList.cs +++ b/src/Ryujinx.Graphics.Vulkan/BufferMirrorRangeList.cs @@ -240,44 +240,47 @@ namespace Ryujinx.Graphics.Vulkan int dstOffset = 0; bool activeRange = false; - for (int i = 0; i < list.Count; i++) + if (list != null) { - var range = list[i]; - - int rangeEnd = range.Offset + range.Size; - - if (activeRange) + for (int i = 0; i < list.Count; i++) { - if (range.Offset >= endOffset) + var range = list[i]; + + int rangeEnd = range.Offset + range.Size; + + if (activeRange) { - break; + if (range.Offset >= endOffset) + { + break; + } } - } - else - { - if (rangeEnd <= offset) + else { - continue; + if (rangeEnd <= offset) + { + continue; + } + + activeRange = true; } - activeRange = true; - } + int baseSize = range.Offset - srcOffset; - int baseSize = range.Offset - srcOffset; + if (baseSize > 0) + { + baseData.Slice(dstOffset, baseSize).CopyTo(result.Slice(dstOffset, baseSize)); + srcOffset += baseSize; + dstOffset += baseSize; + } - if (baseSize > 0) - { - baseData.Slice(dstOffset, baseSize).CopyTo(result.Slice(dstOffset, baseSize)); - srcOffset += baseSize; - dstOffset += baseSize; - } - - int modSize = Math.Min(rangeEnd - srcOffset, endOffset - srcOffset); - if (modSize != 0) - { - modData.Slice(dstOffset, modSize).CopyTo(result.Slice(dstOffset, modSize)); - srcOffset += modSize; - dstOffset += modSize; + int modSize = Math.Min(rangeEnd - srcOffset, endOffset - srcOffset); + if (modSize != 0) + { + modData.Slice(dstOffset, modSize).CopyTo(result.Slice(dstOffset, modSize)); + srcOffset += modSize; + dstOffset += modSize; + } } } diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs index c4b20a618..2a93f6910 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -1691,6 +1691,11 @@ namespace Ryujinx.Graphics.Vulkan return false; } + if (_renderPass == null) + { + return true; + } + var pipeline = pbp == PipelineBindPoint.Compute ? _newState.CreateComputePipeline(Gd, Device, _program, PipelineCache) : _newState.CreateGraphicsPipeline(Gd, Device, _program, PipelineCache, _renderPass.Get(Cbs).Value); diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineLayoutCache.cs b/src/Ryujinx.Graphics.Vulkan/PipelineLayoutCache.cs index 1132cba03..87b3342af 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineLayoutCache.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineLayoutCache.cs @@ -48,7 +48,7 @@ namespace Ryujinx.Graphics.Vulkan return false; } - if (SetDescriptors != null) + if (SetDescriptors != null && other.SetDescriptors != null) { if (SetDescriptors.Count != other.SetDescriptors.Count) { diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineLayoutCacheEntry.cs b/src/Ryujinx.Graphics.Vulkan/PipelineLayoutCacheEntry.cs index c32daefd0..83443f691 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineLayoutCacheEntry.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineLayoutCacheEntry.cs @@ -231,7 +231,7 @@ namespace Ryujinx.Graphics.Vulkan private void FreeCompletedManualDescriptorSets() { FenceHolder signalledFence = null; - while (_pendingManualDsConsumptions.TryPeek(out var pds) && (pds.Fence == signalledFence || pds.Fence.IsSignaled())) + while (_pendingManualDsConsumptions.TryPeek(out var pds) && pds.Fence != null && (pds.Fence == signalledFence || pds.Fence.IsSignaled())) { signalledFence = pds.Fence; // Already checked - don't need to do it again. var dequeued = _pendingManualDsConsumptions.Dequeue(); diff --git a/src/Ryujinx.Graphics.Vulkan/RenderPassHolder.cs b/src/Ryujinx.Graphics.Vulkan/RenderPassHolder.cs index 2f435e819..4b05a8669 100644 --- a/src/Ryujinx.Graphics.Vulkan/RenderPassHolder.cs +++ b/src/Ryujinx.Graphics.Vulkan/RenderPassHolder.cs @@ -134,14 +134,18 @@ namespace Ryujinx.Graphics.Vulkan // Register this render pass with all render target views. - var textures = fb.GetAttachmentViews(); - - foreach (var texture in textures) + if (fb != null) { - texture.AddRenderPass(key, this); + var textures = fb.GetAttachmentViews(); + + foreach (var texture in textures) + { + texture.AddRenderPass(key, this); + } + + _textures = textures; } - _textures = textures; _key = key; _forcedFences = []; diff --git a/src/Ryujinx.Graphics.Vulkan/ShaderCollection.cs b/src/Ryujinx.Graphics.Vulkan/ShaderCollection.cs index 0e19a0088..26bea9148 100644 --- a/src/Ryujinx.Graphics.Vulkan/ShaderCollection.cs +++ b/src/Ryujinx.Graphics.Vulkan/ShaderCollection.cs @@ -544,7 +544,7 @@ namespace Ryujinx.Graphics.Vulkan pipeline.StagesCount = 1; pipeline.PipelineLayout = PipelineLayout; - pipeline.CreateComputePipeline(_gd, _device, this, (_gd.Pipeline as PipelineBase).PipelineCache); + pipeline.CreateComputePipeline(_gd, _device, this, ((PipelineBase)_gd.Pipeline).PipelineCache); pipeline.Dispose(); } @@ -573,7 +573,7 @@ namespace Ryujinx.Graphics.Vulkan pipeline.StagesCount = (uint)_shaders.Length; pipeline.PipelineLayout = PipelineLayout; - pipeline.CreateGraphicsPipeline(_gd, _device, this, (_gd.Pipeline as PipelineBase).PipelineCache, renderPass.Value, throwOnError: true); + pipeline.CreateGraphicsPipeline(_gd, _device, this, ((PipelineBase)_gd.Pipeline).PipelineCache, renderPass.Value, throwOnError: true); pipeline.Dispose(); } diff --git a/src/Ryujinx.Graphics.Vulkan/StagingBuffer.cs b/src/Ryujinx.Graphics.Vulkan/StagingBuffer.cs index 90a47bb67..75fb38580 100644 --- a/src/Ryujinx.Graphics.Vulkan/StagingBuffer.cs +++ b/src/Ryujinx.Graphics.Vulkan/StagingBuffer.cs @@ -266,7 +266,7 @@ namespace Ryujinx.Graphics.Vulkan public void FreeCompleted() { FenceHolder signalledFence = null; - while (_pendingCopies.TryPeek(out var pc) && (pc.Fence == signalledFence || pc.Fence.IsSignaled())) + while (_pendingCopies.TryPeek(out var pc) && pc.Fence != null && (pc.Fence == signalledFence || pc.Fence.IsSignaled())) { signalledFence = pc.Fence; // Already checked - don't need to do it again. var dequeued = _pendingCopies.Dequeue(); diff --git a/src/Ryujinx.HLE/Debugger/Debugger.cs b/src/Ryujinx.HLE/Debugger/Debugger.cs index 1b5b87e8b..cb724376f 100644 --- a/src/Ryujinx.HLE/Debugger/Debugger.cs +++ b/src/Ryujinx.HLE/Debugger/Debugger.cs @@ -58,7 +58,7 @@ namespace Ryujinx.HLE.Debugger internal KProcess Process => Device.System?.DebugGetApplicationProcess(); internal IDebuggableProcess DebugProcess => Device.System?.DebugGetApplicationProcessDebugInterface(); private KThread[] GetThreads() => DebugProcess.GetThreadUids().Select(x => DebugProcess.GetThread(x)).ToArray(); - internal bool IsProcessAarch32 => DebugProcess.GetThread(gThread.Value).Context.IsAarch32; + internal bool IsProcessAarch32 => gThread != null && DebugProcess.GetThread(gThread.Value).Context.IsAarch32; private KernelContext KernelContext => Device.System.KernelContext; const int GdbRegisterCount64 = 68; diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/IUserLocalCommunicationService.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/IUserLocalCommunicationService.cs index 138d802a5..fa6a3a7e4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/IUserLocalCommunicationService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/IUserLocalCommunicationService.cs @@ -1099,7 +1099,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator } if (!IPAddress.TryParse(ldnServer, out IPAddress ipAddress)) { - ipAddress = Dns.GetHostEntry(ldnServer).AddressList[0]; + ipAddress = Dns.GetHostEntry(ldnServer ?? string.Empty).AddressList[0]; } NetworkClient = new LdnMasterProxyClient(ipAddress.ToString(), LanPlayPort, context.Device.Configuration); } diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/Proxy/P2pProxyServer.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/Proxy/P2pProxyServer.cs index 039d0effa..a84f39320 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/Proxy/P2pProxyServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/Proxy/P2pProxyServer.cs @@ -267,7 +267,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy // Attempt to find matching configuration. If we don't find one, wait for a bit and try again. // Woken by new tokens coming in from the master server. - IPAddress address = (session.Socket.RemoteEndPoint as IPEndPoint).Address; + IPAddress address = (session.Socket.RemoteEndPoint as IPEndPoint)?.Address; byte[] addressBytes = ProxyHelpers.AddressTo16Byte(address); long time; @@ -282,7 +282,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy // Allow any client that has a private IP to connect. (indicated by the server as all 0 in the token) bool isPrivate = waitToken.PhysicalIp.AsSpan().SequenceEqual(new byte[16]); - bool ipEqual = isPrivate || waitToken.AddressFamily == address.AddressFamily && waitToken.PhysicalIp.AsSpan().SequenceEqual(addressBytes); + bool ipEqual = address != null && (isPrivate || waitToken.AddressFamily == address.AddressFamily && waitToken.PhysicalIp.AsSpan().SequenceEqual(addressBytes)); if (ipEqual && waitToken.Token.AsSpan().SequenceEqual(config.Token.AsSpan())) { diff --git a/src/Ryujinx/UI/Controls/ApplicationGridView.axaml.cs b/src/Ryujinx/UI/Controls/ApplicationGridView.axaml.cs index cdb4581e3..96b6de99a 100644 --- a/src/Ryujinx/UI/Controls/ApplicationGridView.axaml.cs +++ b/src/Ryujinx/UI/Controls/ApplicationGridView.axaml.cs @@ -37,7 +37,10 @@ namespace Ryujinx.Ava.UI.Controls private void SearchBox_OnKeyUp(object sender, KeyEventArgs args) { - (DataContext as MainWindowViewModel).SearchText = (sender as TextBox)?.Text; + if (DataContext is MainWindowViewModel model) + { + model.SearchText = (sender as TextBox)?.Text; + } } } } diff --git a/src/Ryujinx/UI/Controls/ApplicationListView.axaml.cs b/src/Ryujinx/UI/Controls/ApplicationListView.axaml.cs index da029bbff..b0fd45e44 100644 --- a/src/Ryujinx/UI/Controls/ApplicationListView.axaml.cs +++ b/src/Ryujinx/UI/Controls/ApplicationListView.axaml.cs @@ -38,7 +38,10 @@ namespace Ryujinx.Ava.UI.Controls private void SearchBox_OnKeyUp(object sender, KeyEventArgs args) { - (DataContext as MainWindowViewModel).SearchText = (sender as TextBox)?.Text; + if (DataContext is MainWindowViewModel model) + { + model.SearchText = (sender as TextBox)?.Text; + } } private async void IdString_OnClick(object sender, RoutedEventArgs e)