From 2b6359f396f00d0c07ad6dabe4626431d7e255a7 Mon Sep 17 00:00:00 2001 From: Evan Husted Date: Sun, 10 Nov 2024 17:37:13 -0600 Subject: [PATCH] attempt 1 at fixing this crash --- src/Ryujinx.Graphics.Vulkan/TextureArray.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx.Graphics.Vulkan/TextureArray.cs b/src/Ryujinx.Graphics.Vulkan/TextureArray.cs index 99238b1f5..17c76610d 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureArray.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureArray.cs @@ -1,7 +1,9 @@ +using Gommon; using Ryujinx.Graphics.GAL; using Silk.NET.Vulkan; using System; using System.Collections.Generic; +using System.Linq; namespace Ryujinx.Graphics.Vulkan { @@ -54,18 +56,28 @@ namespace Ryujinx.Graphics.Vulkan public void SetSamplers(int index, ISampler[] samplers) { + if (_textureRefs is null) + return; + for (int i = 0; i < samplers.Length; i++) { ISampler sampler = samplers[i]; + Optional textureRefOpt = _textureRefs.FindElement(index + i); + if (!textureRefOpt.HasValue) continue; + + TextureRef textureRef = textureRefOpt.Value; + if (sampler is SamplerHolder samplerHolder) { - _textureRefs[index + i].Sampler = samplerHolder.GetSampler(); + textureRef.Sampler = samplerHolder.GetSampler(); } else { - _textureRefs[index + i].Sampler = default; + textureRef.Sampler = default; } + + _textureRefs[index + i] = textureRef; } SetDirty();