diff --git a/CMakeLists.txt b/CMakeLists.txt index 39ab3cc9b..b9873b27a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,7 @@ set(VULKAN_SUPPORTED FALSE CACHE INTERNAL "Vulkan is not supported") set(METAL_SUPPORTED FALSE CACHE INTERNAL "Metal is not supported") set(WEBGPU_SUPPORTED FALSE CACHE INTERNAL "WebGPU is not supported") set(ARCHIVER_SUPPORTED FALSE CACHE INTERNAL "Archiver is not supported") -set(SUPER_RESOLUTION_SUPPORTED FALSE CACHE INTERNAL "Super resolution is not supported") +set(SUPER_RESOLUTION_SUPPORTED TRUE CACHE INTERNAL "Super resolution is supported") set(DILIGENT_CORE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "DiligentCore module source directory") @@ -137,7 +137,7 @@ else() message("Target platform: tvOS " ${ARCH}) elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten") set(PLATFORM_WEB TRUE CACHE INTERNAL "Target platform: Web") - set(PLATFORM_EMSCRIPTEN TRUE CACHE INTERNAL "Build with Emscritpen") + set(PLATFORM_EMSCRIPTEN TRUE CACHE INTERNAL "Build with Emscripten") message("Target platform: Web " ${ARCH}) else() message(FATAL_ERROR "Unsupported platform") @@ -181,11 +181,10 @@ if(MINGW) endif() if(PLATFORM_WIN32) - set(GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL is supported on Win32 platform") - set(VULKAN_SUPPORTED TRUE CACHE INTERNAL "Vulkan is supported on Win32 platform") - set(WEBGPU_SUPPORTED TRUE CACHE INTERNAL "WebGPU is supported on Win32 platform") - set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on Win32 platform") - set(SUPER_RESOLUTION_SUPPORTED TRUE CACHE INTERNAL "Super resolution is supported on Win32 platform") + set(GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL is supported on Win32 platform") + set(VULKAN_SUPPORTED TRUE CACHE INTERNAL "Vulkan is supported on Win32 platform") + set(WEBGPU_SUPPORTED TRUE CACHE INTERNAL "WebGPU is supported on Win32 platform") + set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on Win32 platform") target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_WIN32=1) elseif(PLATFORM_UNIVERSAL_WINDOWS) set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on Universal Windows platform") @@ -201,14 +200,12 @@ elseif(PLATFORM_LINUX) set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on Linux platform") target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_LINUX=1) elseif(PLATFORM_MACOS) - set(GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL is supported on MacOS platform") - set(VULKAN_SUPPORTED TRUE CACHE INTERNAL "Vulkan is enabled through MoltenVK on MacOS platform") - set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on MacOS platform") - set(SUPER_RESOLUTION_SUPPORTED TRUE CACHE INTERNAL "Super resolution is supported on MacOS platform") + set(GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL is supported on MacOS platform") + set(VULKAN_SUPPORTED TRUE CACHE INTERNAL "Vulkan is enabled through MoltenVK on MacOS platform") + set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on MacOS platform") target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_MACOS=1 PLATFORM_APPLE=1) elseif(PLATFORM_IOS) - set(GLES_SUPPORTED TRUE CACHE INTERNAL "OpenGLES is supported on iOS platform") - set(SUPER_RESOLUTION_SUPPORTED TRUE CACHE INTERNAL "Super resolution is supported on iOS platform") + set(GLES_SUPPORTED TRUE CACHE INTERNAL "OpenGLES is supported on iOS platform") target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_IOS=1 PLATFORM_APPLE=1) elseif(PLATFORM_TVOS) target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_TVOS=1 PLATFORM_APPLE=1) diff --git a/Graphics/SuperResolution/include/SuperResolutionProvider.hpp b/Graphics/SuperResolution/include/SuperResolutionProvider.hpp index 4b027ac16..397254ac8 100644 --- a/Graphics/SuperResolution/include/SuperResolutionProvider.hpp +++ b/Graphics/SuperResolution/include/SuperResolutionProvider.hpp @@ -51,18 +51,18 @@ class SuperResolutionProvider ValidateSourceSettingsAttribs(Attribs); - float ScaleFactor = 1.0f; - switch (Attribs.OptimizationType) - { - // clang-format off - case SUPER_RESOLUTION_OPTIMIZATION_TYPE_MAX_QUALITY: ScaleFactor = 12.f / 16.f; break; - case SUPER_RESOLUTION_OPTIMIZATION_TYPE_HIGH_QUALITY: ScaleFactor = 11.f / 16.f; break; - case SUPER_RESOLUTION_OPTIMIZATION_TYPE_BALANCED: ScaleFactor = 9.f / 16.f; break; - case SUPER_RESOLUTION_OPTIMIZATION_TYPE_HIGH_PERFORMANCE: ScaleFactor = 8.f / 16.f; break; - case SUPER_RESOLUTION_OPTIMIZATION_TYPE_MAX_PERFORMANCE: ScaleFactor = 5.f / 16.f; break; - default: ScaleFactor = 9.f / 16.f; break; - // clang-format on - } + static constexpr float ScaleFactors[] = { + 24.f / 32.f, // MAX_QUALITY (75%) + 22.f / 32.f, // HIGH_QUALITY (69%) + 18.f / 32.f, // BALANCED (56%) + 16.f / 32.f, // HIGH_PERFORMANCE (50%) + 11.f / 32.f, // MAX_PERFORMANCE (34%) + }; + + static_assert(_countof(ScaleFactors) == SUPER_RESOLUTION_OPTIMIZATION_TYPE_COUNT, + "Scale factor table must match SUPER_RESOLUTION_OPTIMIZATION_TYPE_COUNT"); + + const float ScaleFactor = Attribs.OptimizationType < SUPER_RESOLUTION_OPTIMIZATION_TYPE_COUNT ? ScaleFactors[Attribs.OptimizationType] : ScaleFactors[SUPER_RESOLUTION_OPTIMIZATION_TYPE_BALANCED]; Settings.OptimalInputWidth = std::max(1u, static_cast(Attribs.OutputWidth * ScaleFactor)); Settings.OptimalInputHeight = std::max(1u, static_cast(Attribs.OutputHeight * ScaleFactor));