From d6777a888798be467cb478fb4327427b4a3cc468 Mon Sep 17 00:00:00 2001 From: Bill Freist Date: Mon, 16 Apr 2018 22:04:49 -0700 Subject: [PATCH] Only flush and set the depth test bits if depth is currently enabled already. (#1375) This removes a bug where you could blow away the options set in a previous call to setState() which can enabled/disable depth testing. --- examples/common/debugdraw/debugdraw.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/common/debugdraw/debugdraw.cpp b/examples/common/debugdraw/debugdraw.cpp index 61623348d..bbdd975cf 100644 --- a/examples/common/debugdraw/debugdraw.cpp +++ b/examples/common/debugdraw/debugdraw.cpp @@ -1087,10 +1087,13 @@ struct DebugDrawEncoderImpl if (m_depthTestLess != _depthTestLess) { m_depthTestLess = _depthTestLess; - flush(); Attrib& attrib = m_attrib[m_stack]; - attrib.m_state &= ~BGFX_STATE_DEPTH_TEST_MASK; - attrib.m_state |= _depthTestLess ? BGFX_STATE_DEPTH_TEST_LESS : BGFX_STATE_DEPTH_TEST_GREATER; + if (attrib.m_state & BGFX_STATE_DEPTH_TEST_MASK) + { + flush(); + attrib.m_state &= ~BGFX_STATE_DEPTH_TEST_MASK; + attrib.m_state |= _depthTestLess ? BGFX_STATE_DEPTH_TEST_LESS : BGFX_STATE_DEPTH_TEST_GREATER; + } } }