switch to yolo logger

This commit is contained in:
Ben Kyd
2023-02-28 17:10:23 +00:00
parent 9551eeaa0a
commit 83280e1046
13 changed files with 42 additions and 45 deletions

View File

@@ -40,6 +40,6 @@ compile with `make -j[threads]`
- OpenGL, utilised with GLAD and GLFW - OpenGL, utilised with GLAD and GLFW
- ImGui for lovely GUI - ImGui for lovely GUI
- SPDLog for lovely logging - YOLO for lovely logging
## Acknowledgements ## Acknowledgements

View File

@@ -8,6 +8,7 @@
#include <iostream> #include <iostream>
#include <thread> #include <thread>
#include <condition_variable>
#include <chrono> #include <chrono>
#include <numeric> #include <numeric>
@@ -37,7 +38,7 @@ public:
mState = EModuleState::Build; mState = EModuleState::Build;
mVert = (float*)vert; mNorm = (float*)norm; mVc = vc; mIndices = (uint32_t*)indices; mIc = ic; mVert = (float*)vert; mNorm = (float*)norm; mVc = vc; mIndices = (uint32_t*)indices; mIc = ic;
spdlog::info("[hartcpu] Recieved {} verticies ({}) and {} indicies ({})", vc / 3, vert, ic / 3, indices); yolo::info("[hartcpu] Recieved {} verticies ({}) and {} indicies ({})", vc / 3, vert, ic / 3, indices);
std::vector<uint32_t> indicesToProcess(ic / 3); std::vector<uint32_t> indicesToProcess(ic / 3);
for (uint32_t i = 0; i < ic / 3; ++i) for (uint32_t i = 0; i < ic / 3; ++i)
@@ -47,7 +48,7 @@ public:
mKdTree = new KDTree(mVert, mIndices, indicesToProcess, 0, indicesToProcess.size() - 1, 10); mKdTree = new KDTree(mVert, mIndices, indicesToProcess, 0, indicesToProcess.size() - 1, 10);
mKdTree->printTree(mKdTree->getRoot(), 1); mKdTree->printTree(mKdTree->getRoot(), 1);
spdlog::info("[hartcpu] Accelerator ready.."); yolo::info("[hartcpu] Accelerator ready..");
mState = EModuleState::Idle; mState = EModuleState::Idle;
} }
@@ -61,7 +62,7 @@ public:
mState = EModuleState::Trace; mState = EModuleState::Trace;
_mSignalCv.notify_all(); _mSignalCv.notify_all();
spdlog::info("[hartcpu] Signal master to start"); yolo::info("[hartcpu] Signal master to start");
{ {
std::unique_lock<std::mutex> doneLock(_mDoneMut); std::unique_lock<std::mutex> doneLock(_mDoneMut);

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#include <spdlog/spdlog.h> #include <yolo/yolo.hpp>
#include <string> #include <string>
#include <mutex> #include <mutex>
@@ -93,7 +93,7 @@ public:
std::lock_guard<std::mutex> lock(_mData); std::lock_guard<std::mutex> lock(_mData);
for (const auto& e: queue) for (const auto& e: queue)
mToTrace.push(e); mToTrace.push(e);
spdlog::info("[hartmodule] New trace queue: {}", mToTrace.size()); yolo::info("[hartmodule] New trace queue: {}", mToTrace.size());
} }
inline void pushtoQueue(Ray* ray) inline void pushtoQueue(Ray* ray)
@@ -104,7 +104,7 @@ public:
inline void passContext(void* context, HART_HIT_CALLBACK callback) inline void passContext(void* context, HART_HIT_CALLBACK callback)
{ {
spdlog::debug("[hartmodule] Recieved context"); yolo::debug("[hartmodule] Recieved context");
std::lock_guard<std::mutex> lock(_mData); std::lock_guard<std::mutex> lock(_mData);
mCtx = context; mCtx = context;
Hit = callback; Hit = callback;

View File

@@ -14,7 +14,7 @@ namespace detail {
static std::vector<std::pair<std::string, std::string>> modules; static std::vector<std::pair<std::string, std::string>> modules;
template<typename... Args> template<typename... Args>
std::string format(const std::string& format, Args... args) inline std::string format(const std::string& format, Args... args)
{ {
std::ostringstream oss; std::ostringstream oss;
size_t start = 0; size_t pos; size_t start = 0; size_t pos;
@@ -23,7 +23,7 @@ namespace detail {
return oss.str(); return oss.str();
} }
std::string formatTime() inline std::string formatTime()
{ {
auto now = std::chrono::system_clock::now(); auto now = std::chrono::system_clock::now();
std::time_t time = std::chrono::system_clock::to_time_t(now); std::time_t time = std::chrono::system_clock::to_time_t(now);

View File

@@ -2,7 +2,7 @@
#include "inferno_hart.hpp" #include "inferno_hart.hpp"
#include <spdlog/spdlog.h> #include <yolo/yolo.hpp>
#include <iostream> #include <iostream>
@@ -53,7 +53,7 @@ std::vector<HARTModuleDirectory::discoveryEntry> HARTModuleDirectory::discoverMo
HARTModuleDirectory::discoveryEntry HARTModuleDirectory::registerModule(std::filesystem::path file) HARTModuleDirectory::discoveryEntry HARTModuleDirectory::registerModule(std::filesystem::path file)
{ {
spdlog::info("Registering module at {}", file.c_str()); yolo::info("Registering module at {}", file.c_str());
discoveryEntry entry; discoveryEntry entry;
entry.Location = file; entry.Location = file;
@@ -62,7 +62,7 @@ HARTModuleDirectory::discoveryEntry HARTModuleDirectory::registerModule(std::fil
entry.Handle = LoadLibraryA(file.c_str()); entry.Handle = LoadLibraryA(file.c_str());
if (entry.Handle == NULL) if (entry.Handle == NULL)
{ {
spdlog::error("Cannot load module at {}.", file.c_str()); yolo::error("Cannot load module at {}.", file.c_str());
entry.Handle = NULL; entry.DidLink = false; entry.Handle = NULL; entry.DidLink = false;
return entry; return entry;
} }
@@ -73,7 +73,7 @@ HARTModuleDirectory::discoveryEntry HARTModuleDirectory::registerModule(std::fil
entry.Handle = dlopen(file.c_str(), RTLD_NOW | RTLD_LOCAL); entry.Handle = dlopen(file.c_str(), RTLD_NOW | RTLD_LOCAL);
if (entry.Handle == NULL) if (entry.Handle == NULL)
{ {
spdlog::error("Cannot load module at ", dlerror()); yolo::error("Cannot load module at ", dlerror());
entry.Handle = NULL; entry.DidLink = false; entry.Handle = NULL; entry.DidLink = false;
return entry; return entry;
} }
@@ -84,30 +84,30 @@ HARTModuleDirectory::discoveryEntry HARTModuleDirectory::registerModule(std::fil
if (credit == NULL) if (credit == NULL)
{ {
spdlog::error("Cannot load module at {}... No credit...", file.c_str()); yolo::error("Cannot load module at {}... No credit...", file.c_str());
entry.Handle = NULL; entry.DidLink = false; entry.Handle = NULL; entry.DidLink = false;
return entry; return entry;
} }
if (entry.InitCallback == NULL) if (entry.InitCallback == NULL)
{ {
spdlog::error("Cannot load module at {}... No get...", file.c_str()); yolo::error("Cannot load module at {}... No get...", file.c_str());
entry.Handle = NULL; entry.DidLink = false; entry.Handle = NULL; entry.DidLink = false;
return entry; return entry;
} }
if (entry.DestroyCallback == NULL) if (entry.DestroyCallback == NULL)
{ {
spdlog::error("Cannot load module at {}... No destroy...", file.c_str()); yolo::error("Cannot load module at {}... No destroy...", file.c_str());
entry.Handle = NULL; entry.DidLink = false; entry.Handle = NULL; entry.DidLink = false;
return entry; return entry;
} }
entry.Credit = (ModuleCredit*)credit(); entry.Credit = (ModuleCredit*)credit();
spdlog::info("Module {0} v{1}.{2}.{3} by {4}", entry.Credit->ModuleName, yolo::info("Module {} v{}.{}.{} by {}", entry.Credit->ModuleName,
entry.Credit->VersionMajor, entry.Credit->VersionMajor,
entry.Credit->VersionMinor, entry.Credit->VersionMinor,
entry.Credit->VersionBuild, entry.Credit->VersionBuild,
entry.Credit->AuthorName); entry.Credit->AuthorName);
entry.DidLink = true; entry.DidLink = true;
mEntries[entry.Credit->ModuleName] = { entry, nullptr }; mEntries[entry.Credit->ModuleName] = { entry, nullptr };

View File

@@ -6,7 +6,7 @@
#include <scene/scene.hpp> #include <scene/scene.hpp>
#include <scene/mesh.hpp> #include <scene/mesh.hpp>
#include <spdlog/spdlog.h> #include <yolo/yolo.hpp>
#include <vector> #include <vector>
@@ -46,7 +46,7 @@ void HHM::newScene(Scene* scene)
void* verticies; void* normals; void* indicies; void* verticies; void* normals; void* indicies;
int vertexCount = mesh->getVerticies(&verticies, &normals); int vertexCount = mesh->getVerticies(&verticies, &normals);
int indexCount = mesh->getIndicies(&indicies); int indexCount = mesh->getIndicies(&indicies);
spdlog::debug("Mesh for module ready... {} {}", verticies, normals); yolo::debug("Mesh for module ready... {} {}", verticies, normals);
mod->submitTris(verticies, normals, vertexCount, indicies, indexCount); mod->submitTris(verticies, normals, vertexCount, indicies, indexCount);
} }
} }
@@ -77,7 +77,7 @@ void HHM::startTrace(RayField sourceScatter)
// TODO: Signal start // TODO: Signal start
HARTModule* mod = mDirectory.getActiveModule(); HARTModule* mod = mDirectory.getActiveModule();
mod->passContext((void*)this, &rayHitCallback); mod->passContext((void*)this, &rayHitCallback);
spdlog::debug("SubmitQueue {}", sourceScatter.size()); yolo::debug("SubmitQueue {}", sourceScatter.size());
mod->submitQueue(sourceScatter); mod->submitQueue(sourceScatter);
mod->start(); mod->start();
} }

View File

@@ -16,7 +16,7 @@
#include "scene/material.hpp" #include "scene/material.hpp"
#include "scene/mesh.hpp" #include "scene/mesh.hpp"
#include <spdlog/spdlog.h> #include <yolo/yolo.hpp>
#include <iostream> #include <iostream>
#include <memory> #include <memory>
@@ -28,8 +28,7 @@ using namespace inferno;
Inferno::Inferno() Inferno::Inferno()
{ {
// MOTD // MOTD
spdlog::set_level(spdlog::level::trace); yolo::info("INFERNO HART v" INFERNO_VERSION);
spdlog::info("INFERNO HART v" INFERNO_VERSION);
// Create window // Create window
mWin = &Window::GetInstance(); mWin = &Window::GetInstance();
@@ -72,7 +71,7 @@ void Inferno::uiPreset()
ImGui::DockBuilderDockWindow("Render", dock_main_id); ImGui::DockBuilderDockWindow("Render", dock_main_id);
ImGui::DockBuilderFinish(dockspace_id); ImGui::DockBuilderFinish(dockspace_id);
spdlog::info("LAYOUT SET TO DEFAULT"); yolo::info("LAYOUT SET TO DEFAULT");
} }
void Inferno::moveInput() void Inferno::moveInput()
@@ -320,7 +319,7 @@ int Inferno::run()
case GL_INVALID_FRAMEBUFFER_OPERATION: error = "INVALID_FRAMEBUFFER_OPERATION"; break; case GL_INVALID_FRAMEBUFFER_OPERATION: error = "INVALID_FRAMEBUFFER_OPERATION"; break;
default: error = std::to_string((uint32_t)err); break; default: error = std::to_string((uint32_t)err); break;
} }
spdlog::error("[GL]: {0} {1}", err, error); yolo::error("[GL]: {} {}", err, error);
} }
mWin->render(); mWin->render();

View File

@@ -1,5 +1,5 @@
#include "inferno.hpp" #include "inferno.hpp"
#include "spdlog/spdlog.h" #include "yolo/yolo.hpp"
#include <exception> #include <exception>
@@ -11,7 +11,7 @@ int main(int argc, char** argv)
} }
catch (std::exception e) catch (std::exception e)
{ {
spdlog::error(e.what()); yolo::error(e.what());
return -1; return -1;
} }
} }

