MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / drawFullScreenStencil

Method drawFullScreenStencil

Source/Node/ClipNode.cpp:106–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106void ClipNode::drawFullScreenStencil(uint8_t maskLayer, bool value) {
107 SharedRendererManager.flush();
108 bgfx::TransientVertexBuffer vertexBuffer;
109 bgfx::TransientIndexBuffer indexBuffer;
110 if (bgfx::allocTransientBuffers(&vertexBuffer, PosColorVertex::ms_layout, 4, &indexBuffer, 6)) {
111 Size viewSize = SharedView.getSize();
112 float width = viewSize.width;
113 float height = viewSize.height;
114 Vec4 pos[4] = {
115 {0, height, 0, 1},
116 {width, height, 0, 1},
117 {0, 0, 0, 1},
118 {width, 0, 0, 1}};
119 PosColorVertex* vertices = r_cast<PosColorVertex*>(vertexBuffer.data);
120 Matrix ortho;
121 bx::mtxOrtho(ortho.m, 0, width, 0, height, 0, 1000.0f, 0, bgfx::getCaps()->homogeneousDepth);
122 for (int i = 0; i < 4; i++) {
123 Matrix::mulVec4(&vertices[i].x, ortho, pos[i]);
124 }
125 const uint16_t indices[] = {0, 1, 2, 1, 3, 2};
126 std::memcpy(indexBuffer.data, indices, sizeof(indices[0]) * 6);
127 uint32_t func = BGFX_STENCIL_TEST_NEVER | BGFX_STENCIL_FUNC_REF(maskLayer) | BGFX_STENCIL_FUNC_RMASK(maskLayer);
128 uint32_t fail = value ? BGFX_STENCIL_OP_FAIL_S_REPLACE : BGFX_STENCIL_OP_FAIL_S_ZERO;
129 uint32_t op = fail | BGFX_STENCIL_OP_FAIL_Z_KEEP | BGFX_STENCIL_OP_PASS_Z_KEEP;
130 uint32_t stencil = func | op;
131 bgfx::setStencil(stencil);
132 bgfx::setVertexBuffer(0, &vertexBuffer);
133 bgfx::setIndexBuffer(&indexBuffer);
134 bgfx::setState(BGFX_STATE_NONE);
135 bgfx::ViewId viewId = SharedView.getId();
136 bgfx::submit(viewId, SharedLineRenderer.getDefaultPass()->apply());
137 }
138}
139
140void ClipNode::drawStencil(uint8_t maskLayer, bool value) {
141 uint32_t func = BGFX_STENCIL_TEST_NEVER | BGFX_STENCIL_FUNC_REF(maskLayer) | BGFX_STENCIL_FUNC_RMASK(maskLayer);

Callers

nothing calls this directly

Calls 14

allocTransientBuffersFunction · 0.85
mtxOrthoFunction · 0.85
getCapsFunction · 0.85
getDefaultPassMethod · 0.80
getIdMethod · 0.65
applyMethod · 0.65
memcpyFunction · 0.50
setStencilFunction · 0.50
setVertexBufferFunction · 0.50
setIndexBufferFunction · 0.50
setStateFunction · 0.50
submitFunction · 0.50

Tested by

no test coverage detected