vulkan_image_win.cc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2020 The Chromium 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. #include "gpu/vulkan/vulkan_image.h"
  5. #include "base/logging.h"
  6. #include "gpu/vulkan/vulkan_device_queue.h"
  7. #include "gpu/vulkan/vulkan_function_pointers.h"
  8. namespace gpu {
  9. bool VulkanImage::InitializeFromGpuMemoryBufferHandle(
  10. VulkanDeviceQueue* device_queue,
  11. gfx::GpuMemoryBufferHandle gmb_handle,
  12. const gfx::Size& size,
  13. VkFormat format,
  14. VkImageUsageFlags usage,
  15. VkImageCreateFlags flags,
  16. VkImageTiling image_tiling,
  17. uint32_t queue_family_index) {
  18. NOTIMPLEMENTED();
  19. return false;
  20. }
  21. base::win::ScopedHandle VulkanImage::GetMemoryHandle(
  22. VkExternalMemoryHandleTypeFlagBits handle_type) {
  23. VkMemoryGetWin32HandleInfoKHR get_handle_info = {
  24. .sType = VK_STRUCTURE_TYPE_MEMORY_GET_WIN32_HANDLE_INFO_KHR,
  25. .memory = device_memory_,
  26. .handleType = handle_type,
  27. };
  28. VkDevice device = device_queue_->GetVulkanDevice();
  29. HANDLE handle = nullptr;
  30. vkGetMemoryWin32HandleKHR(device, &get_handle_info, &handle);
  31. if (handle == nullptr) {
  32. DLOG(ERROR) << "Unable to extract file handle out of external VkImage";
  33. return base::win::ScopedHandle();
  34. }
  35. return base::win::ScopedHandle(handle);
  36. }
  37. } // namespace gpu