// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp #include #include #include #include #include #include #include #include #include namespace Nz { VulkanRenderer::~VulkanRenderer() { Vulkan::Uninitialize(); } std::unique_ptr VulkanRenderer::CreateRenderSurfaceImpl() { return std::make_unique(); } std::unique_ptr VulkanRenderer::CreateRenderWindowImpl() { return std::make_unique(); } std::shared_ptr VulkanRenderer::InstanciateRenderDevice(std::size_t deviceIndex) { assert(deviceIndex < m_physDevices.size()); return Vulkan::SelectDevice(m_physDevices[deviceIndex]); } bool VulkanRenderer::IsBetterThan(const RendererImpl* other) const { if (other->QueryAPI() == RenderAPI::Vulkan && QueryAPIVersion() < other->QueryAPIVersion()) return false; return true; //< Vulkan FTW } bool VulkanRenderer::Prepare(const ParameterList& parameters) { return Vulkan::Initialize(APIVersion, parameters); } RenderAPI VulkanRenderer::QueryAPI() const { return RenderAPI::Vulkan; } String VulkanRenderer::QueryAPIString() const { StringStream ss; ss << "Vulkan renderer " << VK_VERSION_MAJOR(APIVersion) << '.' << VK_VERSION_MINOR(APIVersion) << '.' << VK_VERSION_PATCH(APIVersion); return ss; } UInt32 VulkanRenderer::QueryAPIVersion() const { return APIVersion; } std::vector VulkanRenderer::QueryRenderDevices() const { std::vector devices; devices.reserve(m_physDevices.size()); for (const Vk::PhysicalDevice& physDevice : m_physDevices) { RenderDeviceInfo& device = devices.emplace_back(); device.name = physDevice.properties.deviceName; switch (physDevice.properties.deviceType) { case VK_PHYSICAL_DEVICE_TYPE_CPU: device.type = RenderDeviceType::Software; break; case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU: device.type = RenderDeviceType::Dedicated; break; case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU: device.type = RenderDeviceType::Integrated; break; case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU: device.type = RenderDeviceType::Virtual; break; default: NazaraWarning("Device " + device.name + " has handled device type (0x" + String::Number(physDevice.properties.deviceType, 16) + ')'); case VK_PHYSICAL_DEVICE_TYPE_OTHER: device.type = RenderDeviceType::Unknown; break; } } return devices; } }