mirror of https://github.com/AxioDL/metaforce.git
aurora: Reduce buffer sizes; add buffer size debug overlay
This commit is contained in:
parent
4eff37fcb2
commit
52756deac9
|
@ -740,6 +740,20 @@ std::optional<std::string> ImGuiConsole::ShowAboutWindow(bool canClose, std::str
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string BytesToString(size_t bytes) {
|
||||||
|
constexpr std::array suffixes{"B"sv, "KB"sv, "MB"sv, "GB"sv, "TB"sv, "PB"sv, "EB"sv};
|
||||||
|
u32 s = 0;
|
||||||
|
auto count = static_cast<double>(bytes);
|
||||||
|
while (count >= 1024.0 && s < 7) {
|
||||||
|
s++;
|
||||||
|
count /= 1024.0;
|
||||||
|
}
|
||||||
|
if (count - floor(count) == 0.0) {
|
||||||
|
return fmt::format("{}{}", static_cast<size_t>(count), suffixes[s]);
|
||||||
|
}
|
||||||
|
return fmt::format("{:.1f}{}", count, suffixes[s]);
|
||||||
|
}
|
||||||
|
|
||||||
void ImGuiConsole::ShowDebugOverlay() {
|
void ImGuiConsole::ShowDebugOverlay() {
|
||||||
if (!m_frameCounter && !m_frameRate && !m_inGameTime && !m_roomTimer && !m_playerInfo && !m_areaInfo &&
|
if (!m_frameCounter && !m_frameRate && !m_inGameTime && !m_roomTimer && !m_playerInfo && !m_areaInfo &&
|
||||||
!m_worldInfo && !m_randomStats && !m_resourceStats && !m_pipelineInfo) {
|
!m_worldInfo && !m_randomStats && !m_resourceStats && !m_pipelineInfo) {
|
||||||
|
@ -907,6 +921,17 @@ void ImGuiConsole::ShowDebugOverlay() {
|
||||||
|
|
||||||
ImGuiStringViewText(fmt::format(FMT_STRING("Queued pipelines: {}\n"), aurora::gfx::queuedPipelines));
|
ImGuiStringViewText(fmt::format(FMT_STRING("Queued pipelines: {}\n"), aurora::gfx::queuedPipelines));
|
||||||
ImGuiStringViewText(fmt::format(FMT_STRING("Done pipelines: {}\n"), aurora::gfx::createdPipelines));
|
ImGuiStringViewText(fmt::format(FMT_STRING("Done pipelines: {}\n"), aurora::gfx::createdPipelines));
|
||||||
|
ImGuiStringViewText(
|
||||||
|
fmt::format(FMT_STRING("Vertex size: {}\n"), BytesToString(aurora::gfx::g_lastVertSize)));
|
||||||
|
ImGuiStringViewText(
|
||||||
|
fmt::format(FMT_STRING("Uniform size: {}\n"), BytesToString(aurora::gfx::g_lastUniformSize)));
|
||||||
|
ImGuiStringViewText(
|
||||||
|
fmt::format(FMT_STRING("Index size: {}\n"), BytesToString(aurora::gfx::g_lastIndexSize)));
|
||||||
|
ImGuiStringViewText(
|
||||||
|
fmt::format(FMT_STRING("Storage size: {}\n"), BytesToString(aurora::gfx::g_lastStorageSize)));
|
||||||
|
ImGuiStringViewText(fmt::format(FMT_STRING("Total: {}\n"),
|
||||||
|
BytesToString(aurora::gfx::g_lastVertSize + aurora::gfx::g_lastUniformSize +
|
||||||
|
aurora::gfx::g_lastIndexSize + aurora::gfx::g_lastStorageSize)));
|
||||||
}
|
}
|
||||||
ShowCornerContextMenu(m_debugOverlayCorner, m_inputOverlayCorner);
|
ShowCornerContextMenu(m_debugOverlayCorner, m_inputOverlayCorner);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,10 @@ using gpu::g_queue;
|
||||||
std::vector<std::string> g_debugGroupStack;
|
std::vector<std::string> g_debugGroupStack;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
constexpr uint64_t UniformBufferSize = 5242880; // 5mb
|
constexpr uint64_t UniformBufferSize = 3145728; // 3mb
|
||||||
constexpr uint64_t VertexBufferSize = 5242880; // 5mb
|
constexpr uint64_t VertexBufferSize = 3145728; // 3mb
|
||||||
constexpr uint64_t IndexBufferSize = 2097152; // 2mb
|
constexpr uint64_t IndexBufferSize = 1048576; // 1mb
|
||||||
constexpr uint64_t StorageBufferSize = 134217728; // 128mb
|
constexpr uint64_t StorageBufferSize = 8388608; // 8mb
|
||||||
|
|
||||||
constexpr uint64_t StagingBufferSize = UniformBufferSize + VertexBufferSize + IndexBufferSize + StorageBufferSize;
|
constexpr uint64_t StagingBufferSize = UniformBufferSize + VertexBufferSize + IndexBufferSize + StorageBufferSize;
|
||||||
|
|
||||||
|
@ -358,6 +358,12 @@ void begin_frame() {
|
||||||
mapBuffer(g_storage, StorageBufferSize);
|
mapBuffer(g_storage, StorageBufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for imgui debug
|
||||||
|
size_t g_lastVertSize;
|
||||||
|
size_t g_lastUniformSize;
|
||||||
|
size_t g_lastIndexSize;
|
||||||
|
size_t g_lastStorageSize;
|
||||||
|
|
||||||
void end_frame(const wgpu::CommandEncoder& cmd) {
|
void end_frame(const wgpu::CommandEncoder& cmd) {
|
||||||
uint64_t bufferOffset = 0;
|
uint64_t bufferOffset = 0;
|
||||||
const auto writeBuffer = [&](ByteBuffer& buf, wgpu::Buffer& out, uint64_t size, std::string_view label) {
|
const auto writeBuffer = [&](ByteBuffer& buf, wgpu::Buffer& out, uint64_t size, std::string_view label) {
|
||||||
|
@ -367,12 +373,13 @@ void end_frame(const wgpu::CommandEncoder& cmd) {
|
||||||
buf.clear();
|
buf.clear();
|
||||||
}
|
}
|
||||||
bufferOffset += size;
|
bufferOffset += size;
|
||||||
|
return writeSize;
|
||||||
};
|
};
|
||||||
g_stagingBuffers[currentStagingBuffer].Unmap();
|
g_stagingBuffers[currentStagingBuffer].Unmap();
|
||||||
writeBuffer(g_verts, g_vertexBuffer, VertexBufferSize, "Vertex");
|
g_lastVertSize = writeBuffer(g_verts, g_vertexBuffer, VertexBufferSize, "Vertex");
|
||||||
writeBuffer(g_uniforms, g_uniformBuffer, UniformBufferSize, "Uniform");
|
g_lastUniformSize = writeBuffer(g_uniforms, g_uniformBuffer, UniformBufferSize, "Uniform");
|
||||||
writeBuffer(g_indices, g_indexBuffer, IndexBufferSize, "Index");
|
g_lastIndexSize = writeBuffer(g_indices, g_indexBuffer, IndexBufferSize, "Index");
|
||||||
writeBuffer(g_storage, g_storageBuffer, StorageBufferSize, "Storage");
|
g_lastStorageSize = writeBuffer(g_storage, g_storageBuffer, StorageBufferSize, "Storage");
|
||||||
currentStagingBuffer = (currentStagingBuffer + 1) % g_stagingBuffers.size();
|
currentStagingBuffer = (currentStagingBuffer + 1) % g_stagingBuffers.size();
|
||||||
map_staging_buffer();
|
map_staging_buffer();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue