Commit 364a9557 by Luc Ferron Committed by Commit Bot

Vulkan: Implement stencil test support

All the fragment_ops.depth and the fragment_ops.depth tests in dEQP are now working, but not the fragment_ops.depth_stencil. Still debugging these separately and will come up with a fix for them in another commit. Bug: angleproject:2443 Change-Id: I84c3a22f612fb6dcf30598434f96c2100fd29f9c Reviewed-on: https://chromium-review.googlesource.com/993654 Commit-Queue: Luc Ferron <lucferron@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent a8af3a69
......@@ -548,25 +548,27 @@ void ContextVk::syncState(const gl::Context *context, const gl::State::DirtyBits
WARN() << "DIRTY_BIT_DEPTH_MASK unimplemented";
break;
case gl::State::DIRTY_BIT_STENCIL_TEST_ENABLED:
WARN() << "DIRTY_BIT_STENCIL_TEST_ENABLED unimplemented";
mPipelineDesc->updateStencilTestEnabled(glState.getDepthStencilState());
break;
case gl::State::DIRTY_BIT_STENCIL_FUNCS_FRONT:
WARN() << "DIRTY_BIT_STENCIL_FUNCS_FRONT unimplemented";
mPipelineDesc->updateStencilFrontFuncs(glState.getStencilRef(),
glState.getDepthStencilState());
break;
case gl::State::DIRTY_BIT_STENCIL_FUNCS_BACK:
WARN() << "DIRTY_BIT_STENCIL_FUNCS_BACK unimplemented";
mPipelineDesc->updateStencilBackFuncs(glState.getStencilBackRef(),
glState.getDepthStencilState());
break;
case gl::State::DIRTY_BIT_STENCIL_OPS_FRONT:
WARN() << "DIRTY_BIT_STENCIL_OPS_FRONT unimplemented";
mPipelineDesc->updateStencilFrontOps(glState.getDepthStencilState());
break;
case gl::State::DIRTY_BIT_STENCIL_OPS_BACK:
WARN() << "DIRTY_BIT_STENCIL_OPS_BACK unimplemented";
mPipelineDesc->updateStencilBackOps(glState.getDepthStencilState());
break;
case gl::State::DIRTY_BIT_STENCIL_WRITEMASK_FRONT:
WARN() << "DIRTY_BIT_STENCIL_WRITEMASK_FRONT unimplemented";
mPipelineDesc->updateStencilFrontWriteMask(glState.getDepthStencilState());
break;
case gl::State::DIRTY_BIT_STENCIL_WRITEMASK_BACK:
WARN() << "DIRTY_BIT_STENCIL_WRITEMASK_BACK unimplemented";
mPipelineDesc->updateStencilBackWriteMask(glState.getDepthStencilState());
break;
case gl::State::DIRTY_BIT_CULL_FACE_ENABLED:
case gl::State::DIRTY_BIT_CULL_FACE:
......
......@@ -97,9 +97,9 @@ gl::Error RenderbufferVk::setStorage(const gl::Context *context,
vk::CommandBuffer *commandBuffer = nullptr;
ANGLE_TRY(beginWriteResource(renderer, &commandBuffer));
mImage.getImage().changeLayoutWithStages(
VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, commandBuffer);
mImage.getImage().changeLayoutWithStages(aspect, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
VK_PIPELINE_STAGE_TRANSFER_BIT, commandBuffer);
if (isDepthOrStencilFormat)
{
......
......@@ -81,6 +81,32 @@ uint8_t PackGLBlendFactor(GLenum blendFactor)
}
}
uint8_t PackGLStencilOp(GLenum compareOp)
{
switch (compareOp)
{
case GL_KEEP:
return VK_STENCIL_OP_KEEP;
case GL_ZERO:
return VK_STENCIL_OP_ZERO;
case GL_REPLACE:
return VK_STENCIL_OP_REPLACE;
case GL_INCR:
return VK_STENCIL_OP_INCREMENT_AND_CLAMP;
case GL_DECR:
return VK_STENCIL_OP_DECREMENT_AND_CLAMP;
case GL_INCR_WRAP:
return VK_STENCIL_OP_INCREMENT_AND_WRAP;
case GL_DECR_WRAP:
return VK_STENCIL_OP_DECREMENT_AND_WRAP;
case GL_INVERT:
return VK_STENCIL_OP_INVERT;
default:
UNREACHABLE();
return 0;
}
}
uint8_t PackGLCompareFunc(GLenum compareFunc)
{
switch (compareFunc)
......@@ -708,6 +734,56 @@ void PipelineDesc::updateDepthFunc(const gl::DepthStencilState &depthStencilStat
mDepthStencilStateInfo.depthCompareOp = PackGLCompareFunc(depthStencilState.depthFunc);
}
void PipelineDesc::updateStencilTestEnabled(const gl::DepthStencilState &depthStencilState)
{
mDepthStencilStateInfo.stencilTestEnable = static_cast<uint8_t>(depthStencilState.stencilTest);
}
void PipelineDesc::updateStencilFrontFuncs(GLint ref,
const gl::DepthStencilState &depthStencilState)
{
mDepthStencilStateInfo.front.reference = ref;
mDepthStencilStateInfo.front.compareOp = PackGLCompareFunc(depthStencilState.stencilFunc);
mDepthStencilStateInfo.front.compareMask = static_cast<uint32_t>(depthStencilState.stencilMask);
}
void PipelineDesc::updateStencilBackFuncs(GLint ref, const gl::DepthStencilState &depthStencilState)
{
mDepthStencilStateInfo.back.reference = ref;
mDepthStencilStateInfo.back.compareOp = PackGLCompareFunc(depthStencilState.stencilBackFunc);
mDepthStencilStateInfo.back.compareMask =
static_cast<uint32_t>(depthStencilState.stencilBackMask);
}
void PipelineDesc::updateStencilFrontOps(const gl::DepthStencilState &depthStencilState)
{
mDepthStencilStateInfo.front.passOp = PackGLStencilOp(depthStencilState.stencilPassDepthPass);
mDepthStencilStateInfo.front.failOp = PackGLStencilOp(depthStencilState.stencilFail);
mDepthStencilStateInfo.front.depthFailOp =
PackGLStencilOp(depthStencilState.stencilPassDepthFail);
}
void PipelineDesc::updateStencilBackOps(const gl::DepthStencilState &depthStencilState)
{
mDepthStencilStateInfo.back.passOp =
PackGLStencilOp(depthStencilState.stencilBackPassDepthPass);
mDepthStencilStateInfo.back.failOp = PackGLStencilOp(depthStencilState.stencilBackFail);
mDepthStencilStateInfo.back.depthFailOp =
PackGLStencilOp(depthStencilState.stencilBackPassDepthFail);
}
void PipelineDesc::updateStencilFrontWriteMask(const gl::DepthStencilState &depthStencilState)
{
mDepthStencilStateInfo.front.writeMask =
static_cast<uint32_t>(depthStencilState.stencilWritemask);
}
void PipelineDesc::updateStencilBackWriteMask(const gl::DepthStencilState &depthStencilState)
{
mDepthStencilStateInfo.back.writeMask =
static_cast<uint32_t>(depthStencilState.stencilBackWritemask);
}
void PipelineDesc::updateRenderPassDesc(const RenderPassDesc &renderPassDesc)
{
mRenderPassDesc = renderPassDesc;
......
......@@ -301,6 +301,13 @@ class PipelineDesc final
// Depth/stencil states.
void updateDepthTestEnabled(const gl::DepthStencilState &depthStencilState);
void updateDepthFunc(const gl::DepthStencilState &depthStencilState);
void updateStencilTestEnabled(const gl::DepthStencilState &depthStencilState);
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);
private:
// TODO(jmadill): Handle Geometry/Compute shaders when necessary.
......
......@@ -230,7 +230,6 @@
2161 VULKAN : dEQP-GLES2.functional.texture.vertex.* = SKIP
2161 VULKAN : dEQP-GLES2.functional.fragment_ops.random.* = SKIP
2161 VULKAN : dEQP-GLES2.functional.fragment_ops.interaction.* = SKIP
2161 VULKAN : dEQP-GLES2.functional.fragment_ops.stencil.* = SKIP
2161 VULKAN : dEQP-GLES2.functional.fragment_ops.depth_stencil.* = SKIP
2161 VULKAN : dEQP-GLES2.functional.fbo.* = SKIP
// Conflicts with Android expectation, specify the OSs
......@@ -337,7 +336,4 @@
2161 VULKAN : dEQP-GLES2.functional.draw.random.* = SKIP
2161 VULKAN : dEQP-GLES2.functional.default_vertex_attrib.* = SKIP
2161 VULKAN : dEQP-GLES2.functional.lifetime.* = SKIP
2161 VULKAN : dEQP-GLES2.functional.debug_marker.* = SKIP
// Stencil state support isn't implemented yet.
2427 VULKAN : dEQP-GLES2.functional.fragment_ops.scissor.clear_stencil = SKIP
\ No newline at end of file
2161 VULKAN : dEQP-GLES2.functional.debug_marker.* = SKIP
\ No newline at end of file
......@@ -259,7 +259,8 @@ ANGLE_INSTANTIATE_TEST(DepthStencilFormatsTest,
ES2_D3D9(),
ES2_D3D11(),
ES2_OPENGL(),
ES2_OPENGLES());
ES2_OPENGLES(),
ES2_VULKAN());
ANGLE_INSTANTIATE_TEST(DepthStencilFormatsTestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
class TinyDepthStencilWorkaroundTest : public ANGLETest
......
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