diff --git a/Source/Engine/Graphics/Config.h b/Source/Engine/Graphics/Config.h index 02d95c947..1b2dc3427 100644 --- a/Source/Engine/Graphics/Config.h +++ b/Source/Engine/Graphics/Config.h @@ -2,6 +2,8 @@ #pragma once +#include "Engine/Platform/Defines.h" + // Maximum amount of binded render targets at the same time #define GPU_MAX_RT_BINDED 6 @@ -44,11 +46,10 @@ // Enable/disable force shaders recompilation #define GPU_FORCE_RECOMPILE_SHADERS 0 -// True if use BGRA back buffer format -#define GPU_USE_BGRA_BACK_BUFFER 1 - // Default back buffer pixel format +#ifndef GPU_DEPTH_BUFFER_PIXEL_FORMAT #define GPU_DEPTH_BUFFER_PIXEL_FORMAT PixelFormat::D32_Float +#endif // Enable/disable gpu resources naming #define GPU_ENABLE_RESOURCE_NAMING (!BUILD_RELEASE) @@ -62,10 +63,8 @@ #define GPU_MAX_TEXTURE_ARRAY_SIZE 1024 // Define default back buffer(s) format -#if GPU_USE_BGRA_BACK_BUFFER +#ifndef GPU_BACK_BUFFER_PIXEL_FORMAT #define GPU_BACK_BUFFER_PIXEL_FORMAT PixelFormat::B8G8R8A8_UNorm -#else -#define GPU_BACK_BUFFER_PIXEL_FORMAT PixelFormat::R8G8B8A8_UNorm #endif // Validate configuration diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp index bb89399a6..7f604a14a 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp @@ -208,8 +208,6 @@ bool GPUSwapChainVulkan::CreateSwapChain(int32 width, int32 height) { uint32 surfaceFormatsCount; VALIDATE_VULKAN_RESULT(vkGetPhysicalDeviceSurfaceFormatsKHR(gpu, _surface, &surfaceFormatsCount, nullptr)); - ASSERT(surfaceFormatsCount > 0); - Array> surfaceFormats; surfaceFormats.AddZeroed(surfaceFormatsCount); VALIDATE_VULKAN_RESULT(vkGetPhysicalDeviceSurfaceFormatsKHR(gpu, _surface, &surfaceFormatsCount, surfaceFormats.Get())); @@ -229,7 +227,6 @@ bool GPUSwapChainVulkan::CreateSwapChain(int32 width, int32 height) break; } } - if (!found) { LOG(Warning, "Requested pixel format {0} not supported by this swapchain. Falling back to supported swapchain formats...", ScriptingEnum::ToString(resultFormat)); @@ -255,22 +252,18 @@ bool GPUSwapChainVulkan::CreateSwapChain(int32 width, int32 height) { resultFormat = static_cast(pixelFormat); result = surfaceFormats[i]; - LOG(Info, "No swapchain format requested, picking up Vulkan format {0}", (uint32)result.format); + LOG(Info, "No swapchain format requested, picking up format {} (vk={})", ScriptingEnum::ToString(resultFormat), (int32)result.format); break; } } - if (resultFormat != PixelFormat::Unknown) - { break; - } } } if (resultFormat == PixelFormat::Unknown) { LOG(Warning, "Can't find a proper pixel format for the swapchain, trying to pick up the first available"); - const VkFormat format = RenderToolsVulkan::ToVulkanFormat(resultFormat); bool supported = false; for (int32 i = 0; i < surfaceFormats.Count(); i++) @@ -283,24 +276,14 @@ bool GPUSwapChainVulkan::CreateSwapChain(int32 width, int32 height) } } ASSERT(supported); - String msg; for (int32 index = 0; index < surfaceFormats.Count(); index++) { - if (index == 0) - { - msg += TEXT("("); - } - else - { - msg += TEXT(", "); - } + msg += index == 0 ? TEXT("(") : TEXT(", "); msg += StringUtils::ToString((int32)surfaceFormats[index].format); } if (surfaceFormats.HasItems()) - { msg += TEXT(")"); - } LOG(Error, "Unable to find a pixel format for the swapchain; swapchain returned {0} Vulkan formats {1}", surfaceFormats.Count(), *msg); } } @@ -315,16 +298,12 @@ bool GPUSwapChainVulkan::CreateSwapChain(int32 width, int32 height) { uint32 presentModesCount = 0; VALIDATE_VULKAN_RESULT(vkGetPhysicalDeviceSurfacePresentModesKHR(gpu, _surface, &presentModesCount, nullptr)); - ASSERT(presentModesCount > 0); - Array> presentModes; presentModes.Resize(presentModesCount); VALIDATE_VULKAN_RESULT(vkGetPhysicalDeviceSurfacePresentModesKHR(gpu, _surface, &presentModesCount, presentModes.Get())); - bool foundPresentModeMailbox = false; bool foundPresentModeImmediate = false; bool foundPresentModeFifo = false; - for (size_t i = 0; i < presentModesCount; i++) { switch (presentModes[(int32)i]) @@ -340,7 +319,6 @@ bool GPUSwapChainVulkan::CreateSwapChain(int32 width, int32 height) break; } } - if (foundPresentModeMailbox) { presentMode = VK_PRESENT_MODE_MAILBOX_KHR;