Add logic to allow lazy rendering
This commit is contained in:
@@ -17,9 +17,10 @@ namespace OpenVulkano
|
||||
{
|
||||
namespace
|
||||
{
|
||||
const char *NUM_THREADS_STR = "num_threads";
|
||||
const char *FRAMEBUFFER_CLEAR_COLOR_STR = "framebuffer_clear_color";
|
||||
const char *PREFER_FRAMEBUFFER_FORMAT_SRGB_STR = "prefer_framebuffer_format_srgb";
|
||||
const char* NUM_THREADS_STR = "NumThreads";
|
||||
const char* FRAMEBUFFER_CLEAR_COLOR_STR = "FramebufferClearColor";
|
||||
const char* PREFER_FRAMEBUFFER_FORMAT_SRGB_STR = "PreferFramebufferFormatSRGB";
|
||||
const char* LAZY_RENDERING_STR = "LazyRendering";
|
||||
}
|
||||
|
||||
EngineConfiguration::EngineConfiguration()
|
||||
@@ -50,6 +51,11 @@ namespace OpenVulkano
|
||||
{
|
||||
root[PREFER_FRAMEBUFFER_FORMAT_SRGB_STR] >> m_preferFramebufferFormatSRGB;
|
||||
}
|
||||
|
||||
if (root.has_child(LAZY_RENDERING_STR))
|
||||
{
|
||||
root[LAZY_RENDERING_STR] >> m_lazyRendering;
|
||||
}
|
||||
}
|
||||
|
||||
EngineConfiguration* EngineConfiguration::GetEngineConfiguration()
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace OpenVulkano
|
||||
uint32_t m_numThreads = 1;
|
||||
std::array<float, 4> m_frameBufferClearColor = { 0.39f, 0.58f, 0.93f, 1.0f };
|
||||
bool m_preferFramebufferFormatSRGB = true;
|
||||
bool m_lazyRendering = false;
|
||||
|
||||
public:
|
||||
[[nodiscard]] static EngineConfiguration* GetEngineConfiguration();
|
||||
@@ -34,5 +35,8 @@ namespace OpenVulkano
|
||||
|
||||
[[nodiscard]] bool GetPreferFramebufferFormatSRGB() const { return m_preferFramebufferFormatSRGB; }
|
||||
void SetPreferFramebufferFormatSRGB(bool sRGB) { m_preferFramebufferFormatSRGB = sRGB; }
|
||||
|
||||
[[nodiscard]] bool GetLazyRendering() const { return m_lazyRendering; }
|
||||
void SetLazyRendering(bool lazyRender) { m_lazyRendering = lazyRender; }
|
||||
};
|
||||
}
|
||||
@@ -15,6 +15,7 @@ namespace OpenVulkano
|
||||
public:
|
||||
uint64_t frameId = 0;
|
||||
double frameTime = 1;
|
||||
bool shouldDraw = true;
|
||||
|
||||
FrameMetadata() = default;
|
||||
};
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "Base/FrameMetadata.hpp"
|
||||
#include "PlatformProducer.hpp"
|
||||
#include "Input/InputManager.hpp"
|
||||
#include "Base/EngineConfiguration.hpp"
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <stdexcept>
|
||||
@@ -140,11 +141,12 @@ namespace OpenVulkano
|
||||
{
|
||||
Input::InputManager::GetInstance()->Tick();
|
||||
app->Tick();
|
||||
renderer->Tick();
|
||||
if (CURRENT_FRAME.shouldDraw) renderer->Tick();
|
||||
frameTimer.Tick();
|
||||
UpdateFps();
|
||||
CURRENT_FRAME.frameId = frameCount;
|
||||
CURRENT_FRAME.frameTime = frameTimer.GetTickSeconds();
|
||||
CURRENT_FRAME.shouldDraw = !EngineConfiguration::GetEngineConfiguration()->GetLazyRendering();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user