summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2025-01-01 10:52:05 +1100
committerquou <quou@disroot.org>2025-01-01 10:52:05 +1100
commit87393ae98fa459715b0c9616b986a23650e373b6 (patch)
tree163d019f483d79d2563b97865e0b230c422c8040
parent933ef51c7978c1baa414ba294a5b9b4db2cf6d4c (diff)
vram allocator debug hooks
-rw-r--r--video.cpp17
-rw-r--r--video.hpp2
2 files changed, 19 insertions, 0 deletions
diff --git a/video.cpp b/video.cpp
index 1f58e00..372b851 100644
--- a/video.cpp
+++ b/video.cpp
@@ -3838,6 +3838,10 @@ void Vram_Allocator::Page::init(
chunk->next = 0;
chunk->free = true;
chunks = chunk;
+#ifdef DEBUG
+ if (dev->hooks)
+ dev->hooks->on_page_alloc(s);
+#endif
}
Vram_Allocator::Allocation Vram_Allocator::Page::imp_alloc(
@@ -3905,6 +3909,10 @@ Vram_Allocator::Allocation Vram_Allocator::Page::alloc(
if (!a.chunk) return a;
al = align_address((uintptr_t)a.chunk->offset, (size_t)align);
a.chunk->pad = al - a.chunk->offset;
+#if DEBUG
+ if (dev->hooks)
+ dev->hooks->on_vram_alloc(as, align);
+#endif
return a;
}
@@ -4043,3 +4051,12 @@ void Device_Debug_Hooks::on_submit(Context& ctx) {
void Device_Debug_Hooks::on_present(Context& ctx) {
(void)ctx;
}
+
+void Device_Debug_Hooks::on_page_alloc(size_t size) {
+ (void)size;
+}
+
+void Device_Debug_Hooks::on_vram_alloc(size_t size, size_t align) {
+ (void)size;
+ (void)align;
+} \ No newline at end of file
diff --git a/video.hpp b/video.hpp
index bc57f1f..52fffea 100644
--- a/video.hpp
+++ b/video.hpp
@@ -423,6 +423,8 @@ struct Device_Debug_Hooks {
virtual void on_acquire(Context& ctx);
virtual void on_submit(Context& ctx);
virtual void on_present(Context& ctx);
+ virtual void on_page_alloc(size_t size);
+ virtual void on_vram_alloc(size_t size, size_t align);
};
struct Context;