Prevent particle copy, tweak debugging some more

probably not too time-saving
This commit is contained in:
Kae 2023-07-03 18:31:12 +10:00
parent 1dacc0f41a
commit deb96742e0
6 changed files with 28 additions and 24 deletions

View File

@ -16,7 +16,7 @@
"debugFont" : "mono", "debugFont" : "mono",
"debugFontSize" : 7, "debugFontSize" : 7,
"debugFontDirectives" : "?border=1;0007;0000", "debugFontDirectives" : "?border=1;2224;0000",
// Change planet name to support the new internal string formatting. // Change planet name to support the new internal string formatting.
"planetNameFormatString" : "- {} -", "planetNameFormatString" : "- {} -",

View File

@ -389,23 +389,23 @@ void ClientApplication::render() {
auto start = Time::monotonicMicroseconds(); auto start = Time::monotonicMicroseconds();
renderer->switchEffectConfig("world"); renderer->switchEffectConfig("world");
worldClient->render(m_renderData, TilePainter::BorderTileSize); worldClient->render(m_renderData, TilePainter::BorderTileSize);
LogMap::set("render_world_client", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); LogMap::set("client_render_world_client", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start));
start = Time::monotonicMicroseconds(); start = Time::monotonicMicroseconds();
m_worldPainter->render(m_renderData, [&]() { worldClient->waitForLighting(); }); m_worldPainter->render(m_renderData, [&]() { worldClient->waitForLighting(); });
LogMap::set("render_world_painter", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); LogMap::set("client_render_world_painter", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start));
start = Time::monotonicMicroseconds(); start = Time::monotonicMicroseconds();
m_mainInterface->renderInWorldElements(); m_mainInterface->renderInWorldElements();
LogMap::set("render_world_elements", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); LogMap::set("client_render_world_elements", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start));
renderer->switchEffectConfig("default"); renderer->switchEffectConfig("default");
LogMap::set("render_world_total", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); LogMap::set("client_render_world_total", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start));
} }
auto start = Time::monotonicMicroseconds(); auto start = Time::monotonicMicroseconds();
m_mainInterface->render(); m_mainInterface->render();
m_cinematicOverlay->render(); m_cinematicOverlay->render();
LogMap::set("render_interface", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); LogMap::set("client_render_interface", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start));
} }
if (!m_errorScreen->accepted()) if (!m_errorScreen->accepted())
@ -862,14 +862,14 @@ void ClientApplication::updateRunning() {
Vec2F aimPosition = m_player->aimPosition(); Vec2F aimPosition = m_player->aimPosition();
float fps = appController()->renderFps(); float fps = appController()->renderFps();
LogMap::set("render_rate", strf("{:4.2f} FPS ({:4.2f}ms)", fps, (1.0f / appController()->renderFps()) * 1000.0f)); LogMap::set("client_render_rate", strf("{:4.2f} FPS ({:4.2f}ms)", fps, (1.0f / appController()->renderFps()) * 1000.0f));
LogMap::set("update_rate", strf("{:4.2f}Hz", appController()->updateRate())); LogMap::set("client_update_rate", strf("{:4.2f}Hz", appController()->updateRate()));
LogMap::set("player_pos", strf("[ ^#f45;{:4.2f}^reset;, ^#49f;{:4.2f}^reset; ]", m_player->position()[0], m_player->position()[1])); LogMap::set("player_pos", strf("[ ^#f45;{:4.2f}^reset;, ^#49f;{:4.2f}^reset; ]", m_player->position()[0], m_player->position()[1]));
LogMap::set("player_vel", strf("[ ^#f45;{:4.2f}^reset;, ^#49f;{:4.2f}^reset; ]", m_player->velocity()[0], m_player->velocity()[1])); LogMap::set("player_vel", strf("[ ^#f45;{:4.2f}^reset;, ^#49f;{:4.2f}^reset; ]", m_player->velocity()[0], m_player->velocity()[1]));
LogMap::set("player_aim", strf("[ ^#f45;{:4.2f}^reset;, ^#49f;{:4.2f}^reset; ]", aimPosition[0], aimPosition[1])); LogMap::set("player_aim", strf("[ ^#f45;{:4.2f}^reset;, ^#49f;{:4.2f}^reset; ]", aimPosition[0], aimPosition[1]));
if (m_universeClient->worldClient()) { if (m_universeClient->worldClient()) {
LogMap::set("liquid_level", strf("{}", m_universeClient->worldClient()->liquidLevel(Vec2I::floor(aimPosition)).level)); LogMap::set("tile_liquid_level", strf("{}", m_universeClient->worldClient()->liquidLevel(Vec2I::floor(aimPosition)).level));
LogMap::set("dungeon_id", strf("{}", m_universeClient->worldClient()->dungeonId(Vec2I::floor(aimPosition)))); LogMap::set("tile_dungeon_id", strf("{}", m_universeClient->worldClient()->dungeonId(Vec2I::floor(aimPosition))));
} }
if (m_mainInterface->currentState() == MainInterface::ReturnToTitle) if (m_mainInterface->currentState() == MainInterface::ReturnToTitle)

View File

@ -279,12 +279,12 @@ void UniverseClient::update() {
m_celestialDatabase->cleanup(); m_celestialDatabase->cleanup();
if (auto netStats = m_connection->incomingStats()) { if (auto netStats = m_connection->incomingStats()) {
LogMap::set("client_incoming_bps", netStats->bytesPerSecond); LogMap::set("net_incoming_bps", netStats->bytesPerSecond);
LogMap::set("client_worst_incoming", strf("{}:{}", PacketTypeNames.getRight(netStats->worstPacketType), netStats->worstPacketSize)); LogMap::set("net_worst_incoming", strf("{}:{}", PacketTypeNames.getRight(netStats->worstPacketType), netStats->worstPacketSize));
} }
if (auto netStats = m_connection->outgoingStats()) { if (auto netStats = m_connection->outgoingStats()) {
LogMap::set("client_outgoing_bps", netStats->bytesPerSecond); LogMap::set("net_outgoing_bps", netStats->bytesPerSecond);
LogMap::set("client_worst_outgoing", LogMap::set("net_worst_outgoing",
strf("{}:{}", PacketTypeNames.getRight(netStats->worstPacketType), netStats->worstPacketSize)); strf("{}:{}", PacketTypeNames.getRight(netStats->worstPacketType), netStats->worstPacketSize));
} }
} }

