Remove VK_KHR_magma_surface.
Framebuffer backed surface extension has been moved to a layer.
Change-Id: I24f9dc1aed2960419d89e5260705d0f1417446ac
diff --git a/include/vulkan/vk_icd.h b/include/vulkan/vk_icd.h
index d95fe50..7b54fb5 100644
--- a/include/vulkan/vk_icd.h
+++ b/include/vulkan/vk_icd.h
@@ -64,8 +64,7 @@
VK_ICD_WSI_PLATFORM_WIN32,
VK_ICD_WSI_PLATFORM_XCB,
VK_ICD_WSI_PLATFORM_XLIB,
- VK_ICD_WSI_PLATFORM_DISPLAY,
- VK_ICD_WSI_PLATFORM_MAGMA
+ VK_ICD_WSI_PLATFORM_DISPLAY
} VkIcdWsiPlatform;
typedef struct {
@@ -118,13 +117,6 @@
} VkIcdSurfaceAndroid;
#endif //VK_USE_PLATFORM_ANDROID_KHR
-#ifdef VK_USE_PLATFORM_MAGMA_KHR
-typedef struct _VkIcdSurfaceMagma {
- VkIcdSurfaceBase base;
- bool has_fb;
-} VkIcdSurfaceMagma;
-#endif // VK_USE_PLATFORM_MAGMA_KHR
-
typedef struct {
VkIcdSurfaceBase base;
VkDisplayModeKHR displayMode;
diff --git a/src/intel/vulkan/BUILD.gn b/src/intel/vulkan/BUILD.gn
index 94d35ee..e37beb5 100644
--- a/src/intel/vulkan/BUILD.gn
+++ b/src/intel/vulkan/BUILD.gn
@@ -85,7 +85,6 @@
"$mesa_build_root/src/util",
"$mesa_build_root/src/vulkan/util",
"$msd_intel_gen_build_root/include",
- "//zircon/public/lib/framebuffer",
]
sources = [
@@ -119,7 +118,6 @@
"anv_queue.c",
"anv_util.c",
"anv_wsi.c",
- "anv_wsi_magma.cc",
"vk_format_info.h",
]
}
diff --git a/src/intel/vulkan/anv_extensions.py b/src/intel/vulkan/anv_extensions.py
index bc43f3c..e55f0a6 100755
--- a/src/intel/vulkan/anv_extensions.py
+++ b/src/intel/vulkan/anv_extensions.py
@@ -88,7 +88,6 @@
Extension('VK_KHR_xlib_surface', 6, 'VK_USE_PLATFORM_XLIB_KHR'),
Extension('VK_KHX_multiview', 1, False),
Extension('VK_EXT_debug_report', 8, True),
- Extension('VK_KHR_magma_surface', 1, 'VK_USE_PLATFORM_MAGMA_KHR'),
Extension('VK_KHR_external_memory_fuchsia', 1, 'VK_USE_PLATFORM_MAGMA_KHR'),
Extension('VK_KHR_external_semaphore_fuchsia', 1, 'VK_USE_PLATFORM_MAGMA_KHR'),
Extension('VK_GOOGLE_image_usage_scanout', 1, 'VK_USE_PLATFORM_MAGMA_KHR'),
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index d891d07..08d83cd 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -32,19 +32,6 @@
};
#endif
-#ifdef VK_USE_PLATFORM_MAGMA_KHR
-#include "anv_wsi_magma.h"
-
-static const struct wsi_magma_callbacks wsi_magma_cbs = {
- .get_render_connection = anv_wsi_magma_get_render_connection,
- .destroy_surface = anv_wsi_magma_destroy_surface,
- .create_wsi_image = anv_wsi_magma_image_create,
- .free_wsi_image = anv_wsi_magma_image_free,
- .get_platform_semaphore = anv_wsi_magma_get_platform_semaphore,
- .signal_semaphore = anv_wsi_magma_signal_semaphore,
-};
-#endif
-
VkResult
anv_init_wsi(struct anv_physical_device *physical_device)
{
@@ -52,13 +39,6 @@
memset(physical_device->wsi_device.wsi, 0, sizeof(physical_device->wsi_device.wsi));
-#ifdef VK_USE_PLATFORM_MAGMA_KHR
- result = wsi_magma_init_wsi(&physical_device->wsi_device, &physical_device->instance->alloc,
- &wsi_magma_cbs);
- if (result != VK_SUCCESS)
- return result;
-#endif
-
#ifdef VK_USE_PLATFORM_XCB_KHR
result = wsi_x11_init_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
if (result != VK_SUCCESS)
@@ -83,9 +63,6 @@
void
anv_finish_wsi(struct anv_physical_device *physical_device)
{
-#ifdef VK_USE_PLATFORM_MAGMA_KHR
- wsi_magma_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
-#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
wsi_wl_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
#endif
@@ -105,10 +82,6 @@
if (!surface)
return;
-#ifdef VK_USE_PLATFORM_MAGMA_KHR
- wsi_magma_cbs.destroy_surface(surface);
-#endif
-
vk_free2(&instance->alloc, pAllocator, surface);
}
@@ -194,6 +167,7 @@
pPresentModes);
}
+
static VkResult
anv_wsi_image_create(VkDevice device_h,
const VkSwapchainCreateInfoKHR *pCreateInfo,
@@ -404,13 +378,8 @@
ANV_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
ANV_FROM_HANDLE(anv_fence, fence, _fence);
-#ifdef VK_USE_PLATFORM_MAGMA_KHR
- // We don't handle fences correctly
- if (fence)
- printf("WARNING [%s:%d] acquire fence not supported\n", __FILE__, __LINE__);
-#endif
-
- VkResult result = swapchain->acquire_next_image(swapchain, timeout, semaphore, pImageIndex);
+ VkResult result = swapchain->acquire_next_image(swapchain, timeout,
+ semaphore, pImageIndex);
/* Thanks to implicit sync, the image is ready immediately. However, we
* should wait for the current GPU state to finish.
@@ -461,9 +430,7 @@
item_result = swapchain->queue_present(swapchain,
pPresentInfo->pImageIndices[i],
- region,
- pPresentInfo->waitSemaphoreCount,
- pPresentInfo->pWaitSemaphores);
+ region);
/* TODO: What if one of them returns OUT_OF_DATE? */
if (pPresentInfo->pResults != NULL)
pPresentInfo->pResults[i] = item_result;
@@ -478,7 +445,7 @@
if (last != VK_NULL_HANDLE) {
anv_WaitForFences(anv_device_to_handle(queue->device),
- 1, &last, true, UINT64_MAX);
+ 1, &last, true, 1);
}
}
diff --git a/src/intel/vulkan/anv_wsi_magma.cc b/src/intel/vulkan/anv_wsi_magma.cc
deleted file mode 100644
index 6da4622..0000000
--- a/src/intel/vulkan/anv_wsi_magma.cc
+++ /dev/null
@@ -1,153 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "anv_wsi_magma.h"
-#include "anv_magma.h"
-#include "wsi_common_magma.h"
-#include <fcntl.h>
-#include <lib/framebuffer/framebuffer.h>
-
-#include "vk_format_info.h"
-
-VkBool32 anv_GetPhysicalDeviceMagmaPresentationSupportKHR(VkPhysicalDevice physicalDevice,
- uint32_t queueFamilyIndex)
-{
- ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
-
- return wsi_get_physical_device_magma_presentation_support(
- &device->wsi_device, &device->instance->alloc, queueFamilyIndex);
-}
-
-VkResult anv_CreateMagmaSurfaceKHR(VkInstance _instance,
- const VkMagmaSurfaceCreateInfoKHR* pCreateInfo,
- const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface)
-{
- ANV_FROM_HANDLE(anv_instance, instance, _instance);
-
- assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_MAGMA_SURFACE_CREATE_INFO_KHR);
- assert(pCreateInfo->imagePipeHandle == 0);
-
- if (!pAllocator)
- pAllocator = &instance->alloc;
-
- auto surface = reinterpret_cast<VkIcdSurfaceMagma*>(
- vk_alloc(pAllocator, sizeof(VkIcdSurfaceMagma), 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT));
- if (!surface)
- return VK_ERROR_OUT_OF_HOST_MEMORY;
-
- surface->base.platform = VK_ICD_WSI_PLATFORM_MAGMA;
- const char* err;
- surface->has_fb = fb_bind(false, &err) == ZX_OK;
-
- *pSurface = VkIcdSurfaceBase_to_handle(&surface->base);
-
- return VK_SUCCESS;
-}
-
-void* anv_wsi_magma_get_render_connection(VkDevice device)
-{
- return anv_device_from_handle(device)->connection;
-}
-
-void anv_wsi_magma_destroy_surface(VkIcdSurfaceBase* icd_surface)
-{
- auto surface = reinterpret_cast<VkIcdSurfaceMagma*>(icd_surface);
- if (surface->has_fb)
- fb_release();
-}
-
-VkResult anv_wsi_magma_image_create(VkDevice device_h, const VkSwapchainCreateInfoKHR* pCreateInfo,
- const VkAllocationCallbacks* pAllocator, VkImage* image_p,
- VkDeviceMemory* memory_p, uint32_t* size, uint32_t* offset,
- uint32_t* row_pitch, uintptr_t* buffer_handle_p)
-{
- struct anv_device* device = anv_device_from_handle(device_h);
- VkImage image_h;
- struct anv_image* image;
- int ret;
-
- VkImageCreateInfo create_info = {
- .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
- .imageType = VK_IMAGE_TYPE_2D,
- .format = pCreateInfo->imageFormat,
- .extent = {.width = pCreateInfo->imageExtent.width,
- .height = pCreateInfo->imageExtent.height,
- .depth = 1},
- .mipLevels = 1,
- .arrayLayers = 1,
- .samples = VK_SAMPLE_COUNT_1_BIT,
- .tiling = VK_IMAGE_TILING_OPTIMAL,
- .usage = (pCreateInfo->imageUsage |
- VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
- VK_IMAGE_USAGE_SCANOUT_BIT_GOOGLE),
- .flags = 0,
- };
-
- anv_image_create_info image_create_info = {
- .isl_tiling_flags = 0, .stride = 0, .vk_info = &create_info};
-
- VkResult result;
- result = anv_image_create(anv_device_to_handle(device), &image_create_info, NULL, &image_h);
-
- if (result != VK_SUCCESS)
- return result;
-
- image = anv_image_from_handle(image_h);
- assert(vk_format_is_color(image->vk_format));
-
- VkMemoryAllocateInfo allocate_info = {
- .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
- .allocationSize = image->size,
- .memoryTypeIndex = 0,
- };
-
- VkDeviceMemory memory_h;
- struct anv_device_memory* memory;
- result = anv_AllocateMemory(anv_device_to_handle(device), &allocate_info,
- NULL /* XXX: pAllocator */, &memory_h);
- if (result != VK_SUCCESS) {
- anv_DestroyImage(device_h, image_h, pAllocator);
- return result;
- }
-
- memory = anv_device_memory_from_handle(memory_h);
-
- anv_BindImageMemory(VK_NULL_HANDLE, image_h, memory_h, 0);
- assert(image->planes[0].offset == 0);
-
- struct anv_surface *surface = &image->planes[0].surface;
-
- *row_pitch = surface->isl.row_pitch;
- *image_p = image_h;
- *memory_p = memory_h;
- *buffer_handle_p = image->planes[0].bo->gem_handle;
- *size = image->size;
- *offset = 0;
- return VK_SUCCESS;
-}
-
-void anv_wsi_magma_image_free(VkDevice device, const VkAllocationCallbacks* pAllocator,
- VkImage image_h, VkDeviceMemory memory_h)
-{
- anv_DestroyImage(device, image_h, pAllocator);
-
- anv_FreeMemory(device, memory_h, pAllocator);
-}
-
-uintptr_t anv_wsi_magma_get_platform_semaphore(VkDevice vk_device, VkSemaphore vk_semaphore)
-{
- anv_device* device = anv_device_from_handle(vk_device);
- ANV_FROM_HANDLE(anv_semaphore, semaphore, vk_semaphore);
- anv_semaphore_impl* impl = semaphore->temporary.type != ANV_SEMAPHORE_TYPE_NONE
- ? &semaphore->temporary : &semaphore->permanent;
- return impl->syncobj;
-}
-
-void anv_wsi_magma_signal_semaphore(VkSemaphore vk_semaphore)
-{
- ANV_FROM_HANDLE(anv_semaphore, semaphore, vk_semaphore);
- anv_semaphore_impl* impl = semaphore->temporary.type != ANV_SEMAPHORE_TYPE_NONE
- ? &semaphore->temporary : &semaphore->permanent;
- magma_signal_semaphore(impl->syncobj);
-}
diff --git a/src/intel/vulkan/anv_wsi_magma.h b/src/intel/vulkan/anv_wsi_magma.h
deleted file mode 100644
index 32b9f38..0000000
--- a/src/intel/vulkan/anv_wsi_magma.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ANV_WSI_MAGMA_H
-#define ANV_WSI_MAGMA_H
-
-#include "anv_private.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void* anv_wsi_magma_get_render_connection(VkDevice device);
-
-void anv_wsi_magma_destroy_surface(VkIcdSurfaceBase* icd_surface);
-
-VkResult anv_wsi_magma_image_create(VkDevice device_h, const VkSwapchainCreateInfoKHR* pCreateInfo,
- const VkAllocationCallbacks* pAllocator, VkImage* image_p,
- VkDeviceMemory* memory_p, uint32_t* size, uint32_t* offset,
- uint32_t* row_pitch, uintptr_t* buffer_handle_p);
-
-void anv_wsi_magma_image_free(VkDevice device, const VkAllocationCallbacks* pAllocator,
- VkImage image_h, VkDeviceMemory memory_h);
-
-uintptr_t anv_wsi_magma_get_platform_semaphore(VkDevice device, VkSemaphore semaphore);
-
-void anv_wsi_magma_signal_semaphore(VkSemaphore semaphore);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANV_WSI_MAGMA_H
diff --git a/src/intel/vulkan/tests/BUILD.gn b/src/intel/vulkan/tests/BUILD.gn
index e2f2148..64b2239 100644
--- a/src/intel/vulkan/tests/BUILD.gn
+++ b/src/intel/vulkan/tests/BUILD.gn
@@ -27,7 +27,6 @@
":state_pool",
":state_pool_free_list_only",
":state_pool_no_free",
- ":test_wsi_magma",
]
}
@@ -94,21 +93,3 @@
"..:vulkan_internal",
]
}
-
-executable("test_wsi_magma") {
- sources = [
- "test_wsi_magma.cc",
- ]
-
- configs += [ "$mesa_build_root/src:common_config" ]
-
- deps = [
- "$magma_build_root/include:magma_abi",
- "$magma_build_root/src/magma_util",
- "$magma_build_root/tests/mock:magma_system",
- "$magma_build_root/tests/vulkan_shim",
- "$mesa_build_root/include:c_compat",
- "$mesa_build_root/include:vulkan",
- "..:vulkan_internal",
- ]
-}
diff --git a/src/intel/vulkan/tests/test_wsi_magma.cc b/src/intel/vulkan/tests/test_wsi_magma.cc
deleted file mode 100644
index 9468e08..0000000
--- a/src/intel/vulkan/tests/test_wsi_magma.cc
+++ /dev/null
@@ -1,321 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <vector>
-
-#include "magma.h"
-#include "magma_util/macros.h"
-#include "vulkan_shim.h"
-
-class TestWsiMagma {
-public:
- ~TestWsiMagma();
-
- bool Init();
- bool Run(uint32_t frame_count);
-
-private:
- VkInstance instance_;
- VkDevice device_;
- VkSurfaceKHR surface_;
- VkExtent2D extent_;
- VkSwapchainKHR swapchain_ = VK_NULL_HANDLE;
- VkQueue queue_;
-
- PFN_vkGetPhysicalDeviceSurfaceSupportKHR fpGetPhysicalDeviceSurfaceSupportKHR_;
- PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR fpGetPhysicalDeviceSurfaceCapabilitiesKHR_;
- PFN_vkGetPhysicalDeviceSurfaceFormatsKHR fpGetPhysicalDeviceSurfaceFormatsKHR_;
- PFN_vkGetPhysicalDeviceSurfacePresentModesKHR fpGetPhysicalDeviceSurfacePresentModesKHR_;
- PFN_vkCreateSwapchainKHR fpCreateSwapchainKHR_;
- PFN_vkDestroySwapchainKHR fpDestroySwapchainKHR_;
- PFN_vkGetSwapchainImagesKHR fpGetSwapchainImagesKHR_;
- PFN_vkAcquireNextImageKHR fpAcquireNextImageKHR_;
- PFN_vkQueuePresentKHR fpQueuePresentKHR_;
-};
-
-bool operator==(VkExtent2D& a, VkExtent2D b) { return a.width == b.width && a.height == b.height; }
-
-bool TestWsiMagma::Init()
-{
- // Enumerate and create a device - use the anv_magma_stubs though
- VkInstanceCreateInfo create_info{
- VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // VkStructureType sType;
- nullptr, // const void* pNext;
- 0, // VkInstanceCreateFlags flags;
- nullptr, // const VkApplicationInfo* pApplicationInfo;
- 0, // uint32_t enabledLayerCount;
- nullptr, // const char* const* ppEnabledLayerNames;
- 0, // uint32_t enabledExtensionCount;
- nullptr, // const char* const* ppEnabledExtensionNames;
- };
-
- VkResult result;
-
- result = vkCreateInstance(&create_info, nullptr /*allocation_callbacks*/, &instance_);
- if (result != VK_SUCCESS)
- return DRETF(false, "vkCreateInstance failed %d", result);
-
- fpGetPhysicalDeviceSurfaceSupportKHR_ =
- reinterpret_cast<PFN_vkGetPhysicalDeviceSurfaceSupportKHR>(
- vkGetInstanceProcAddr(instance_, "vkGetPhysicalDeviceSurfaceSupportKHR"));
- assert(fpGetPhysicalDeviceSurfaceSupportKHR_);
- fpGetPhysicalDeviceSurfaceCapabilitiesKHR_ =
- reinterpret_cast<PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR>(
- vkGetInstanceProcAddr(instance_, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR"));
- assert(fpGetPhysicalDeviceSurfaceCapabilitiesKHR_);
- fpGetPhysicalDeviceSurfaceFormatsKHR_ =
- reinterpret_cast<PFN_vkGetPhysicalDeviceSurfaceFormatsKHR>(
- vkGetInstanceProcAddr(instance_, "vkGetPhysicalDeviceSurfaceFormatsKHR"));
- assert(fpGetPhysicalDeviceSurfaceFormatsKHR_);
- fpGetPhysicalDeviceSurfacePresentModesKHR_ =
- reinterpret_cast<PFN_vkGetPhysicalDeviceSurfacePresentModesKHR>(
- vkGetInstanceProcAddr(instance_, "vkGetPhysicalDeviceSurfacePresentModesKHR"));
- assert(fpGetPhysicalDeviceSurfacePresentModesKHR_);
- fpCreateSwapchainKHR_ = reinterpret_cast<PFN_vkCreateSwapchainKHR>(
- vkGetInstanceProcAddr(instance_, "vkCreateSwapchainKHR"));
- assert(fpCreateSwapchainKHR_);
- fpDestroySwapchainKHR_ = reinterpret_cast<PFN_vkDestroySwapchainKHR>(
- vkGetInstanceProcAddr(instance_, "vkDestroySwapchainKHR"));
- assert(fpDestroySwapchainKHR_);
- fpGetSwapchainImagesKHR_ = reinterpret_cast<PFN_vkGetSwapchainImagesKHR>(
- vkGetInstanceProcAddr(instance_, "vkGetSwapchainImagesKHR"));
- assert(fpGetSwapchainImagesKHR_);
- fpAcquireNextImageKHR_ = reinterpret_cast<PFN_vkAcquireNextImageKHR>(
- vkGetInstanceProcAddr(instance_, "vkAcquireNextImageKHR"));
- assert(fpAcquireNextImageKHR_);
- fpQueuePresentKHR_ = reinterpret_cast<PFN_vkQueuePresentKHR>(
- vkGetInstanceProcAddr(instance_, "vkQueuePresentKHR"));
- assert(fpQueuePresentKHR_);
-
- uint32_t physical_device_count;
- result = vkEnumeratePhysicalDevices(instance_, &physical_device_count, nullptr);
- if (result != VK_SUCCESS)
- return DRETF(false, "vkEnumeratePhysicalDevices failed %d", result);
-
- if (physical_device_count < 1)
- return DRETF(false, "unexpected physical_device_count %d", physical_device_count);
-
- std::vector<VkPhysicalDevice> physical_devices(physical_device_count);
- if ((result = vkEnumeratePhysicalDevices(instance_, &physical_device_count,
- physical_devices.data())) != VK_SUCCESS)
- return DRETF(false, "vkEnumeratePhysicalDevices failed %d", result);
-
- uint32_t queue_family_count;
- vkGetPhysicalDeviceQueueFamilyProperties(physical_devices[0], &queue_family_count, nullptr);
-
- if (queue_family_count < 1)
- return DRETF(false, "invalid queue_family_count %d", queue_family_count);
-
- std::vector<VkQueueFamilyProperties> queue_family_properties(queue_family_count);
- vkGetPhysicalDeviceQueueFamilyProperties(physical_devices[0], &queue_family_count,
- queue_family_properties.data());
-
- VkMagmaSurfaceCreateInfoKHR createInfo = {
- .sType = VK_STRUCTURE_TYPE_MAGMA_SURFACE_CREATE_INFO_KHR, .pNext = nullptr,
- };
-
- result = vkCreateMagmaSurfaceKHR(instance_, &createInfo, nullptr, &surface_);
- if (result != VK_SUCCESS)
- return DRETF(false, "vkCreateMagmaSurfaceKHR failed: %d", result);
-
- uint32_t queue_family_index = UINT32_MAX;
-
- for (uint32_t i = 0; i < queue_family_count; i++) {
- VkBool32 supports_present;
- fpGetPhysicalDeviceSurfaceSupportKHR_(physical_devices[0], i, surface_, &supports_present);
- if (supports_present)
- queue_family_index = i;
- }
-
- if (queue_family_index == UINT32_MAX)
- return DRETF(false, "couldn't find a queue supporting present");
-
- uint32_t formatCount;
- result =
- fpGetPhysicalDeviceSurfaceFormatsKHR_(physical_devices[0], surface_, &formatCount, nullptr);
- if (result != VK_SUCCESS)
- return DRETF(false, "fpGetPhysicalDeviceSurfaceFormatsKHR failed %d", result);
-
- std::vector<VkSurfaceFormatKHR> surfFormats(formatCount);
- result = fpGetPhysicalDeviceSurfaceFormatsKHR_(physical_devices[0], surface_, &formatCount,
- surfFormats.data());
- if (result != VK_SUCCESS)
- return DRETF(false, "fpGetPhysicalDeviceSurfaceFormatsKHR failed %d", result);
-
- if (surfFormats.size() != 1)
- return DRETF(false, "unexpected number of surface formats %zd", surfFormats.size());
-
- if (surfFormats[0].format != VK_FORMAT_B8G8R8A8_UNORM)
- return DRETF(false, "unexpected surface format 0x%x", surfFormats[0].format);
-
- uint32_t presentModeCount;
- result = fpGetPhysicalDeviceSurfacePresentModesKHR_(physical_devices[0], surface_,
- &presentModeCount, nullptr);
- if (result != VK_SUCCESS)
- return DRETF(false, "fpGetPhysicalDeviceSurfacePresentModesKHR failed %d", result);
-
- std::vector<VkPresentModeKHR> presentModes(presentModeCount);
- result = fpGetPhysicalDeviceSurfacePresentModesKHR_(physical_devices[0], surface_,
- &presentModeCount, presentModes.data());
- if (result != VK_SUCCESS)
- return DRETF(false, "fpGetPhysicalDeviceSurfacePresentModesKHR failed %d", result);
-
- if (presentModes.size() != 1)
- return DRETF(false, "unexpected number of present modes %zd", presentModes.size());
-
- if (presentModes[0] != VK_PRESENT_MODE_FIFO_KHR)
- return DRETF(false, "unexpected present mode 0x%x", presentModes[0]);
-
- VkSurfaceCapabilitiesKHR surf_caps;
- result = fpGetPhysicalDeviceSurfaceCapabilitiesKHR_(physical_devices[0], surface_, &surf_caps);
- if (result != VK_SUCCESS)
- return DRETF(false, "fpGetPhysicalDeviceSurfaceCapabilitiesKHR_ failed %d", result);
-
- if (surf_caps.currentExtent == VkExtent2D{0, 0})
- return DRETF(false, "unexpected extent");
-
- if (!(surf_caps.currentExtent == VkExtent2D{UINT32_MAX, UINT32_MAX}))
- return DRETF(false, "unexpected extent");
-
- if (!(surf_caps.minImageExtent == VkExtent2D{1,1}))
- return DRETF(false, "unexpected minImageExtent");
-
- if (!(surf_caps.maxImageExtent == VkExtent2D{UINT32_MAX, UINT32_MAX}))
- return DRETF(false, "unexpected maxImageExtent");
-
- extent_ = VkExtent2D{1024,768};
-
- if (surf_caps.supportedCompositeAlpha !=
- (VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR | VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR))
- return DRETF(false, "unexpected supportedCompositeAlpha 0x%x",
- surf_caps.supportedCompositeAlpha);
-
- if (surf_caps.minImageCount != 2)
- return DRETF(false, "unexpected minImageCount %d", surf_caps.minImageCount);
-
- if (surf_caps.maxImageCount != 3)
- return DRETF(false, "unexpected minImageCount %d", surf_caps.maxImageCount);
-
- if (surf_caps.supportedTransforms != VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR)
- return DRETF(false, "unexpected supportedTransforms 0x%x", surf_caps.supportedTransforms);
-
- if (surf_caps.maxImageArrayLayers != 1)
- return DRETF(false, "unexpected maxImageArrayLayers 0x%x", surf_caps.maxImageArrayLayers);
-
- if (surf_caps.supportedUsageFlags !=
- (VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_SAMPLED_BIT |
- VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT))
- return DRETF(false, "unexpected supportedUsageFlags 0x%x", surf_caps.supportedUsageFlags);
-
- // Create the device.
-
- float queue_priorities[1] = {0.0};
-
- VkDeviceQueueCreateInfo queue_create_info = {.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
- .pNext = nullptr,
- .flags = 0,
- .queueFamilyIndex = queue_family_index,
- .queueCount = 1,
- .pQueuePriorities = queue_priorities};
- VkDeviceCreateInfo device_create_info = {.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
- .pNext = nullptr,
- .flags = 0,
- .queueCreateInfoCount = 1,
- .pQueueCreateInfos = &queue_create_info,
- .enabledLayerCount = 0,
- .ppEnabledLayerNames = nullptr,
- .enabledExtensionCount = 0,
- .ppEnabledExtensionNames = nullptr,
- .pEnabledFeatures = nullptr};
-
- result = vkCreateDevice(physical_devices[0], &device_create_info,
- nullptr /* allocationcallbacks */, &device_);
- if (result != VK_SUCCESS)
- return DRETF(false, "vkCreateDevice failed: %d", result);
-
- vkGetDeviceQueue(device_, queue_family_index, 0, &queue_);
-
- VkSwapchainCreateInfoKHR swapchain_create_info = {
- .sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
- .pNext = nullptr,
- .surface = surface_,
- .minImageCount = 2,
- .imageFormat = VK_FORMAT_B8G8R8A8_UNORM,
- .imageColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR, // the only supported value?
- .imageExtent = extent_,
- .imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
- .preTransform = surf_caps.currentTransform,
- .compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR,
- .imageArrayLayers = 1,
- .imageSharingMode = VK_SHARING_MODE_EXCLUSIVE,
- .queueFamilyIndexCount = 0,
- .pQueueFamilyIndices = NULL,
- .presentMode = presentModes[0],
- .oldSwapchain = VK_NULL_HANDLE,
- .clipped = true,
- };
-
- result = fpCreateSwapchainKHR_(device_, &swapchain_create_info, nullptr, &swapchain_);
- if (result != VK_SUCCESS)
- return DRETF(false, "fpCreateSwapchainKHR failed: %d", result);
-
- return true;
-}
-
-bool TestWsiMagma::Run(uint32_t frame_count)
-{
- uint32_t image_count;
-
- VkResult result = fpGetSwapchainImagesKHR_(device_, swapchain_, &image_count, nullptr);
- if (result != VK_SUCCESS)
- return DRETF(false, "fpGetSwapchainImagesKHR failed: %d", result);
-
- std::vector<VkImage> images(image_count);
-
- result = fpGetSwapchainImagesKHR_(device_, swapchain_, &image_count, images.data());
- if (result != VK_SUCCESS)
- return DRETF(false, "fpGetSwapchainImagesKHR failed: %d", result);
-
- uint32_t image_index;
-
- for (uint32_t frame = 0; frame < frame_count; frame++) {
- result = fpAcquireNextImageKHR_(device_, swapchain_, 0, VK_NULL_HANDLE, VK_NULL_HANDLE,
- &image_index);
- if (result != VK_SUCCESS)
- return DRETF(false, "fpAcquireNextImageKHR_ failed: %d", result);
-
- VkPresentInfoKHR present = {
- .sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
- .pNext = nullptr,
- .waitSemaphoreCount = 0,
- .pWaitSemaphores = nullptr,
- .swapchainCount = 1,
- .pSwapchains = &swapchain_,
- .pImageIndices = &image_index,
- };
-
- result = fpQueuePresentKHR_(queue_, &present);
- if (result != VK_SUCCESS)
- return DRETF(false, "fpQueuePresentKHR_ failed (image index %u): %d", image_index, result);
- }
-
- return true;
-}
-
-TestWsiMagma::~TestWsiMagma()
-{
- if (swapchain_ != VK_NULL_HANDLE)
- fpDestroySwapchainKHR_(device_, swapchain_, nullptr);
-}
-
-int main(int argc, char** argv)
-{
- VulkanShimInit();
-
- TestWsiMagma test;
- if (!test.Init())
- return -1;
- if (!test.Run(100))
- return 0;
-}
diff --git a/src/vulkan/wsi/BUILD.gn b/src/vulkan/wsi/BUILD.gn
index 8b2d732..ff57c3a 100644
--- a/src/vulkan/wsi/BUILD.gn
+++ b/src/vulkan/wsi/BUILD.gn
@@ -27,20 +27,7 @@
mesa_source_set("wsi") {
public_configs = [ ":wsi_config" ]
-
sources = [
"wsi_common.h",
- "wsi_common_magma.cc",
]
-
- deps = [
- "$magma_build_root/include:magma_abi",
- "$magma_build_root/src/magma_util",
- "$mesa_build_root/include:vulkan",
- "$mesa_build_root/src/util",
- "//zircon/public/lib/framebuffer",
- "//zircon/public/lib/zx",
- ]
-
- include_dirs = [ "$mesa_build_root/src/vulkan/util" ]
}
diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index 2e01016..8166b7d 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -68,9 +68,9 @@
VkResult (*acquire_next_image)(struct wsi_swapchain *swap_chain,
uint64_t timeout, VkSemaphore semaphore,
uint32_t *image_index);
- VkResult (*queue_present)(struct wsi_swapchain* swap_chain, uint32_t image_index,
- const VkPresentRegionKHR *damage,
- uint32_t wait_semaphore_count, const VkSemaphore* wait_semaphores);
+ VkResult (*queue_present)(struct wsi_swapchain *swap_chain,
+ uint32_t image_index,
+ const VkPresentRegionKHR *damage);
void (*get_image_and_linear)(struct wsi_swapchain *swapchain,
int imageIndex,
VkImage *image,
@@ -112,7 +112,7 @@
struct wsi_swapchain **swapchain);
};
-#define VK_ICD_WSI_PLATFORM_MAX 7
+#define VK_ICD_WSI_PLATFORM_MAX 5
struct wsi_device {
struct wsi_interface * wsi[VK_ICD_WSI_PLATFORM_MAX];
@@ -124,21 +124,6 @@
VkFormatProperties *pFormatProperties);
};
-struct wsi_magma_callbacks {
- void* (*get_render_connection)(VkDevice device);
- void (*destroy_surface)(VkIcdSurfaceBase* surface);
- VkResult (*create_wsi_image)(VkDevice device_h, const VkSwapchainCreateInfoKHR* pCreateInfo,
- const VkAllocationCallbacks* pAllocator, VkImage* image_p,
- VkDeviceMemory* memory_p, uint32_t* size_p, uint32_t* offset_p,
- uint32_t* row_pitch_p, uintptr_t* buffer_handle_p);
- void (*free_wsi_image)(VkDevice device,
- const VkAllocationCallbacks *pAllocator,
- VkImage image_h,
- VkDeviceMemory memory_h);
- uintptr_t (*get_platform_semaphore)(VkDevice device, VkSemaphore semaphore);
- void (*signal_semaphore)(VkSemaphore semaphore);
-};
-
#define WSI_DEFINE_NONDISP_HANDLE_CASTS(__wsi_type, __VkType) \
\
static inline struct __wsi_type * \
@@ -184,9 +169,6 @@
const struct wsi_callbacks *cbs);
void wsi_wl_finish_wsi(struct wsi_device *wsi_device,
const VkAllocationCallbacks *alloc);
-VkResult wsi_magma_init_wsi(struct wsi_device* wsi_device, const VkAllocationCallbacks* alloc,
- const struct wsi_magma_callbacks* callbacks);
-void wsi_magma_finish_wsi(struct wsi_device *wsi_device,
- const VkAllocationCallbacks *alloc);
+
#endif
diff --git a/src/vulkan/wsi/wsi_common_magma.cc b/src/vulkan/wsi/wsi_common_magma.cc
deleted file mode 100644
index c2da472..0000000
--- a/src/vulkan/wsi/wsi_common_magma.cc
+++ /dev/null
@@ -1,486 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <functional>
-#include <lib/framebuffer/framebuffer.h>
-#include <memory>
-#include <vector>
-#include <zircon/syscalls.h>
-
-#include "util/macros.h"
-#include "wsi_common_magma.h"
-
-#include "magma.h"
-#include "magma_util/dlog.h"
-#include "magma_util/macros.h"
-
-#define typed_memcpy(dest, src, count) \
- ({ \
- static_assert(sizeof(*src) == sizeof(*dest), ""); \
- memcpy((dest), (src), (count) * sizeof(*(src))); \
- })
-
-static const VkSurfaceFormatKHR formats[] = {
- {
- .format = VK_FORMAT_B8G8R8A8_UNORM,
- },
-};
-
-static const VkPresentModeKHR present_modes[] = {
- VK_PRESENT_MODE_FIFO_KHR,
-};
-
-class WsiMagma : public wsi_interface {
-public:
- WsiMagma(const wsi_magma_callbacks* callbacks) : callbacks_(callbacks) {}
-
- const wsi_magma_callbacks* callbacks() { return callbacks_; }
-
-private:
- const wsi_magma_callbacks* callbacks_;
-};
-
-class WsiMagmaConnections {
-public:
- WsiMagmaConnections(magma_connection_t* render_connection,
- const wsi_magma_callbacks* callbacks)
- : callbacks_(callbacks), render_connection_(render_connection)
- {
- }
-
- magma_connection_t* render_connection() { return render_connection_; }
-
-private:
- const wsi_magma_callbacks* callbacks_; // not owned
- magma_connection_t* render_connection_; // not owned
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-class MagmaImage {
-public:
- static std::unique_ptr<MagmaImage> Create(VkDevice device, const wsi_magma_callbacks* callbacks,
- std::shared_ptr<WsiMagmaConnections> connections,
- const VkSwapchainCreateInfoKHR* create_info,
- const VkAllocationCallbacks* pAllocator);
-
- ~MagmaImage();
-
- uint64_t display_buffer() { return display_buffer_; }
-
- zx_handle_t buffer_presented_semaphore() { return buffer_presented_semaphore_; }
-
- uint64_t buffer_presented_semaphore_id() { return buffer_presented_semaphore_id_; }
-
- VkImage image() { return image_; }
-
- VkDevice device() { return device_; }
-
- const wsi_magma_callbacks* callbacks() { return callbacks_; }
-
-private:
- MagmaImage(VkDevice device, const wsi_magma_callbacks* callbacks,
- std::shared_ptr<WsiMagmaConnections> connections, magma_buffer_t render_buffer,
- uint64_t display_buffer, zx_handle_t buffer_presented_semaphore,
- uint64_t buffer_presented_semaphore_id, VkImage image, VkDeviceMemory device_memory,
- const VkAllocationCallbacks* allocator)
- : device_(device), image_(image), device_memory_(device_memory), callbacks_(callbacks),
- connections_(std::move(connections)), render_buffer_(render_buffer),
- display_buffer_(display_buffer), buffer_presented_semaphore_(buffer_presented_semaphore),
- buffer_presented_semaphore_id_(buffer_presented_semaphore_id), allocator_(allocator)
- {
- }
-
- VkDevice device_;
- VkImage image_;
- VkDeviceMemory device_memory_;
- const wsi_magma_callbacks* callbacks_;
- std::shared_ptr<WsiMagmaConnections> connections_;
- magma_buffer_t render_buffer_; // render_buffer is not owned
- uint64_t display_buffer_;
- zx_handle_t buffer_presented_semaphore_;
- uint64_t buffer_presented_semaphore_id_;
- const VkAllocationCallbacks* allocator_;
-};
-
-std::unique_ptr<MagmaImage> MagmaImage::Create(VkDevice device,
- const wsi_magma_callbacks* callbacks,
- std::shared_ptr<WsiMagmaConnections> connections,
- const VkSwapchainCreateInfoKHR* pCreateInfo,
- const VkAllocationCallbacks* allocator)
-{
- VkResult result;
- uint32_t row_pitch;
- uint32_t offset;
- uint32_t bpp = 32;
- magma_buffer_t render_buffer;
- uint64_t display_buffer;
- zx_handle_t buffer_presented_semaphore;
- uint32_t buffer_handle, semaphore_handle;
- uint32_t size;
- VkImage image;
- VkDeviceMemory device_memory;
-
- result = callbacks->create_wsi_image(device, pCreateInfo, allocator, &image, &device_memory,
- &size, &offset, &row_pitch, &render_buffer);
- if (result != VK_SUCCESS)
- return DRETP(nullptr, "create_wsi_image failed");
-
- magma_status_t status =
- magma_export(connections->render_connection(), render_buffer, &buffer_handle);
- if (status != MAGMA_STATUS_OK)
- return DRETP(nullptr, "failed to export buffer");
-
- // Must be consistent with intel-gpu-core.h and the tiling format
- // used by VK_IMAGE_USAGE_SCANOUT_BIT_GOOGLE.
- const uint32_t kImageTypeXTiled = 1;
- status = fb_import_image(buffer_handle, kImageTypeXTiled, &display_buffer);
- if (status != MAGMA_STATUS_OK)
- return DRETP(nullptr, "failed to import buffer");
-
- if (zx_event_create(0, &buffer_presented_semaphore) != ZX_OK
- || zx_object_signal(buffer_presented_semaphore, 0, ZX_EVENT_SIGNALED) != ZX_OK)
- return DRETP(nullptr, "failed to create or signal semaphore");
-
- zx_info_handle_basic_t info;
- if (zx_object_get_info(buffer_presented_semaphore, ZX_INFO_HANDLE_BASIC,
- &info, sizeof(info), nullptr, nullptr) != ZX_OK)
- return DRETP(nullptr, "failed to get semaphore id");
-
- zx_handle_t dup;
- if (zx_handle_duplicate(buffer_presented_semaphore, ZX_RIGHT_SAME_RIGHTS, &dup) != ZX_OK
- || fb_import_event(dup, info.koid) != ZX_OK)
- return DRETP(nullptr, "failed to duplicate or import display semaphore");
-
- return std::unique_ptr<MagmaImage>(new MagmaImage(
- device, callbacks, std::move(connections), render_buffer, display_buffer,
- buffer_presented_semaphore, info.koid, image, device_memory, allocator));
-}
-
-MagmaImage::~MagmaImage()
-{
- callbacks_->free_wsi_image(device_, allocator_, image_, device_memory_);
-
- fb_release_image(display_buffer_);
- fb_release_event(buffer_presented_semaphore_id_);
-
- zx_handle_close(buffer_presented_semaphore_);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-class MagmaSwapchain : public wsi_swapchain {
-public:
- MagmaSwapchain(VkDevice device, std::shared_ptr<WsiMagmaConnections> connections)
- : connections_(connections)
- {
- // Default-initialize the anv_swapchain base
- wsi_swapchain* base = static_cast<wsi_swapchain*>(this);
- *base = {};
-
- // Make sure that did mostly what we expected
- assert(this->alloc.pUserData == 0);
- assert(this->fences[0] == VK_NULL_HANDLE);
-
- this->device = device;
- this->destroy = Destroy;
- this->get_images = GetImages;
- this->acquire_next_image = AcquireNextImage;
- this->queue_present = QueuePresent;
- }
-
- magma_connection_t* render_connection() { return connections_->render_connection(); }
-
- uint32_t image_count() { return images_.size(); }
-
- MagmaImage* get_image(uint32_t index)
- {
- assert(index < images_.size());
- return images_[index].get();
- }
-
- void AddImage(std::unique_ptr<MagmaImage> image) { images_.push_back(std::move(image)); }
-
- static VkResult Destroy(wsi_swapchain* wsi_chain, const VkAllocationCallbacks* pAllocator)
- {
- DLOG("Destroy");
- MagmaSwapchain* chain = cast(wsi_chain);
- delete chain;
- return VK_SUCCESS;
- }
-
- static VkResult GetImages(wsi_swapchain* wsi_chain, uint32_t* pCount, VkImage* pSwapchainImages)
- {
- DLOG("GetImages");
- MagmaSwapchain* chain = cast(wsi_chain);
-
- if (!pSwapchainImages) {
- *pCount = chain->image_count();
- return VK_SUCCESS;
- }
-
- assert(chain->image_count() <= *pCount);
-
- for (uint32_t i = 0; i < chain->image_count(); i++)
- pSwapchainImages[i] = chain->get_image(i)->image();
-
- *pCount = chain->image_count();
-
- return VK_SUCCESS;
- }
-
- static VkResult AcquireNextImage(wsi_swapchain* wsi_chain, uint64_t timeout_ns,
- VkSemaphore semaphore, uint32_t* pImageIndex)
- {
- MagmaSwapchain* chain = cast(wsi_chain);
-
- uint32_t index = chain->next_index_;
- MagmaImage* image = chain->get_image(index);
-
- DLOG("AcquireNextImage semaphore id 0x%" PRIx64,
- image->buffer_presented_semaphore_id());
-
- // The zircon display APIs don't support providing an image back to the driver
- // before the image is retired. Returning the presented semaphore from the vulkan API
- // only prevents clients from rendering into the buffer, not from presenting the
- // buffer (with a wait semaphore). So we can't return the buffer until this is signaled.
- zx_signals_t observed;
- zx_status_t status;
- if ((status = zx_object_wait_one(image->buffer_presented_semaphore(), ZX_EVENT_SIGNALED,
- zx_deadline_after(timeout_ns), &observed)) != ZX_OK) {
- return VK_TIMEOUT;
- }
- // Unsignal the event.
- zx_object_signal(image->buffer_presented_semaphore(), ZX_EVENT_SIGNALED, 0);
- if (semaphore) {
- image->callbacks()->signal_semaphore(semaphore);
- }
-
- if (++chain->next_index_ >= chain->image_count())
- chain->next_index_ = 0;
-
- *pImageIndex = index;
- DLOG("AcquireNextImage returning index %u id 0x%" PRIx64, *pImageIndex,
- image->display_buffer());
-
- return VK_SUCCESS;
- }
-
- static VkResult QueuePresent(wsi_swapchain* swapchain, uint32_t image_index,
- const VkPresentRegionKHR *damage,
- uint32_t wait_semaphore_count, const VkSemaphore* wait_semaphores)
- {
- MagmaSwapchain* magma_swapchain = cast(swapchain);
- MagmaImage* image = magma_swapchain->get_image(image_index);
-
- DLOG("QueuePresent image_index %u id 0x%" PRIx64, image_index,
- image->display_buffer());
-
- magma_status_t status;
-
- // TODO(MA-375): Support more than 1 wait semaphore
- assert(wait_semaphore_count <= 1);
-
- uint64_t wait_sem_id = FB_INVALID_ID;
- for (uint32_t i = 0; i < wait_semaphore_count; i++) {
- uint32_t semaphore_handle;
- uintptr_t platform_sem = image->callbacks()
- ->get_platform_semaphore(swapchain->device, wait_semaphores[i]);
- wait_sem_id = magma_get_semaphore_id(platform_sem);
-
- status = magma_export_semaphore(
- magma_swapchain->render_connection(), platform_sem, &semaphore_handle);
- if (status != MAGMA_STATUS_OK) {
- DLOG("Failed to export wait semaphore");
- continue;
- }
- magma_semaphore_t semaphore;
- status = fb_import_event(semaphore_handle, wait_sem_id);
- if (status != ZX_OK)
- DLOG("failed to import wait semaphore");
- }
-
- fb_present_image(image->display_buffer(),
- wait_sem_id, FB_INVALID_ID, image->buffer_presented_semaphore_id());
-
- for (uint32_t i = 0; i < wait_semaphore_count; i++) {
- fb_release_event(wait_sem_id);
- }
-
- return VK_SUCCESS;
- }
-
-private:
- static MagmaSwapchain* cast(wsi_swapchain* swapchain)
- {
- auto magma_swapchain = static_cast<MagmaSwapchain*>(swapchain);
- assert(magma_swapchain->magic_ == kMagic);
- return magma_swapchain;
- }
-
- static constexpr uint32_t kMagic = 0x6D617377; // 'masw'
-
- const uint32_t magic_ = kMagic;
- std::shared_ptr<WsiMagmaConnections> connections_;
- std::vector<std::unique_ptr<MagmaImage>> images_;
- uint32_t next_index_ = 0;
-};
-
-static VkResult magma_surface_get_support(VkIcdSurfaceBase* icd_surface,
- struct wsi_device* wsi_device,
- const VkAllocationCallbacks* alloc,
- uint32_t queueFamilyIndex,
- int local_fd,
- bool can_handle_different_gpu,
- VkBool32* pSupported)
-{
- auto surface = reinterpret_cast<VkIcdSurfaceMagma*>(icd_surface);
- DLOG("magma_surface_get_support queue %u connection %d", queueFamilyIndex, surface->has_fb);
-
- *pSupported = surface->has_fb;
- return VK_SUCCESS;
-}
-
-static VkResult magma_surface_get_capabilities(VkIcdSurfaceBase* icd_surface,
- VkSurfaceCapabilitiesKHR* caps)
-{
- auto surface = reinterpret_cast<VkIcdSurfaceMagma*>(icd_surface);
- DLOG("magma_surface_get_capabilities connection %d", surface->has_fb);
-
- VkExtent2D extent = {0xFFFFFFFF, 0xFFFFFFFF};
-
- uint32_t width, height, stride;
- zx_pixel_format_t format;
- fb_get_config(&width, &height, &stride, &format);
- extent = {width, height};
-
- caps->minImageExtent = {1, 1};
- caps->maxImageExtent = {extent};
- caps->currentExtent = extent;
-
- caps->supportedCompositeAlpha =
- VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR | VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
-
- caps->minImageCount = 2;
- caps->maxImageCount = 3;
- caps->supportedTransforms = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
- caps->currentTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
- caps->maxImageArrayLayers = 1;
- caps->supportedUsageFlags = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_SAMPLED_BIT |
- VK_IMAGE_USAGE_TRANSFER_DST_BIT |
- VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
-
- return VK_SUCCESS;
-}
-
-static VkResult magma_surface_get_formats(VkIcdSurfaceBase* surface, struct wsi_device* device,
- uint32_t* pSurfaceFormatCount,
- VkSurfaceFormatKHR* pSurfaceFormats)
-{
- DLOG("magma_surface_get_formats");
-
- if (pSurfaceFormats == NULL) {
- *pSurfaceFormatCount = ARRAY_SIZE(formats);
- return VK_SUCCESS;
- }
-
- assert(*pSurfaceFormatCount >= ARRAY_SIZE(formats));
- typed_memcpy(pSurfaceFormats, formats, *pSurfaceFormatCount);
- *pSurfaceFormatCount = ARRAY_SIZE(formats);
-
- return VK_SUCCESS;
-}
-
-static VkResult magma_surface_get_present_modes(VkIcdSurfaceBase* surface,
- uint32_t* pPresentModeCount,
- VkPresentModeKHR* pPresentModes)
-{
- DLOG("magma_surface_get_present_modes");
-
- if (pPresentModes == NULL) {
- *pPresentModeCount = ARRAY_SIZE(present_modes);
- return VK_SUCCESS;
- }
-
- assert(*pPresentModeCount >= ARRAY_SIZE(present_modes));
- typed_memcpy(pPresentModes, present_modes, *pPresentModeCount);
- *pPresentModeCount = ARRAY_SIZE(present_modes);
-
- return VK_SUCCESS;
-}
-
-static VkResult magma_surface_create_swapchain(VkIcdSurfaceBase* icd_surface, VkDevice device,
- wsi_device* wsi_device,
- int local_fd,
- const VkSwapchainCreateInfoKHR* pCreateInfo,
- const VkAllocationCallbacks* pAllocator,
- const struct wsi_image_fns* image_fns,
- struct wsi_swapchain** swapchain_out)
-{
- DLOG("magma_surface_create_swapchain");
-
- assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR);
-
- auto wsi_magma = static_cast<WsiMagma*>(wsi_device->wsi[VK_ICD_WSI_PLATFORM_MAGMA]);
- assert(wsi_magma);
-
- auto render_connection =
- reinterpret_cast<magma_connection_t*>(wsi_magma->callbacks()->get_render_connection(device));
- auto magma_surface = reinterpret_cast<VkIcdSurfaceMagma*>(icd_surface);
-
- // TODO(MA-115): use pAllocator here and for images (and elsewhere in magma?)
- auto connections = std::make_shared<WsiMagmaConnections>(render_connection,
- wsi_magma->callbacks());
-
- auto chain = std::make_unique<MagmaSwapchain>(device, connections);
-
- uint32_t num_images = pCreateInfo->minImageCount;
-
- for (uint32_t i = 0; i < num_images; i++) {
- std::unique_ptr<MagmaImage> image =
- MagmaImage::Create(device, wsi_magma->callbacks(), connections, pCreateInfo, pAllocator);
- if (!image)
- return VK_ERROR_OUT_OF_DEVICE_MEMORY;
-
- chain->AddImage(std::move(image));
- }
-
- *swapchain_out = chain.release();
-
- return VK_SUCCESS;
-}
-
-VkResult wsi_magma_init_wsi(wsi_device* device, const VkAllocationCallbacks* alloc,
- const wsi_magma_callbacks* callbacks)
-{
- device->wsi[VK_ICD_WSI_PLATFORM_MAGMA] = nullptr;
-
- auto wsi = new WsiMagma(callbacks);
- if (!wsi)
- return VK_ERROR_OUT_OF_HOST_MEMORY;
-
- wsi->get_support = magma_surface_get_support;
- wsi->get_capabilities = magma_surface_get_capabilities;
- wsi->get_formats = magma_surface_get_formats;
- wsi->get_present_modes = magma_surface_get_present_modes;
- wsi->create_swapchain = magma_surface_create_swapchain;
-
- device->wsi[VK_ICD_WSI_PLATFORM_MAGMA] = wsi;
-
- return VK_SUCCESS;
-}
-
-void wsi_magma_finish_wsi(wsi_device* device, const VkAllocationCallbacks* alloc)
-{
- auto wsi_magma = static_cast<WsiMagma*>(device->wsi[VK_ICD_WSI_PLATFORM_MAGMA]);
- if (wsi_magma)
- delete wsi_magma;
-}
-
-VkBool32 wsi_get_physical_device_magma_presentation_support(struct wsi_device* wsi_device,
- VkAllocationCallbacks* alloc,
- uint32_t queueFamilyIndex)
-{
- return VK_TRUE;
-}
diff --git a/src/vulkan/wsi/wsi_common_magma.h b/src/vulkan/wsi/wsi_common_magma.h
deleted file mode 100644
index a628c4d..0000000
--- a/src/vulkan/wsi/wsi_common_magma.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef WSI_COMMON_MAGMA_H
-#define WSI_COMMON_MAGMA_H
-
-extern "C" {
-
-#include "wsi_common.h"
-
-VkBool32 wsi_get_physical_device_magma_presentation_support(struct wsi_device* wsi_device,
- VkAllocationCallbacks* alloc,
- uint32_t queueFamilyIndex);
-
-}
-
-#endif