mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
Reduce logging overhead and reuse WMO culling futures
This commit is contained in:
parent
4ea4cb761c
commit
c914295d20
4 changed files with 22 additions and 7 deletions
|
|
@ -6,6 +6,7 @@
|
|||
#include <mutex>
|
||||
#include <fstream>
|
||||
#include <chrono>
|
||||
#include <atomic>
|
||||
|
||||
namespace wowee {
|
||||
namespace core {
|
||||
|
|
@ -31,29 +32,35 @@ public:
|
|||
|
||||
void log(LogLevel level, const std::string& message);
|
||||
void setLogLevel(LogLevel level);
|
||||
bool shouldLog(LogLevel level) const;
|
||||
|
||||
template<typename... Args>
|
||||
void debug(Args&&... args) {
|
||||
if (!shouldLog(LogLevel::DEBUG)) return;
|
||||
log(LogLevel::DEBUG, format(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void info(Args&&... args) {
|
||||
if (!shouldLog(LogLevel::INFO)) return;
|
||||
log(LogLevel::INFO, format(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void warning(Args&&... args) {
|
||||
if (!shouldLog(LogLevel::WARNING)) return;
|
||||
log(LogLevel::WARNING, format(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void error(Args&&... args) {
|
||||
if (!shouldLog(LogLevel::ERROR)) return;
|
||||
log(LogLevel::ERROR, format(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void fatal(Args&&... args) {
|
||||
if (!shouldLog(LogLevel::FATAL)) return;
|
||||
log(LogLevel::FATAL, format(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
|
|
@ -70,7 +77,7 @@ private:
|
|||
return oss.str();
|
||||
}
|
||||
|
||||
LogLevel minLevel = LogLevel::INFO; // Changed from DEBUG to reduce log spam
|
||||
std::atomic<int> minLevel_{static_cast<int>(LogLevel::INFO)};
|
||||
std::mutex mutex;
|
||||
std::ofstream fileStream;
|
||||
bool fileReady = false;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <future>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline {
|
||||
|
|
@ -633,6 +634,7 @@ private:
|
|||
uint32_t portalCulled = 0;
|
||||
uint32_t distanceCulled = 0;
|
||||
};
|
||||
std::vector<std::future<std::vector<InstanceDrawList>>> cullFutures_;
|
||||
|
||||
// Collision query profiling (per frame).
|
||||
mutable double queryTimeMs = 0.0;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ void Logger::ensureFile() {
|
|||
}
|
||||
|
||||
void Logger::log(LogLevel level, const std::string& message) {
|
||||
if (level < minLevel) {
|
||||
if (!shouldLog(level)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +93,11 @@ void Logger::log(LogLevel level, const std::string& message) {
|
|||
}
|
||||
|
||||
void Logger::setLogLevel(LogLevel level) {
|
||||
minLevel = level;
|
||||
minLevel_.store(static_cast<int>(level), std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
bool Logger::shouldLog(LogLevel level) const {
|
||||
return static_cast<int>(level) >= minLevel_.load(std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
|
|
|
|||
|
|
@ -1176,13 +1176,15 @@ void WMORenderer::render(VkCommandBuffer cmd, VkDescriptorSet perFrameSet, const
|
|||
const size_t chunkSize = visibleInstances.size() / numThreads;
|
||||
const size_t remainder = visibleInstances.size() % numThreads;
|
||||
|
||||
std::vector<std::future<std::vector<InstanceDrawList>>> futures;
|
||||
futures.reserve(numThreads);
|
||||
cullFutures_.clear();
|
||||
if (cullFutures_.capacity() < numThreads) {
|
||||
cullFutures_.reserve(numThreads);
|
||||
}
|
||||
|
||||
size_t start = 0;
|
||||
for (size_t t = 0; t < numThreads; ++t) {
|
||||
size_t end = start + chunkSize + (t < remainder ? 1 : 0);
|
||||
futures.push_back(std::async(std::launch::async,
|
||||
cullFutures_.push_back(std::async(std::launch::async,
|
||||
[&, start, end]() {
|
||||
std::vector<InstanceDrawList> chunk;
|
||||
chunk.reserve(end - start);
|
||||
|
|
@ -1193,7 +1195,7 @@ void WMORenderer::render(VkCommandBuffer cmd, VkDescriptorSet perFrameSet, const
|
|||
start = end;
|
||||
}
|
||||
|
||||
for (auto& f : futures) {
|
||||
for (auto& f : cullFutures_) {
|
||||
auto chunk = f.get();
|
||||
for (auto& dl : chunk)
|
||||
drawLists.push_back(std::move(dl));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue