MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / End

Method End

Source/Engine/Render2D/Render2D.cpp:732–819  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

730}
731
732void Render2D::End()
733{
734 RENDER2D_CHECK_RENDERING_STATE;
735 ASSERT(Context != nullptr && Output != nullptr);
736 ASSERT(GUIShader != nullptr);
737
738 // Skip if has nothing to draw
739 if (DrawCalls.IsEmpty())
740 {
741 // End
742 Context = nullptr;
743 Output = nullptr;
744 return;
745 }
746
747 PROFILE_GPU_CPU_NAMED("Render2D");
748
749 // Prepare shader
750 GPUShader* shader;
751 {
752 if (!GUIShader->IsLoaded() && GUIShader->WaitForLoaded())
753 {
754 // End
755 DrawCalls.Clear();
756 Context = nullptr;
757 Output = nullptr;
758 return;
759 }
760 shader = GUIShader->GetShader();
761 }
762
763 // Flush geometry buffers
764 {
765 GPUMemoryPass pass(Context);
766 VB.Flush(Context);
767 IB.Flush(Context);
768 }
769
770 // Set output
771 Context->ResetSR();
772 Context->SetRenderTarget(DepthBuffer, Output);
773 Context->SetViewportAndScissors(View);
774 Context->FlushState();
775
776 // Prepare constant buffer
777 GPUConstantBuffer* constantBuffer = shader->GetCB(0);
778 Data data;
779 Matrix::Transpose(ViewProjection, data.ViewProjection);
780 Context->UpdateCB(constantBuffer, &data);
781 Context->BindCB(0, constantBuffer);
782
783 // Prepare PSO
784 if (!PsoDepth.Inited)
785 {
786 PsoDepth.Init(GUIShader.Get()->GetShader(), true);
787 PsoNoDepth.Init(GUIShader.Get()->GetShader(), false);
788 }
789 CurrentPso = DepthBuffer ? &PsoDepth : &PsoNoDepth;

Callers

nothing calls this directly

Calls 15

CanBatchDrawCallsFunction · 0.85
WaitForLoadedMethod · 0.80
DrawBatchFunction · 0.70
TransposeFunction · 0.50
IsEmptyMethod · 0.45
IsLoadedMethod · 0.45
ClearMethod · 0.45
GetShaderMethod · 0.45
FlushMethod · 0.45
ResetSRMethod · 0.45
SetRenderTargetMethod · 0.45
FlushStateMethod · 0.45

Tested by

no test coverage detected