View File

@ -535,8 +535,8 @@ void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) {
} }
} }
renderData.particles = m_particles->particles(); renderData.particles = &m_particles->particles();
LogMap::set("active_particles", renderData.particles.size()); LogMap::set("client_render_particle_count", renderData.particles->size());
renderData.skyRenderData = m_sky->renderData(); renderData.skyRenderData = m_sky->renderData();
@ -569,9 +569,10 @@ void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) {
} }
} }
auto functionDatabase = Root::singleton().functionDatabase();
for (auto& layer : renderData.parallaxLayers) { for (auto& layer : renderData.parallaxLayers) {
if (!layer.timeOfDayCorrelation.empty()) if (!layer.timeOfDayCorrelation.empty())
layer.alpha *= clamp((float)Root::singleton().functionDatabase()->function(layer.timeOfDayCorrelation)->evaluate(m_sky->timeOfDay() / m_sky->dayLength()), 0.0f, 1.0f); layer.alpha *= clamp((float)functionDatabase->function(layer.timeOfDayCorrelation)->evaluate(m_sky->timeOfDay() / m_sky->dayLength()), 0.0f, 1.0f);
} }
stableSort(renderData.parallaxLayers, [](ParallaxLayer const& a, ParallaxLayer const& b) { stableSort(renderData.parallaxLayers, [](ParallaxLayer const& a, ParallaxLayer const& b) {
@ -1458,7 +1459,7 @@ void WorldClient::lightingMain() {
m_lightingCalculator.calculate(m_renderData->lightMap); m_lightingCalculator.calculate(m_renderData->lightMap);
m_renderData = nullptr; m_renderData = nullptr;
LogMap::set("render_world_async_lighting_calc_time", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); LogMap::set("client_render_world_async_light_calc", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start));
} }
m_lightingCond.wait(m_lightingMutex); m_lightingCond.wait(m_lightingMutex);

View File

@ -30,7 +30,7 @@ struct WorldRenderData {
Image tileLightMap; Image tileLightMap;
List<EntityDrawables> entityDrawables; List<EntityDrawables> entityDrawables;
List<Particle> particles; List<Particle> const* particles;
List<OverheadBar> overheadBars; List<OverheadBar> overheadBars;
List<Drawable> nametags; List<Drawable> nametags;
@ -48,10 +48,10 @@ struct WorldRenderData {
}; };
inline void WorldRenderData::clear() { inline void WorldRenderData::clear() {
tiles.clear(); tiles.resize({0, 0}); // keep reserved
entityDrawables.clear(); entityDrawables.clear();
particles.clear(); particles = nullptr;
overheadBars.clear(); overheadBars.clear();
nametags.clear(); nametags.clear();
backgroundOverlays.clear(); backgroundOverlays.clear();

View File

@ -72,7 +72,7 @@ void WorldPainter::render(WorldRenderData& renderData, function<void()> lightWai
if (lightWaiter) { if (lightWaiter) {
auto start = Time::monotonicMicroseconds(); auto start = Time::monotonicMicroseconds();
lightWaiter(); lightWaiter();
LogMap::set("render_world_async_lighting_wait_time", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start)); LogMap::set("client_render_world_async_light_wait", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start));
} }
if (renderData.isFullbright) { if (renderData.isFullbright) {
@ -166,7 +166,10 @@ void WorldPainter::renderParticles(WorldRenderData& renderData, Particle::Layer
const int textParticleFontSize = m_assets->json("/rendering.config:textParticleFontSize").toInt(); const int textParticleFontSize = m_assets->json("/rendering.config:textParticleFontSize").toInt();
const RectF particleRenderWindow = RectF::withSize(Vec2F(), Vec2F(m_camera.screenSize())).padded(m_assets->json("/rendering.config:particleRenderWindowPadding").toInt()); const RectF particleRenderWindow = RectF::withSize(Vec2F(), Vec2F(m_camera.screenSize())).padded(m_assets->json("/rendering.config:particleRenderWindowPadding").toInt());
for (Particle const& particle : renderData.particles) { if (!renderData.particles)
return;
for (Particle const& particle : *renderData.particles) {
if (layer != particle.layer) if (layer != particle.layer)
continue; continue;
@ -218,7 +221,7 @@ void WorldPainter::renderParticles(WorldRenderData& renderData, Particle::Layer
} else if (particle.type == Particle::Type::Text) { } else if (particle.type == Particle::Type::Text) {
Vec2F position = m_camera.worldToScreen(particle.position); Vec2F position = m_camera.worldToScreen(particle.position);
unsigned size = round((float)textParticleFontSize * m_camera.pixelRatio() * particle.size); int size = min(128.0f, round((float)textParticleFontSize * m_camera.pixelRatio() * particle.size));
if (size > 0) { if (size > 0) {
m_textPainter->setFontSize(size); m_textPainter->setFontSize(size);
m_textPainter->setFontColor(particle.color.toRgba()); m_textPainter->setFontColor(particle.color.toRgba());