Splits PrepareScene and remove intermediates

We don't need to have intermediate functions as they don't add something
useful.
This commit is contained in:
Vladislav Belov
2026-07-13 00:40:36 +02:00
parent 43dd988ee7
commit d2375de187
6 changed files with 67 additions and 63 deletions
+23 -15
View File
@@ -196,9 +196,16 @@ const CCamera& CGameView::GetCamera() const
return m->ViewCamera;
}
const CCamera& CGameView::GetCullCamera() const
{
return m->CullCamera;
}
void CGameView::SetCamera(const CCamera& camera)
{
m->ViewCamera = camera;
UpdateCullCamera();
}
CCinemaManager* CGameView::GetCinema()
@@ -236,22 +243,9 @@ void CGameView::RegisterInit()
}, L"TerrainTextures", 61);
}
void CGameView::BeginFrame()
void CGameView::EnumerateSceneObjects()
{
if (m->LockCullCamera == false)
{
// Set up cull camera
m->CullCamera = m->ViewCamera;
}
g_Renderer.GetSceneRenderer().SetSceneCamera(m->ViewCamera, m->CullCamera);
m->Game->CachePlayerColors();
}
void CGameView::Prepare(
Renderer::Backend::IDeviceCommandContext* deviceCommandContext)
{
g_Renderer.GetSceneRenderer().PrepareScene(deviceCommandContext, *this);
g_Renderer.GetSceneRenderer().EnumerateSceneObjects(*this);
}
///////////////////////////////////////////////////////////
@@ -297,6 +291,12 @@ void CGameView::Update(const float deltaRealTime)
{
m->MiniMapTexture.Update(deltaRealTime);
UpdateCamera(deltaRealTime);
UpdateCullCamera();
}
void CGameView::UpdateCamera(const float deltaRealTime)
{
m->CinemaManager.Update(deltaRealTime, m->ViewCamera);
if (m->CinemaManager.IsPlaying())
return;
@@ -311,6 +311,12 @@ void CGameView::Update(const float deltaRealTime)
m->CameraController->Update(deltaRealTime);
}
void CGameView::UpdateCullCamera()
{
if (!m->LockCullCamera)
m->CullCamera = m->ViewCamera;
}
CVector3D CGameView::GetCameraPivot() const
{
return m->CameraController->GetCameraPivot();
@@ -334,6 +340,8 @@ float CGameView::GetCameraZoom() const
void CGameView::SetCamera(const CVector3D& pos, float rotX, float rotY, float zoom)
{
m->CameraController->SetCamera(pos, rotX, rotY, zoom);
UpdateCullCamera();
}
void CGameView::MoveCameraTarget(const CVector3D& target)
+5 -2
View File
@@ -52,8 +52,7 @@ public:
*/
void Update(const float deltaRealTime);
void BeginFrame();
void Prepare(Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
void EnumerateSceneObjects();
CVector3D GetCameraPivot() const;
CVector3D GetCameraPosition() const;
@@ -79,6 +78,8 @@ public:
const CCamera& GetCamera() const;
void SetCamera(const CCamera& camera);
const CCamera& GetCullCamera() const;
CCinemaManager* GetCinema();
CObjectManager& GetObjectManager();
@@ -91,6 +92,8 @@ public:
private:
// Unloads all graphics resources loaded by RegisterInit.
void UnloadResources();
void UpdateCamera(const float deltaRealTime);
void UpdateCullCamera();
CGameViewImpl* m;
};
+11 -5
View File
@@ -565,7 +565,12 @@ void CRenderer::RenderFrameImpl(
// prepare before starting the renderer frame
if (g_Game && g_Game->IsGameStarted())
g_Game->GetView()->BeginFrame();
{
const CGameView& gameView{*g_Game->GetView()};
m->sceneRenderer.SetSceneCamera(gameView.GetCamera(), gameView.GetCullCamera());
g_Game->CachePlayerColors();
}
if (g_Game)
m->sceneRenderer.SetSimulation(g_Game->GetSimulation2());
@@ -575,9 +580,10 @@ void CRenderer::RenderFrameImpl(
if (g_Game && g_Game->IsGameStarted())
{
ENSURE(g_Game->GetView());
CGameView& gameView{*g_Game->GetView()};
gameView.Prepare(m->deviceCommandContext.get());
gameView.EnumerateSceneObjects();
m->sceneRenderer.PrepareSubmissions(m->deviceCommandContext.get());
CPostprocManager& postprocManager{GetPostprocManager()};
if (postprocManager.IsEnabled())
@@ -632,7 +638,7 @@ void CRenderer::RenderGameAndGUI(
m->deviceCommandContext->BeginFramebufferPass(framebuffer);
m->deviceCommandContext->SetViewports(1, &viewportRect);
m->sceneRenderer.RenderScene(m->deviceCommandContext.get());
m->sceneRenderer.RenderSubmissions(m->deviceCommandContext.get());
RenderGameOverlays(gameView);
Render2D(renderGUI, renderLogger);
@@ -662,7 +668,7 @@ void CRenderer::RenderGameWithPostProcessingAndGUI(
m->deviceCommandContext->BeginFramebufferPass(framebuffer);
m->deviceCommandContext->SetViewports(1, &viewportRect);
m->sceneRenderer.RenderScene(m->deviceCommandContext.get());
m->sceneRenderer.RenderSubmissions(m->deviceCommandContext.get());
m->deviceCommandContext->EndFramebufferPass();
+16 -23
View File
@@ -749,12 +749,17 @@ void CSceneRenderer::RenderParticles(
}
void CSceneRenderer::PrepareSubmissions(
Renderer::Backend::IDeviceCommandContext* deviceCommandContext,
const CBoundingBoxAligned& waterScissor)
Renderer::Backend::IDeviceCommandContext* deviceCommandContext)
{
PROFILE3_GPU(deviceCommandContext, "prepare submissions");
GPU_SCOPED_LABEL(deviceCommandContext, "Prepare submissions");
if (m->waterManager.m_RenderWater && m_WaterScissor.GetVolume() > 0 && m->waterManager.WillRenderFancyWater())
{
// Render the waves to the Fancy effects texture
m->waterManager.RenderWaves(deviceCommandContext, m_CullCamera.GetFrustum());
}
m->skyManager.LoadAndUploadSkyTexturesIfNeeded(deviceCommandContext);
GetScene().GetLOSTexture().InterpolateLOS(deviceCommandContext);
@@ -802,16 +807,16 @@ void CSceneRenderer::PrepareSubmissions(
if (m->waterManager.m_RenderWater)
{
if (waterScissor.GetVolume() > 0 && m->waterManager.WillRenderFancyWater())
if (m_WaterScissor.GetVolume() > 0 && m->waterManager.WillRenderFancyWater())
{
m->waterManager.UpdateQuality();
PROFILE3_GPU(deviceCommandContext, "water scissor");
if (g_RenderingOptions.GetWaterReflection())
RenderReflections(deviceCommandContext, context, waterScissor);
RenderReflections(deviceCommandContext, context, m_WaterScissor);
if (g_RenderingOptions.GetWaterRefraction())
RenderRefractions(deviceCommandContext, context, waterScissor);
RenderRefractions(deviceCommandContext, context, m_WaterScissor);
if (g_RenderingOptions.GetWaterFancyEffects())
m->terrainRenderer.RenderWaterFoamOccluders(deviceCommandContext, CULL_DEFAULT);
@@ -820,12 +825,13 @@ void CSceneRenderer::PrepareSubmissions(
}
void CSceneRenderer::RenderSubmissions(
Renderer::Backend::IDeviceCommandContext* deviceCommandContext,
const CBoundingBoxAligned& waterScissor)
Renderer::Backend::IDeviceCommandContext* deviceCommandContext)
{
PROFILE3("render submissions");
GPU_SCOPED_LABEL(deviceCommandContext, "Render submissions");
ENSURE(m_CurrentScene);
CShaderDefines context = m->globalContext;
constexpr int cullGroup = CULL_DEFAULT;
@@ -845,7 +851,7 @@ void CSceneRenderer::RenderSubmissions(
RenderModels(deviceCommandContext, context, cullGroup);
// render water
if (m->waterManager.m_RenderWater && g_Game && waterScissor.GetVolume() > 0)
if (m->waterManager.m_RenderWater && g_Game && m_WaterScissor.GetVolume() > 0)
{
if (m->waterManager.WillRenderFancyWater())
{
@@ -1041,12 +1047,11 @@ void CSceneRenderer::SubmitNonRecursive(CModel* model)
}
}
void CSceneRenderer::PrepareScene(
Renderer::Backend::IDeviceCommandContext* deviceCommandContext, Scene& scene)
void CSceneRenderer::EnumerateSceneObjects(Scene& scene)
{
m_CurrentScene = &scene;
CFrustum frustum = m_CullCamera.GetFrustum();
const CFrustum& frustum{m_CullCamera.GetFrustum()};
m_CurrentCullGroup = CULL_DEFAULT;
@@ -1103,24 +1108,12 @@ void CSceneRenderer::PrepareScene(
scene.EnumerateObjects(refractionCamera.GetFrustum(), this);
}
// Render the waves to the Fancy effects texture
m->waterManager.RenderWaves(deviceCommandContext, frustum);
}
}
else
m_WaterScissor = CBoundingBoxAligned{};
m_CurrentCullGroup = -1;
PrepareSubmissions(deviceCommandContext, m_WaterScissor);
}
void CSceneRenderer::RenderScene(
Renderer::Backend::IDeviceCommandContext* deviceCommandContext)
{
ENSURE(m_CurrentScene);
RenderSubmissions(deviceCommandContext, m_WaterScissor);
}
void CSceneRenderer::RenderSceneOverlays(
+9 -16
View File
@@ -92,15 +92,20 @@ public:
/**
* Enumerate and submit all objects of the given scene which should be rendered.
* Must be called before RenderScene.
* Must be called before PrepareSubmissions and RenderScene.
*/
void PrepareScene(
Renderer::Backend::IDeviceCommandContext* deviceCommandContext, Scene& scene);
void EnumerateSceneObjects(Scene& scene);
/**
* Update and upload all needed data for submitted objects.
*/
void PrepareSubmissions(
Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
/**
* Render submitted objects of the previously given scene.
*/
void RenderScene(
void RenderSubmissions(
Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
/**
@@ -204,18 +209,6 @@ protected:
void Submit(SOverlaySphere* overlay) override;
void SubmitNonRecursive(CModel* model) override;
/**
* Update and upload all needed data for submitted objects.
*/
void PrepareSubmissions(
Renderer::Backend::IDeviceCommandContext* deviceCommandContext,
const CBoundingBoxAligned& waterScissor);
// render any batched objects
void RenderSubmissions(
Renderer::Backend::IDeviceCommandContext* deviceCommandContext,
const CBoundingBoxAligned& waterScissor);
// patch rendering stuff
void RenderPatches(
Renderer::Backend::IDeviceCommandContext* deviceCommandContext,
@@ -557,7 +557,8 @@ void ActorViewer::Render()
Renderer::Backend::IDeviceCommandContext* deviceCommandContext =
g_Renderer.GetDeviceCommandContext();
sceneRenderer.PrepareScene(deviceCommandContext, m);
sceneRenderer.EnumerateSceneObjects(m);
sceneRenderer.PrepareSubmissions(deviceCommandContext);
Renderer::Backend::IFramebuffer* backbuffer =
swapChain->GetCurrentBackbuffer(
@@ -572,7 +573,7 @@ void ActorViewer::Render()
viewportRect.height = backbuffer->GetHeight();
deviceCommandContext->SetViewports(1, &viewportRect);
sceneRenderer.RenderScene(deviceCommandContext);
sceneRenderer.RenderSubmissions(deviceCommandContext);
sceneRenderer.RenderSceneOverlays(deviceCommandContext);
{