MCPcopy Create free account
hub / github.com/comaps/comaps / EndFrame

Method EndFrame

libs/drape_frontend/postprocess_renderer.cpp:258–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256}
257
258bool PostprocessRenderer::EndFrame(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> gpuProgramManager,
259 dp::Viewport const & viewport)
260{
261 TRACE_SECTION("[drape] PostprocessRenderer::EndFrame");
262 if (!IsEnabled())
263 return true;
264
265 // Subpixel Morphological Antialiasing (SMAA).
266 if (m_frameStarted && CanRenderAntialiasing())
267 {
268 ASSERT(m_staticTextures->m_smaaAreaTexture != nullptr, ());
269 ASSERT(m_staticTextures->m_smaaSearchTexture != nullptr, ());
270
271 if (m_apiVersion == dp::ApiVersion::OpenGLES3)
272 {
273 ASSERT_GREATER(m_staticTextures->m_smaaAreaTexture->GetID(), 0, ());
274 ASSERT_GREATER(m_staticTextures->m_smaaSearchTexture->GetID(), 0, ());
275 }
276
277 context->SetClearColor(dp::Color::Transparent());
278 context->SetStencilTestEnabled(true);
279
280 // Render edges to texture.
281 {
282 TRACE_SECTION("[drape][SMAA] Edges rendering");
283 context->SetFramebuffer(make_ref(m_edgesFramebuffer));
284 context->Clear(dp::ClearBits::ColorBit, dp::ClearBits::ColorBit | dp::ClearBits::StencilBit /* storeBits */);
285 if (m_apiVersion == dp::ApiVersion::Metal || m_apiVersion == dp::ApiVersion::Vulkan)
286 context->SetStencilFunction(dp::StencilFace::FrontAndBack, dp::TestFunction::Greater);
287 else
288 context->SetStencilFunction(dp::StencilFace::FrontAndBack, dp::TestFunction::NotEqual);
289 context->SetStencilActions(dp::StencilFace::FrontAndBack, dp::StencilAction::Zero, dp::StencilAction::Zero,
290 dp::StencilAction::Replace);
291 context->SetStencilReferenceValue(1);
292 context->ApplyFramebuffer("SMAA edges");
293 viewport.Apply(context);
294
295 EdgesRenderParams params;
296 params.SetParams(m_mainFramebuffer->GetTexture(), m_width, m_height);
297
298 auto program = gpuProgramManager->GetProgram(params.GetRenderState().GetProgram<gpu::Program>());
299 m_screenQuadRenderer->Render(context, program, params.GetRenderState(), gpuProgramManager->GetParamsSetter(),
300 params.GetProgramParams());
301 }
302
303 // Render blending weight to texture.
304 {
305 TRACE_SECTION("[drape][SMAA] Blending weight rendering");
306 context->SetFramebuffer(make_ref(m_blendingWeightFramebuffer));
307 context->Clear(dp::ClearBits::ColorBit, dp::ClearBits::ColorBit | dp::ClearBits::StencilBit /* storeBits */);
308 context->SetStencilFunction(dp::StencilFace::FrontAndBack, dp::TestFunction::Equal);
309 context->SetStencilActions(dp::StencilFace::FrontAndBack, dp::StencilAction::Keep, dp::StencilAction::Keep,
310 dp::StencilAction::Keep);
311 context->ApplyFramebuffer("SMAA blending");
312 viewport.Apply(context);
313
314 BlendingWeightRenderParams params;
315 params.SetParams(m_edgesFramebuffer->GetTexture(), m_staticTextures->m_smaaAreaTexture,

Callers 1

RenderSceneMethod · 0.80

Calls 15

ASSERTFunction · 0.85
make_refFunction · 0.85
GetParamsSetterMethod · 0.80
GetIDMethod · 0.45
SetClearColorMethod · 0.45
SetStencilTestEnabledMethod · 0.45
SetFramebufferMethod · 0.45
ClearMethod · 0.45
SetStencilFunctionMethod · 0.45
SetStencilActionsMethod · 0.45
ApplyFramebufferMethod · 0.45

Tested by

no test coverage detected