Commit c16f518e by Geoff Lang Committed by Commit Bot

Vulkan: Disable the depth/stencil states when there are no depth/stencil buffers

We sometimes emulate depth-only or stencil-only buffers with depth-stencil buffers. Disable depth-stencil states that allow reading or writing to these buffers that should not exist. BUG=angleproject:2739 Change-Id: I4f54800404f340eb53f04176e208f19a83a2899c Reviewed-on: https://chromium-review.googlesource.com/1141932Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 639bc908
......@@ -504,16 +504,19 @@ gl::Error ContextVk::syncState(const gl::Context *context, const gl::State::Dirt
case gl::State::DIRTY_BIT_SAMPLE_MASK:
break;
case gl::State::DIRTY_BIT_DEPTH_TEST_ENABLED:
mPipelineDesc->updateDepthTestEnabled(glState.getDepthStencilState());
mPipelineDesc->updateDepthTestEnabled(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
break;
case gl::State::DIRTY_BIT_DEPTH_FUNC:
mPipelineDesc->updateDepthFunc(glState.getDepthStencilState());
break;
case gl::State::DIRTY_BIT_DEPTH_MASK:
mPipelineDesc->updateDepthWriteEnabled(glState.getDepthStencilState());
mPipelineDesc->updateDepthWriteEnabled(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
break;
case gl::State::DIRTY_BIT_STENCIL_TEST_ENABLED:
mPipelineDesc->updateStencilTestEnabled(glState.getDepthStencilState());
mPipelineDesc->updateStencilTestEnabled(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
break;
case gl::State::DIRTY_BIT_STENCIL_FUNCS_FRONT:
mPipelineDesc->updateStencilFrontFuncs(glState.getStencilRef(),
......@@ -530,10 +533,12 @@ gl::Error ContextVk::syncState(const gl::Context *context, const gl::State::Dirt
mPipelineDesc->updateStencilBackOps(glState.getDepthStencilState());
break;
case gl::State::DIRTY_BIT_STENCIL_WRITEMASK_FRONT:
mPipelineDesc->updateStencilFrontWriteMask(glState.getDepthStencilState());
mPipelineDesc->updateStencilFrontWriteMask(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
break;
case gl::State::DIRTY_BIT_STENCIL_WRITEMASK_BACK:
mPipelineDesc->updateStencilBackWriteMask(glState.getDepthStencilState());
mPipelineDesc->updateStencilBackWriteMask(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
break;
case gl::State::DIRTY_BIT_CULL_FACE_ENABLED:
case gl::State::DIRTY_BIT_CULL_FACE:
......@@ -599,6 +604,16 @@ gl::Error ContextVk::syncState(const gl::Context *context, const gl::State::Dirt
updateColorMask(glState.getBlendState());
mPipelineDesc->updateCullMode(glState.getRasterizerState());
updateScissor(glState);
mPipelineDesc->updateDepthTestEnabled(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
mPipelineDesc->updateDepthWriteEnabled(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
mPipelineDesc->updateStencilTestEnabled(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
mPipelineDesc->updateStencilFrontWriteMask(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
mPipelineDesc->updateStencilBackWriteMask(glState.getDepthStencilState(),
glState.getDrawFramebuffer());
break;
}
case gl::State::DIRTY_BIT_RENDERBUFFER_BINDING:
......
......@@ -748,9 +748,13 @@ void PipelineDesc::updateColorWriteMask(VkColorComponentFlags colorComponentFlag
}
}
void PipelineDesc::updateDepthTestEnabled(const gl::DepthStencilState &depthStencilState)
void PipelineDesc::updateDepthTestEnabled(const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer)
{
mDepthStencilStateInfo.depthTestEnable = static_cast<uint8_t>(depthStencilState.depthTest);
// Only enable the depth test if the draw framebuffer has a depth buffer. It's possible that
// we're emulating a stencil-only buffer with a depth-stencil buffer
mDepthStencilStateInfo.depthTestEnable =
static_cast<uint8_t>(depthStencilState.depthTest && drawFramebuffer->hasDepth());
}
void PipelineDesc::updateDepthFunc(const gl::DepthStencilState &depthStencilState)
......@@ -758,14 +762,21 @@ void PipelineDesc::updateDepthFunc(const gl::DepthStencilState &depthStencilStat
mDepthStencilStateInfo.depthCompareOp = PackGLCompareFunc(depthStencilState.depthFunc);
}
void PipelineDesc::updateDepthWriteEnabled(const gl::DepthStencilState &depthStencilState)
void PipelineDesc::updateDepthWriteEnabled(const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer)
{
mDepthStencilStateInfo.depthWriteEnable = (depthStencilState.depthMask == GL_FALSE ? 0 : 1);
// Don't write to depth buffers that should not exist
mDepthStencilStateInfo.depthWriteEnable =
static_cast<uint8_t>(drawFramebuffer->hasDepth() ? depthStencilState.depthMask : 0);
}
void PipelineDesc::updateStencilTestEnabled(const gl::DepthStencilState &depthStencilState)
void PipelineDesc::updateStencilTestEnabled(const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer)
{
mDepthStencilStateInfo.stencilTestEnable = static_cast<uint8_t>(depthStencilState.stencilTest);
// Only enable the stencil test if the draw framebuffer has a stencil buffer. It's possible
// that we're emulating a depth-only buffer with a depth-stencil buffer
mDepthStencilStateInfo.stencilTestEnable =
static_cast<uint8_t>(depthStencilState.stencilTest && drawFramebuffer->hasStencil());
}
void PipelineDesc::updateStencilFrontFuncs(GLint ref,
......@@ -801,16 +812,20 @@ void PipelineDesc::updateStencilBackOps(const gl::DepthStencilState &depthStenci
PackGLStencilOp(depthStencilState.stencilBackPassDepthFail);
}
void PipelineDesc::updateStencilFrontWriteMask(const gl::DepthStencilState &depthStencilState)
void PipelineDesc::updateStencilFrontWriteMask(const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer)
{
mDepthStencilStateInfo.front.writeMask =
static_cast<uint32_t>(depthStencilState.stencilWritemask);
// Don't write to stencil buffers that should not exist
mDepthStencilStateInfo.front.writeMask = static_cast<uint32_t>(
drawFramebuffer->hasStencil() ? depthStencilState.stencilWritemask : 0);
}
void PipelineDesc::updateStencilBackWriteMask(const gl::DepthStencilState &depthStencilState)
void PipelineDesc::updateStencilBackWriteMask(const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer)
{
mDepthStencilStateInfo.back.writeMask =
static_cast<uint32_t>(depthStencilState.stencilBackWritemask);
// Don't write to stencil buffers that should not exist
mDepthStencilStateInfo.back.writeMask = static_cast<uint32_t>(
drawFramebuffer->hasStencil() ? depthStencilState.stencilBackWritemask : 0);
}
void PipelineDesc::updateRenderPassDesc(const RenderPassDesc &renderPassDesc)
......
......@@ -392,16 +392,21 @@ class PipelineDesc final
const gl::DrawBufferMask &alphaMask);
// Depth/stencil states.
void updateDepthTestEnabled(const gl::DepthStencilState &depthStencilState);
void updateDepthTestEnabled(const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer);
void updateDepthFunc(const gl::DepthStencilState &depthStencilState);
void updateDepthWriteEnabled(const gl::DepthStencilState &depthStencilState);
void updateStencilTestEnabled(const gl::DepthStencilState &depthStencilState);
void updateDepthWriteEnabled(const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer);
void updateStencilTestEnabled(const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer);
void updateStencilFrontFuncs(GLint ref, const gl::DepthStencilState &depthStencilState);
void updateStencilBackFuncs(GLint ref, const gl::DepthStencilState &depthStencilState);
void updateStencilFrontOps(const gl::DepthStencilState &depthStencilState);
void updateStencilBackOps(const gl::DepthStencilState &depthStencilState);
void updateStencilFrontWriteMask(const gl::DepthStencilState &depthStencilState);
void updateStencilBackWriteMask(const gl::DepthStencilState &depthStencilState);
void updateStencilFrontWriteMask(const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer);
void updateStencilBackWriteMask(const gl::DepthStencilState &depthStencilState,
const gl::Framebuffer *drawFramebuffer);
private:
// TODO(jmadill): Use gl::ShaderMap when we can pack into fewer bits. http://anglebug.com/2522
......
......@@ -174,8 +174,6 @@
2715 WIN VULKAN : dEQP-EGL.functional.query_surface.simple.pbuffer.rgb888_no_depth_no_stencil = FAIL
2715 WIN VULKAN : dEQP-EGL.functional.query_surface.simple.pbuffer.rgba8888_depth_no_stencil = FAIL
2715 WIN VULKAN : dEQP-EGL.functional.query_surface.simple.pbuffer.rgba8888_no_depth_no_stencil = FAIL
2739 WIN VULKAN : dEQP-EGL.functional.render.multi_context.gles2.* = FAIL
2739 WIN VULKAN : dEQP-EGL.functional.render.single_context.gles2.* = FAIL
2635 WIN VULKAN : dEQP-EGL.functional.resize.surface_size.grow = FAIL
2635 WIN VULKAN : dEQP-EGL.functional.resize.surface_size.stretch_height = FAIL
2635 WIN VULKAN : dEQP-EGL.functional.resize.surface_size.stretch_width = FAIL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment