mirror of https://github.com/bkaradzic/bgfx
Fixed stencil clear when using clear quad.
This commit is contained in:
parent
5b2a141473
commit
8a6b6133ec
|
@ -30,7 +30,7 @@ project "bgfx"
|
||||||
BGFX_DIR .. "src/**.mm",
|
BGFX_DIR .. "src/**.mm",
|
||||||
}
|
}
|
||||||
|
|
||||||
configuration { "(not nacl*) and (not qnx*)" }
|
configuration { "vs*" }
|
||||||
includedirs {
|
includedirs {
|
||||||
--nacl has GLES2 headers modified...
|
--nacl has GLES2 headers modified...
|
||||||
BGFX_DIR .. "3rdparty/glext",
|
BGFX_DIR .. "3rdparty/glext",
|
||||||
|
|
|
@ -1252,12 +1252,14 @@ namespace bgfx
|
||||||
void setViewClear(uint8_t _id, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)
|
void setViewClear(uint8_t _id, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)
|
||||||
{
|
{
|
||||||
BGFX_CHECK_MAIN_THREAD();
|
BGFX_CHECK_MAIN_THREAD();
|
||||||
|
BX_CHECK(_flags != BGFX_CLEAR_NONE, "At least one clear bit flag must be used.");
|
||||||
s_ctx.setViewClear(_id, _flags, _rgba, _depth, _stencil);
|
s_ctx.setViewClear(_id, _flags, _rgba, _depth, _stencil);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setViewClearMask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)
|
void setViewClearMask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)
|
||||||
{
|
{
|
||||||
BGFX_CHECK_MAIN_THREAD();
|
BGFX_CHECK_MAIN_THREAD();
|
||||||
|
BX_CHECK(_flags != BGFX_CLEAR_NONE, "At least one clear bit flag must be used.");
|
||||||
s_ctx.setViewClearMask(_viewMask, _flags, _rgba, _depth, _stencil);
|
s_ctx.setViewClearMask(_viewMask, _flags, _rgba, _depth, _stencil);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -768,7 +768,7 @@ namespace bgfx
|
||||||
|
|
||||||
uint32_t fstencil = unpackStencil(0, _stencil);
|
uint32_t fstencil = unpackStencil(0, _stencil);
|
||||||
uint32_t ref = (fstencil&BGFX_STENCIL_FUNC_REF_MASK)>>BGFX_STENCIL_FUNC_REF_SHIFT;
|
uint32_t ref = (fstencil&BGFX_STENCIL_FUNC_REF_MASK)>>BGFX_STENCIL_FUNC_REF_SHIFT;
|
||||||
_stencil &= packStencil(BGFX_STENCIL_FUNC_REF_MASK, BGFX_STENCIL_MASK);
|
_stencil &= packStencil(~BGFX_STENCIL_FUNC_REF_MASK, BGFX_STENCIL_MASK);
|
||||||
|
|
||||||
HashMurmur2A murmur;
|
HashMurmur2A murmur;
|
||||||
murmur.begin();
|
murmur.begin();
|
||||||
|
@ -1339,8 +1339,19 @@ namespace bgfx
|
||||||
state |= _clear.m_flags & BGFX_CLEAR_COLOR_BIT ? BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE : 0;
|
state |= _clear.m_flags & BGFX_CLEAR_COLOR_BIT ? BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE : 0;
|
||||||
state |= _clear.m_flags & BGFX_CLEAR_DEPTH_BIT ? BGFX_STATE_DEPTH_TEST_ALWAYS|BGFX_STATE_DEPTH_WRITE : 0;
|
state |= _clear.m_flags & BGFX_CLEAR_DEPTH_BIT ? BGFX_STATE_DEPTH_TEST_ALWAYS|BGFX_STATE_DEPTH_WRITE : 0;
|
||||||
|
|
||||||
|
uint64_t stencil = 0;
|
||||||
|
stencil |= _clear.m_flags & BGFX_CLEAR_STENCIL_BIT ? 0
|
||||||
|
| BGFX_STENCIL_TEST_ALWAYS
|
||||||
|
| BGFX_STENCIL_FUNC_REF(_clear.m_stencil)
|
||||||
|
| BGFX_STENCIL_FUNC_RMASK(0xff)
|
||||||
|
| BGFX_STENCIL_OP_FAIL_S_REPLACE
|
||||||
|
| BGFX_STENCIL_OP_FAIL_Z_REPLACE
|
||||||
|
| BGFX_STENCIL_OP_PASS_Z_REPLACE
|
||||||
|
: 0
|
||||||
|
;
|
||||||
|
|
||||||
s_renderCtx.setBlendState(state);
|
s_renderCtx.setBlendState(state);
|
||||||
s_renderCtx.setDepthStencilState(state);
|
s_renderCtx.setDepthStencilState(state, stencil);
|
||||||
s_renderCtx.setRasterizerState(state, false);
|
s_renderCtx.setRasterizerState(state, false);
|
||||||
|
|
||||||
Program& program = s_renderCtx.m_program[m_program.idx];
|
Program& program = s_renderCtx.m_program[m_program.idx];
|
||||||
|
|
|
@ -1938,13 +1938,35 @@ namespace bgfx
|
||||||
#if BGFX_CONFIG_CLEAR_QUAD
|
#if BGFX_CONFIG_CLEAR_QUAD
|
||||||
if (s_renderCtx.m_useClearQuad)
|
if (s_renderCtx.m_useClearQuad)
|
||||||
{
|
{
|
||||||
GL_CHECK(glDisable(GL_STENCIL_TEST) );
|
|
||||||
GL_CHECK(glEnable(GL_DEPTH_TEST) );
|
|
||||||
GL_CHECK(glDepthFunc(GL_ALWAYS) );
|
|
||||||
GL_CHECK(glDisable(GL_CULL_FACE) );
|
GL_CHECK(glDisable(GL_CULL_FACE) );
|
||||||
GL_CHECK(glDisable(GL_BLEND) );
|
GL_CHECK(glDisable(GL_BLEND) );
|
||||||
GL_CHECK(glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) );
|
|
||||||
GL_CHECK(glDepthMask(GL_TRUE) );
|
GLboolean colorMask = !!(BGFX_CLEAR_COLOR_BIT & _clear.m_flags);
|
||||||
|
GL_CHECK(glColorMask(colorMask, colorMask, colorMask, colorMask) );
|
||||||
|
|
||||||
|
GLboolean depthMask = !!(BGFX_CLEAR_DEPTH_BIT & _clear.m_flags);
|
||||||
|
if (depthMask)
|
||||||
|
{
|
||||||
|
GL_CHECK(glEnable(GL_DEPTH_TEST) );
|
||||||
|
GL_CHECK(glDepthFunc(GL_ALWAYS) );
|
||||||
|
GL_CHECK(glDepthMask(depthMask) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GL_CHECK(glDisable(GL_DEPTH_TEST) );
|
||||||
|
}
|
||||||
|
|
||||||
|
GLboolean stencilMask = !!(BGFX_CLEAR_STENCIL_BIT & _clear.m_flags);
|
||||||
|
if (stencilMask)
|
||||||
|
{
|
||||||
|
GL_CHECK(glEnable(GL_STENCIL_TEST) );
|
||||||
|
GL_CHECK(glStencilFuncSeparate(GL_FRONT_AND_BACK, GL_ALWAYS, _clear.m_stencil, 0xff) );
|
||||||
|
GL_CHECK(glStencilOpSeparate(GL_FRONT_AND_BACK, GL_REPLACE, GL_REPLACE, GL_REPLACE) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GL_CHECK(glDisable(GL_STENCIL_TEST) );
|
||||||
|
}
|
||||||
|
|
||||||
VertexBuffer& vb = s_renderCtx.m_vertexBuffers[m_vb->handle.idx];
|
VertexBuffer& vb = s_renderCtx.m_vertexBuffers[m_vb->handle.idx];
|
||||||
VertexDecl& vertexDecl = s_renderCtx.m_vertexDecls[m_vb->decl.idx];
|
VertexDecl& vertexDecl = s_renderCtx.m_vertexDecls[m_vb->decl.idx];
|
||||||
|
|
Loading…
Reference in New Issue