aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Vulkan/PipelineFull.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2023-08-18 02:25:54 -0300
committerGitHub <noreply@github.com>2023-08-18 05:25:54 +0000
commit153b8bfc7c8c8711f8c2ce40f88085355d870b6a (patch)
treec39e2e728e4c2fc230615ecb27f4924aae0c0dea /src/Ryujinx.Graphics.Vulkan/PipelineFull.cs
parentc6a699414a9937946b711ceff02e95972a816d0d (diff)
Implement support for masked stencil clears on Vulkan (#5589)1.1.997
* Implement support for masked stencil clears on Vulkan * PR feedback
Diffstat (limited to 'src/Ryujinx.Graphics.Vulkan/PipelineFull.cs')
-rw-r--r--src/Ryujinx.Graphics.Vulkan/PipelineFull.cs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineFull.cs b/src/Ryujinx.Graphics.Vulkan/PipelineFull.cs
index dcc6c530..c3e6f37c 100644
--- a/src/Ryujinx.Graphics.Vulkan/PipelineFull.cs
+++ b/src/Ryujinx.Graphics.Vulkan/PipelineFull.cs
@@ -81,6 +81,42 @@ namespace Ryujinx.Graphics.Vulkan
}
}
+ public void ClearRenderTargetDepthStencil(int layer, int layerCount, float depthValue, bool depthMask, int stencilValue, int stencilMask)
+ {
+ if (FramebufferParams == null)
+ {
+ return;
+ }
+
+ if (stencilMask != 0 && stencilMask != 0xff)
+ {
+ // We can't use CmdClearAttachments if not clearing all (mask is all ones, 0xFF) or none (mask is 0) of the stencil bits,
+ // because on Vulkan, the pipeline state does not affect clears.
+ var dstTexture = FramebufferParams.GetDepthStencilAttachment();
+ if (dstTexture == null)
+ {
+ return;
+ }
+
+ // TODO: Clear only the specified layer.
+ Gd.HelperShader.Clear(
+ Gd,
+ dstTexture,
+ depthValue,
+ depthMask,
+ stencilValue,
+ stencilMask,
+ (int)FramebufferParams.Width,
+ (int)FramebufferParams.Height,
+ FramebufferParams.AttachmentFormats[FramebufferParams.AttachmentsCount - 1],
+ ClearScissor);
+ }
+ else
+ {
+ ClearRenderTargetDepthStencil(layer, layerCount, depthValue, depthMask, stencilValue, stencilMask != 0);
+ }
+ }
+
public void EndHostConditionalRendering()
{
if (Gd.Capabilities.SupportsConditionalRendering)