Add GPUContext::SetStencilRef to stencil reference value

This commit is contained in:
Wojtek Figat
2023-06-19 11:21:35 +02:00
parent 228ef4e130
commit 1c9d8aa470
9 changed files with 46 additions and 2 deletions

View File

@@ -727,6 +727,7 @@ void GPUContextVulkan::FrameBegin()
_cbDirtyFlag = 0;
_rtCount = 0;
_vbCount = 0;
_stencilRef = 0;
_renderPass = nullptr;
_currentState = nullptr;
_rtDepth = nullptr;
@@ -972,6 +973,16 @@ void GPUContextVulkan::SetBlendFactor(const Float4& value)
vkCmdSetBlendConstants(cmdBuffer->GetHandle(), value.Raw);
}
void GPUContextVulkan::SetStencilRef(uint32 value)
{
if (_stencilRef != value)
{
_stencilRef = value;
const auto cmdBuffer = _cmdBufferManager->GetCmdBuffer();
vkCmdSetStencilReference(cmdBuffer->GetHandle(), VK_STENCIL_FRONT_AND_BACK, _stencilRef);
}
}
void GPUContextVulkan::ResetSR()
{
Platform::MemoryClear(_srHandles, sizeof(_srHandles));

View File

@@ -97,6 +97,7 @@ private:
int32 _rtCount;
int32 _vbCount;
uint32 _stencilRef;
RenderPassVulkan* _renderPass;
GPUPipelineStateVulkan* _currentState;
@@ -185,6 +186,7 @@ public:
void SetRenderTarget(GPUTextureView* depthBuffer, GPUTextureView* rt) override;
void SetRenderTarget(GPUTextureView* depthBuffer, const Span<GPUTextureView*>& rts) override;
void SetBlendFactor(const Float4& value) override;
void SetStencilRef(uint32 value) override;
void ResetSR() override;
void ResetUA() override;
void ResetCB() override;

View File

@@ -274,7 +274,7 @@ bool GPUPipelineStateVulkan::Init(const Description& desc)
_descDynamic.pDynamicStates = _dynamicStates;
_dynamicStates[_descDynamic.dynamicStateCount++] = VK_DYNAMIC_STATE_VIEWPORT;
_dynamicStates[_descDynamic.dynamicStateCount++] = VK_DYNAMIC_STATE_SCISSOR;
//_dynamicStates[_descDynamic.dynamicStateCount++] = VK_DYNAMIC_STATE_STENCIL_REFERENCE;
_dynamicStates[_descDynamic.dynamicStateCount++] = VK_DYNAMIC_STATE_STENCIL_REFERENCE;
static_assert(ARRAY_COUNT(_dynamicStates) <= 3, "Invalid dynamic states array.");
_desc.pDynamicState = &_descDynamic;