#include "test_utils/VulkanHelper.h"
#include <vector>
#include "common/bitset_utils.h"
#include "common/debug.h"
#include "common/system_utils.h"
#include "common/vulkan/vulkan_icd.h"
#include "test_utils/ANGLETest.h"
#include "vulkan/vulkan_core.h"
namespace angle
{
namespace
{
std::vector<VkPhysicalDevice> EnumeratePhysicalDevices(VkInstance instance)
{ … }
std::vector<VkExtensionProperties> EnumerateDeviceExtensionProperties(
VkPhysicalDevice physicalDevice,
const char *layerName)
{ … }
std::vector<VkQueueFamilyProperties> GetPhysicalDeviceQueueFamilyProperties(
VkPhysicalDevice physicalDevice)
{ … }
bool HasExtension(const std::vector<VkExtensionProperties> instanceExtensions,
const char *extensionName)
{ … }
bool HasExtension(const std::vector<const char *> enabledExtensions, const char *extensionName)
{ … }
bool HasExtension(const char *const *enabledExtensions, const char *extensionName)
{ … }
uint32_t FindMemoryType(const VkPhysicalDeviceMemoryProperties &memoryProperties,
uint32_t memoryTypeBits,
VkMemoryPropertyFlags requiredMemoryPropertyFlags)
{ … }
void ImageMemoryBarrier(VkCommandBuffer commandBuffer,
VkImage image,
uint32_t srcQueueFamilyIndex,
uint32_t dstQueueFamilyIndex,
VkImageLayout oldLayout,
VkImageLayout newLayout)
{ … }
}
VulkanHelper::VulkanHelper() { … }
VulkanHelper::~VulkanHelper()
{ … }
void VulkanHelper::initialize(bool useSwiftshader, bool enableValidationLayers)
{ … }
void VulkanHelper::initializeFromANGLE()
{ … }
VkResult VulkanHelper::createImage2D(VkFormat format,
VkImageCreateFlags createFlags,
VkImageUsageFlags usageFlags,
VkExtent3D extent,
VkImage *imageOut,
VkDeviceMemory *deviceMemoryOut,
VkDeviceSize *deviceMemorySizeOut,
VkImageCreateInfo *imageCreateInfoOut)
{ … }
bool VulkanHelper::canCreateImageExternal(VkFormat format,
VkImageType type,
VkImageTiling tiling,
VkImageCreateFlags createFlags,
VkImageUsageFlags usageFlags,
VkExternalMemoryHandleTypeFlagBits handleType) const
{ … }
VkResult VulkanHelper::createImage2DExternal(VkFormat format,
VkImageCreateFlags createFlags,
VkImageUsageFlags usageFlags,
const void *imageCreateInfoPNext,
VkExtent3D extent,
VkExternalMemoryHandleTypeFlags handleTypes,
VkImage *imageOut,
VkDeviceMemory *deviceMemoryOut,
VkDeviceSize *deviceMemorySizeOut)
{ … }
bool VulkanHelper::canCreateImageOpaqueFd(VkFormat format,
VkImageType type,
VkImageTiling tiling,
VkImageCreateFlags createFlags,
VkImageUsageFlags usageFlags) const
{ … }
VkResult VulkanHelper::createImage2DOpaqueFd(VkFormat format,
VkImageCreateFlags createFlags,
VkImageUsageFlags usageFlags,
const void *imageCreateInfoPNext,
VkExtent3D extent,
VkImage *imageOut,
VkDeviceMemory *deviceMemoryOut,
VkDeviceSize *deviceMemorySizeOut)
{ … }
VkResult VulkanHelper::exportMemoryOpaqueFd(VkDeviceMemory deviceMemory, int *fd)
{ … }
bool VulkanHelper::canCreateImageZirconVmo(VkFormat format,
VkImageType type,
VkImageTiling tiling,
VkImageCreateFlags createFlags,
VkImageUsageFlags usageFlags) const
{ … }
VkResult VulkanHelper::createImage2DZirconVmo(VkFormat format,
VkImageCreateFlags createFlags,
VkImageUsageFlags usageFlags,
const void *imageCreateInfoPNext,
VkExtent3D extent,
VkImage *imageOut,
VkDeviceMemory *deviceMemoryOut,
VkDeviceSize *deviceMemorySizeOut)
{ … }
VkResult VulkanHelper::exportMemoryZirconVmo(VkDeviceMemory deviceMemory, zx_handle_t *vmo)
{ … }
bool VulkanHelper::canCreateSemaphoreOpaqueFd() const
{ … }
VkResult VulkanHelper::createSemaphoreOpaqueFd(VkSemaphore *semaphore)
{ … }
VkResult VulkanHelper::exportSemaphoreOpaqueFd(VkSemaphore semaphore, int *fd)
{ … }
bool VulkanHelper::canCreateSemaphoreZirconEvent() const
{ … }
VkResult VulkanHelper::createSemaphoreZirconEvent(VkSemaphore *semaphore)
{ … }
VkResult VulkanHelper::exportSemaphoreZirconEvent(VkSemaphore semaphore, zx_handle_t *event)
{ … }
void VulkanHelper::releaseImageAndSignalSemaphore(VkImage image,
VkImageLayout oldLayout,
VkImageLayout newLayout,
VkSemaphore semaphore)
{ … }
void VulkanHelper::signalSemaphore(VkSemaphore semaphore)
{ … }
void VulkanHelper::waitSemaphoreAndAcquireImage(VkImage image,
VkImageLayout oldLayout,
VkImageLayout newLayout,
VkSemaphore semaphore)
{ … }
void VulkanHelper::readPixels(VkImage srcImage,
VkImageLayout srcImageLayout,
VkFormat srcImageFormat,
VkOffset3D imageOffset,
VkExtent3D imageExtent,
void *pixels,
size_t pixelsSize)
{ … }
void VulkanHelper::writePixels(VkImage dstImage,
VkImageLayout imageLayout,
VkFormat imageFormat,
VkOffset3D imageOffset,
VkExtent3D imageExtent,
const void *pixels,
size_t pixelsSize)
{ … }
}