Browse Source

Render: Fix release build via out-of-line destructors

master
Riyyi 3 months ago
parent
commit
67bb6a5671
  1. 45
      src/inferno/render/renderer.cpp
  2. 14
      src/inferno/render/renderer.h
  3. 2
      src/inferno/system/textareasystem.h

45
src/inferno/render/renderer.cpp

@ -65,7 +65,6 @@ void Renderer<T>::initialize()
template<typename T> template<typename T>
void Renderer<T>::destroy() void Renderer<T>::destroy()
{ {
delete[] m_vertexBufferBase;
} }
template<typename T> template<typename T>
@ -161,7 +160,7 @@ void Renderer<T>::flush()
uploadElementBuffer(); uploadElementBuffer();
// Upload vertex data to GPU // Upload vertex data to GPU
m_vertexArray->at(0)->uploadData(m_vertexBufferBase, m_vertexIndex * sizeof(T)); m_vertexArray->at(0)->uploadData(m_vertexBufferBase.get(), m_vertexIndex * sizeof(T));
bind(); bind();
@ -180,7 +179,7 @@ void Renderer<T>::startBatch()
{ {
m_vertexIndex = 0; m_vertexIndex = 0;
m_elementIndex = 0; m_elementIndex = 0;
m_vertexBufferPtr = m_vertexBufferBase; m_vertexBufferPtr = m_vertexBufferBase.get();
m_textureSlotIndex = 1; m_textureSlotIndex = 1;
} }
@ -199,6 +198,10 @@ Renderer2D::Renderer2D(s)
Renderer2D::initialize(); Renderer2D::initialize();
} }
Renderer2D::~Renderer2D()
{
}
void Renderer2D::initialize() void Renderer2D::initialize()
{ {
Renderer::initialize(); Renderer::initialize();
@ -207,8 +210,8 @@ void Renderer2D::initialize()
// CPU // CPU
// Create array for storing quads vertices // Create array for storing quads vertices
m_vertexBufferBase = new QuadVertex[maxVertices]; m_vertexBufferBase = std::make_unique<QuadVertex[]>(maxVertices);
m_vertexBufferPtr = m_vertexBufferBase; m_vertexBufferPtr = m_vertexBufferBase.get();
// Set default quad vertex positions // Set default quad vertex positions
m_vertexPositions[0] = { -1.0f, -1.0f, 0.0f, 1.0f }; m_vertexPositions[0] = { -1.0f, -1.0f, 0.0f, 1.0f };
@ -290,6 +293,10 @@ RendererCubemap::RendererCubemap(s)
RendererCubemap::initialize(); RendererCubemap::initialize();
} }
RendererCubemap::~RendererCubemap()
{
}
void RendererCubemap::initialize() void RendererCubemap::initialize()
{ {
Renderer::initialize(); Renderer::initialize();
@ -298,8 +305,8 @@ void RendererCubemap::initialize()
// CPU // CPU
// Create array for storing quads vertices // Create array for storing quads vertices
m_vertexBufferBase = new CubemapVertex[maxVertices]; m_vertexBufferBase = std::make_unique<CubemapVertex[]>(maxVertices);
m_vertexBufferPtr = m_vertexBufferBase; m_vertexBufferPtr = m_vertexBufferBase.get();
// Set default cubemap vertex positions // Set default cubemap vertex positions
@ -413,8 +420,8 @@ RendererFont::RendererFont(s)
// CPU // CPU
// Create array for storing quads vertices // Create array for storing quads vertices
m_vertexBufferBase = new SymbolVertex[maxVertices]; m_vertexBufferBase = std::make_unique<SymbolVertex[]>(maxVertices);
m_vertexBufferPtr = m_vertexBufferBase; m_vertexBufferPtr = m_vertexBufferBase.get();
// --------------------------------- // ---------------------------------
// GPU // GPU
@ -440,6 +447,10 @@ RendererFont::RendererFont(s)
ruc::info("RendererFont initialized"); ruc::info("RendererFont initialized");
} }
RendererFont::~RendererFont()
{
}
void RendererFont::drawSymbol(std::array<SymbolVertex, vertexPerQuad>& symbolQuad, std::shared_ptr<Texture> texture) void RendererFont::drawSymbol(std::array<SymbolVertex, vertexPerQuad>& symbolQuad, std::shared_ptr<Texture> texture)
{ {
// Create a new batch if the quad limit has been reached // Create a new batch if the quad limit has been reached
@ -485,8 +496,8 @@ Renderer3D::Renderer3D(s)
// CPU // CPU
// Create array for storing quads vertices // Create array for storing quads vertices
m_vertexBufferBase = new Vertex[maxVertices]; m_vertexBufferBase = std::make_unique<Vertex[]>(maxVertices);
m_vertexBufferPtr = m_vertexBufferBase; m_vertexBufferPtr = m_vertexBufferBase.get();
// --------------------------------- // ---------------------------------
// GPU // GPU
@ -508,6 +519,10 @@ Renderer3D::Renderer3D(s)
ruc::info("Renderer3D initialized"); ruc::info("Renderer3D initialized");
} }
Renderer3D::~Renderer3D()
{
}
void Renderer3D::drawModel(std::span<const Vertex> vertices, std::span<const uint32_t> elements, const TransformComponent& transform, glm::vec4 color, std::shared_ptr<Texture> texture) void Renderer3D::drawModel(std::span<const Vertex> vertices, std::span<const uint32_t> elements, const TransformComponent& transform, glm::vec4 color, std::shared_ptr<Texture> texture)
{ {
// ruc::error("drawModel"); // ruc::error("drawModel");
@ -579,6 +594,10 @@ void Renderer3D::startBatch()
// ----------------------------------------- // -----------------------------------------
RendererPostProcess::~RendererPostProcess()
{
}
void RendererPostProcess::drawQuad(const TransformComponent& transform, std::shared_ptr<Texture> albedo, std::shared_ptr<Texture> position, std::shared_ptr<Texture> normal) void RendererPostProcess::drawQuad(const TransformComponent& transform, std::shared_ptr<Texture> albedo, std::shared_ptr<Texture> position, std::shared_ptr<Texture> normal)
{ {
nextBatch(); nextBatch();
@ -614,6 +633,10 @@ void RendererPostProcess::loadShader()
// ----------------------------------------- // -----------------------------------------
RendererLightCube::~RendererLightCube()
{
}
void RendererLightCube::loadShader() void RendererLightCube::loadShader()
{ {
m_shader = AssetManager::the().load<Shader>("assets/glsl/lightsource"); m_shader = AssetManager::the().load<Shader>("assets/glsl/lightsource");

14
src/inferno/render/renderer.h

@ -105,7 +105,7 @@ protected:
// CPU quad vertices // CPU quad vertices
uint32_t m_vertexIndex { 0 }; uint32_t m_vertexIndex { 0 };
uint32_t m_elementIndex { 0 }; uint32_t m_elementIndex { 0 };
T* m_vertexBufferBase { nullptr }; std::unique_ptr<T[]> m_vertexBufferBase { nullptr };
T* m_vertexBufferPtr { nullptr }; T* m_vertexBufferPtr { nullptr };
// Texture units // Texture units
@ -133,7 +133,7 @@ class Renderer2D
, public ruc::Singleton<Renderer2D> { , public ruc::Singleton<Renderer2D> {
public: public:
Renderer2D(s); Renderer2D(s);
virtual ~Renderer2D() = default; virtual ~Renderer2D();
using Singleton<Renderer2D>::destroy; using Singleton<Renderer2D>::destroy;
@ -163,7 +163,7 @@ public:
public: public:
RendererCubemap(s); RendererCubemap(s);
virtual ~RendererCubemap() = default; virtual ~RendererCubemap();
using Singleton<RendererCubemap>::destroy; using Singleton<RendererCubemap>::destroy;
@ -191,7 +191,7 @@ class RendererFont final
, public ruc::Singleton<RendererFont> { , public ruc::Singleton<RendererFont> {
public: public:
RendererFont(s); RendererFont(s);
virtual ~RendererFont() = default; virtual ~RendererFont();
using Singleton<RendererFont>::destroy; using Singleton<RendererFont>::destroy;
@ -208,7 +208,7 @@ class Renderer3D final
, public ruc::Singleton<Renderer3D> { , public ruc::Singleton<Renderer3D> {
public: public:
Renderer3D(s); Renderer3D(s);
virtual ~Renderer3D() = default; virtual ~Renderer3D();
using Singleton<Renderer3D>::destroy; using Singleton<Renderer3D>::destroy;
@ -236,7 +236,7 @@ public:
: Renderer2D() : Renderer2D()
{ {
} }
virtual ~RendererPostProcess() = default; virtual ~RendererPostProcess();
using Singleton<RendererPostProcess>::the; using Singleton<RendererPostProcess>::the;
using Singleton<RendererPostProcess>::destroy; using Singleton<RendererPostProcess>::destroy;
@ -258,7 +258,7 @@ public:
{ {
m_enableDepthBuffer = true; m_enableDepthBuffer = true;
} }
virtual ~RendererLightCube() = default; virtual ~RendererLightCube();
using Singleton<RendererLightCube>::the; using Singleton<RendererLightCube>::the;
using Singleton<RendererLightCube>::destroy; using Singleton<RendererLightCube>::destroy;

2
src/inferno/system/textareasystem.h

@ -18,7 +18,7 @@
namespace Inferno { namespace Inferno {
using Symbols = std::vector<std::shared_ptr<Symbol>>; using Symbols = std::vector<std::shared_ptr<Symbol>>;
using SymbolQuad = std::array<SymbolVertex, Renderer<void>::vertexPerQuad>; using SymbolQuad = std::array<SymbolVertex, RendererFont::vertexPerQuad>;
class Scene; class Scene;
class TextAreaComponent; class TextAreaComponent;

Loading…
Cancel
Save