View File

@@ -3,8 +3,6 @@
#include "hart_module.hpp" #include "hart_module.hpp"
#include "renderer.hpp" #include "renderer.hpp"
#include <spdlog/spdlog.h>
#include <mutex> #include <mutex>
#include <chrono> #include <chrono>

View File

@@ -11,7 +11,7 @@
#include "hart_module.hpp" #include "hart_module.hpp"
#include "ray_source.hpp" #include "ray_source.hpp"
#include <spdlog/spdlog.h> #include <yolo/yolo.hpp>
#include <iostream> #include <iostream>
@@ -83,7 +83,7 @@ void RayRenderer::prepare()
assert(mCurrentScene != nullptr); assert(mCurrentScene != nullptr);
if (mCurrentScene->didUpdate()) if (mCurrentScene->didUpdate())
{ {
spdlog::debug("New Scene!"); yolo::debug("New Scene!");
mIface->newScene(mCurrentScene); mIface->newScene(mCurrentScene);
} }
} }
@@ -105,7 +105,7 @@ void RayRenderer::draw()
// before we start we now want to check that it hasn't been force-stopped // before we start we now want to check that it hasn't been force-stopped
mIface->startTrace(startRays.Field); mIface->startTrace(startRays.Field);
spdlog::info("Sample complete"); yolo::info("Sample complete");
for (auto* ray : startRays.Field) for (auto* ray : startRays.Field)
{ {
@@ -120,7 +120,7 @@ void RayRenderer::computeHit(HitInfo* info)
// TODO: Make sure signal is started // TODO: Make sure signal is started
if (!(*mCurrentRefTable).count(info->Caller->Reference)) if (!(*mCurrentRefTable).count(info->Caller->Reference))
{ {
spdlog::warn("Why is the ray not in the map?!"); yolo::warn("Why is the ray not in the map?!");
return; return;
} }
glm::ivec2 pos = (*mCurrentRefTable)[info->Caller->Reference]; glm::ivec2 pos = (*mCurrentRefTable)[info->Caller->Reference];

View File

@@ -1,6 +1,6 @@
#include "mesh.hpp" #include "mesh.hpp"
#include <spdlog/spdlog.h> #include <yolo/yolo.hpp>
#include <scene/objloader.hpp> #include <scene/objloader.hpp>
@@ -71,14 +71,13 @@ void Mesh::ready()
glBindVertexArray(0); glBindVertexArray(0);
spdlog::debug("Mesh for preview ready..."); yolo::debug("Mesh for preview ready...");
} }
int Mesh::getVerticies(void** v, void** n) int Mesh::getVerticies(void** v, void** n)
{ {
*v = (void*)&mObjLoader->getPositions()[0]; *v = (void*)&mObjLoader->getPositions()[0];
*n = (void*)&mObjLoader->getNormals()[0]; *n = (void*)&mObjLoader->getNormals()[0];
// spdlog::debug("Mesh get {} {}", v, n);
return mObjLoader->getVertCount(); return mObjLoader->getVertCount();
} }

