| 730 | } |
| 731 | |
| 732 | void 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; |
nothing calls this directly
no test coverage detected