diff options
author | gdkchan <gab.dark.100@gmail.com> | 2024-08-20 20:49:17 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-21 00:49:17 +0100 |
commit | 460f9faf4e3ccb5a21b1c6f149815dfda095a16e (patch) | |
tree | 8f1be7d93c534aa7a34597061716ca5d1695ac35 | |
parent | 552c15739c10e9443e7e7a2acc775bfbc08faa0c (diff) |
Fix NRE when using buffer image array (#7159)1.1.1378
-rw-r--r-- | src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs | 27 | ||||
-rw-r--r-- | src/Ryujinx.Graphics.Vulkan/ImageArray.cs | 2 | ||||
-rw-r--r-- | src/Ryujinx.Graphics.Vulkan/ResourceArray.cs | 11 | ||||
-rw-r--r-- | src/Ryujinx.Graphics.Vulkan/TextureArray.cs | 2 |
4 files changed, 29 insertions, 13 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs index 01e34c777..8b9243b1e 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs | |||
@@ -340,7 +340,7 @@ namespace Ryujinx.Graphics.Gpu.Image | |||
340 | /// <returns>True if any used entries of the pool might have been modified, false otherwise</returns> | 340 | /// <returns>True if any used entries of the pool might have been modified, false otherwise</returns> |
341 | public bool SamplerPoolModified() | 341 | public bool SamplerPoolModified() |
342 | { | 342 | { |
343 | return SamplerPool.WasModified(ref _samplerPoolSequence); | 343 | return SamplerPool != null && SamplerPool.WasModified(ref _samplerPoolSequence); |
344 | } | 344 | } |
345 | } | 345 | } |
346 | 346 | ||
@@ -516,12 +516,15 @@ namespace Ryujinx.Graphics.Gpu.Image | |||
516 | } | 516 | } |
517 | 517 | ||
518 | // Check if any of our cached samplers changed on the pool. | 518 | // Check if any of our cached samplers changed on the pool. |
519 | foreach ((int samplerId, (Sampler sampler, SamplerDescriptor descriptor)) in SamplerIds) | 519 | if (SamplerPool != null) |
520 | { | 520 | { |
521 | if (SamplerPool.GetCachedItem(samplerId) != sampler || | 521 | foreach ((int samplerId, (Sampler sampler, SamplerDescriptor descriptor)) in SamplerIds) |
522 | (sampler == null && SamplerPool.IsValidId(samplerId) && !SamplerPool.GetDescriptorRef(samplerId).Equals(descriptor))) | ||
523 | { | 522 | { |
524 | return true; | 523 | if (SamplerPool.GetCachedItem(samplerId) != sampler || |
524 | (sampler == null && SamplerPool.IsValidId(samplerId) && !SamplerPool.GetDescriptorRef(samplerId).Equals(descriptor))) | ||
525 | { | ||
526 | return true; | ||
527 | } | ||
525 | } | 528 | } |
526 | } | 529 | } |
527 | 530 | ||
@@ -899,13 +902,19 @@ namespace Ryujinx.Graphics.Gpu.Image | |||
899 | } | 902 | } |
900 | } | 903 | } |
901 | 904 | ||
902 | Sampler sampler = samplerPool?.Get(samplerId); | ||
903 | |||
904 | entry.TextureIds[textureId] = (texture, descriptor); | 905 | entry.TextureIds[textureId] = (texture, descriptor); |
905 | entry.SamplerIds[samplerId] = (sampler, samplerPool?.GetDescriptorRef(samplerId) ?? default); | ||
906 | 906 | ||
907 | ITexture hostTexture = texture?.GetTargetTexture(bindingInfo.Target); | 907 | ITexture hostTexture = texture?.GetTargetTexture(bindingInfo.Target); |
908 | ISampler hostSampler = sampler?.GetHostSampler(texture); | 908 | ISampler hostSampler = null; |
909 | |||
910 | if (!isImage && bindingInfo.Target != Target.TextureBuffer) | ||
911 | { | ||
912 | Sampler sampler = samplerPool?.Get(samplerId); | ||
913 | |||
914 | entry.SamplerIds[samplerId] = (sampler, samplerPool?.GetDescriptorRef(samplerId) ?? default); | ||
915 | |||
916 | hostSampler = sampler?.GetHostSampler(texture); | ||
917 | } | ||
909 | 918 | ||
910 | Format format = bindingInfo.Format; | 919 | Format format = bindingInfo.Format; |
911 | 920 | ||
diff --git a/src/Ryujinx.Graphics.Vulkan/ImageArray.cs b/src/Ryujinx.Graphics.Vulkan/ImageArray.cs index e42750d3c..467b01111 100644 --- a/src/Ryujinx.Graphics.Vulkan/ImageArray.cs +++ b/src/Ryujinx.Graphics.Vulkan/ImageArray.cs | |||
@@ -95,7 +95,7 @@ namespace Ryujinx.Graphics.Vulkan | |||
95 | { | 95 | { |
96 | _cachedCommandBufferIndex = -1; | 96 | _cachedCommandBufferIndex = -1; |
97 | _storages = null; | 97 | _storages = null; |
98 | SetDirty(_gd); | 98 | SetDirty(_gd, isImage: true); |
99 | } | 99 | } |
100 | 100 | ||
101 | public void QueueWriteToReadBarriers(CommandBufferScoped cbs, PipelineStageFlags stageFlags) | 101 | public void QueueWriteToReadBarriers(CommandBufferScoped cbs, PipelineStageFlags stageFlags) |
diff --git a/src/Ryujinx.Graphics.Vulkan/ResourceArray.cs b/src/Ryujinx.Graphics.Vulkan/ResourceArray.cs index 0880a10f0..f96b4a845 100644 --- a/src/Ryujinx.Graphics.Vulkan/ResourceArray.cs +++ b/src/Ryujinx.Graphics.Vulkan/ResourceArray.cs | |||
@@ -14,13 +14,20 @@ namespace Ryujinx.Graphics.Vulkan | |||
14 | 14 | ||
15 | private int _bindCount; | 15 | private int _bindCount; |
16 | 16 | ||
17 | protected void SetDirty(VulkanRenderer gd) | 17 | protected void SetDirty(VulkanRenderer gd, bool isImage) |
18 | { | 18 | { |
19 | ReleaseDescriptorSet(); | 19 | ReleaseDescriptorSet(); |
20 | 20 | ||
21 | if (_bindCount != 0) | 21 | if (_bindCount != 0) |
22 | { | 22 | { |
23 | gd.PipelineInternal.ForceTextureDirty(); | 23 | if (isImage) |
24 | { | ||
25 | gd.PipelineInternal.ForceImageDirty(); | ||
26 | } | ||
27 | else | ||
28 | { | ||
29 | gd.PipelineInternal.ForceTextureDirty(); | ||
30 | } | ||
24 | } | 31 | } |
25 | } | 32 | } |
26 | 33 | ||
diff --git a/src/Ryujinx.Graphics.Vulkan/TextureArray.cs b/src/Ryujinx.Graphics.Vulkan/TextureArray.cs index 31c408d64..99238b1f5 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureArray.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureArray.cs | |||
@@ -104,7 +104,7 @@ namespace Ryujinx.Graphics.Vulkan | |||
104 | { | 104 | { |
105 | _cachedCommandBufferIndex = -1; | 105 | _cachedCommandBufferIndex = -1; |
106 | _storages = null; | 106 | _storages = null; |
107 | SetDirty(_gd); | 107 | SetDirty(_gd, isImage: false); |
108 | } | 108 | } |
109 | 109 | ||
110 | public void QueueWriteToReadBarriers(CommandBufferScoped cbs, PipelineStageFlags stageFlags) | 110 | public void QueueWriteToReadBarriers(CommandBufferScoped cbs, PipelineStageFlags stageFlags) |