Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/msvc_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
# Ruleset file that will determine what checks will be run
ruleset: NativeRecommendedRules.ruleset
# Paths to ignore analysis of CMake targets and includes
ignoredPaths: '${{ github.workspace }}/ThirdParty'
ignoredPaths: '${{ github.workspace }}/ThirdParty;${{ env.DILIGENT_BUILD_DIR }}/_deps'

# Upload SARIF file to GitHub Code Scanning Alerts
- name: Upload SARIF to GitHub
Expand Down
24 changes: 16 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +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(DILIGENT_CORE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "DiligentCore module source directory")

Expand Down Expand Up @@ -180,10 +181,11 @@ 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(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")
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")
Expand All @@ -199,12 +201,14 @@ 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(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")
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(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")
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)
Expand Down Expand Up @@ -303,6 +307,7 @@ else()
option(DILIGENT_NO_WEBGPU "Disable WebGPU backend" ON)
endif()
option(DILIGENT_NO_ARCHIVER "Do not build archiver" OFF)
option(DILIGENT_NO_SUPER_RESOLUTION "Do not build super resolution" OFF)

option(DILIGENT_EMSCRIPTEN_STRIP_DEBUG_INFO "Strip debug information from WebAsm binaries" OFF)

Expand All @@ -329,6 +334,9 @@ endif()
if(${DILIGENT_NO_ARCHIVER})
set(ARCHIVER_SUPPORTED FALSE CACHE INTERNAL "Archiver is forcibly disabled")
endif()
if(${DILIGENT_NO_SUPER_RESOLUTION})
set(SUPER_RESOLUTION_SUPPORTED FALSE CACHE INTERNAL "Super resolution is forcibly disabled")
endif()

if(NOT (${D3D11_SUPPORTED} OR ${D3D12_SUPPORTED} OR ${GL_SUPPORTED} OR ${GLES_SUPPORTED} OR ${VULKAN_SUPPORTED} OR ${METAL_SUPPORTED} OR ${WEBGPU_SUPPORTED}))
message(FATAL_ERROR "No rendering backends are select to build")
Expand Down
5 changes: 4 additions & 1 deletion Graphics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,7 @@ if(ARCHIVER_SUPPORTED)
endif()

add_subdirectory(GraphicsTools)
add_subdirectory(SuperResolution)

if(SUPER_RESOLUTION_SUPPORTED)
add_subdirectory(SuperResolution)
endif()
34 changes: 30 additions & 4 deletions Graphics/SuperResolution/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
cmake_minimum_required (VERSION 3.10)
cmake_minimum_required (VERSION 3.11)

include(../../BuildTools/CMake/BuildUtils.cmake)

project(Diligent-SuperResolution CXX)

if(D3D12_SUPPORTED)
# Fetch DirectSR headers
FetchContent_DeclareShallowGit(DirectSR-Headers
GIT_REPOSITORY https://github.com/MikhailGorobets/DirectSR-Headers.git
GIT_TAG dev
)
FetchContent_MakeAvailable(DirectSR-Headers)
if(TARGET DirectSR-AgilitySDK)
set_target_properties(DirectSR-AgilitySDK PROPERTIES FOLDER DiligentCore/ThirdParty)
endif()
endif()

set(INCLUDE
include/SuperResolutionBase.hpp
include/SuperResolutionInternal.hpp
)

set(INTERFACE
Expand All @@ -18,6 +32,7 @@ set(SOURCE
)

if(D3D12_SUPPORTED)
list(APPEND INCLUDE include/SuperResolution_D3D12.hpp)
list(APPEND SOURCE src/SuperResolution_D3D12.cpp)
endif()

Expand All @@ -29,6 +44,7 @@ set(DLL_SOURCE
add_library(Diligent-SuperResolutionInterface INTERFACE)
target_link_libraries (Diligent-SuperResolutionInterface INTERFACE Diligent-GraphicsEngineInterface)
target_include_directories(Diligent-SuperResolutionInterface INTERFACE interface)
target_compile_definitions(Diligent-SuperResolutionInterface INTERFACE SUPER_RESOLUTION_SUPPORTED=1)

add_library(Diligent-SuperResolution-static STATIC
${SOURCE} ${INTERFACE} ${INCLUDE}
Expand All @@ -45,24 +61,34 @@ endif()
target_include_directories(Diligent-SuperResolution-static
PRIVATE
include
../GraphicsEngine/include
../GraphicsEngineD3DBase/include
../GraphicsEngineNextGenBase/include
)

target_compile_definitions(Diligent-SuperResolution-shared PUBLIC DILIGENT_SUPER_RESOLUTION_SHARED=1)


target_link_libraries(Diligent-SuperResolution-static
PUBLIC
Diligent-SuperResolutionInterface
PRIVATE
Diligent-BuildSettings
Diligent-Common
Diligent-GraphicsAccessories
Diligent-ShaderTools
)

if(D3D12_SUPPORTED)
target_link_libraries(Diligent-SuperResolution-static PRIVATE Diligent-GraphicsEngineD3D12-static)
target_link_libraries(Diligent-SuperResolution-static PRIVATE Diligent-GraphicsEngineD3D12-static DirectSR-Headers)
target_include_directories(Diligent-SuperResolution-static PRIVATE ../GraphicsEngineD3D12/include)
endif()

if(METAL_SUPPORTED)
target_include_directories(Diligent-SuperResolution-static PRIVATE
${CMAKE_SOURCE_DIR}/DiligentCorePro/Graphics/SuperResolution/include
)
endif()

target_link_libraries(Diligent-SuperResolution-shared
PUBLIC
Diligent-SuperResolutionInterface
Expand All @@ -86,7 +112,7 @@ endif()
if (MINGW_BUILD)
# Restrict export to GetSuperResolutionFactory
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/export.map
"{ global: *GetSuperResolutionFactory*; local: *; };"
"{ global: *CreateSuperResolutionFactory*; local: *; };"
)
target_link_options(Diligent-SuperResolution-shared PRIVATE LINKER:--version-script=export.map)
endif()
Expand Down
91 changes: 91 additions & 0 deletions Graphics/SuperResolution/include/SuperResolutionBase.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright 2026 Diligent Graphics LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* In no event and under no legal theory, whether in tort (including negligence),
* contract, or otherwise, unless required by applicable law (such as deliberate
* and grossly negligent acts) or agreed to in writing, shall any Contributor be
* liable for any damages, including any direct, indirect, special, incidental,
* or consequential damages of any character arising as a result of this License or
* out of the use or inability to use the software (including but not limited to damages
* for loss of goodwill, work stoppage, computer failure or malfunction, or any and
* all other commercial damages or losses), even if such Contributor has been advised
* of the possibility of such damages.
*/

#pragma once

#include "ObjectBase.hpp"
#include "SuperResolution.h"

#include <vector>
#include <string>

namespace Diligent
{

class SuperResolutionBase : public ObjectBase<ISuperResolution>
{
public:
using TBase = ObjectBase<ISuperResolution>;

SuperResolutionBase(IReferenceCounters* pRefCounters,
const SuperResolutionDesc& Desc) :
TBase{pRefCounters},
m_Desc{Desc}
{
if (Desc.Name != nullptr)
{
m_Name = Desc.Name;
m_Desc.Name = m_Name.c_str();
}
}

IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_SuperResolution, TBase)

Check warning

Code scanning / CodeQL

Local variable address stored in non-local memory Warning

A stack address which arrived via a
parameter
may be assigned to a non-local variable.

virtual const SuperResolutionDesc& DILIGENT_CALL_TYPE GetDesc() const override final
{
return m_Desc;
}

virtual void DILIGENT_CALL_TYPE GetJitterOffset(Uint32 Index, float* pJitterX, float* pJitterY) const override final
{
DEV_CHECK_ERR(pJitterX != nullptr && pJitterY != nullptr, "pJitterX and pJitterY must not be null");

if (!m_JitterPattern.empty())
{
const Uint32 WrappedIndex = Index % static_cast<Uint32>(m_JitterPattern.size());
*pJitterX = m_JitterPattern[WrappedIndex].X;
*pJitterY = m_JitterPattern[WrappedIndex].Y;
}
else
{
*pJitterX = 0.0f;
*pJitterY = 0.0f;
}
}

protected:
struct JitterOffset
{
float X = 0.0f;
float Y = 0.0f;
};

SuperResolutionDesc m_Desc;
std::string m_Name;
std::vector<JitterOffset> m_JitterPattern;
};

} // namespace Diligent
47 changes: 47 additions & 0 deletions Graphics/SuperResolution/include/SuperResolutionInternal.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2026 Diligent Graphics LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* In no event and under no legal theory, whether in tort (including negligence),
* contract, or otherwise, unless required by applicable law (such as deliberate
* and grossly negligent acts) or agreed to in writing, shall any Contributor be
* liable for any damages, including any direct, indirect, special, incidental,
* or consequential damages of any character arising as a result of this License or
* out of the use or inability to use the software (including but not limited to damages
* for loss of goodwill, work stoppage, computer failure or malfunction, or any and
* all other commercial damages or losses), even if such Contributor has been advised
* of the possibility of such damages.
*/

#pragma once

#include "SuperResolutionFactory.h"

#include <array>
#include <vector>

namespace Diligent
{

enum SUPER_RESOLUTION_BACKEND : Uint8
{
SUPER_RESOLUTION_BACKEND_D3D12_DSR,
SUPER_RESOLUTION_BACKEND_METAL_FX,
SUPER_RESOLUTION_BACKEND_SOFTWARE,
SUPER_RESOLUTION_BACKEND_COUNT
};

using SuperResolutionVariants = std::array<std::vector<SuperResolutionInfo>, SUPER_RESOLUTION_BACKEND_COUNT>;

} // namespace Diligent
51 changes: 51 additions & 0 deletions Graphics/SuperResolution/include/SuperResolution_D3D12.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2026 Diligent Graphics LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* In no event and under no legal theory, whether in tort (including negligence),
* contract, or otherwise, unless required by applicable law (such as deliberate
* and grossly negligent acts) or agreed to in writing, shall any Contributor be
* liable for any damages, including any direct, indirect, special, incidental,
* or consequential damages of any character arising as a result of this License or
* out of the use or inability to use the software (including but not limited to damages
* for loss of goodwill, work stoppage, computer failure or malfunction, or any and
* all other commercial damages or losses), even if such Contributor has been advised
* of the possibility of such damages.
*/

#pragma once

#include "SuperResolutionInternal.hpp"

#include "../../GraphicsEngineD3D12/include/pch.h"
#include <directsr.h>

namespace Diligent
{

CComPtr<IDSRDevice> CreateDSRDeviceD3D12(IRenderDevice* pDevice);

void EnumerateVariantsD3D12(IDSRDevice* pDSRDevice,
std::vector<SuperResolutionInfo>& Variants);

void GetSourceSettingsD3D12(IDSRDevice* pDSRDevice,
const SuperResolutionSourceSettingsAttribs& Attribs,
SuperResolutionSourceSettings& Settings);

void CreateSuperResolutionD3D12(IRenderDevice* pDevice,
IDSRDevice* pDSRDevice,
const SuperResolutionDesc& Desc,
ISuperResolution** ppUpscaler);

} // namespace Diligent
Loading
Loading