Browse Source

vulkan: Forgot to commit VulkanBufferContext files

rdb 1 year ago
parent
commit
e2df1e5665

+ 22 - 0
panda/src/vulkandisplay/vulkanBufferContext.I

@@ -0,0 +1,22 @@
+/**
+ * PANDA 3D SOFTWARE
+ * Copyright (c) Carnegie Mellon University.  All rights reserved.
+ *
+ * All use of this software is subject to the terms of the revised BSD
+ * license.  You should have received a copy of this license along
+ * with this source code in a file named "LICENSE."
+ *
+ * @file vulkanBufferContext.I
+ * @author rdb
+ * @date 2024-10-16
+ */
+
+/**
+ *
+ */
+INLINE VulkanBufferContext::
+VulkanBufferContext(PreparedGraphicsObjects *pgo,
+                    TypedWritableReferenceCount *object) :
+  BufferContext(&pgo->_sbuffer_residency, object),
+  _buffer(VK_NULL_HANDLE) {
+}

+ 36 - 0
panda/src/vulkandisplay/vulkanBufferContext.cxx

@@ -0,0 +1,36 @@
+/**
+ * PANDA 3D SOFTWARE
+ * Copyright (c) Carnegie Mellon University.  All rights reserved.
+ *
+ * All use of this software is subject to the terms of the revised BSD
+ * license.  You should have received a copy of this license along
+ * with this source code in a file named "LICENSE."
+ *
+ * @file vulkanBufferContext.cxx
+ * @author rdb
+ * @date 2024-10-16
+ */
+
+#include "vulkanBufferContext.h"
+
+TypeHandle VulkanBufferContext::_type_handle;
+
+/**
+ * Evicts the page from the LRU.  Called internally when the LRU determines
+ * that it is full.  May also be called externally when necessary to
+ * explicitly evict the page.
+ *
+ * It is legal for this method to either evict the page as requested, do
+ * nothing (in which case the eviction will be requested again at the next
+ * epoch), or requeue itself on the tail of the queue (in which case the
+ * eviction will be requested again much later).
+ */
+void VulkanBufferContext::
+evict_lru() {
+  /*dequeue_lru();
+
+  TODO: manage freeing when not currently bound
+
+  update_data_size_bytes(0);
+  mark_unloaded();*/
+}

+ 56 - 0
panda/src/vulkandisplay/vulkanBufferContext.h

@@ -0,0 +1,56 @@
+/**
+ * PANDA 3D SOFTWARE
+ * Copyright (c) Carnegie Mellon University.  All rights reserved.
+ *
+ * All use of this software is subject to the terms of the revised BSD
+ * license.  You should have received a copy of this license along
+ * with this source code in a file named "LICENSE."
+ *
+ * @file vulkanBufferContext.h
+ * @author rdb
+ * @date 2024-10-16
+ */
+
+#ifndef VULKANBUFFERCONTEXT_H
+#define VULKANBUFFERCONTEXT_H
+
+#include "config_vulkandisplay.h"
+#include "bufferContext.h"
+#include "deletedChain.h"
+
+/**
+ * Generic buffer (used for shader buffers).
+ */
+class EXPCL_VULKANDISPLAY VulkanBufferContext : public BufferContext {
+public:
+  INLINE VulkanBufferContext(PreparedGraphicsObjects *pgo,
+                             TypedWritableReferenceCount *object);
+  ALLOC_DELETED_CHAIN(VulkanBufferContext);
+
+  virtual void evict_lru();
+
+public:
+  VkBuffer _buffer;
+  VulkanMemoryBlock _block;
+
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    BufferContext::init_type();
+    register_type(_type_handle, "VulkanBufferContext",
+                  BufferContext::get_class_type());
+  }
+  virtual TypeHandle get_type() const {
+    return get_class_type();
+  }
+  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
+
+private:
+  static TypeHandle _type_handle;
+};
+
+#include "vulkanBufferContext.I"
+
+#endif