#include "dawn/native/vulkan/BackendVk.h"
#include <algorithm>
#include <string>
#include <utility>
#include "dawn/common/BitSetIterator.h"
#include "dawn/common/Log.h"
#include "dawn/common/SystemUtils.h"
#include "dawn/native/ChainUtils.h"
#include "dawn/native/Instance.h"
#include "dawn/native/VulkanBackend.h"
#include "dawn/native/vulkan/DeviceVk.h"
#include "dawn/native/vulkan/PhysicalDeviceVk.h"
#include "dawn/native/vulkan/UtilsVulkan.h"
#include "dawn/native/vulkan/VulkanError.h"
#if defined(DAWN_ENABLE_SWIFTSHADER)
#if DAWN_PLATFORM_IS(LINUX) || DAWN_PLATFORM_IS(FUCHSIA)
constexpr char kSwiftshaderLibName[] = …;
#elif DAWN_PLATFORM_IS(WINDOWS)
constexpr char kSwiftshaderLibName[] = "vk_swiftshader.dll";
#elif DAWN_PLATFORM_IS(MACOS)
constexpr char kSwiftshaderLibName[] = "libvk_swiftshader.dylib";
#else
#error "Unimplemented Swiftshader Vulkan backend platform"
#endif
#endif
#if DAWN_PLATFORM_IS(LINUX)
#if DAWN_PLATFORM_IS(ANDROID)
constexpr char kVulkanLibName[] = "libvulkan.so";
#else
constexpr char kVulkanLibName[] = …;
#endif
#elif DAWN_PLATFORM_IS(WINDOWS)
constexpr char kVulkanLibName[] = "vulkan-1.dll";
#elif DAWN_PLATFORM_IS(MACOS)
constexpr char kVulkanLibName[] = "libvulkan.dylib";
#elif DAWN_PLATFORM_IS(FUCHSIA)
constexpr char kVulkanLibName[] = "libvulkan.so";
#else
#error "Unimplemented Vulkan backend platform"
#endif
struct SkippedMessage { … };
constexpr SkippedMessage kSkippedMessages[] = …;
namespace dawn::native::vulkan {
namespace {
static constexpr ICD kICDs[] = …;
bool ShouldReportDebugMessage(const char* messageId, const char* message) { … }
void LogCallbackData(LogSeverity severity,
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData) { … }
VKAPI_ATTR VkBool32 VKAPI_CALL
OnDebugUtilsCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT ,
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
void* pUserData) { … }
VKAPI_ATTR VkBool32 VKAPI_CALL
OnInstanceCreationDebugUtilsCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT ,
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
void* ) { … }
}
VulkanInstance::VulkanInstance() = default;
VulkanInstance::~VulkanInstance() { … }
const VulkanFunctions& VulkanInstance::GetFunctions() const { … }
VkInstance VulkanInstance::GetVkInstance() const { … }
const VulkanGlobalInfo& VulkanInstance::GetGlobalInfo() const { … }
const std::vector<VkPhysicalDevice>& VulkanInstance::GetVkPhysicalDevices() const { … }
ResultOrError<Ref<VulkanInstance>> VulkanInstance::Create(const InstanceBase* instance, ICD icd) { … }
MaybeError VulkanInstance::Initialize(const InstanceBase* instance, ICD icd) { … }
ResultOrError<VulkanGlobalKnobs> VulkanInstance::CreateVkInstance(const InstanceBase* instance) { … }
MaybeError VulkanInstance::RegisterDebugUtils() { … }
void VulkanInstance::StartListeningForDeviceMessages(Device* device) { … }
void VulkanInstance::StopListeningForDeviceMessages(Device* device) { … }
bool VulkanInstance::HandleDeviceMessage(std::string deviceDebugPrefix, std::string message) { … }
Backend::Backend(InstanceBase* instance) : … { … }
Backend::~Backend() = default;
std::vector<Ref<PhysicalDeviceBase>> Backend::DiscoverPhysicalDevices(
const UnpackedPtr<RequestAdapterOptions>& options) { … }
BackendConnection* Connect(InstanceBase* instance) { … }
}