1 // Copyright 2019 The ANGLE Project Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 // 5 // MemoryObjectVk.h: Defines the class interface for MemoryObjectVk, 6 // implementing MemoryObjectImpl. 7 8 #ifndef LIBANGLE_RENDERER_VULKAN_MEMORYOBJECTVK_H_ 9 #define LIBANGLE_RENDERER_VULKAN_MEMORYOBJECTVK_H_ 10 11 #include "libANGLE/renderer/MemoryObjectImpl.h" 12 #include "libANGLE/renderer/vulkan/vk_helpers.h" 13 #include "libANGLE/renderer/vulkan/vk_wrapper.h" 14 15 namespace rx 16 { 17 18 class MemoryObjectVk : public MemoryObjectImpl 19 { 20 public: 21 MemoryObjectVk(); 22 ~MemoryObjectVk() override; 23 24 void onDestroy(const gl::Context *context) override; 25 26 angle::Result setDedicatedMemory(const gl::Context *context, bool dedicatedMemory) override; 27 angle::Result setProtectedMemory(const gl::Context *context, bool protectedMemory) override; 28 29 angle::Result importFd(gl::Context *context, 30 GLuint64 size, 31 gl::HandleType handleType, 32 GLint fd) override; 33 34 angle::Result importZirconHandle(gl::Context *context, 35 GLuint64 size, 36 gl::HandleType handleType, 37 GLuint handle) override; 38 39 angle::Result createImage(ContextVk *context, 40 gl::TextureType type, 41 size_t levels, 42 GLenum internalFormat, 43 const gl::Extents &size, 44 GLuint64 offset, 45 vk::ImageHelper *image, 46 GLbitfield createFlags, 47 GLbitfield usageFlags, 48 const void *imageCreateInfoPNext); 49 50 private: 51 static constexpr int kInvalidFd = -1; 52 angle::Result importOpaqueFd(ContextVk *contextVk, GLuint64 size, GLint fd); 53 angle::Result importZirconVmo(ContextVk *contextVk, GLuint64 size, GLuint handle); 54 55 // Imported memory object was a dedicated allocation. 56 bool mDedicatedMemory = false; 57 bool mProtectedMemory = false; 58 59 GLuint64 mSize = 0; 60 gl::HandleType mHandleType = gl::HandleType::InvalidEnum; 61 int mFd = kInvalidFd; 62 63 zx_handle_t mZirconHandle = ZX_HANDLE_INVALID; 64 }; 65 66 } // namespace rx 67 68 #endif // LIBANGLE_RENDERER_VULKAN_MEMORYOBJECTVK_H_ 69