| 488 | } |
| 489 | |
| 490 | static void ApplyRenderState(HRenderContext render_context, dmGraphics::HContext graphics_context, dmGraphics::PipelineState ps_default, const RenderObject* ro) |
| 491 | { |
| 492 | dmGraphics::PipelineState ps_now = ps_default; |
| 493 | |
| 494 | if (ro->m_SetBlendFactors) |
| 495 | { |
| 496 | ps_now.m_BlendSrcFactor = ro->m_SourceBlendFactor; |
| 497 | ps_now.m_BlendDstFactor = ro->m_DestinationBlendFactor; |
| 498 | ps_now.m_BlendSrcFactorAlpha = ro->m_SourceBlendFactor; |
| 499 | ps_now.m_BlendDstFactorAlpha = ro->m_DestinationBlendFactor; |
| 500 | } |
| 501 | |
| 502 | if (ro->m_SetFaceWinding) |
| 503 | { |
| 504 | ps_now.m_FaceWinding = ro->m_FaceWinding; |
| 505 | } |
| 506 | |
| 507 | if (ro->m_SetStencilTest) |
| 508 | { |
| 509 | const StencilTestParams& stp = ro->m_StencilTestParams; |
| 510 | if (stp.m_ClearBuffer) |
| 511 | { |
| 512 | // Note: We don't need to save any of these values in the pipeline |
| 513 | if (render_context->m_StencilBufferCleared) |
| 514 | { |
| 515 | // render.clear command will set context m_StencilBufferCleared to 1 if stencil clear flag is set. |
| 516 | // We skip clear and reset context m_StencilBufferCleared to 0, indicating that the stencil is no longer cleared. |
| 517 | // Concecutive calls with m_ClearBuffer option will result in a clear until render.clear is called with stencil clear flag set. |
| 518 | render_context->m_StencilBufferCleared = 0; |
| 519 | } |
| 520 | else |
| 521 | { |
| 522 | dmGraphics::SetStencilMask(graphics_context, 0xff); |
| 523 | dmGraphics::Clear(graphics_context, dmGraphics::BUFFER_TYPE_STENCIL_BIT, 0, 0, 0, 0, 1.0f, 0); |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | ps_now.m_WriteColorMask = stp.m_ColorBufferMask; |
| 528 | ps_now.m_StencilWriteMask = stp.m_BufferMask; |
| 529 | ps_now.m_StencilReference = stp.m_Ref; |
| 530 | ps_now.m_StencilCompareMask = stp.m_RefMask; |
| 531 | ps_now.m_StencilFrontTestFunc = stp.m_Front.m_Func; |
| 532 | ps_now.m_StencilFrontOpFail = stp.m_Front.m_OpSFail; |
| 533 | ps_now.m_StencilFrontOpDepthFail = stp.m_Front.m_OpDPFail; |
| 534 | ps_now.m_StencilFrontOpPass = stp.m_Front.m_OpDPPass; |
| 535 | |
| 536 | if (stp.m_SeparateFaceStates) |
| 537 | { |
| 538 | ps_now.m_StencilBackTestFunc = stp.m_Back.m_Func; |
| 539 | ps_now.m_StencilBackOpFail = stp.m_Back.m_OpSFail; |
| 540 | ps_now.m_StencilBackOpDepthFail = stp.m_Back.m_OpDPFail; |
| 541 | ps_now.m_StencilBackOpPass = stp.m_Back.m_OpDPPass; |
| 542 | } |
| 543 | else |
| 544 | { |
| 545 | ps_now.m_StencilBackTestFunc = stp.m_Front.m_Func; |
| 546 | ps_now.m_StencilBackOpFail = stp.m_Front.m_OpSFail; |
| 547 | ps_now.m_StencilBackOpDepthFail = stp.m_Front.m_OpDPFail; |
no test coverage detected