Move error message hack outside of scene render loop

Use std::string_view instead of std::string in more places
This commit is contained in:
Alexander Bock
2020-08-06 16:02:45 +02:00
parent 65546d9863
commit d39d4a91ec
8 changed files with 35 additions and 45 deletions

View File

@@ -719,7 +719,7 @@ void RenderableLabels::renderLabels(const RenderData& data,
ghoul::fontrendering::FontRenderer::defaultProjectionRenderer().render(
*_font,
transformedPos,
_labelText,
_labelText.value(),
textColor,
labelInfo
);

View File

@@ -1293,8 +1293,6 @@ void reset(TileProvider& tp) {
int maxLevel(TileProvider& tp) {
ZoneScoped
switch (tp.type) {
case Type::DefaultTileProvider: {
DefaultTileProvider& t = static_cast<DefaultTileProvider&>(tp);

View File

@@ -1419,40 +1419,42 @@ void RenderEngine::renderScreenLog() {
if (alpha <= 0.f) {
break;
}
const std::string lvl = "(" + ghoul::to_string(e->level) + ")";
const std::string& message = e->message.substr(0, MessageLength);
const std::string_view lvl = ghoul::to_string(e->level);
const std::string_view message =
std::string_view(e->message).substr(0, MessageLength);
nr += std::count(message.begin(), message.end(), '\n');
const glm::vec4 white(0.9f, 0.9f, 0.9f, alpha);
std::string str = fmt::format(
"{:<15} {}{}",
e->timeString,
e->category.substr(0, CategoryLength),
e->category.length() > CategoryLength ? "..." : ""
);
RenderFont(
*_fontLog,
glm::vec2(
10.f,
_fontLog->pointSize() * nr * 2 + fontRes.y * _verticalLogOffset
),
fmt::format(
"{:<15} {}{}",
e->timeString,
e->category.substr(0, CategoryLength),
e->category.length() > CategoryLength ? "..." : ""
),
str,
white
);
const glm::vec4 color = [alpha, white](ScreenLog::LogLevel level) {
switch (level) {
case ghoul::logging::LogLevel::Debug:
return glm::vec4(0.f, 1.f, 0.f, alpha);
case ghoul::logging::LogLevel::Warning:
return glm::vec4(1.f, 1.f, 0.f, alpha);
case ghoul::logging::LogLevel::Error:
return glm::vec4(1.f, 0.f, 0.f, alpha);
case ghoul::logging::LogLevel::Fatal:
return glm::vec4(0.3f, 0.3f, 0.85f, alpha);
default:
return white;
case ghoul::logging::LogLevel::Debug:
return glm::vec4(0.f, 1.f, 0.f, alpha);
case ghoul::logging::LogLevel::Warning:
return glm::vec4(1.f, 1.f, 0.f, alpha);
case ghoul::logging::LogLevel::Error:
return glm::vec4(1.f, 0.f, 0.f, alpha);
case ghoul::logging::LogLevel::Fatal:
return glm::vec4(0.3f, 0.3f, 0.85f, alpha);
default:
return white;
}
}(e->level);
@@ -1462,7 +1464,7 @@ void RenderEngine::renderScreenLog() {
10 + 30 * _fontLog->pointSize(),
_fontLog->pointSize() * nr * 2 + fontRes.y * _verticalLogOffset
),
lvl,
fmt::format("({})", lvl),
color
);

View File

@@ -33,7 +33,6 @@
#include <openspace/util/updatestructures.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/dictionary.h>
#include <ghoul/misc/profiling.h>
#include <ghoul/misc/templatefactory.h>
namespace {
@@ -96,8 +95,6 @@ const glm::dmat3& Rotation::matrix() const {
}
void Rotation::update(const UpdateData& data) {
ZoneScoped
if (!_needsUpdate && (data.time.j2000Seconds() == _cachedTime)) {
return;
}

View File

@@ -32,7 +32,6 @@
#include <openspace/util/updatestructures.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/dictionary.h>
#include <ghoul/misc/profiling.h>
#include <ghoul/misc/templatefactory.h>
namespace {
@@ -91,8 +90,6 @@ glm::dvec3 Scale::scaleValue() const {
}
void Scale::update(const UpdateData& data) {
ZoneScoped
if (!_needsUpdate && data.time.j2000Seconds() == _cachedTime) {
return;
}

View File

@@ -341,20 +341,19 @@ void Scene::render(const RenderData& data, RendererTasks& tasks) {
if (global::callback::webBrowserPerformanceHotfix) {
(*global::callback::webBrowserPerformanceHotfix)();
}
}
{
ZoneScopedN("Get Error Hack")
{
ZoneScopedN("Get Error Hack")
// @TODO(abock 2019-08-19) This glGetError call is a hack to prevent the GPU
// thread and the CPU thread from diverging too much, particularly the
// uploading of a lot of textures for the globebrowsing planets can cause a
// hard stuttering effect. Asking for a glGetError after every rendering call
// will force the threads to implicitly synchronize and thus prevent the
// stuttering. The better solution would be to reduce the number of uploads
// per frame, use a staggered buffer, or something else like that preventing a
// large spike in uploads
glGetError();
}
// @TODO(abock 2019-08-19) This glGetError call is a hack to prevent the GPU
// thread and the CPU thread from diverging too much, particularly the uploading
// of a lot of textures for the globebrowsing planets can cause a hard stuttering
// effect. Asking for a glGetError after every rendering call will force the
// threads to implicitly synchronize and thus prevent the stuttering. The better
// solution would be to reduce the number of uploads per frame, use a staggered
// buffer, or something else like that preventing a large spike in uploads
glGetError();
}
}

View File

@@ -31,7 +31,6 @@
#include <openspace/util/updatestructures.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/dictionary.h>
#include <ghoul/misc/profiling.h>
#include <ghoul/misc/templatefactory.h>
namespace {
@@ -84,8 +83,6 @@ bool Translation::initialize() {
}
void Translation::update(const UpdateData& data) {
ZoneScoped
if (!_needsUpdate && data.time.j2000Seconds() == _cachedTime) {
return;
}