Commit 75875885 by Le Hoang Quyen Committed by Commit Bot

Metal: Fix glDisable(GL_DEPTH_TEST) didn't disable depth write

Per standard glDisable(GL_DEPTH_TEST) will disable depth write also regardless of the value of glDepthMask() Tests done: - dEQP.GLES2/functional_fragment_ops_depth_stencil_stencil_*_no_depth Bug: angleproject:2634 Change-Id: I3b101b8c0b3060f5ddbb18d3f97d7d6889cdec01 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1966184 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 5245de82
...@@ -233,7 +233,7 @@ class ContextMtl : public ContextImpl, public mtl::Context ...@@ -233,7 +233,7 @@ class ContextMtl : public ContextImpl, public mtl::Context
uint32_t getClearStencilValue() const; uint32_t getClearStencilValue() const;
// Return front facing stencil write mask // Return front facing stencil write mask
uint32_t getStencilMask() const; uint32_t getStencilMask() const;
bool isDepthWriteEnabled() const; bool getDepthMask() const;
const mtl::Format &getPixelFormat(angle::FormatID angleFormatId) const; const mtl::Format &getPixelFormat(angle::FormatID angleFormatId) const;
// See mtl::FormatTable::getVertexFormat() // See mtl::FormatTable::getVertexFormat()
......
...@@ -986,9 +986,9 @@ uint32_t ContextMtl::getStencilMask() const ...@@ -986,9 +986,9 @@ uint32_t ContextMtl::getStencilMask() const
return getState().getDepthStencilState().stencilWritemask; return getState().getDepthStencilState().stencilWritemask;
} }
bool ContextMtl::isDepthWriteEnabled() const bool ContextMtl::getDepthMask() const
{ {
return mDepthStencilDesc.depthWriteEnabled; return getState().getDepthStencilState().depthMask;
} }
const mtl::Format &ContextMtl::getPixelFormat(angle::FormatID angleFormatId) const const mtl::Format &ContextMtl::getPixelFormat(angle::FormatID angleFormatId) const
......
...@@ -587,7 +587,7 @@ angle::Result FramebufferMtl::clearImpl(const gl::Context *context, ...@@ -587,7 +587,7 @@ angle::Result FramebufferMtl::clearImpl(const gl::Context *context,
MTLColorWriteMask colorMask = contextMtl->getColorMask(); MTLColorWriteMask colorMask = contextMtl->getColorMask();
uint32_t stencilMask = contextMtl->getStencilMask(); uint32_t stencilMask = contextMtl->getStencilMask();
if (!contextMtl->isDepthWriteEnabled()) if (!contextMtl->getDepthMask())
{ {
// Disable depth clearing, since depth write is disable // Disable depth clearing, since depth write is disable
clearOpts.clearDepth.reset(); clearOpts.clearDepth.reset();
......
...@@ -270,16 +270,18 @@ void DepthStencilDesc::updateDepthTestEnabled(const gl::DepthStencilState &dsSta ...@@ -270,16 +270,18 @@ void DepthStencilDesc::updateDepthTestEnabled(const gl::DepthStencilState &dsSta
if (!dsState.depthTest) if (!dsState.depthTest)
{ {
depthCompareFunction = MTLCompareFunctionAlways; depthCompareFunction = MTLCompareFunctionAlways;
depthWriteEnabled = false;
} }
else else
{ {
updateDepthCompareFunc(dsState); updateDepthCompareFunc(dsState);
updateDepthWriteEnabled(dsState);
} }
} }
void DepthStencilDesc::updateDepthWriteEnabled(const gl::DepthStencilState &dsState) void DepthStencilDesc::updateDepthWriteEnabled(const gl::DepthStencilState &dsState)
{ {
depthWriteEnabled = dsState.depthMask; depthWriteEnabled = dsState.depthTest && dsState.depthMask;
} }
void DepthStencilDesc::updateDepthCompareFunc(const gl::DepthStencilState &dsState) void DepthStencilDesc::updateDepthCompareFunc(const gl::DepthStencilState &dsState)
......
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