From 019afa91f502eba27ee4f7eb9bf08856022f6623 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Sat, 2 Mar 2024 23:10:44 -0800 Subject: [PATCH] fix stencil API --- lib/RefreshCS | 2 +- src/Graphics/RefreshStructs.cs | 9 +------- src/Graphics/Resources/GraphicsPipeline.cs | 6 +++++- src/Graphics/State/DepthStencilState.cs | 24 ++++++++++++++++++++-- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/lib/RefreshCS b/lib/RefreshCS index 4268db4..86cc5fa 160000 --- a/lib/RefreshCS +++ b/lib/RefreshCS @@ -1 +1 @@ -Subproject commit 4268db46161ec5ff924c8006a66aa59635d3ca50 +Subproject commit 86cc5fa1422c8b79c436c4e4fc345114e9615dbb diff --git a/src/Graphics/RefreshStructs.cs b/src/Graphics/RefreshStructs.cs index 1e63f4d..7d376e3 100644 --- a/src/Graphics/RefreshStructs.cs +++ b/src/Graphics/RefreshStructs.cs @@ -154,11 +154,7 @@ namespace MoonWorks.Graphics public StencilOp PassOp; public StencilOp DepthFailOp; public CompareOp CompareOp; - public uint CompareMask; - public uint WriteMask; - public uint Reference; - // FIXME: can we do an explicit cast here? public Refresh.StencilOpState ToRefresh() { return new Refresh.StencilOpState @@ -166,10 +162,7 @@ namespace MoonWorks.Graphics failOp = (Refresh.StencilOp) FailOp, passOp = (Refresh.StencilOp) PassOp, depthFailOp = (Refresh.StencilOp) DepthFailOp, - compareOp = (Refresh.CompareOp) CompareOp, - compareMask = CompareMask, - writeMask = WriteMask, - reference = Reference + compareOp = (Refresh.CompareOp) CompareOp }; } } diff --git a/src/Graphics/Resources/GraphicsPipeline.cs b/src/Graphics/Resources/GraphicsPipeline.cs index f854bf9..a25995f 100644 --- a/src/Graphics/Resources/GraphicsPipeline.cs +++ b/src/Graphics/Resources/GraphicsPipeline.cs @@ -61,7 +61,11 @@ namespace MoonWorks.Graphics refreshGraphicsPipelineCreateInfo.blendConstants[2] = blendConstants.B; refreshGraphicsPipelineCreateInfo.blendConstants[3] = blendConstants.A; - refreshGraphicsPipelineCreateInfo.depthStencilState.stencilState = depthStencilState.StencilState.ToRefresh(); + refreshGraphicsPipelineCreateInfo.depthStencilState.backStencilState = depthStencilState.BackStencilState.ToRefresh(); + refreshGraphicsPipelineCreateInfo.depthStencilState.frontStencilState = depthStencilState.FrontStencilState.ToRefresh(); + refreshGraphicsPipelineCreateInfo.depthStencilState.compareMask = depthStencilState.CompareMask; + refreshGraphicsPipelineCreateInfo.depthStencilState.writeMask = depthStencilState.WriteMask; + refreshGraphicsPipelineCreateInfo.depthStencilState.reference = depthStencilState.Reference; refreshGraphicsPipelineCreateInfo.depthStencilState.compareOp = (Refresh.CompareOp) depthStencilState.CompareOp; refreshGraphicsPipelineCreateInfo.depthStencilState.depthBoundsTestEnable = Conversions.BoolToByte(depthStencilState.DepthBoundsTestEnable); refreshGraphicsPipelineCreateInfo.depthStencilState.depthTestEnable = Conversions.BoolToByte(depthStencilState.DepthTestEnable); diff --git a/src/Graphics/State/DepthStencilState.cs b/src/Graphics/State/DepthStencilState.cs index 8f0f96c..40febd3 100644 --- a/src/Graphics/State/DepthStencilState.cs +++ b/src/Graphics/State/DepthStencilState.cs @@ -11,9 +11,29 @@ public bool DepthTestEnable; /// - /// Describes the stencil operation. + /// Describes the back-face stencil operation. /// - public StencilOpState StencilState; + public StencilOpState BackStencilState; + + /// + /// Describes the front-face stencil operation. + /// + public StencilOpState FrontStencilState; + + /// + /// The compare mask for stencil ops. + /// + public uint CompareMask; + + /// + /// The write mask for stencil ops. + /// + public uint WriteMask; + + /// + /// The stencil reference value. + /// + public uint Reference; /// /// The comparison operator used in the depth test.