Changeset 27232
- Timestamp:
- Nov 18, 2022, 8:59:18 PM (20 months ago)
- Location:
- ps/trunk/source
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/source/graphics/GameView.cpp
r26250 r27232 234 234 } 235 235 236 void CGameView::Render() 237 { 238 g_Renderer.GetSceneRenderer().RenderScene(g_Renderer.GetDeviceCommandContext(), *this); 236 void CGameView::Prepare( 237 Renderer::Backend::IDeviceCommandContext* deviceCommandContext) 238 { 239 g_Renderer.GetSceneRenderer().PrepareScene(deviceCommandContext, *this); 240 } 241 242 void CGameView::Render( 243 Renderer::Backend::IDeviceCommandContext* deviceCommandContext) 244 { 245 g_Renderer.GetSceneRenderer().RenderScene(deviceCommandContext); 246 } 247 248 void CGameView::RenderOverlays( 249 Renderer::Backend::IDeviceCommandContext* deviceCommandContext) 250 { 251 g_Renderer.GetSceneRenderer().RenderSceneOverlays(deviceCommandContext); 239 252 } 240 253 -
ps/trunk/source/graphics/GameView.h
r26249 r27232 19 19 #define INCLUDED_GAMEVIEW 20 20 21 21 22 #include "renderer/Scene.h" 22 23 #include "simulation2/system/Entity.h" … … 38 39 public: 39 40 CGameView(CGame *pGame); 40 ~CGameView() ;41 ~CGameView(); 41 42 42 43 void SetViewport(const SViewPort& vp); … … 54 55 55 56 void BeginFrame(); 56 void Render(); 57 void Prepare(Renderer::Backend::IDeviceCommandContext* deviceCommandContext); 58 void Render(Renderer::Backend::IDeviceCommandContext* deviceCommandContext); 59 void RenderOverlays(Renderer::Backend::IDeviceCommandContext* deviceCommandContext); 57 60 58 61 InReaction HandleEvent(const SDL_Event_* ev); -
ps/trunk/source/renderer/Renderer.cpp
r27184 r27232 464 464 if (g_Game && g_Game->IsGameStarted()) 465 465 { 466 g_Game->GetView()->Render(); 467 } 468 469 m->deviceCommandContext->BeginFramebufferPass( 470 m->deviceCommandContext->GetDevice()->GetCurrentBackbuffer()); 466 g_Game->GetView()->Prepare(m->deviceCommandContext.get()); 467 468 m->deviceCommandContext->SetGraphicsPipelineState( 469 Renderer::Backend::MakeDefaultGraphicsPipelineStateDesc()); 470 471 CPostprocManager& postprocManager = g_Renderer.GetPostprocManager(); 472 if (postprocManager.IsEnabled()) 473 { 474 // We have to update the post process manager with real near/far planes 475 // that we use for the scene rendering. 476 postprocManager.SetDepthBufferClipPlanes( 477 m->sceneRenderer.GetViewCamera().GetNearPlane(), 478 m->sceneRenderer.GetViewCamera().GetFarPlane() 479 ); 480 postprocManager.Initialize(); 481 postprocManager.CaptureRenderOutput(m->deviceCommandContext.get()); 482 } 483 else 484 { 485 m->deviceCommandContext->BeginFramebufferPass( 486 m->deviceCommandContext->GetDevice()->GetCurrentBackbuffer()); 487 } 488 489 g_Game->GetView()->Render(m->deviceCommandContext.get()); 490 491 if (postprocManager.IsEnabled()) 492 { 493 m->deviceCommandContext->EndFramebufferPass(); 494 495 if (postprocManager.IsMultisampleEnabled()) 496 postprocManager.ResolveMultisampleFramebuffer(m->deviceCommandContext.get()); 497 498 postprocManager.ApplyPostproc(m->deviceCommandContext.get()); 499 postprocManager.ReleaseRenderOutput(m->deviceCommandContext.get()); 500 501 m->deviceCommandContext->BeginFramebufferPass( 502 m->deviceCommandContext->GetDevice()->GetCurrentBackbuffer()); 503 } 504 505 g_Game->GetView()->RenderOverlays(m->deviceCommandContext.get()); 506 } 507 else 508 { 509 m->deviceCommandContext->BeginFramebufferPass( 510 m->deviceCommandContext->GetDevice()->GetCurrentBackbuffer()); 511 } 471 512 472 513 // If we're in Atlas game view, render special tools -
ps/trunk/source/renderer/SceneRenderer.cpp
r27207 r27232 52 52 #include "renderer/OverlayRenderer.h" 53 53 #include "renderer/ParticleRenderer.h" 54 #include "renderer/PostprocManager.h"55 54 #include "renderer/Renderer.h" 56 55 #include "renderer/RenderingOptions.h" … … 758 757 } 759 758 760 // RenderSubmissions: force rendering of any batched objects 761 void CSceneRenderer::RenderSubmissions( 759 void CSceneRenderer::PrepareSubmissions( 762 760 Renderer::Backend::IDeviceCommandContext* deviceCommandContext, 763 761 const CBoundingBoxAligned& waterScissor) 764 762 { 765 PROFILE3(" rendersubmissions");766 GPU_SCOPED_LABEL(deviceCommandContext, " Rendersubmissions");763 PROFILE3(" submissions"); 764 GPU_SCOPED_LABEL(deviceCommandContext, " submissions"); 767 765 768 766 m->skyManager.LoadAndUploadSkyTexturesIfNeeded(deviceCommandContext); … … 774 772 775 773 CShaderDefines context = m->globalContext; 776 777 int cullGroup = CULL_DEFAULT;778 774 779 775 // Set the camera … … 830 826 831 827 if (g_RenderingOptions.GetWaterFancyEffects()) 832 m->terrainRenderer.RenderWaterFoamOccluders(deviceCommandContext, cullGroup);828 m->terrainRenderer.RenderWaterFoamOccluders(deviceCommandContext, ); 833 829 } 834 830 } 835 836 deviceCommandContext->SetGraphicsPipelineState( 837 Renderer::Backend::MakeDefaultGraphicsPipelineStateDesc()); 838 839 CPostprocManager& postprocManager = g_Renderer.GetPostprocManager(); 840 if (postprocManager.IsEnabled()) 841 { 842 // We have to update the post process manager with real near/far planes 843 // that we use for the scene rendering. 844 postprocManager.SetDepthBufferClipPlanes( 845 m_ViewCamera.GetNearPlane(), m_ViewCamera.GetFarPlane() 846 ); 847 postprocManager.Initialize(); 848 postprocManager.CaptureRenderOutput(deviceCommandContext); 849 } 850 else 851 { 852 deviceCommandContext->BeginFramebufferPass( 853 deviceCommandContext->GetDevice()->GetCurrentBackbuffer()); 854 } 831 } 832 833 void CSceneRenderer::RenderSubmissions( 834 Renderer::Backend::IDeviceCommandContext* deviceCommandContext, 835 const CBoundingBoxAligned& waterScissor) 836 { 837 PROFILE3("render submissions"); 838 GPU_SCOPED_LABEL(deviceCommandContext, "Render submissions"); 839 840 CShaderDefines context = m->globalContext; 841 842 constexpr int cullGroup = CULL_DEFAULT; 855 843 856 844 { … … 913 901 } 914 902 915 if (postprocManager.IsEnabled())916 {917 deviceCommandContext->EndFramebufferPass();918 919 if (g_Renderer.GetPostprocManager().IsMultisampleEnabled())920 g_Renderer.GetPostprocManager().ResolveMultisampleFramebuffer(deviceCommandContext);921 922 postprocManager.ApplyPostproc(deviceCommandContext);923 postprocManager.ReleaseRenderOutput(deviceCommandContext);924 deviceCommandContext->BeginFramebufferPass(925 deviceCommandContext->GetDevice()->GetCurrentBackbuffer());926 }927 928 if (g_RenderingOptions.GetSilhouettes())929 {930 RenderSilhouettes(deviceCommandContext, context);931 }932 933 903 // render debug lines 934 904 if (g_RenderingOptions.GetDisplayFrustum()) … … 939 909 940 910 m->silhouetteRenderer.RenderDebugBounds(deviceCommandContext); 941 m->silhouetteRenderer.RenderDebugOverlays(deviceCommandContext);942 943 // render overlays that should appear on top of all other objects944 m->overlayRenderer.RenderForegroundOverlays(deviceCommandContext, m_ViewCamera);945 946 deviceCommandContext->EndFramebufferPass();947 911 } 948 912 … … 1094 1058 } 1095 1059 1096 // Render the given scene 1097 void CSceneRenderer::RenderScene( 1060 void CSceneRenderer::PrepareScene( 1098 1061 Renderer::Backend::IDeviceCommandContext* deviceCommandContext, Scene& scene) 1099 1062 { … … 1132 1095 } 1133 1096 1134 CBoundingBoxAligned waterScissor;1135 1097 if (m->waterManager.m_RenderWater) 1136 1098 { 1137 waterScissor = m->terrainRenderer.ScissorWater(CULL_DEFAULT, m_ViewCamera);1138 1139 if ( waterScissor.GetVolume() > 0 && m->waterManager.WillRenderFancyWater())1099 aterScissor = m->terrainRenderer.ScissorWater(CULL_DEFAULT, m_ViewCamera); 1100 1101 if (aterScissor.GetVolume() > 0 && m->waterManager.WillRenderFancyWater()) 1140 1102 { 1141 1103 if (g_RenderingOptions.GetWaterReflection()) … … 1144 1106 1145 1107 CCamera reflectionCamera; 1146 ComputeReflectionCamera(reflectionCamera, waterScissor);1108 ComputeReflectionCamera(reflectionCamera, aterScissor); 1147 1109 1148 1110 scene.EnumerateObjects(reflectionCamera.GetFrustum(), this); … … 1154 1116 1155 1117 CCamera refractionCamera; 1156 ComputeRefractionCamera(refractionCamera, waterScissor);1118 ComputeRefractionCamera(refractionCamera, aterScissor); 1157 1119 1158 1120 scene.EnumerateObjects(refractionCamera.GetFrustum(), this); … … 1163 1125 } 1164 1126 } 1127 1128 1165 1129 1166 1130 m_CurrentCullGroup = -1; 1167 1131 1168 RenderSubmissions(deviceCommandContext, waterScissor); 1169 1170 m_CurrentScene = NULL; 1132 PrepareSubmissions(deviceCommandContext, m_WaterScissor); 1133 } 1134 1135 void CSceneRenderer::RenderScene( 1136 Renderer::Backend::IDeviceCommandContext* deviceCommandContext) 1137 { 1138 ENSURE(m_CurrentScene); 1139 RenderSubmissions(deviceCommandContext, m_WaterScissor); 1140 } 1141 1142 void CSceneRenderer::RenderSceneOverlays( 1143 Renderer::Backend::IDeviceCommandContext* deviceCommandContext) 1144 { 1145 if (g_RenderingOptions.GetSilhouettes()) 1146 { 1147 RenderSilhouettes(deviceCommandContext, m->globalContext); 1148 } 1149 1150 m->silhouetteRenderer.RenderDebugOverlays(deviceCommandContext); 1151 1152 // Render overlays that should appear on top of all other objects. 1153 m->overlayRenderer.RenderForegroundOverlays(deviceCommandContext, m_ViewCamera); 1154 1155 m_CurrentScene = nullptr; 1171 1156 } 1172 1157 -
ps/trunk/source/renderer/SceneRenderer.h
r26858 r27232 22 22 #include "graphics/ShaderDefines.h" 23 23 #include "graphics/ShaderProgramPtr.h" 24 24 25 #include "ps/Singleton.h" 25 26 #include "renderer/backend/IDeviceCommandContext.h" … … 95 96 96 97 /** 97 * Render the given scene immediately. 98 * @param scene a Scene object describing what should be rendered. 99 */ 100 void RenderScene(Renderer::Backend::IDeviceCommandContext* deviceCommandContext, Scene& scene); 98 * Enumerate and submit all objects of the given scene which should be rendered. 99 * Must be called before RenderScene. 100 */ 101 void PrepareScene( 102 Renderer::Backend::IDeviceCommandContext* deviceCommandContext, Scene& scene); 103 104 /** 105 * Render submitted objects of the previously given scene. 106 */ 107 void RenderScene( 108 Renderer::Backend::IDeviceCommandContext* deviceCommandContext); 109 110 /** 111 * Render overlays of the previously given scene. 112 * Must be called after RenderScene. 113 */ 114 void RenderSceneOverlays( 115 Renderer::Backend::IDeviceCommandContext* deviceCommandContext); 101 116 102 117 /** … … 194 209 void SubmitNonRecursive(CModel* model) override; 195 210 211 212 213 214 215 216 217 196 218 // render any batched objects 197 219 void RenderSubmissions( … … 273 295 int m_CurrentCullGroup; 274 296 297 298 275 299 // current lighting setup 276 300 CLightEnv* m_LightEnv; -
ps/trunk/source/tools/atlas/GameInterface/ActorViewer.cpp
r27111 r27232 45 45 #include "ps/ProfileViewer.h" 46 46 #include "ps/VideoMode.h" 47 48 47 49 #include "renderer/Renderer.h" 48 50 #include "renderer/RenderingOptions.h" … … 510 512 // TODO: ActorViewer should reuse CRenderer code and not duplicate it. 511 513 514 515 512 516 // Set simulation context for rendering purposes 513 g_Renderer.GetSceneRenderer().SetSimulation(&m.Simulation2);517 .SetSimulation(&m.Simulation2); 514 518 515 519 // Find the centre of the interesting region, in the middle of the patch … … 527 531 camera.UpdateFrustum(); 528 532 529 g_Renderer.GetSceneRenderer().SetSceneCamera(camera, camera);533 .SetSceneCamera(camera, camera); 530 534 531 535 g_Renderer.BeginFrame(); 532 536 533 g_Renderer.GetSceneRenderer().RenderScene(g_Renderer.GetDeviceCommandContext(), m); 534 535 { 536 CCanvas2D canvas(g_xres, g_yres, g_VideoMode.GetScale(), g_Renderer.GetDeviceCommandContext()); 537 Renderer::Backend::IDeviceCommandContext* deviceCommandContext = 538 g_Renderer.GetDeviceCommandContext(); 539 540 sceneRenderer.PrepareScene(deviceCommandContext, m); 541 542 deviceCommandContext->BeginFramebufferPass( 543 deviceCommandContext->GetDevice()->GetCurrentBackbuffer()); 544 545 sceneRenderer.RenderScene(deviceCommandContext); 546 sceneRenderer.RenderSceneOverlays(deviceCommandContext); 547 548 { 549 CCanvas2D canvas(g_xres, g_yres, g_VideoMode.GetScale(), deviceCommandContext); 537 550 g_Logger->Render(canvas); 538 551 g_ProfileViewer.RenderProfile(canvas); 539 552 } 553 554 540 555 541 556 g_Renderer.EndFrame();
Note:
See TracChangeset
for help on using the changeset viewer.