summaryrefslogtreecommitdiff
path: root/video.cpp
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-12-30 10:17:36 +1100
committerquou <quou@disroot.org>2024-12-30 10:17:36 +1100
commit19f6f130f9bc60cb89155dcff11c34c52714416f (patch)
tree40c007668dc7a3d5676a9ed45272cb658c1018a6 /video.cpp
parent6f3f76b8511dee30e835a998005adba57adebe17 (diff)
Staged_Buffer
Diffstat (limited to 'video.cpp')
-rw-r--r--video.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/video.cpp b/video.cpp
index 09261b5..d5efb34 100644
--- a/video.cpp
+++ b/video.cpp
@@ -3900,3 +3900,41 @@ Vram_Allocator::Allocation Vram_Allocator::alloc(
void Vram_Allocator::free(Allocation& alloc) {
alloc.chunk->free = true;
}
+
+void Staged_Buffer::init(
+ Device* dev,
+ const char* name,
+ int s,
+ int flags
+) {
+ size = s;
+ stage = dev->create_buffer(
+ name,
+ size,
+ Buffer_Flags::copy_src |
+ Buffer_Flags::cpu_readwrite
+ );
+ gpuonly = dev->create_buffer(
+ name,
+ size,
+ Buffer_Flags::copy_dst |
+ flags
+ );
+}
+
+void Staged_Buffer::destroy(Device* dev) {
+ dev->destroy_buffer(stage);
+ dev->destroy_buffer(gpuonly);
+}
+
+void* Staged_Buffer::map(Device* dev) {
+ return dev->map_buffer(stage, 0, size);
+}
+
+void Staged_Buffer::unmap(Device* dev) {
+ dev->unmap_buffer(stage);
+}
+
+void Staged_Buffer::update(Context& ctx) {
+ ctx.copy(gpuonly, stage);
+}