mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-15 07:00:58 +00:00
Fixed UI clipping bugs #669
This commit is contained in:
parent
1c4968a873
commit
17e865ae2c
4 changed files with 36 additions and 21 deletions
|
@ -162,8 +162,8 @@ void Framebuffer::ResizeFramebuffers()
|
|||
|
||||
globalFramebuffers.ldrFBO = new Framebuffer( "_ldr",
|
||||
nvrhi::FramebufferDesc()
|
||||
.addColorAttachment( globalImages->ldrImage->texture ) );
|
||||
//.setDepthAttachment( globalImages->currentDepthImage->texture ) );
|
||||
.addColorAttachment( globalImages->ldrImage->texture )
|
||||
.setDepthAttachment( globalImages->currentDepthImage->texture ) );
|
||||
|
||||
globalFramebuffers.hdrFBO = new Framebuffer( "_hdr",
|
||||
nvrhi::FramebufferDesc()
|
||||
|
|
|
@ -271,13 +271,6 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf )
|
|||
|
||||
uint64_t stateBits = glStateBits;
|
||||
|
||||
if( currentFrameBuffer == globalFramebuffers.ldrFBO )
|
||||
{
|
||||
// make sure that FBO doesn't require a depth buffer
|
||||
stateBits |= GLS_DEPTHFUNC_ALWAYS | GLS_DEPTHMASK;
|
||||
stateBits &= ~( GLS_STENCIL_FUNC_BITS | GLS_STENCIL_OP_BITS );
|
||||
}
|
||||
|
||||
int program = renderProgManager.CurrentProgram();
|
||||
PipelineKey key{ stateBits, program, depthBias, slopeScaleBias, currentFrameBuffer };
|
||||
auto pipeline = pipelineCache.GetOrCreatePipeline( key );
|
||||
|
|
|
@ -355,14 +355,12 @@ void PipelineCache::GetRenderState( uint64 stateBits, PipelineKey key, nvrhi::Re
|
|||
}
|
||||
}
|
||||
|
||||
nvrhi::DepthStencilState::StencilOpDesc stencilOp;
|
||||
|
||||
//
|
||||
// stencil
|
||||
//
|
||||
//if( diff & ( GLS_STENCIL_FUNC_BITS | GLS_STENCIL_OP_BITS ) )
|
||||
{
|
||||
if( ( stateBits & ( GLS_STENCIL_FUNC_BITS | GLS_STENCIL_OP_BITS ) ) != 0 )
|
||||
if( ( stateBits & ( GLS_STENCIL_FUNC_BITS | GLS_STENCIL_OP_BITS | GLS_SEPARATE_STENCIL ) ) != 0 )
|
||||
{
|
||||
depthStencilState.enableStencil();
|
||||
}
|
||||
|
@ -372,14 +370,40 @@ void PipelineCache::GetRenderState( uint64 stateBits, PipelineKey key, nvrhi::Re
|
|||
}
|
||||
}
|
||||
|
||||
// TODO implement Carmack's Reverse with GLS_SEPARATE_STENCIL
|
||||
|
||||
if( stateBits & ( GLS_STENCIL_FUNC_BITS | GLS_STENCIL_FUNC_REF_BITS | GLS_STENCIL_FUNC_MASK_BITS ) )
|
||||
{
|
||||
depthStencilState.setStencilRefValue( ( stateBits & GLS_STENCIL_FUNC_REF_BITS ) >> GLS_STENCIL_FUNC_REF_SHIFT );
|
||||
depthStencilState.setStencilReadMask( ( stateBits & GLS_STENCIL_FUNC_MASK_BITS ) >> GLS_STENCIL_FUNC_MASK_SHIFT );
|
||||
depthStencilState.setStencilWriteMask( ( stateBits & GLS_STENCIL_FUNC_MASK_BITS ) >> GLS_STENCIL_FUNC_MASK_SHIFT );
|
||||
uint32 ref = uint32( ( stateBits & GLS_STENCIL_FUNC_REF_BITS ) >> GLS_STENCIL_FUNC_REF_SHIFT );
|
||||
uint32 mask = uint32( ( stateBits & GLS_STENCIL_FUNC_MASK_BITS ) >> GLS_STENCIL_FUNC_MASK_SHIFT );
|
||||
|
||||
depthStencilState.setStencilRefValue( ref );
|
||||
depthStencilState.setStencilReadMask( mask );
|
||||
depthStencilState.setStencilWriteMask( 0xFF );
|
||||
}
|
||||
|
||||
// Carmack's Reverse with GLS_SEPARATE_STENCIL
|
||||
if( stateBits & GLS_SEPARATE_STENCIL )
|
||||
{
|
||||
nvrhi::DepthStencilState::StencilOpDesc frontStencilOp = GetStencilOpState( stateBits & GLS_STENCIL_FRONT_OPS );
|
||||
nvrhi::DepthStencilState::StencilOpDesc backStencilOp = GetStencilOpState( ( stateBits & GLS_STENCIL_BACK_OPS ) >> 12 );
|
||||
|
||||
depthStencilState.setFrontFaceStencil( frontStencilOp );
|
||||
depthStencilState.setFrontFaceStencil( backStencilOp );
|
||||
}
|
||||
else
|
||||
{
|
||||
nvrhi::DepthStencilState::StencilOpDesc stencilOp = GetStencilOpState( stateBits );
|
||||
|
||||
depthStencilState.setFrontFaceStencil( stencilOp );
|
||||
depthStencilState.setBackFaceStencil( stencilOp );
|
||||
}
|
||||
}
|
||||
|
||||
nvrhi::DepthStencilState::StencilOpDesc PipelineCache::GetStencilOpState( uint64 stateBits )
|
||||
{
|
||||
nvrhi::DepthStencilState::StencilOpDesc stencilOp;
|
||||
|
||||
//if( stateBits & ( GLS_STENCIL_OP_FAIL_BITS | GLS_STENCIL_OP_ZFAIL_BITS | GLS_STENCIL_OP_PASS_BITS ) )
|
||||
{
|
||||
switch( stateBits & GLS_STENCIL_FUNC_BITS )
|
||||
{
|
||||
case GLS_STENCIL_FUNC_NEVER:
|
||||
|
@ -407,10 +431,7 @@ void PipelineCache::GetRenderState( uint64 stateBits, PipelineKey key, nvrhi::Re
|
|||
stencilOp.setStencilFunc( nvrhi::ComparisonFunc::Always );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( stateBits & ( GLS_STENCIL_OP_FAIL_BITS | GLS_STENCIL_OP_ZFAIL_BITS | GLS_STENCIL_OP_PASS_BITS ) )
|
||||
{
|
||||
switch( stateBits & GLS_STENCIL_OP_FAIL_BITS )
|
||||
{
|
||||
case GLS_STENCIL_OP_FAIL_KEEP:
|
||||
|
@ -496,5 +517,5 @@ void PipelineCache::GetRenderState( uint64 stateBits, PipelineKey key, nvrhi::Re
|
|||
}
|
||||
}
|
||||
|
||||
depthStencilState.setFrontFaceStencil( stencilOp );
|
||||
return stencilOp;
|
||||
}
|
|
@ -77,6 +77,7 @@ public:
|
|||
private:
|
||||
|
||||
void GetRenderState( uint64 stateBits, PipelineKey key, nvrhi::RenderState& renderState );
|
||||
nvrhi::DepthStencilState::StencilOpDesc GetStencilOpState( uint64 stateBits );
|
||||
|
||||
nvrhi::DeviceHandle device;
|
||||
idHashIndex pipelineHash;
|
||||
|
|
Loading…
Reference in a new issue