Skip to content

Commit

Permalink
Vulkan: Fix barriers on macOS (#5700)
Browse files Browse the repository at this point in the history
* Use old method on macOS

* gdk suggestions

* Update src/Ryujinx.Graphics.Vulkan/TextureStorage.cs

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

* Update src/Ryujinx.Graphics.Vulkan/TextureStorage.cs

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

---------

Co-authored-by: gdkchan <gab.dark.100@gmail.com>
  • Loading branch information
IsaacMarovitz and gdkchan authored Sep 23, 2023
1 parent fe9e19d commit d9f9bbf
Showing 1 changed file with 60 additions and 14 deletions.
74 changes: 60 additions & 14 deletions src/Ryujinx.Graphics.Vulkan/TextureStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,36 @@ public void InsertReadToWriteBarrier(CommandBufferScoped cbs, AccessFlags dstAcc

if (lastReadStage != PipelineStageFlags.None)
{
TextureView.InsertMemoryBarrier(
_gd.Api,
cbs.CommandBuffer,
_lastReadAccess,
dstAccessFlags,
lastReadStage,
dstStageFlags);
// This would result in a validation error, but is
// required on MoltenVK as the generic barrier results in
// severe texture flickering in some scenarios.
if (_gd.IsMoltenVk)
{
ImageAspectFlags aspectFlags = Info.Format.ConvertAspectFlags();
TextureView.InsertImageBarrier(
_gd.Api,
cbs.CommandBuffer,
_imageAuto.Get(cbs).Value,
_lastReadAccess,
dstAccessFlags,
_lastReadStage,
dstStageFlags,
aspectFlags,
0,
0,
_info.GetLayers(),
_info.Levels);
}
else
{
TextureView.InsertMemoryBarrier(
_gd.Api,
cbs.CommandBuffer,
_lastReadAccess,
dstAccessFlags,
lastReadStage,
dstStageFlags);
}

_lastReadAccess = AccessFlags.None;
_lastReadStage = PipelineStageFlags.None;
Expand All @@ -474,13 +497,36 @@ public void InsertWriteToReadBarrier(CommandBufferScoped cbs, AccessFlags dstAcc

if (_lastModificationAccess != AccessFlags.None)
{
TextureView.InsertMemoryBarrier(
_gd.Api,
cbs.CommandBuffer,
_lastModificationAccess,
dstAccessFlags,
_lastModificationStage,
dstStageFlags);
// This would result in a validation error, but is
// required on MoltenVK as the generic barrier results in
// severe texture flickering in some scenarios.
if (_gd.IsMoltenVk)
{
ImageAspectFlags aspectFlags = Info.Format.ConvertAspectFlags();
TextureView.InsertImageBarrier(
_gd.Api,
cbs.CommandBuffer,
_imageAuto.Get(cbs).Value,
_lastModificationAccess,
dstAccessFlags,
_lastModificationStage,
dstStageFlags,
aspectFlags,
0,
0,
_info.GetLayers(),
_info.Levels);
}
else
{
TextureView.InsertMemoryBarrier(
_gd.Api,
cbs.CommandBuffer,
_lastModificationAccess,
dstAccessFlags,
_lastModificationStage,
dstStageFlags);
}

_lastModificationAccess = AccessFlags.None;
}
Expand Down

0 comments on commit d9f9bbf

Please sign in to comment.