Skip to content

Commit 205d204

Browse files
Add MetalFX (Metal) super resolution implementation
1 parent eedebec commit 205d204

3 files changed

Lines changed: 31 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,14 @@ elseif(PLATFORM_LINUX)
201201
set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on Linux platform")
202202
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_LINUX=1)
203203
elseif(PLATFORM_MACOS)
204-
set(GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL is supported on MacOS platform")
205-
set(VULKAN_SUPPORTED TRUE CACHE INTERNAL "Vulkan is enabled through MoltenVK on MacOS platform")
206-
set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on MacOS platform")
204+
set(GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL is supported on MacOS platform")
205+
set(VULKAN_SUPPORTED TRUE CACHE INTERNAL "Vulkan is enabled through MoltenVK on MacOS platform")
206+
set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on MacOS platform")
207+
set(SUPER_RESOLUTION_SUPPORTED TRUE CACHE INTERNAL "Super resolution is supported on MacOS platform")
207208
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_MACOS=1 PLATFORM_APPLE=1)
208209
elseif(PLATFORM_IOS)
209-
set(GLES_SUPPORTED TRUE CACHE INTERNAL "OpenGLES is supported on iOS platform")
210+
set(GLES_SUPPORTED TRUE CACHE INTERNAL "OpenGLES is supported on iOS platform")
211+
set(SUPER_RESOLUTION_SUPPORTED TRUE CACHE INTERNAL "Super resolution is supported on iOS platform")
210212
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_IOS=1 PLATFORM_APPLE=1)
211213
elseif(PLATFORM_TVOS)
212214
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_TVOS=1 PLATFORM_APPLE=1)

Graphics/SuperResolution/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ if(D3D12_SUPPORTED)
8383
target_include_directories(Diligent-SuperResolution-static PRIVATE ../GraphicsEngineD3D12/include)
8484
endif()
8585

86+
if(METAL_SUPPORTED)
87+
target_include_directories(Diligent-SuperResolution-static PRIVATE
88+
${CMAKE_SOURCE_DIR}/DiligentCorePro/Graphics/SuperResolution/include
89+
)
90+
endif()
91+
8692
target_link_libraries(Diligent-SuperResolution-shared
8793
PUBLIC
8894
Diligent-SuperResolutionInterface

Graphics/SuperResolution/src/SuperResolutionFactory.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
# include "SuperResolution_D3D12.hpp"
3838
#endif
3939

40+
#if METAL_SUPPORTED
41+
# include "SuperResolution_Metal.hpp"
42+
#endif
43+
4044
namespace Diligent
4145
{
4246

@@ -97,6 +101,11 @@ void SuperResolutionFactoryImpl::PopulateVariants()
97101
if (m_pDSRDevice)
98102
EnumerateVariantsD3D12(m_pDSRDevice, m_Variants[SUPER_RESOLUTION_BACKEND_D3D12_DSR]);
99103
#endif
104+
105+
#if METAL_SUPPORTED
106+
if (m_pDevice != nullptr && m_pDevice->GetDeviceInfo().Type == RENDER_DEVICE_TYPE_METAL)
107+
EnumerateVariantsMetal(m_pDevice, m_Variants[SUPER_RESOLUTION_BACKEND_METAL_FX]);
108+
#endif
100109
}
101110

102111
SUPER_RESOLUTION_BACKEND SuperResolutionFactoryImpl::FindVariant(const INTERFACE_ID& VariantId) const
@@ -154,6 +163,11 @@ void SuperResolutionFactoryImpl::GetSourceSettings(const SuperResolutionSourceSe
154163
case SUPER_RESOLUTION_BACKEND_D3D12_DSR:
155164
GetSourceSettingsD3D12(m_pDSRDevice, Attribs, Settings);
156165
break;
166+
#endif
167+
#if METAL_SUPPORTED
168+
case SUPER_RESOLUTION_BACKEND_METAL_FX:
169+
GetSourceSettingsMetal(Attribs, Settings);
170+
break;
157171
#endif
158172
default:
159173
LOG_WARNING_MESSAGE("Unknown super resolution backend");
@@ -184,6 +198,11 @@ void SuperResolutionFactoryImpl::CreateSuperResolution(const SuperResolutionDesc
184198
case SUPER_RESOLUTION_BACKEND_D3D12_DSR:
185199
CreateSuperResolutionD3D12(m_pDevice, m_pDSRDevice, Desc, ppUpscaler);
186200
break;
201+
#endif
202+
#if METAL_SUPPORTED
203+
case SUPER_RESOLUTION_BACKEND_METAL_FX:
204+
CreateSuperResolutionMetal(m_pDevice, Desc, ppUpscaler);
205+
break;
187206
#endif
188207
default:
189208
LOG_ERROR_MESSAGE("Unknown super resolution backend");

0 commit comments

Comments
 (0)