MCPcopy Create free account
hub / github.com/defold/defold / TestDrawStateDispatch

Function TestDrawStateDispatch

engine/render/src/test/test_render.cpp:607–663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

605};
606
607static void TestDrawStateDispatch(dmRender::RenderListDispatchParams const & params)
608{
609 if (params.m_Operation == dmRender::RENDER_LIST_OPERATION_BATCH)
610 {
611 TestDrawStateDispatchCtx* user_ctx = (TestDrawStateDispatchCtx*) params.m_UserData;
612 dmRender::RenderObject* ro_0 = &user_ctx->m_RenderObjects[0];
613
614 ro_0->Init();
615 ro_0->m_Material = user_ctx->m_Material;
616 ro_0->m_VertexCount = 1;
617 ro_0->m_VertexDeclaration = user_ctx->m_VertexDeclaration;
618 ro_0->m_VertexBuffer = user_ctx->m_VertexBuffer;
619
620 // Override blending factors
621 ro_0->m_SetBlendFactors = true;
622 ro_0->m_SourceBlendFactor = dmGraphics::BLEND_FACTOR_ONE;
623 ro_0->m_DestinationBlendFactor = dmGraphics::BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA;
624
625 // Override face winding
626 ro_0->m_SetFaceWinding = true;
627 ro_0->m_FaceWinding = dmGraphics::FACE_WINDING_CW;
628
629 ro_0->m_SetStencilTest = true;
630 ro_0->m_StencilTestParams.m_Front.m_Func = dmGraphics::COMPARE_FUNC_EQUAL;
631 ro_0->m_StencilTestParams.m_Ref = 16; // expected: 0xff after render
632 ro_0->m_StencilTestParams.m_RefMask = 22; // expected: 0x0f after render
633 ro_0->m_StencilTestParams.m_ColorBufferMask = dmGraphics::DM_GRAPHICS_STATE_WRITE_R | dmGraphics::DM_GRAPHICS_STATE_WRITE_A;
634 ro_0->m_StencilTestParams.m_BufferMask = 1;
635
636 dmRender::RenderObject* ro_1 = &user_ctx->m_RenderObjects[1];
637 ro_1->Init();
638 ro_1->m_Material = user_ctx->m_Material;
639 ro_1->m_VertexCount = 1;
640 ro_1->m_VertexDeclaration = user_ctx->m_VertexDeclaration;
641 ro_1->m_VertexBuffer = user_ctx->m_VertexBuffer;
642
643 ro_1->m_SetStencilTest = true;
644 ro_1->m_StencilTestParams.m_SeparateFaceStates = 1;
645
646 // Set some non-specific state values
647 ro_1->m_StencilTestParams.m_Front.m_Func = dmGraphics::COMPARE_FUNC_NOTEQUAL;
648 ro_1->m_StencilTestParams.m_Front.m_OpSFail = dmGraphics::STENCIL_OP_INCR_WRAP;
649 ro_1->m_StencilTestParams.m_Front.m_OpDPFail = dmGraphics::STENCIL_OP_DECR;
650 ro_1->m_StencilTestParams.m_Front.m_OpDPPass = dmGraphics::STENCIL_OP_DECR_WRAP;
651
652 ro_1->m_StencilTestParams.m_Back.m_Func = dmGraphics::COMPARE_FUNC_GEQUAL;
653 ro_1->m_StencilTestParams.m_Back.m_OpSFail = dmGraphics::STENCIL_OP_REPLACE;
654 ro_1->m_StencilTestParams.m_Back.m_OpDPFail = dmGraphics::STENCIL_OP_INVERT;
655 ro_1->m_StencilTestParams.m_Back.m_OpDPPass = dmGraphics::STENCIL_OP_INCR_WRAP;
656
657 ro_1->m_StencilTestParams.m_Ref = 127; // expected: 0xff after render
658 ro_1->m_StencilTestParams.m_RefMask = 11; // expected: 0x0f after render
659
660 AddToRender(user_ctx->m_Context, ro_0);
661 AddToRender(user_ctx->m_Context, ro_1);
662 }
663}
664

Callers

nothing calls this directly

Calls 2

AddToRenderFunction · 0.85
InitMethod · 0.45

Tested by

no test coverage detected