more fixes

This commit is contained in:
Till Wübbers
2025-04-29 08:01:26 +02:00
parent 171e25ac76
commit 02c40aeea6
5 changed files with 76 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
$texturecPath = ".\cmake-build\texturec.exe"
$texturecPath = "..\tools\texturec.exe"
$textureAssetDir = "..\assets\textures"
$outputBaseDir = ".\textures"

View File

@@ -58,10 +58,8 @@ namespace Game
LOG_ERROR("Can't resize to more than previous size!");
return false;
}
LOG("Resizing last allocation from %llu to %llu", arena.LastAllocSize, newByteCount);
arena.Used -= arena.LastAllocSize;
arena.Used += newByteCount;
LOG("New total: %llu", arena.Used);
return true;
}

View File

@@ -69,6 +69,7 @@ namespace Game
uint8_t DebugCardRotation = 0;
bool ShortenLogFileNames = true;
bool ShowStats = true;
bool ShowArenaUsage = false;
};
struct GameInstance

View File

@@ -8,6 +8,7 @@
#include "Tools.h"
#include "bx/filepath.h"
#include "bx/string.h"
#include "bx/timer.h"
#include <imgui.h>
#include <tracy/Tracy.hpp>
@@ -121,6 +122,50 @@ namespace Tools
return changed;
}
constexpr const char* UnitStrings[]{
"b",
"kb",
"mb",
"gb",
};
const char* GetUnitString(uint64_t byteCount, uint64_t& outCount)
{
outCount = byteCount;
int32_t strIdx = 0;
for (int32_t i = 0; i < BX_COUNTOF(UnitStrings); ++i)
{
if (outCount < 1024) break;
++strIdx;
outCount /= 1024;
}
return UnitStrings[strIdx];
}
void ProgressBar(const char* title, uint64_t current, uint64_t max)
{
ImGui::PushID(title);
float percent = static_cast<double>(current) / static_cast<double>(max);
ImVec2 startPos = ImGui::GetCursorScreenPos();
char content[128]{0};
uint64_t currentUnit = 0;
const char* currentUnitStr = GetUnitString(current, currentUnit);
uint64_t maxUnit = 0;
const char* maxUnitStr = GetUnitString(max, maxUnit);
bx::snprintf(content,
sizeof(content),
"%s: %u %s/%u %s (%.2f%%)",
title,
currentUnit,
currentUnitStr,
maxUnit,
maxUnitStr,
percent);
ImGui::Text("%s", content);
ImGui::PopID();
}
bool TransformUI(Gen::Transform& transform)
{
bool changed = false;
@@ -420,6 +465,23 @@ namespace Tools
}
}
ImGui::End();
if (ImGui::Begin("Debug"))
{
ImGui::Checkbox("Arenas", &debug.ShowArenaUsage);
ImGui::Checkbox("ImGui Demo", &debug.ShowImguiDemo);
}
ImGui::End();
if (debug.ShowArenaUsage)
{
if (ImGui::Begin("Arenas", &debug.ShowArenaUsage))
{
ProgressBar("Permanent", shared.Game.PermanentArena.Used, shared.Game.PermanentArena.MaxSize);
ProgressBar("Entity", shared.Game.EntityArena.Used, shared.Game.EntityArena.MaxSize);
ProgressBar("Transient", shared.Game.TransientArena.Used, shared.Game.TransientArena.MaxSize);
}
ImGui::End();
}
}
if (debug.ShowStats)
{

View File

@@ -235,8 +235,18 @@ namespace Game
*_orientation = imageContainer.m_orientation;
}
const bgfx::Memory* mem =
bgfx::makeRef(data->data + imageContainer.m_offset, data->size - imageContainer.m_offset);
// We're working with ktx textures, so the size should be in front of the actual data
const uint32_t* texSizePtr = reinterpret_cast<uint32_t*>(data->data + imageContainer.m_offset);
uint8_t* dataPtr = data->data + imageContainer.m_offset + sizeof(uint32_t);
uint32_t dataSize = data->size - imageContainer.m_offset - sizeof(uint32_t);
// Extra sanity check
if (*texSizePtr != dataSize)
{
LOG_WARN("Texture size sanity check failed! %u != %u", texSizePtr, dataSize);
return handle;
}
const bgfx::Memory* mem = bgfx::makeRef(dataPtr, dataSize);
if (NULL != _info)
{