View File

@@ -1,7 +1,7 @@
// Adapted from https://raw.githubusercontent.com/tamato/simple-obj-loader/master/objloader.cpp // Adapted from https://raw.githubusercontent.com/tamato/simple-obj-loader/master/objloader.cpp
#include "objloader.hpp" #include "objloader.hpp"
#include <spdlog/spdlog.h> #include <yolo/yolo.hpp>
#include <iostream> #include <iostream>
#include <cstdlib> #include <cstdlib>
@@ -54,7 +54,7 @@ void ObjLoader::load(std::filesystem::path file)
{ {
if (!std::filesystem::exists(file)) if (!std::filesystem::exists(file))
{ {
spdlog::error("OBJ File does not exist at ", file.string()); yolo::error("OBJ File does not exist at ", file.string());
return; return;
} }
@@ -62,7 +62,7 @@ void ObjLoader::load(std::filesystem::path file)
inf.open(file.c_str(), std::ios_base::in); inf.open(file.c_str(), std::ios_base::in);
if (!inf.is_open()) if (!inf.is_open())
{ {
spdlog::error("Failed to open OBJ file ", file.string()); yolo::error("Failed to open OBJ file ", file.string());
return; return;
} }

View File

@@ -2,7 +2,7 @@
#include "gui/style.hpp" #include "gui/style.hpp"
#include "spdlog/spdlog.h" #include "yolo/yolo.hpp"
using namespace inferno; using namespace inferno;
@@ -188,5 +188,5 @@ void Window::glfwKeyCallback(GLFWwindow* window, int key, int scancode, int acti
} }
void Window::glfwErrorCallback(int error, const char* description) { void Window::glfwErrorCallback(int error, const char* description) {
spdlog::error("[GLFW {0}] {1}", error, description); yolo::error("[GLFW {}] {}", error, description);
} }