mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-12-01 16:32:17 +00:00
- add depth bias
This commit is contained in:
parent
cf49e1ec21
commit
eaf367e876
5 changed files with 25 additions and 1 deletions
|
@ -245,7 +245,7 @@ void VkRenderPassSetup::CreatePipeline(const VkRenderPassKey &key)
|
||||||
builder.addDynamicState(VK_DYNAMIC_STATE_VIEWPORT);
|
builder.addDynamicState(VK_DYNAMIC_STATE_VIEWPORT);
|
||||||
builder.addDynamicState(VK_DYNAMIC_STATE_SCISSOR);
|
builder.addDynamicState(VK_DYNAMIC_STATE_SCISSOR);
|
||||||
// builder.addDynamicState(VK_DYNAMIC_STATE_LINE_WIDTH);
|
// builder.addDynamicState(VK_DYNAMIC_STATE_LINE_WIDTH);
|
||||||
// builder.addDynamicState(VK_DYNAMIC_STATE_DEPTH_BIAS);
|
builder.addDynamicState(VK_DYNAMIC_STATE_DEPTH_BIAS);
|
||||||
// builder.addDynamicState(VK_DYNAMIC_STATE_BLEND_CONSTANTS);
|
// builder.addDynamicState(VK_DYNAMIC_STATE_BLEND_CONSTANTS);
|
||||||
// builder.addDynamicState(VK_DYNAMIC_STATE_DEPTH_BOUNDS);
|
// builder.addDynamicState(VK_DYNAMIC_STATE_DEPTH_BOUNDS);
|
||||||
// builder.addDynamicState(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK);
|
// builder.addDynamicState(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK);
|
||||||
|
@ -296,6 +296,7 @@ void VkRenderPassSetup::CreatePipeline(const VkRenderPassKey &key)
|
||||||
builder.setDepthStencilEnable(key.DepthTest, key.DepthWrite, key.StencilTest);
|
builder.setDepthStencilEnable(key.DepthTest, key.DepthWrite, key.StencilTest);
|
||||||
builder.setDepthFunc(depthfunc2vk[key.DepthFunc]);
|
builder.setDepthFunc(depthfunc2vk[key.DepthFunc]);
|
||||||
builder.setDepthClampEnable(key.DepthClamp);
|
builder.setDepthClampEnable(key.DepthClamp);
|
||||||
|
builder.setDepthBias(key.DepthBias, 0.0f, 0.0f, 0.0f);
|
||||||
builder.setCull(key.CullMode == Cull_None ? VK_CULL_MODE_NONE : VK_CULL_MODE_FRONT_AND_BACK, key.CullMode == Cull_CW ? VK_FRONT_FACE_CLOCKWISE : VK_FRONT_FACE_COUNTER_CLOCKWISE);
|
builder.setCull(key.CullMode == Cull_None ? VK_CULL_MODE_NONE : VK_CULL_MODE_FRONT_AND_BACK, key.CullMode == Cull_CW ? VK_FRONT_FACE_CLOCKWISE : VK_FRONT_FACE_COUNTER_CLOCKWISE);
|
||||||
builder.setColorWriteMask((VkColorComponentFlagBits)key.ColorMask);
|
builder.setColorWriteMask((VkColorComponentFlagBits)key.ColorMask);
|
||||||
builder.setStencil(VK_STENCIL_OP_KEEP, op2vk[key.StencilPassOp], VK_STENCIL_OP_KEEP, VK_COMPARE_OP_EQUAL, 0xffffffff, 0xffffffff, 0);
|
builder.setStencil(VK_STENCIL_OP_KEEP, op2vk[key.StencilPassOp], VK_STENCIL_OP_KEEP, VK_COMPARE_OP_EQUAL, 0xffffffff, 0xffffffff, 0);
|
||||||
|
|
|
@ -19,6 +19,7 @@ public:
|
||||||
int DepthTest;
|
int DepthTest;
|
||||||
int DepthFunc;
|
int DepthFunc;
|
||||||
int DepthClamp;
|
int DepthClamp;
|
||||||
|
int DepthBias;
|
||||||
int StencilTest;
|
int StencilTest;
|
||||||
int StencilPassOp;
|
int StencilPassOp;
|
||||||
int ColorMask;
|
int ColorMask;
|
||||||
|
|
|
@ -222,6 +222,7 @@ void VkRenderState::Apply(int dt)
|
||||||
ApplyScissor();
|
ApplyScissor();
|
||||||
ApplyViewport();
|
ApplyViewport();
|
||||||
ApplyStencilRef();
|
ApplyStencilRef();
|
||||||
|
ApplyDepthBias();
|
||||||
ApplyStreamData();
|
ApplyStreamData();
|
||||||
ApplyMatrices();
|
ApplyMatrices();
|
||||||
ApplyPushConstants();
|
ApplyPushConstants();
|
||||||
|
@ -231,6 +232,15 @@ void VkRenderState::Apply(int dt)
|
||||||
mNeedApply = false;
|
mNeedApply = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VkRenderState::ApplyDepthBias()
|
||||||
|
{
|
||||||
|
if (mBias.mChanged)
|
||||||
|
{
|
||||||
|
mCommandBuffer->setDepthBias(mBias.mUnits, 0.0f, mBias.mFactor);
|
||||||
|
mBias.mChanged = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void VkRenderState::ApplyRenderPass(int dt)
|
void VkRenderState::ApplyRenderPass(int dt)
|
||||||
{
|
{
|
||||||
auto fb = GetVulkanFrameBuffer();
|
auto fb = GetVulkanFrameBuffer();
|
||||||
|
@ -245,6 +255,7 @@ void VkRenderState::ApplyRenderPass(int dt)
|
||||||
passKey.DepthWrite = mDepthTest && mDepthWrite;
|
passKey.DepthWrite = mDepthTest && mDepthWrite;
|
||||||
passKey.DepthFunc = mDepthFunc;
|
passKey.DepthFunc = mDepthFunc;
|
||||||
passKey.DepthClamp = mDepthClamp;
|
passKey.DepthClamp = mDepthClamp;
|
||||||
|
passKey.DepthBias = !(mBias.mFactor == 0 && mBias.mUnits == 0);
|
||||||
passKey.StencilTest = mStencilTest;
|
passKey.StencilTest = mStencilTest;
|
||||||
passKey.StencilPassOp = mStencilOp;
|
passKey.StencilPassOp = mStencilOp;
|
||||||
passKey.ColorMask = mColorMask;
|
passKey.ColorMask = mColorMask;
|
||||||
|
@ -273,6 +284,7 @@ void VkRenderState::ApplyRenderPass(int dt)
|
||||||
mScissorChanged = true;
|
mScissorChanged = true;
|
||||||
mViewportChanged = true;
|
mViewportChanged = true;
|
||||||
mStencilRefChanged = true;
|
mStencilRefChanged = true;
|
||||||
|
mBias.mChanged = true;
|
||||||
}
|
}
|
||||||
else if (changingRenderPass)
|
else if (changingRenderPass)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,6 +48,7 @@ private:
|
||||||
void Apply(int dt);
|
void Apply(int dt);
|
||||||
void ApplyRenderPass(int dt);
|
void ApplyRenderPass(int dt);
|
||||||
void ApplyStencilRef();
|
void ApplyStencilRef();
|
||||||
|
void ApplyDepthBias();
|
||||||
void ApplyScissor();
|
void ApplyScissor();
|
||||||
void ApplyViewport();
|
void ApplyViewport();
|
||||||
void ApplyStreamData();
|
void ApplyStreamData();
|
||||||
|
|
|
@ -189,6 +189,7 @@ public:
|
||||||
void setDepthStencilEnable(bool test, bool write, bool stencil);
|
void setDepthStencilEnable(bool test, bool write, bool stencil);
|
||||||
void setDepthFunc(VkCompareOp func);
|
void setDepthFunc(VkCompareOp func);
|
||||||
void setDepthClampEnable(bool value);
|
void setDepthClampEnable(bool value);
|
||||||
|
void setDepthBias(bool enable, float biasConstantFactor, float biasClamp, float biasSlopeFactor);
|
||||||
void setColorWriteMask(VkColorComponentFlags mask);
|
void setColorWriteMask(VkColorComponentFlags mask);
|
||||||
void setStencil(VkStencilOp failOp, VkStencilOp passOp, VkStencilOp depthFailOp, VkCompareOp compareOp, uint32_t compareMask, uint32_t writeMask, uint32_t reference);
|
void setStencil(VkStencilOp failOp, VkStencilOp passOp, VkStencilOp depthFailOp, VkCompareOp compareOp, uint32_t compareMask, uint32_t writeMask, uint32_t reference);
|
||||||
|
|
||||||
|
@ -806,6 +807,14 @@ inline void GraphicsPipelineBuilder::setDepthClampEnable(bool value)
|
||||||
rasterizer.depthClampEnable = value ? VK_TRUE : VK_FALSE;
|
rasterizer.depthClampEnable = value ? VK_TRUE : VK_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void GraphicsPipelineBuilder::setDepthBias(bool enable, float biasConstantFactor, float biasClamp, float biasSlopeFactor)
|
||||||
|
{
|
||||||
|
rasterizer.depthBiasEnable = enable ? VK_TRUE : VK_FALSE;
|
||||||
|
rasterizer.depthBiasConstantFactor = biasConstantFactor;
|
||||||
|
rasterizer.depthBiasClamp = biasClamp;
|
||||||
|
rasterizer.depthBiasSlopeFactor = biasSlopeFactor;
|
||||||
|
}
|
||||||
|
|
||||||
inline void GraphicsPipelineBuilder::setColorWriteMask(VkColorComponentFlags mask)
|
inline void GraphicsPipelineBuilder::setColorWriteMask(VkColorComponentFlags mask)
|
||||||
{
|
{
|
||||||
colorBlendAttachment.colorWriteMask = mask;
|
colorBlendAttachment.colorWriteMask = mask;
|
||||||
|
|
Loading…
Reference in a new issue