diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUAdapterVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUAdapterVulkan.cpp deleted file mode 100644 index 2ddeb19b4..000000000 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUAdapterVulkan.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. - -#if GRAPHICS_API_VULKAN - -#include "GPUAdapterVulkan.h" -#include "GPUDeviceVulkan.h" - -GPUAdapterVulkan::GPUAdapterVulkan(VkPhysicalDevice gpu) - : Gpu(gpu) -{ - vkGetPhysicalDeviceProperties(gpu, &GpuProps); - Description = GpuProps.deviceName; -} - -#endif diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUAdapterVulkan.h b/Source/Engine/GraphicsDevice/Vulkan/GPUAdapterVulkan.h index d35c596e4..f27f2aedf 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUAdapterVulkan.h +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUAdapterVulkan.h @@ -37,12 +37,6 @@ public: return *this; } - /// - /// Initializes a new instance of the class. - /// - /// The GPU device handle. - GPUAdapterVulkan(VkPhysicalDevice gpu); - public: /// @@ -67,12 +61,10 @@ public: { return Gpu != VK_NULL_HANDLE; } - uint32 GetVendorId() const override { return GpuProps.vendorID; } - String GetDescription() const override { return Description; diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.Layers.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.Layers.cpp index 87e0673d3..ca71a5f56 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.Layers.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.Layers.cpp @@ -179,6 +179,16 @@ static bool FindLayerExtension(const Array& list, const char* ex return FindLayerExtension(list, extensionName, dummy); } +static bool ListContains(const Array& list, const char* name) +{ + for (const char* element : list) + { + if (!StringUtils::Compare(element, name)) + return true; + } + return false; +} + void GPUDeviceVulkan::GetInstanceLayersAndExtensions(Array& outInstanceExtensions, Array& outInstanceLayers, bool& outDebugUtils) { VkResult result; @@ -486,6 +496,7 @@ void GPUDeviceVulkan::GetDeviceExtensionsAndLayers(VkPhysicalDevice gpu, Array availableExtensions; { for (int32 i = 0; i < deviceLayerExtensions[0].Extensions.Count(); i++) @@ -512,19 +523,7 @@ void GPUDeviceVulkan::GetDeviceExtensionsAndLayers(VkPhysicalDevice gpu, Array& list, const char* name) - { - for (const char* element : list) - { - if (!StringUtils::Compare(element, name)) - { - return true; - } - } - - return false; - }; - + // Pick extensions to use Array platformExtensions; VulkanPlatform::GetDeviceExtensions(platformExtensions, outDeviceLayers); for (const char* extension : platformExtensions) @@ -535,7 +534,6 @@ void GPUDeviceVulkan::GetDeviceExtensionsAndLayers(VkPhysicalDevice gpu, Array= 1); - Array gpus; - gpus.AddZeroed(gpuCount); + Array> gpus; + gpus.Resize(gpuCount); VALIDATE_VULKAN_RESULT(vkEnumeratePhysicalDevices(Instance, &gpuCount, gpus.Get())); - Array adapters; - adapters.EnsureCapacity(gpuCount); + Array> adapters; + adapters.Resize(gpuCount); for (uint32 gpuIndex = 0; gpuIndex < gpuCount; gpuIndex++) { - GPUAdapterVulkan adapter(gpus[gpuIndex]); - adapters.Add(adapter); + GPUAdapterVulkan& adapter = adapters[gpuIndex]; + adapter.Gpu = gpus[gpuIndex]; + vkGetPhysicalDeviceProperties(adapter.Gpu, &adapter.GpuProps); + adapter.Description = adapter.GpuProps.deviceName; const Char* type; switch (adapter.GpuProps.deviceType) @@ -1490,7 +1492,7 @@ bool GPUDeviceVulkan::Init() vkGetPhysicalDeviceQueueFamilyProperties(gpu, &queueCount, QueueFamilyProps.Get()); // Query device features - vkGetPhysicalDeviceFeatures(Adapter->Gpu, &PhysicalDeviceFeatures); + vkGetPhysicalDeviceFeatures(gpu, &PhysicalDeviceFeatures); // Get extensions and layers Array deviceExtensions; diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp index df310cc5c..d9a49d9e4 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp @@ -312,7 +312,7 @@ bool GPUSwapChainVulkan::CreateSwapChain(int32 width, int32 height) VALIDATE_VULKAN_RESULT(vkGetPhysicalDeviceSurfacePresentModesKHR(gpu, _surface, &presentModesCount, nullptr)); ASSERT(presentModesCount > 0); - Array presentModes; + Array> presentModes; presentModes.Resize(presentModesCount); VALIDATE_VULKAN_RESULT(vkGetPhysicalDeviceSurfacePresentModesKHR(gpu, _surface, &presentModesCount, presentModes.Get()));