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 28 angle::Result importFd(gl::Context *context, 29 GLuint64 size, 30 gl::HandleType handleType, 31 GLint fd) override; 32 33 angle::Result importZirconHandle(gl::Context *context, 34 GLuint64 size, 35 gl::HandleType handleType, 36 GLuint handle) override; 37 38 angle::Result createImage(ContextVk *context, 39 gl::TextureType type, 40 size_t levels, 41 GLenum internalFormat, 42 const gl::Extents &size, 43 GLuint64 offset, 44 vk::ImageHelper *image); 45 46 private: 47 static constexpr int kInvalidFd = -1; 48 angle::Result importOpaqueFd(ContextVk *contextVk, GLuint64 size, GLint fd); 49 angle::Result importZirconVmo(ContextVk *contextVk, GLuint64 size, GLuint handle); 50 51 GLuint64 mSize = 0; 52 gl::HandleType mHandleType = gl::HandleType::InvalidEnum; 53 int mFd = kInvalidFd; 54 55 zx_handle_t mZirconHandle = ZX_HANDLE_INVALID; 56 }; 57 58 } // namespace rx 59 60 #endif // LIBANGLE_RENDERER_VULKAN_MEMORYOBJECTVK_H_ 61