forked from mirrors/0ad
Pass device command context by reference in DebugRenderer
Improve the DebugRenderer API by passing the IDeviceCommandContext as a reference instead of calling g_Renderer. Fixes: #6650
This commit is contained in:
committed by
Vladislav Belov
parent
8962e066c9
commit
5daae13525
@@ -63,6 +63,7 @@
|
||||
{ "name": "Cédric Houbart" },
|
||||
{ "nick": "Ceres" },
|
||||
{ "nick": "Chakakhan", "name": "Kenny Long" },
|
||||
{ "nick": "Chrzanof", "name": "Filip Chrzanowski" },
|
||||
{ "nick": "Clockwork-Muse", "name": "Stephen A. Imhoff" },
|
||||
{ "nick": "cpc", "name": "Clément Pit-Claudel" },
|
||||
{ "nick": "Cracker78", "name": "Chad Heim" },
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -54,13 +54,13 @@ void CCinemaManager::Update(const float deltaRealTime) const
|
||||
cmpCinemaManager->PlayQueue(deltaRealTime, g_Game->GetView()->GetCamera());
|
||||
}
|
||||
|
||||
void CCinemaManager::Render() const
|
||||
void CCinemaManager::Render(Renderer::Backend::IDeviceCommandContext& deviceCommandContext) const
|
||||
{
|
||||
if (!IsEnabled() && m_DrawPaths)
|
||||
DrawPaths();
|
||||
DrawPaths(deviceCommandContext);
|
||||
}
|
||||
|
||||
void CCinemaManager::DrawPaths() const
|
||||
void CCinemaManager::DrawPaths(Renderer::Backend::IDeviceCommandContext& deviceCommandContext) const
|
||||
{
|
||||
CmpPtr<ICmpCinemaManager> cmpCinemaManager(g_Game->GetSimulation2()->GetSimContext().GetSystemEntity());
|
||||
if (!cmpCinemaManager)
|
||||
@@ -68,18 +68,18 @@ void CCinemaManager::DrawPaths() const
|
||||
|
||||
for (const std::pair<const CStrW, CCinemaPath>& p : cmpCinemaManager->GetPaths())
|
||||
{
|
||||
DrawSpline(p.second, CColor(0.2f, 0.2f, 1.f, 0.9f), 128);
|
||||
DrawNodes(p.second, CColor(0.1f, 1.f, 0.f, 1.f));
|
||||
DrawSpline(deviceCommandContext, p.second, CColor(0.2f, 0.2f, 1.f, 0.9f), 128);
|
||||
DrawNodes(deviceCommandContext, p.second, CColor(0.1f, 1.f, 0.f, 1.f));
|
||||
|
||||
if (p.second.GetTargetSpline().GetAllNodes().empty())
|
||||
continue;
|
||||
|
||||
DrawSpline(p.second.GetTargetSpline(), CColor(1.f, 0.3f, 0.4f, 0.9f), 128);
|
||||
DrawNodes(p.second.GetTargetSpline(), CColor(1.f, 0.1f, 0.f, 1.f));
|
||||
DrawSpline(deviceCommandContext, p.second.GetTargetSpline(), CColor(1.f, 0.3f, 0.4f, 0.9f), 128);
|
||||
DrawNodes(deviceCommandContext, p.second.GetTargetSpline(), CColor(1.f, 0.1f, 0.f, 1.f));
|
||||
}
|
||||
}
|
||||
|
||||
void CCinemaManager::DrawSpline(const RNSpline& spline, const CColor& splineColor, int smoothness) const
|
||||
void CCinemaManager::DrawSpline(Renderer::Backend::IDeviceCommandContext& deviceCommandContext, const RNSpline& spline, const CColor& splineColor, int smoothness) const
|
||||
{
|
||||
if (spline.GetAllNodes().size() < 2)
|
||||
return;
|
||||
@@ -94,7 +94,8 @@ void CCinemaManager::DrawSpline(const RNSpline& spline, const CColor& splineColo
|
||||
const float time = start * i / spline.MaxDistance.ToFloat();
|
||||
line.emplace_back(spline.GetPosition(time));
|
||||
}
|
||||
g_Renderer.GetDebugRenderer().DrawLine(line, splineColor, 0.2f, false);
|
||||
|
||||
g_Renderer.GetDebugRenderer().DrawLine(deviceCommandContext, line, splineColor, 0.2f, false);
|
||||
|
||||
// Height indicator
|
||||
if (g_Game && g_Game->GetWorld())
|
||||
@@ -104,16 +105,17 @@ void CCinemaManager::DrawSpline(const RNSpline& spline, const CColor& splineColo
|
||||
const float time = start * i / spline.MaxDistance.ToFloat();
|
||||
const CVector3D tmp = spline.GetPosition(time);
|
||||
const float groundY = g_Game->GetWorld()->GetTerrain().GetExactGroundLevel(tmp.X, tmp.Z);
|
||||
g_Renderer.GetDebugRenderer().DrawLine(tmp, CVector3D(tmp.X, groundY, tmp.Z), splineColor, 0.1f, false);
|
||||
g_Renderer.GetDebugRenderer().DrawLine(deviceCommandContext, tmp, CVector3D(tmp.X, groundY, tmp.Z), splineColor, 0.1f, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCinemaManager::DrawNodes(const RNSpline& spline, const CColor& nodeColor) const
|
||||
void CCinemaManager::DrawNodes(Renderer::Backend::IDeviceCommandContext& deviceCommandContext, const RNSpline& spline, const CColor& nodeColor) const
|
||||
{
|
||||
for (const SplineData& node : spline.GetAllNodes())
|
||||
{
|
||||
g_Renderer.GetDebugRenderer().DrawCircle(
|
||||
deviceCommandContext,
|
||||
CVector3D(node.Position.X.ToFloat(), node.Position.Y.ToFloat(), node.Position.Z.ToFloat()),
|
||||
0.5f, nodeColor);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
/**
|
||||
* Renders paths and their nodes (if enabled).
|
||||
*/
|
||||
void Render() const;
|
||||
void Render(Renderer::Backend::IDeviceCommandContext& deviceCommandContext) const;
|
||||
|
||||
bool IsPlaying() const;
|
||||
bool IsEnabled() const;
|
||||
@@ -49,9 +49,9 @@ public:
|
||||
void SetPathsDrawing(const bool drawPath);
|
||||
|
||||
private:
|
||||
void DrawPaths() const;
|
||||
void DrawSpline(const RNSpline& spline, const CColor& splineColor, int smoothness) const;
|
||||
void DrawNodes(const RNSpline& spline, const CColor& nodesColor) const;
|
||||
void DrawPaths(Renderer::Backend::IDeviceCommandContext& deviceCommandContext) const;
|
||||
void DrawSpline(Renderer::Backend::IDeviceCommandContext& deviceCommandContext, const RNSpline& spline, const CColor& splineColor, int smoothness) const;
|
||||
void DrawNodes(Renderer::Backend::IDeviceCommandContext& deviceCommandContext, const RNSpline& spline, const CColor& nodesColor) const;
|
||||
|
||||
bool m_DrawPaths;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -52,38 +52,37 @@ void CDebugRenderer::Initialize()
|
||||
}
|
||||
|
||||
void CDebugRenderer::DrawLine(
|
||||
Renderer::Backend::IDeviceCommandContext& deviceCommandContext,
|
||||
const CVector3D& from, const CVector3D& to, const CColor& color,
|
||||
const float width, const bool depthTestEnabled)
|
||||
{
|
||||
if (from == to)
|
||||
return;
|
||||
|
||||
DrawLine({from, to}, color, width, depthTestEnabled);
|
||||
DrawLine(deviceCommandContext, {from, to}, color, width, depthTestEnabled);
|
||||
}
|
||||
|
||||
void CDebugRenderer::DrawLine(
|
||||
Renderer::Backend::IDeviceCommandContext& deviceCommandContext,
|
||||
const std::vector<CVector3D>& line, const CColor& color,
|
||||
const float width, const bool depthTestEnabled)
|
||||
{
|
||||
if (line.size() <= 1)
|
||||
return;
|
||||
|
||||
Renderer::Backend::IDeviceCommandContext* deviceCommandContext =
|
||||
g_Renderer.GetDeviceCommandContext();
|
||||
|
||||
CShaderTechniquePtr debugLineTech =
|
||||
GetShaderTechnique(str_debug_line, color, depthTestEnabled);
|
||||
deviceCommandContext->SetGraphicsPipelineState(
|
||||
deviceCommandContext.SetGraphicsPipelineState(
|
||||
debugLineTech->GetGraphicsPipelineState());
|
||||
deviceCommandContext->BeginPass();
|
||||
deviceCommandContext.BeginPass();
|
||||
|
||||
const CCamera& viewCamera = g_Renderer.GetSceneRenderer().GetViewCamera();
|
||||
|
||||
Renderer::Backend::IShaderProgram* debugLineShader = debugLineTech->GetShader();
|
||||
const CMatrix3D transform = viewCamera.GetViewProjection();
|
||||
deviceCommandContext->SetUniform(
|
||||
deviceCommandContext.SetUniform(
|
||||
debugLineShader->GetBindingSlot(str_transform), transform.AsFloatArray());
|
||||
deviceCommandContext->SetUniform(
|
||||
deviceCommandContext.SetUniform(
|
||||
debugLineShader->GetBindingSlot(str_color), color.AsFloatArray());
|
||||
|
||||
const CVector3D cameraIn = viewCamera.GetOrientation().GetIn();
|
||||
@@ -115,35 +114,34 @@ void CDebugRenderer::DrawLine(
|
||||
|
||||
#undef ADD
|
||||
|
||||
deviceCommandContext->SetVertexInputLayout(m_VertexInputLayout);
|
||||
deviceCommandContext->SetVertexBufferData(
|
||||
deviceCommandContext.SetVertexInputLayout(m_VertexInputLayout);
|
||||
deviceCommandContext.SetVertexBufferData(
|
||||
0, vertices.data(), vertices.size() * sizeof(vertices[0]));
|
||||
|
||||
deviceCommandContext->Draw(0, vertices.size() / 3);
|
||||
deviceCommandContext.Draw(0, vertices.size() / 3);
|
||||
|
||||
deviceCommandContext->EndPass();
|
||||
deviceCommandContext.EndPass();
|
||||
}
|
||||
|
||||
void CDebugRenderer::DrawCircle(const CVector3D& origin, const float radius, const CColor& color)
|
||||
void CDebugRenderer::DrawCircle(
|
||||
Renderer::Backend::IDeviceCommandContext& deviceCommandContext,
|
||||
const CVector3D& origin, const float radius, const CColor& color)
|
||||
{
|
||||
CShaderTechniquePtr debugCircleTech =
|
||||
GetShaderTechnique(str_debug_line, color);
|
||||
|
||||
Renderer::Backend::IDeviceCommandContext* deviceCommandContext =
|
||||
g_Renderer.GetDeviceCommandContext();
|
||||
|
||||
deviceCommandContext->SetGraphicsPipelineState(
|
||||
deviceCommandContext.SetGraphicsPipelineState(
|
||||
debugCircleTech->GetGraphicsPipelineState());
|
||||
deviceCommandContext->BeginPass();
|
||||
deviceCommandContext.BeginPass();
|
||||
|
||||
const CCamera& camera = g_Renderer.GetSceneRenderer().GetViewCamera();
|
||||
|
||||
Renderer::Backend::IShaderProgram* debugCircleShader = debugCircleTech->GetShader();
|
||||
|
||||
const CMatrix3D transform = camera.GetViewProjection();
|
||||
deviceCommandContext->SetUniform(
|
||||
deviceCommandContext.SetUniform(
|
||||
debugCircleShader->GetBindingSlot(str_transform), transform.AsFloatArray());
|
||||
deviceCommandContext->SetUniform(
|
||||
deviceCommandContext.SetUniform(
|
||||
debugCircleShader->GetBindingSlot(str_color), color.AsFloatArray());
|
||||
|
||||
const CVector3D cameraUp = camera.GetOrientation().GetUp();
|
||||
@@ -169,16 +167,17 @@ void CDebugRenderer::DrawCircle(const CVector3D& origin, const float radius, con
|
||||
|
||||
#undef ADD
|
||||
|
||||
deviceCommandContext->SetVertexInputLayout(m_VertexInputLayout);
|
||||
deviceCommandContext->SetVertexBufferData(
|
||||
deviceCommandContext.SetVertexInputLayout(m_VertexInputLayout);
|
||||
deviceCommandContext.SetVertexBufferData(
|
||||
0, vertices.data(), vertices.size() * sizeof(vertices[0]));
|
||||
|
||||
deviceCommandContext->Draw(0, vertices.size() / 3);
|
||||
deviceCommandContext.Draw(0, vertices.size() / 3);
|
||||
|
||||
deviceCommandContext->EndPass();
|
||||
deviceCommandContext.EndPass();
|
||||
}
|
||||
|
||||
void CDebugRenderer::DrawCameraFrustum(const CCamera& camera, const CColor& color, int intermediates, bool wireframe)
|
||||
void CDebugRenderer::DrawCameraFrustum(Renderer::Backend::IDeviceCommandContext& deviceCommandContext,
|
||||
const CCamera& camera, const CColor& color, int intermediates, bool wireframe)
|
||||
{
|
||||
CCamera::Quad nearPoints{camera.GetViewQuad(camera.GetNearPlane())};
|
||||
for (CVector3D& point : nearPoints)
|
||||
@@ -190,18 +189,16 @@ void CDebugRenderer::DrawCameraFrustum(const CCamera& camera, const CColor& colo
|
||||
CShaderTechniquePtr overlayTech =
|
||||
GetShaderTechnique(str_debug_line, color, true, wireframe);
|
||||
|
||||
Renderer::Backend::IDeviceCommandContext* deviceCommandContext =
|
||||
g_Renderer.GetDeviceCommandContext();
|
||||
deviceCommandContext->SetGraphicsPipelineState(
|
||||
deviceCommandContext.SetGraphicsPipelineState(
|
||||
overlayTech->GetGraphicsPipelineState());
|
||||
deviceCommandContext->BeginPass();
|
||||
deviceCommandContext.BeginPass();
|
||||
|
||||
Renderer::Backend::IShaderProgram* overlayShader = overlayTech->GetShader();
|
||||
|
||||
const CMatrix3D transform = g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection();
|
||||
deviceCommandContext->SetUniform(
|
||||
deviceCommandContext.SetUniform(
|
||||
overlayShader->GetBindingSlot(str_transform), transform.AsFloatArray());
|
||||
deviceCommandContext->SetUniform(
|
||||
deviceCommandContext.SetUniform(
|
||||
overlayShader->GetBindingSlot(str_color), color.AsFloatArray());
|
||||
|
||||
std::vector<float> vertices;
|
||||
@@ -243,11 +240,11 @@ void CDebugRenderer::DrawCameraFrustum(const CCamera& camera, const CColor& colo
|
||||
ADD(intermediatePoints[3]);
|
||||
}
|
||||
|
||||
deviceCommandContext->SetVertexInputLayout(m_VertexInputLayout);
|
||||
deviceCommandContext->SetVertexBufferData(
|
||||
deviceCommandContext.SetVertexInputLayout(m_VertexInputLayout);
|
||||
deviceCommandContext.SetVertexBufferData(
|
||||
0, vertices.data(), vertices.size() * sizeof(vertices[0]));
|
||||
|
||||
deviceCommandContext->Draw(0, vertices.size() / 3);
|
||||
deviceCommandContext.Draw(0, vertices.size() / 3);
|
||||
|
||||
vertices.clear();
|
||||
|
||||
@@ -263,43 +260,44 @@ void CDebugRenderer::DrawCameraFrustum(const CCamera& camera, const CColor& colo
|
||||
ADD(farPoints[nextI]);
|
||||
}
|
||||
|
||||
deviceCommandContext->SetVertexInputLayout(m_VertexInputLayout);
|
||||
deviceCommandContext->SetVertexBufferData(
|
||||
deviceCommandContext.SetVertexInputLayout(m_VertexInputLayout);
|
||||
deviceCommandContext.SetVertexBufferData(
|
||||
0, vertices.data(), vertices.size() * sizeof(vertices[0]));
|
||||
|
||||
deviceCommandContext->Draw(0, vertices.size() / 3);
|
||||
deviceCommandContext.Draw(0, vertices.size() / 3);
|
||||
#undef ADD
|
||||
|
||||
deviceCommandContext->EndPass();
|
||||
deviceCommandContext.EndPass();
|
||||
}
|
||||
|
||||
void CDebugRenderer::DrawBoundingBox(
|
||||
Renderer::Backend::IDeviceCommandContext& deviceCommandContext,
|
||||
const CBoundingBoxAligned& boundingBox, const CColor& color,
|
||||
bool wireframe)
|
||||
{
|
||||
DrawBoundingBox(
|
||||
deviceCommandContext,
|
||||
boundingBox, color,
|
||||
g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection(), wireframe);
|
||||
}
|
||||
|
||||
void CDebugRenderer::DrawBoundingBox(
|
||||
Renderer::Backend::IDeviceCommandContext& deviceCommandContext,
|
||||
const CBoundingBoxAligned& boundingBox, const CColor& color,
|
||||
const CMatrix3D& transform, bool wireframe)
|
||||
{
|
||||
CShaderTechniquePtr shaderTech =
|
||||
GetShaderTechnique(str_debug_line, color, true, wireframe);
|
||||
|
||||
Renderer::Backend::IDeviceCommandContext* deviceCommandContext =
|
||||
g_Renderer.GetDeviceCommandContext();
|
||||
deviceCommandContext->SetGraphicsPipelineState(
|
||||
deviceCommandContext.SetGraphicsPipelineState(
|
||||
shaderTech->GetGraphicsPipelineState());
|
||||
deviceCommandContext->BeginPass();
|
||||
deviceCommandContext.BeginPass();
|
||||
|
||||
Renderer::Backend::IShaderProgram* shader = shaderTech->GetShader();
|
||||
|
||||
deviceCommandContext->SetUniform(
|
||||
deviceCommandContext.SetUniform(
|
||||
shader->GetBindingSlot(str_transform), transform.AsFloatArray());
|
||||
deviceCommandContext->SetUniform(
|
||||
deviceCommandContext.SetUniform(
|
||||
shader->GetBindingSlot(str_color), color.AsFloatArray());
|
||||
|
||||
std::vector<float> data;
|
||||
@@ -323,32 +321,32 @@ void CDebugRenderer::DrawBoundingBox(
|
||||
|
||||
#undef ADD_FACE
|
||||
|
||||
deviceCommandContext->SetVertexInputLayout(m_VertexInputLayout);
|
||||
deviceCommandContext->SetVertexBufferData(
|
||||
deviceCommandContext.SetVertexInputLayout(m_VertexInputLayout);
|
||||
deviceCommandContext.SetVertexBufferData(
|
||||
0, data.data(), data.size() * sizeof(data[0]));
|
||||
|
||||
deviceCommandContext->Draw(0, 6 * 6);
|
||||
deviceCommandContext.Draw(0, 6 * 6);
|
||||
|
||||
deviceCommandContext->EndPass();
|
||||
deviceCommandContext.EndPass();
|
||||
}
|
||||
|
||||
void CDebugRenderer::DrawBrush(const CBrush& brush, const CColor& color, bool wireframe)
|
||||
void CDebugRenderer::DrawBrush(
|
||||
Renderer::Backend::IDeviceCommandContext& deviceCommandContext,
|
||||
const CBrush& brush, const CColor& color, bool wireframe)
|
||||
{
|
||||
CShaderTechniquePtr shaderTech =
|
||||
GetShaderTechnique(str_debug_line, color, true, wireframe);
|
||||
|
||||
Renderer::Backend::IDeviceCommandContext* deviceCommandContext =
|
||||
g_Renderer.GetDeviceCommandContext();
|
||||
deviceCommandContext->SetGraphicsPipelineState(
|
||||
deviceCommandContext.SetGraphicsPipelineState(
|
||||
shaderTech->GetGraphicsPipelineState());
|
||||
deviceCommandContext->BeginPass();
|
||||
deviceCommandContext.BeginPass();
|
||||
|
||||
Renderer::Backend::IShaderProgram* shader = shaderTech->GetShader();
|
||||
|
||||
const CMatrix3D transform = g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection();
|
||||
deviceCommandContext->SetUniform(
|
||||
deviceCommandContext.SetUniform(
|
||||
shader->GetBindingSlot(str_transform), transform.AsFloatArray());
|
||||
deviceCommandContext->SetUniform(
|
||||
deviceCommandContext.SetUniform(
|
||||
shader->GetBindingSlot(str_color), color.AsFloatArray());
|
||||
|
||||
std::vector<float> data;
|
||||
@@ -376,13 +374,13 @@ void CDebugRenderer::DrawBrush(const CBrush& brush, const CColor& color, bool wi
|
||||
|
||||
#undef ADD_VERT
|
||||
|
||||
deviceCommandContext->SetVertexInputLayout(m_VertexInputLayout);
|
||||
deviceCommandContext->SetVertexBufferData(
|
||||
deviceCommandContext.SetVertexInputLayout(m_VertexInputLayout);
|
||||
deviceCommandContext.SetVertexBufferData(
|
||||
0, data.data(), data.size() * sizeof(data[0]));
|
||||
|
||||
deviceCommandContext->Draw(0, data.size() / 5);
|
||||
deviceCommandContext.Draw(0, data.size() / 5);
|
||||
|
||||
deviceCommandContext->EndPass();
|
||||
deviceCommandContext.EndPass();
|
||||
}
|
||||
|
||||
size_t CDebugRenderer::ShaderTechniqueKeyHash::operator()(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -43,15 +43,15 @@ public:
|
||||
/**
|
||||
* Render the line in world space.
|
||||
*/
|
||||
void DrawLine(const CVector3D& from, const CVector3D& to,
|
||||
const CColor& color, const float width, const bool depthTestEnabled = true);
|
||||
void DrawLine(const std::vector<CVector3D>& line,
|
||||
void DrawLine(Renderer::Backend::IDeviceCommandContext& deviceCommandContext, const CVector3D& from, const CVector3D& to,
|
||||
const CColor& color, const float width, const bool depthTestEnabled = true);
|
||||
void DrawLine(Renderer::Backend::IDeviceCommandContext& deviceCommandContext, const std::vector<CVector3D>& line,
|
||||
const CColor& color, const float width, const bool depthTestEnabled = true);
|
||||
|
||||
/**
|
||||
* Render the circle in world space oriented to the view camera.
|
||||
*/
|
||||
void DrawCircle(const CVector3D& origin, const float radius, const CColor& color);
|
||||
void DrawCircle(Renderer::Backend::IDeviceCommandContext& deviceCommandContext, const CVector3D& origin, const float radius, const CColor& color);
|
||||
|
||||
/**
|
||||
* Render: Renders the camera's frustum in world space.
|
||||
@@ -59,18 +59,18 @@ public:
|
||||
* @param intermediates determines how many intermediate distance planes should
|
||||
* be hinted at between the near and far planes
|
||||
*/
|
||||
void DrawCameraFrustum(const CCamera& camera, const CColor& color, int intermediates = 0, bool wireframe = false);
|
||||
void DrawCameraFrustum(Renderer::Backend::IDeviceCommandContext& deviceCommandContext, const CCamera& camera, const CColor& color, int intermediates = 0, bool wireframe = false);
|
||||
|
||||
/**
|
||||
* Render the surfaces of the bound box as triangles.
|
||||
*/
|
||||
void DrawBoundingBox(const CBoundingBoxAligned& boundingBox, const CColor& color, bool wireframe = false);
|
||||
void DrawBoundingBox(const CBoundingBoxAligned& boundingBox, const CColor& color, const CMatrix3D& transform, bool wireframe = false);
|
||||
void DrawBoundingBox(Renderer::Backend::IDeviceCommandContext& deviceCommandContext, const CBoundingBoxAligned& boundingBox, const CColor& color, bool wireframe = false);
|
||||
void DrawBoundingBox(Renderer::Backend::IDeviceCommandContext& deviceCommandContext, const CBoundingBoxAligned& boundingBox, const CColor& color, const CMatrix3D& transform, bool wireframe = false);
|
||||
|
||||
/**
|
||||
* Render the surfaces of the brush as triangles.
|
||||
*/
|
||||
void DrawBrush(const CBrush& brush, const CColor& color, bool wireframe = false);
|
||||
void DrawBrush(Renderer::Backend::IDeviceCommandContext& deviceCommandContext, const CBrush& brush, const CColor& color, bool wireframe = false);
|
||||
|
||||
private:
|
||||
const CShaderTechniquePtr& GetShaderTechnique(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -509,7 +509,7 @@ void OverlayRenderer::RenderOverlaysBeforeWater(
|
||||
if (line->m_Coords.empty())
|
||||
continue;
|
||||
|
||||
g_Renderer.GetDebugRenderer().DrawLine(line->m_Coords, line->m_Color, static_cast<float>(line->m_Thickness));
|
||||
g_Renderer.GetDebugRenderer().DrawLine(*deviceCommandContext, line->m_Coords, line->m_Color, static_cast<float>(line->m_Thickness));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -198,12 +198,13 @@ void ParticleRenderer::RenderParticles(
|
||||
deviceCommandContext->EndPass();
|
||||
}
|
||||
|
||||
void ParticleRenderer::RenderBounds(int cullGroup)
|
||||
void ParticleRenderer::RenderBounds(Renderer::Backend::IDeviceCommandContext& deviceCommandContext, int cullGroup)
|
||||
{
|
||||
for (const CParticleEmitter* emitter : m->emitters[cullGroup])
|
||||
{
|
||||
const CBoundingBoxAligned bounds =
|
||||
emitter->m_Type->CalculateBounds(emitter->GetPosition(), emitter->GetParticleBounds());
|
||||
g_Renderer.GetDebugRenderer().DrawBoundingBox(bounds, CColor(0.0f, 1.0f, 0.0f, 1.0f), true);
|
||||
|
||||
g_Renderer.GetDebugRenderer().DrawBoundingBox(deviceCommandContext, bounds, CColor(0.0f, 1.0f, 0.0f, 1.0f), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
/**
|
||||
* Render bounding boxes for all the submitted emitters.
|
||||
*/
|
||||
void RenderBounds(int cullGroup);
|
||||
void RenderBounds(Renderer::Backend::IDeviceCommandContext& deviceCommandContext, int cullGroup);
|
||||
|
||||
private:
|
||||
ParticleRendererInternals* m;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -1299,7 +1299,7 @@ void CPatchRData::RenderStreams(
|
||||
}
|
||||
}
|
||||
|
||||
void CPatchRData::RenderOutline()
|
||||
void CPatchRData::RenderOutline(Renderer::Backend::IDeviceCommandContext& deviceCommandContext)
|
||||
{
|
||||
CTerrain* terrain = m_Patch->m_Parent;
|
||||
ssize_t gx = m_Patch->m_X * PATCH_SIZE;
|
||||
@@ -1328,7 +1328,7 @@ void CPatchRData::RenderOutline()
|
||||
line.push_back(pos);
|
||||
}
|
||||
|
||||
g_Renderer.GetDebugRenderer().DrawLine(line, CColor(0.0f, 0.0f, 1.0f, 1.0f), 0.1f);
|
||||
g_Renderer.GetDebugRenderer().DrawLine(deviceCommandContext, line, CColor(0.0f, 0.0f, 1.0f, 1.0f), 0.1f);
|
||||
}
|
||||
|
||||
void CPatchRData::RenderSides(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
static Renderer::Backend::IVertexInputLayout* GetWaterShoreVertexInputLayout();
|
||||
|
||||
void Update(CSimulation2* simulation);
|
||||
void RenderOutline();
|
||||
void RenderOutline(Renderer::Backend::IDeviceCommandContext& deviceCommandContext);
|
||||
void RenderPriorities(CTextRenderer& textRenderer);
|
||||
|
||||
void RenderWaterSurface(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -573,7 +573,7 @@ void CRenderer::RenderFrameImpl(const bool renderGUI, const bool renderLogger)
|
||||
|
||||
g_Game->GetView()->RenderOverlays(m->deviceCommandContext.get());
|
||||
|
||||
g_Game->GetView()->GetCinema()->Render();
|
||||
g_Game->GetView()->GetCinema()->Render(*m->deviceCommandContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -603,7 +603,7 @@ void CRenderer::RenderFrameImpl(const bool renderGUI, const bool renderLogger)
|
||||
// If we're in Atlas game view, render special tools
|
||||
if (g_AtlasGameLoop && g_AtlasGameLoop->view)
|
||||
{
|
||||
g_AtlasGameLoop->view->DrawCinemaPathTool();
|
||||
g_AtlasGameLoop->view->DrawCinemaPathTool(*m->deviceCommandContext);
|
||||
}
|
||||
|
||||
RenderFrame2D(renderGUI, renderLogger);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -781,7 +781,7 @@ void CSceneRenderer::RenderParticles(
|
||||
{
|
||||
m->particleRenderer.RenderParticles(
|
||||
deviceCommandContext, cullGroup, true);
|
||||
m->particleRenderer.RenderBounds(cullGroup);
|
||||
m->particleRenderer.RenderBounds(*deviceCommandContext, cullGroup);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -921,10 +921,10 @@ void CSceneRenderer::RenderSubmissions(
|
||||
|
||||
// render debug lines
|
||||
if (g_RenderingOptions.GetDisplayFrustum())
|
||||
DisplayFrustum();
|
||||
DisplayFrustum(*deviceCommandContext);
|
||||
|
||||
if (g_RenderingOptions.GetDisplayShadowsFrustum())
|
||||
m->shadow.RenderDebugBounds();
|
||||
m->shadow.RenderDebugBounds(*deviceCommandContext);
|
||||
|
||||
m->silhouetteRenderer.RenderDebugBounds(deviceCommandContext);
|
||||
}
|
||||
@@ -946,10 +946,10 @@ void CSceneRenderer::EndFrame()
|
||||
m->Model.TranspUnskinned->EndFrame();
|
||||
}
|
||||
|
||||
void CSceneRenderer::DisplayFrustum()
|
||||
void CSceneRenderer::DisplayFrustum(Renderer::Backend::IDeviceCommandContext& deviceCommandContext)
|
||||
{
|
||||
g_Renderer.GetDebugRenderer().DrawCameraFrustum(m_CullCamera, CColor(1.0f, 1.0f, 1.0f, 0.25f), 2);
|
||||
g_Renderer.GetDebugRenderer().DrawCameraFrustum(m_CullCamera, CColor(1.0f, 1.0f, 1.0f, 1.0f), 2, true);
|
||||
g_Renderer.GetDebugRenderer().DrawCameraFrustum(deviceCommandContext, m_CullCamera, CColor(1.0f, 1.0f, 1.0f, 0.25f), 2);
|
||||
g_Renderer.GetDebugRenderer().DrawCameraFrustum(deviceCommandContext, m_CullCamera, CColor(1.0f, 1.0f, 1.0f, 1.0f), 2, true);
|
||||
}
|
||||
|
||||
// Text overlay rendering
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -254,7 +254,7 @@ protected:
|
||||
void ComputeRefractionCamera(CCamera& camera, const CBoundingBoxAligned& scissor) const;
|
||||
|
||||
// debugging
|
||||
void DisplayFrustum();
|
||||
void DisplayFrustum(Renderer::Backend::IDeviceCommandContext& deviceCommandContext);
|
||||
|
||||
// enable oblique frustum clipping with the given clip plane
|
||||
void SetObliqueFrustumClipping(CCamera& camera, const CVector4D& clipPlane) const;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -720,7 +720,7 @@ void ShadowMap::SetDepthTextureBits(int bits)
|
||||
}
|
||||
}
|
||||
|
||||
void ShadowMap::RenderDebugBounds()
|
||||
void ShadowMap::RenderDebugBounds(Renderer::Backend::IDeviceCommandContext& deviceCommandContext)
|
||||
{
|
||||
// Render various shadow bounds:
|
||||
// Yellow = bounds of objects in view frustum that receive shadows
|
||||
@@ -730,13 +730,16 @@ void ShadowMap::RenderDebugBounds()
|
||||
const CMatrix3D transform = g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection() * m->InvLightTransform;
|
||||
|
||||
g_Renderer.GetDebugRenderer().DrawBoundingBox(
|
||||
deviceCommandContext,
|
||||
m->ShadowReceiverBound, CColor(1.0f, 1.0f, 0.0f, 1.0f), transform, true);
|
||||
|
||||
for (int cascade = 0; cascade < GetCascadeCount(); ++cascade)
|
||||
{
|
||||
g_Renderer.GetDebugRenderer().DrawBoundingBox(
|
||||
deviceCommandContext,
|
||||
m->Cascades[cascade].ShadowRenderBound, CColor(0.0f, 0.0f, 1.0f, 0.10f), transform);
|
||||
g_Renderer.GetDebugRenderer().DrawBoundingBox(
|
||||
deviceCommandContext,
|
||||
m->Cascades[cascade].ShadowRenderBound, CColor(0.0f, 0.0f, 1.0f, 0.5f), transform, true);
|
||||
|
||||
const CFrustum frustum = GetShadowCasterCullFrustum(cascade);
|
||||
@@ -747,8 +750,8 @@ void ShadowMap::RenderDebugBounds()
|
||||
CBrush frustumBrush;
|
||||
brush.Intersect(frustum, frustumBrush);
|
||||
|
||||
g_Renderer.GetDebugRenderer().DrawBrush(frustumBrush, CColor(1.0f, 0.0f, 0.0f, 0.1f));
|
||||
g_Renderer.GetDebugRenderer().DrawBrush(frustumBrush, CColor(1.0f, 0.0f, 0.0f, 0.1f), true);
|
||||
g_Renderer.GetDebugRenderer().DrawBrush(deviceCommandContext, frustumBrush, CColor(1.0f, 0.0f, 0.0f, 0.1f));
|
||||
g_Renderer.GetDebugRenderer().DrawBrush(deviceCommandContext, frustumBrush, CColor(1.0f, 0.0f, 0.0f, 0.1f), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
* Visualize shadow mapping calculations to help in
|
||||
* debugging and optimal shadow map usage.
|
||||
*/
|
||||
void RenderDebugBounds();
|
||||
void RenderDebugBounds(Renderer::Backend::IDeviceCommandContext& deviceCommandContext);
|
||||
|
||||
private:
|
||||
ShadowMapInternals* m;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -464,13 +464,13 @@ void SilhouetteRenderer::RenderSubmitCasters(SceneCollector& collector)
|
||||
collector.SubmitNonRecursive(m_VisibleModelCasters[i]);
|
||||
}
|
||||
|
||||
void SilhouetteRenderer::RenderDebugBounds(Renderer::Backend::IDeviceCommandContext*)
|
||||
void SilhouetteRenderer::RenderDebugBounds(Renderer::Backend::IDeviceCommandContext* deviceCommandContext)
|
||||
{
|
||||
if (m_DebugBounds.empty())
|
||||
return;
|
||||
|
||||
for (size_t i = 0; i < m_DebugBounds.size(); ++i)
|
||||
g_Renderer.GetDebugRenderer().DrawBoundingBox(m_DebugBounds[i].bounds, m_DebugBounds[i].color, true);
|
||||
g_Renderer.GetDebugRenderer().DrawBoundingBox(*deviceCommandContext, m_DebugBounds[i].bounds, m_DebugBounds[i].color, true);
|
||||
}
|
||||
|
||||
void SilhouetteRenderer::RenderDebugOverlays(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -407,7 +407,7 @@ void TerrainRenderer::RenderOutlines(
|
||||
GPU_SCOPED_LABEL(deviceCommandContext, "Render terrain outlines");
|
||||
|
||||
for (size_t i = 0; i < visiblePatches.size(); ++i)
|
||||
visiblePatches[i]->RenderOutline();
|
||||
visiblePatches[i]->RenderOutline(*deviceCommandContext);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ void AtlasViewGame::Render()
|
||||
g_VideoMode.GetBackendDevice()->Present();
|
||||
}
|
||||
|
||||
void AtlasViewGame::DrawCinemaPathTool()
|
||||
void AtlasViewGame::DrawCinemaPathTool(Renderer::Backend::IDeviceCommandContext& deviceCommandContext)
|
||||
{
|
||||
if (!m_DrawMoveTool)
|
||||
return;
|
||||
@@ -256,12 +256,15 @@ void AtlasViewGame::DrawCinemaPathTool()
|
||||
const float lineWidth = scale / 1e3f;
|
||||
|
||||
g_Renderer.GetDebugRenderer().DrawLine(
|
||||
deviceCommandContext,
|
||||
focus, focus + CVector3D(axisLength, 0, 0),
|
||||
CColor(1.0f, 0.0f, 0.0f, 1.0f), lineWidth, false);
|
||||
g_Renderer.GetDebugRenderer().DrawLine(
|
||||
deviceCommandContext,
|
||||
focus, focus + CVector3D(0, axisLength, 0),
|
||||
CColor(0.0f, 1.0f, 0.0f, 1.0f), lineWidth, false);
|
||||
g_Renderer.GetDebugRenderer().DrawLine(
|
||||
deviceCommandContext,
|
||||
focus, focus + CVector3D(0, 0, axisLength),
|
||||
CColor(0.0f, 0.0f, 1.0f, 1.0f), lineWidth, false);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
virtual ~AtlasView();
|
||||
virtual void Update(float /*realFrameLength*/) { };
|
||||
virtual void Render() { };
|
||||
virtual void DrawCinemaPathTool() { };
|
||||
virtual void DrawCinemaPathTool(Renderer::Backend::IDeviceCommandContext&) { };
|
||||
virtual void DrawOverlays(CCanvas2D& /*canvas*/) { };
|
||||
virtual CCamera& GetCamera() = 0;
|
||||
virtual CSimulation2* GetSimulation2() { return NULL; }
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
virtual ~AtlasViewGame();
|
||||
virtual void Update(float realFrameLength);
|
||||
virtual void Render();
|
||||
virtual void DrawCinemaPathTool();
|
||||
virtual void DrawCinemaPathTool(Renderer::Backend::IDeviceCommandContext& deviceCommandContext);
|
||||
virtual void DrawOverlays(CCanvas2D& canvas);
|
||||
virtual CCamera& GetCamera();
|
||||
virtual CSimulation2* GetSimulation2();
|
||||
|
||||
Reference in New Issue
Block a user