HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RV_VKMemory.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: RV_VKMemory.h ( RV Library, C++)
7  *
8  * COMMENTS:
9  * Class Representing a Vulkan memory allocation,
10  * And the creation info used to allocate it.
11  * Memory blocks are needed by VkImages and VkBuffers
12  */
13 
14 #ifndef RV_VKMemory_h
15 #define RV_VKMemory_h
16 
17 #include "RV_API.h"
18 
19 #include <SYS/SYS_Types.h>
20 #include <SYS/SYS_Handle.h>
21 
22 #include <UT/UT_Debug.h>
23 #include <UT/UT_Array.h>
24 #include <UT/UT_Assert.h>
25 #include <UT/UT_UniquePtr.h>
26 
27 #include <VE/VE_VK.h>
28 
29 #include <VE/VE_Memory.h>
30 
31 #include "RV_Instance.h"
32 #include "RV_Render.h"
33 #include "RV_Type.h"
34 #include "RV_TypePtrs.h"
35 #include "RV_VKExt.h"
36 
37 class RV_Instance;
38 class RV_VKMemory;
40 
41 typedef RV_VKMemory RV_VKMemory;
42 
44 {
45 public:
46  bool isCoherent() const
47  {
48  uint32_t mem_type = allocInfo().memoryType;
49  const auto props = myInst->getMemoryProps();
50  auto flags = props->memoryTypes[mem_type].propertyFlags;
51 
53  }
55  { return exportMemory(r->instance()); }
57  {
60  inst->getDevice(),
61  inst->getExt()
62  );
63  if (res.ok())
64  return res.unpack();
65  return SYS_Handle();
66  }
67 
68 private:
69  struct PassKey {};
70 public:
71  RV_VKMemory(RV_Instance *inst, VE_Memory &&mem, const PassKey &)
72  : VE_Memory(std::move(mem))
73  , myInst(inst)
74  {}
75 
76 private:
77  RV_Instance *myInst;
78 
79  friend class RV_VKMemAllocator;
80 };
81 
83 {
84 public:
85  RV_VKMemoryPtr allocateImage(
87  const VkImageCreateInfo& img_info,
88  VkImage& vk_img);
89  RV_VKMemoryPtr allocateBuffer(
90  RV_MemType type,
91  const VkBufferCreateInfo& buf_info,
92  VkBuffer& vk_buf,
93  exint alignment = 0);
94  RV_VKMemoryPtr allocateMemory(
95  RV_MemType type,
96  const VkMemoryRequirements& info);
97 
99 
102 
104  { return myAllocator; }
105 
106 private:
107  using PassKey = RV_VKMemory::PassKey;
108 
109  // Primary handles
110  RV_Instance* myInst = nullptr;
111  VE_MemoryAllocator myAllocator;
112 };
113 
114 
115 #endif
GLbitfield flags
Definition: glcorearb.h:1596
VE_Result< SYS_Handle > getExternalHandle(VkDevice device, const VE_Ext *ext)
VkFlags VkExternalMemoryHandleTypeFlags
Definition: vulkan_core.h:4970
SYS_Handle exportMemory(RV_Instance *inst)
Definition: RV_VKMemory.h:56
static VkExternalMemoryHandleTypeFlags getExternMemHandleType()
bool ok() const
Returns true if we have a valid result. Otherwise, we have an error.
Definition: VE_Result.h:33
int64 exint
Definition: SYS_Types.h:125
UT_UniquePtr< RV_VKMemory > RV_VKMemoryPtr
Definition: RV_TypePtrs.h:50
static VkExternalMemoryHandleTypeFlags getExternMemHandleType()
Definition: RV_VKMemory.h:100
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
RV_VKMemory RV_VKMemory
Definition: RV_VKMemory.h:39
#define RV_API
Definition: RV_API.h:10
const VmaAllocationInfo & allocInfo() const
Definition: VE_Memory.h:125
RV_VKMemory(RV_Instance *inst, VE_Memory &&mem, const PassKey &)
Definition: RV_VKMemory.h:71
bool isCoherent() const
Definition: RV_VKMemory.h:46
Handle to the main interface of Vulkan.
Definition: RV_Instance.h:44
SYS_Handle exportMemory(RV_Render *r)
Definition: RV_VKMemory.h:54
RV_Instance * instance()
The instance associated with this render.
Definition: RV_Render.h:92
VE_MemType getType() const
Definition: VE_Memory.h:131
RV_VKExt * getExt()
Object containing function pointers to Vulkan extensions.
Definition: RV_Instance.h:197
VkDevice getDevice()
Get the raw vulkan device assocated with this instance.
RV_MemType
Definition: RV_Type.h:111
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
GLboolean r
Definition: glcorearb.h:1222
const VE_MemoryAllocator & getBaseAllocator() const
Definition: RV_VKMemory.h:103
GLenum GLuint GLsizei const GLenum * props
Definition: glcorearb.h:2525