0
0
Fork 0
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2024-10-18 16:21:41 +00:00

Fix NRE when using buffer image array (#7159)

This commit is contained in:
gdkchan 2024-08-20 20:49:17 -03:00 committed by GitHub
parent 552c15739c
commit 460f9faf4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 13 deletions

View file

@ -340,7 +340,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <returns>True if any used entries of the pool might have been modified, false otherwise</returns> /// <returns>True if any used entries of the pool might have been modified, false otherwise</returns>
public bool SamplerPoolModified() public bool SamplerPoolModified()
{ {
return SamplerPool.WasModified(ref _samplerPoolSequence); return SamplerPool != null && SamplerPool.WasModified(ref _samplerPoolSequence);
} }
} }
@ -516,6 +516,8 @@ namespace Ryujinx.Graphics.Gpu.Image
} }
// Check if any of our cached samplers changed on the pool. // Check if any of our cached samplers changed on the pool.
if (SamplerPool != null)
{
foreach ((int samplerId, (Sampler sampler, SamplerDescriptor descriptor)) in SamplerIds) foreach ((int samplerId, (Sampler sampler, SamplerDescriptor descriptor)) in SamplerIds)
{ {
if (SamplerPool.GetCachedItem(samplerId) != sampler || if (SamplerPool.GetCachedItem(samplerId) != sampler ||
@ -524,6 +526,7 @@ namespace Ryujinx.Graphics.Gpu.Image
return true; return true;
} }
} }
}
return false; return false;
} }
@ -899,13 +902,19 @@ namespace Ryujinx.Graphics.Gpu.Image
} }
} }
Sampler sampler = samplerPool?.Get(samplerId);
entry.TextureIds[textureId] = (texture, descriptor); entry.TextureIds[textureId] = (texture, descriptor);
entry.SamplerIds[samplerId] = (sampler, samplerPool?.GetDescriptorRef(samplerId) ?? default);
ITexture hostTexture = texture?.GetTargetTexture(bindingInfo.Target); ITexture hostTexture = texture?.GetTargetTexture(bindingInfo.Target);
ISampler hostSampler = sampler?.GetHostSampler(texture); ISampler hostSampler = null;
if (!isImage && bindingInfo.Target != Target.TextureBuffer)
{
Sampler sampler = samplerPool?.Get(samplerId);
entry.SamplerIds[samplerId] = (sampler, samplerPool?.GetDescriptorRef(samplerId) ?? default);
hostSampler = sampler?.GetHostSampler(texture);
}
Format format = bindingInfo.Format; Format format = bindingInfo.Format;

View file

@ -95,7 +95,7 @@ namespace Ryujinx.Graphics.Vulkan
{ {
_cachedCommandBufferIndex = -1; _cachedCommandBufferIndex = -1;
_storages = null; _storages = null;
SetDirty(_gd); SetDirty(_gd, isImage: true);
} }
public void QueueWriteToReadBarriers(CommandBufferScoped cbs, PipelineStageFlags stageFlags) public void QueueWriteToReadBarriers(CommandBufferScoped cbs, PipelineStageFlags stageFlags)

View file

@ -14,15 +14,22 @@ namespace Ryujinx.Graphics.Vulkan
private int _bindCount; private int _bindCount;
protected void SetDirty(VulkanRenderer gd) protected void SetDirty(VulkanRenderer gd, bool isImage)
{ {
ReleaseDescriptorSet(); ReleaseDescriptorSet();
if (_bindCount != 0) if (_bindCount != 0)
{
if (isImage)
{
gd.PipelineInternal.ForceImageDirty();
}
else
{ {
gd.PipelineInternal.ForceTextureDirty(); gd.PipelineInternal.ForceTextureDirty();
} }
} }
}
public bool TryGetCachedDescriptorSets(CommandBufferScoped cbs, ShaderCollection program, int setIndex, out DescriptorSet[] sets) public bool TryGetCachedDescriptorSets(CommandBufferScoped cbs, ShaderCollection program, int setIndex, out DescriptorSet[] sets)
{ {

View file

@ -104,7 +104,7 @@ namespace Ryujinx.Graphics.Vulkan
{ {
_cachedCommandBufferIndex = -1; _cachedCommandBufferIndex = -1;
_storages = null; _storages = null;
SetDirty(_gd); SetDirty(_gd, isImage: false);
} }
public void QueueWriteToReadBarriers(CommandBufferScoped cbs, PipelineStageFlags stageFlags) public void QueueWriteToReadBarriers(CommandBufferScoped cbs, PipelineStageFlags stageFlags)