Browse Source

- Some fixes and including PR feedback

Sergio Alapont 3 years ago
parent
commit
c7f4f9a574

+ 1 - 0
.gitignore

@@ -1,3 +1,4 @@
 build*/*
 build*/*
 out/*
 out/*
 .*
 .*
+CMakeSettings.json

+ 1 - 0
AnKi/Config.h.cmake

@@ -23,6 +23,7 @@
 #define ANKI_TESTS ${ANKI_TESTS}
 #define ANKI_TESTS ${ANKI_TESTS}
 #define ANKI_ENABLE_TRACE ${_ANKI_ENABLE_TRACE}
 #define ANKI_ENABLE_TRACE ${_ANKI_ENABLE_TRACE}
 #define ANKI_SOURCE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
 #define ANKI_SOURCE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+#define ANKI_DLSS ${_ANKI_ENABLE_DLSS}
 
 
 // Compiler
 // Compiler
 #if defined(__clang__)
 #if defined(__clang__)

+ 1 - 1
AnKi/Gr/CMakeLists.txt

@@ -114,7 +114,7 @@ if(VULKAN)
 		Vulkan/VulkanObject.h
 		Vulkan/VulkanObject.h
 		Vulkan/GrUpscalerImpl.h)
 		Vulkan/GrUpscalerImpl.h)
 
 
-	if(DLSS_SUPPORT)
+	if(ANKI_DLSS)
 		set(backend_sources ${backend_sources} "Vulkan/GrUpscalerImpl.cpp")
 		set(backend_sources ${backend_sources} "Vulkan/GrUpscalerImpl.cpp")
 	else()
 	else()
 		set(backend_sources ${backend_sources} "Vulkan/GrUpscalerImplDummy.cpp")
 		set(backend_sources ${backend_sources} "Vulkan/GrUpscalerImplDummy.cpp")

+ 10 - 10
AnKi/Gr/CommandBuffer.h

@@ -413,18 +413,18 @@ public:
 
 
 	/// Do upscaling by an external upscaler
 	/// Do upscaling by an external upscaler
 	/// @param[in] upscaler the upscaler to use for upscaling
 	/// @param[in] upscaler the upscaler to use for upscaling
-	/// @param[in] srcRt Source LowRes RenderTarget.
-	/// @param[out] dstRt Destination HighRes RenderTarget
-	/// @param[in] mvRt Motion Vectors
-	/// @param[in] depthRt Depth attachment
+	/// @param[in] inColor Source LowRes RenderTarget.
+	/// @param[out] outUpscaledColor Destination HighRes RenderTarget
+	/// @param[in] motionVectors Motion Vectors
+	/// @param[in] depth Depth attachment
 	/// @param[in] exposure 1x1 texture containing exposure
 	/// @param[in] exposure 1x1 texture containing exposure
 	/// @param[in] resetAccumulation whether to clean or not any temporal history
 	/// @param[in] resetAccumulation whether to clean or not any temporal history
-	/// @param[in] jitterOffset Jittering offset that was applied during the generation of srcRt
-	/// @param[in] mVScale Any scale factor that might need to be applied to the mvRt (i.e UV space to Pixel space
-	/// conversion)
-	void upscale(const GrUpscalerPtr& upscaler, const TextureViewPtr& srcRt, const TextureViewPtr& dstRt,
-				 const TextureViewPtr& mvRt, const TextureViewPtr& depthRt, const TextureViewPtr& exposure,
-				 const Bool resetAccumulation, const Vec2& jitterOffset, const Vec2& mVScale);
+	/// @param[in] jitterOffset Jittering offset that was applied during the generation of sourceTexture
+	/// @param[in] motionVectorsScale Any scale factor that might need to be applied to the motionVectorsTexture (i.e UV
+	/// space to Pixel space conversion)
+	void upscale(const GrUpscalerPtr& upscaler, const TextureViewPtr& inColor, const TextureViewPtr& outUpscaledColor,
+				 const TextureViewPtr& motionVectors, const TextureViewPtr& depth, const TextureViewPtr& exposure,
+				 const Bool resetAccumulation, const Vec2& jitterOffset, const Vec2& motionVectorsScale);
 
 
 	/// @}
 	/// @}
 
 

+ 1 - 1
AnKi/Gr/Common.h

@@ -185,7 +185,7 @@ public:
 	Bool m_unalignedBbpTextureFormats = false;
 	Bool m_unalignedBbpTextureFormats = false;
 
 
 	/// DLSS.
 	/// DLSS.
-	Bool m_dlssSupport = false;
+	Bool m_dlss = false;
 };
 };
 ANKI_END_PACKED_STRUCT
 ANKI_END_PACKED_STRUCT
 static_assert(sizeof(GpuDeviceCapabilities)
 static_assert(sizeof(GpuDeviceCapabilities)

+ 1 - 1
AnKi/Gr/GrObject.h

@@ -29,7 +29,7 @@ enum class GrObjectType : U8
 	FENCE,
 	FENCE,
 	RENDER_GRAPH,
 	RENDER_GRAPH,
 	ACCELERATION_STRUCTURE,
 	ACCELERATION_STRUCTURE,
-	GRUPSCALER,
+	GR_UPSCALER,
 
 
 	COUNT,
 	COUNT,
 	FIRST = 0
 	FIRST = 0

+ 17 - 12
AnKi/Gr/GrUpscaler.h

@@ -39,26 +39,26 @@ public:
 };
 };
 
 
 /// Initialization structure for the upscaler
 /// Initialization structure for the upscaler
-class GrUpscalerInitInfo
+class GrUpscalerInitInfo : public GrBaseInitInfo
 {
 {
 public:
 public:
-	UVec2 m_srcRes = {0, 0};
-	UVec2 m_dstRes = {0, 0};
-	UpscalerType m_type;
+	UVec2 m_sourceImageResolution = UVec2(0, 0);
+	UVec2 m_targetImageResolution = UVec2(0, 0);
+	UpscalerType m_upscalerType = UpscalerType::INVALID;
 	union
 	union
 	{
 	{
 		DLSSInitInfo m_dlssInitInfo;
 		DLSSInitInfo m_dlssInitInfo;
 	};
 	};
 
 
 	GrUpscalerInitInfo()
 	GrUpscalerInitInfo()
-		: m_type(UpscalerType::INVALID)
+		: GrBaseInitInfo()
 	{
 	{
 	}
 	}
 
 
 	GrUpscalerInitInfo(const UVec2& srcRes, const UVec2& dstRes, const DLSSInitInfo& info)
 	GrUpscalerInitInfo(const UVec2& srcRes, const UVec2& dstRes, const DLSSInitInfo& info)
-		: m_srcRes(srcRes)
-		, m_dstRes(dstRes)
-		, m_type(UpscalerType::DLSS_2)
+		: m_sourceImageResolution(srcRes)
+		, m_targetImageResolution(dstRes)
+		, m_upscalerType(UpscalerType::DLSS_2)
 		, m_dlssInitInfo(info)
 		, m_dlssInitInfo(info)
 	{
 	{
 	}
 	}
@@ -69,11 +69,12 @@ class GrUpscaler : public GrObject
 	ANKI_GR_OBJECT
 	ANKI_GR_OBJECT
 
 
 public:
 public:
-	static constexpr GrObjectType CLASS_TYPE = GrObjectType::GRUPSCALER;
+	static constexpr GrObjectType CLASS_TYPE = GrObjectType::GR_UPSCALER;
 
 
-	void upscale(CommandBufferPtr cmdb, const TextureViewPtr& srcRt, const TextureViewPtr& dstRt,
-				 const TextureViewPtr& mvRt, const TextureViewPtr& depthRt, const TextureViewPtr& exposure,
-				 const Bool resetAccumulation, const Vec2& jitterOffset, const Vec2& mVScale);
+	UpscalerType getUpscalerType() const
+	{
+		return m_initInfo.m_upscalerType;
+	}
 
 
 protected:
 protected:
 	/// Construct.
 	/// Construct.
@@ -87,7 +88,11 @@ protected:
 	{
 	{
 	}
 	}
 
 
+	GrUpscalerInitInfo m_initInfo;
+
 private:
 private:
+	[[nodiscard]] Error init(const GrUpscalerInitInfo& init);
+
 	/// Allocate and initialize a new instance.
 	/// Allocate and initialize a new instance.
 	static GrUpscaler* newInstance(GrManager* manager, const GrUpscalerInitInfo& init);
 	static GrUpscaler* newInstance(GrManager* manager, const GrUpscalerInitInfo& init);
 };
 };

+ 6 - 4
AnKi/Gr/Vulkan/CommandBuffer.cpp

@@ -362,12 +362,14 @@ void CommandBuffer::buildAccelerationStructure(const AccelerationStructurePtr& a
 	self.buildAccelerationStructureInternal(as);
 	self.buildAccelerationStructureInternal(as);
 }
 }
 
 
-void CommandBuffer::upscale(const GrUpscalerPtr& upscaler, const TextureViewPtr& srcRt, const TextureViewPtr& dstRt,
-							const TextureViewPtr& mvRt, const TextureViewPtr& depthRt, const TextureViewPtr& exposure,
-							const Bool resetAccumulation, const Vec2& jitterOffset, const Vec2& mVScale)
+void CommandBuffer::upscale(const GrUpscalerPtr& upscaler, const TextureViewPtr& inColor,
+							const TextureViewPtr& outUpscaledColor, const TextureViewPtr& motionVectors,
+							const TextureViewPtr& depth, const TextureViewPtr& exposure, const Bool resetAccumulation,
+							const Vec2& jitterOffset, const Vec2& motionVectorsScale)
 {
 {
 	ANKI_VK_SELF(CommandBufferImpl);
 	ANKI_VK_SELF(CommandBufferImpl);
-	self.upscaleInternal(upscaler, srcRt, dstRt, mvRt, depthRt, exposure, resetAccumulation, jitterOffset, mVScale);
+	self.upscaleInternal(upscaler, inColor, outUpscaledColor, motionVectors, depth, exposure, resetAccumulation,
+						 jitterOffset, motionVectorsScale);
 }
 }
 
 
 void CommandBuffer::setTextureBarrier(const TexturePtr& tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage,
 void CommandBuffer::setTextureBarrier(const TexturePtr& tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage,

+ 89 - 8
AnKi/Gr/Vulkan/CommandBufferImpl.cpp

@@ -8,10 +8,18 @@
 #include <AnKi/Gr/Vulkan/GrManagerImpl.h>
 #include <AnKi/Gr/Vulkan/GrManagerImpl.h>
 
 
 #include <AnKi/Gr/Framebuffer.h>
 #include <AnKi/Gr/Framebuffer.h>
-#include <AnKi/Gr/GrUpscaler.h>
+#include <AnKi/Gr/Vulkan/GrUpscalerImpl.h>
 #include <AnKi/Gr/Vulkan/AccelerationStructureImpl.h>
 #include <AnKi/Gr/Vulkan/AccelerationStructureImpl.h>
 #include <AnKi/Gr/Vulkan/FramebufferImpl.h>
 #include <AnKi/Gr/Vulkan/FramebufferImpl.h>
 
 
+#ifdef ANKI_DLSS
+// Ngx specific
+#	include <ThirdParty/nvngx_dlss_sdk/sdk/include/nvsdk_ngx.h>
+#	include <ThirdParty/nvngx_dlss_sdk/sdk/include/nvsdk_ngx_helpers.h>
+#	include <ThirdParty/nvngx_dlss_sdk/sdk/include/nvsdk_ngx_vk.h>
+#	include <ThirdParty/nvngx_dlss_sdk/sdk/include/nvsdk_ngx_helpers_vk.h>
+#endif
+
 #include <algorithm>
 #include <algorithm>
 
 
 namespace anki {
 namespace anki {
@@ -787,15 +795,88 @@ void CommandBufferImpl::buildAccelerationStructureInternal(const AccelerationStr
 	m_microCmdb->pushObjectRef(scratchBuff);
 	m_microCmdb->pushObjectRef(scratchBuff);
 }
 }
 
 
-void CommandBufferImpl::upscaleInternal(const GrUpscalerPtr& upscaler, const TextureViewPtr& srcRt,
-										const TextureViewPtr& dstRt, const TextureViewPtr& mvRt,
-										const TextureViewPtr& depthRt, const TextureViewPtr& exposure,
-										const Bool resetAccumulation, const Vec2& jitterOffset, const Vec2& mVScale)
+#ifdef ANKI_DLSS
+static NVSDK_NGX_Resource_VK getNGXResourceFromAnkiTexture(const TextureViewImpl& tex, Bool isUAV)
+{
+	NVSDK_NGX_Resource_VK resourceVK = {};
+	VkImageView imageView = tex.getHandle();
+	VkFormat format = convertFormat(tex.getTextureImpl().getFormat());
+	VkImage image = tex.getTextureImpl().m_imageHandle;
+	VkImageSubresourceRange subresourceRange = tex.getVkImageSubresourceRange();
+
+	return NVSDK_NGX_Create_ImageView_Resource_VK(imageView, image, subresourceRange, format,
+												  tex.getTextureImpl().getWidth(), tex.getTextureImpl().getHeight(),
+												  isUAV);
+}
+#endif
+
+void CommandBufferImpl::upscaleInternal(const GrUpscalerPtr& upscaler, const TextureViewPtr& inColor,
+										const TextureViewPtr& outUpscaledColor, const TextureViewPtr& motionVectors,
+										const TextureViewPtr& depth, const TextureViewPtr& exposure,
+										const Bool resetAccumulation, const Vec2& jitterOffset,
+										const Vec2& motionVectorsScale)
 {
 {
 	commandCommon();
 	commandCommon();
-	// Hide implementation details from the CommandBuffer as these might involve an external SDK
-	upscaler->upscale(CommandBufferPtr(this), srcRt, dstRt, mvRt, depthRt, exposure, resetAccumulation, jitterOffset,
-					  mVScale);
+
+#ifdef ANKI_DLSS
+	if(upscaler->getUpscalerType() == UpscalerType::DLSS_2)
+	{
+		const GrUpscalerImpl& upscalerImpl = static_cast<const GrUpscalerImpl&>(*upscaler);
+		if(!upscalerImpl.isNgxInitialized())
+		{
+			ANKI_VK_LOGE("Attempt to upscale an image without NGX being initialized.");
+			return;
+		}
+
+		const TextureViewImpl& srcViewImpl = static_cast<const TextureViewImpl&>(*inColor);
+		const TextureViewImpl& dstViewImpl = static_cast<const TextureViewImpl&>(*outUpscaledColor);
+		const TextureViewImpl& mvViewImpl = static_cast<const TextureViewImpl&>(*motionVectors);
+		const TextureViewImpl& depthViewImpl = static_cast<const TextureViewImpl&>(*depth);
+		const TextureViewImpl& exposureViewImpl = static_cast<const TextureViewImpl&>(*exposure);
+
+		NVSDK_NGX_Resource_VK srcResVk = getNGXResourceFromAnkiTexture(srcViewImpl, false);
+		NVSDK_NGX_Resource_VK dstResVk = getNGXResourceFromAnkiTexture(dstViewImpl, true);
+		NVSDK_NGX_Resource_VK mvResVk = getNGXResourceFromAnkiTexture(mvViewImpl, false);
+		NVSDK_NGX_Resource_VK depthResVk = getNGXResourceFromAnkiTexture(depthViewImpl, false);
+		NVSDK_NGX_Resource_VK exposureResVk = getNGXResourceFromAnkiTexture(exposureViewImpl, true);
+
+		NVSDK_NGX_Coordinates renderingOffset = {0, 0};
+		NVSDK_NGX_Dimensions renderingSize = {srcViewImpl.getTextureImpl().getWidth(),
+											  srcViewImpl.getTextureImpl().getHeight()};
+
+		NVSDK_NGX_VK_DLSS_Eval_Params vkDlssEvalParams;
+		memset(&vkDlssEvalParams, 0, sizeof(vkDlssEvalParams));
+		vkDlssEvalParams.Feature.pInColor = &srcResVk;
+		vkDlssEvalParams.Feature.pInOutput = &dstResVk;
+		vkDlssEvalParams.pInDepth = &depthResVk;
+		vkDlssEvalParams.pInMotionVectors = &mvResVk;
+		vkDlssEvalParams.pInExposureTexture = &exposureResVk;
+		vkDlssEvalParams.InJitterOffsetX = jitterOffset.x();
+		vkDlssEvalParams.InJitterOffsetY = jitterOffset.y();
+		vkDlssEvalParams.Feature.InSharpness = upscalerImpl.getRecommendedSettings().m_recommendedSharpness;
+		vkDlssEvalParams.InReset = resetAccumulation;
+		vkDlssEvalParams.InMVScaleX = motionVectorsScale.x();
+		vkDlssEvalParams.InMVScaleY = motionVectorsScale.y();
+		vkDlssEvalParams.InColorSubrectBase = renderingOffset;
+		vkDlssEvalParams.InDepthSubrectBase = renderingOffset;
+		vkDlssEvalParams.InTranslucencySubrectBase = renderingOffset;
+		vkDlssEvalParams.InMVSubrectBase = renderingOffset;
+		vkDlssEvalParams.InRenderSubrectDimensions = renderingSize;
+
+		getGrManagerImpl().beginMarker(m_handle, "DLSS");
+		NVSDK_NGX_Parameter* dlssParameters(upscalerImpl.getParameters());
+		NVSDK_NGX_Handle* dlssFeature(upscalerImpl.getFeature());
+		const NVSDK_NGX_Result result =
+			NGX_VULKAN_EVALUATE_DLSS_EXT(m_handle, dlssFeature, dlssParameters, &vkDlssEvalParams);
+		getGrManagerImpl().endMarker(m_handle);
+
+		if(NVSDK_NGX_FAILED(result))
+		{
+			ANKI_LOGE("Failed to NVSDK_NGX_VULKAN_EvaluateFeature for DLSS, code = 0x%08x, info: %ls", result,
+					  GetNGXResultAsString(result));
+		}
+	}
+#endif
 }
 }
 
 
 } // end namespace anki
 } // end namespace anki

+ 4 - 3
AnKi/Gr/Vulkan/CommandBufferImpl.h

@@ -396,9 +396,10 @@ public:
 
 
 	void buildAccelerationStructureInternal(const AccelerationStructurePtr& as);
 	void buildAccelerationStructureInternal(const AccelerationStructurePtr& as);
 
 
-	void upscaleInternal(const GrUpscalerPtr& upscaler, const TextureViewPtr& srcRt, const TextureViewPtr& dstRt,
-						 const TextureViewPtr& mvRt, const TextureViewPtr& depthRt, const TextureViewPtr& exposure,
-						 const Bool resetAccumulation, const Vec2& jitterOffset, const Vec2& mVScale);
+	void upscaleInternal(const GrUpscalerPtr& upscaler, const TextureViewPtr& inColor,
+						 const TextureViewPtr& outUpscaledColor, const TextureViewPtr& motionVectors,
+						 const TextureViewPtr& depth, const TextureViewPtr& exposure, const Bool resetAccumulation,
+						 const Vec2& jitterOffset, const Vec2& motionVectorsScale);
 
 
 	void setPushConstantsInternal(const void* data, U32 dataSize);
 	void setPushConstantsInternal(const void* data, U32 dataSize);
 
 

+ 2 - 2
AnKi/Gr/Vulkan/GrManagerImpl.cpp

@@ -548,10 +548,10 @@ Error GrManagerImpl::initInstance()
 #endif
 #endif
 
 
 	// DLSS checks
 	// DLSS checks
-#ifdef DLSS_SUPPORT
+#ifdef ANKI_DLSS
 	if(m_capabilities.m_gpuVendor == GpuVendor::NVIDIA)
 	if(m_capabilities.m_gpuVendor == GpuVendor::NVIDIA)
 	{
 	{
-		m_capabilities.m_dlssSupport = true;
+		m_capabilities.m_dlss = true;
 	}
 	}
 #endif
 #endif
 
 

+ 3 - 5
AnKi/Gr/Vulkan/GrUpscaler.cpp

@@ -6,7 +6,6 @@
 #include <AnKi/Gr/GrUpscaler.h>
 #include <AnKi/Gr/GrUpscaler.h>
 #include <AnKi/Gr/GrManager.h>
 #include <AnKi/Gr/GrManager.h>
 #include <AnKi/Gr/Texture.h>
 #include <AnKi/Gr/Texture.h>
-#include <AnKi/Gr/CommandBuffer.h>
 #include <AnKi/Gr/Vulkan/GrUpscalerImpl.h>
 #include <AnKi/Gr/Vulkan/GrUpscalerImpl.h>
 
 
 namespace anki {
 namespace anki {
@@ -24,12 +23,11 @@ GrUpscaler* GrUpscaler::newInstance(GrManager* manager, const GrUpscalerInitInfo
 	return impl;
 	return impl;
 }
 }
 
 
-void GrUpscaler::upscale(CommandBufferPtr cmdb, const TextureViewPtr& srcRt, const TextureViewPtr& dstRt,
-						 const TextureViewPtr& mvRt, const TextureViewPtr& depthRt, const TextureViewPtr& exposure,
-						 const Bool resetAccumulation, const Vec2& jitterOffset, const Vec2& mVScale)
+Error GrUpscaler::init(const GrUpscalerInitInfo& init)
 {
 {
+	m_initInfo = init;
 	ANKI_VK_SELF(GrUpscalerImpl);
 	ANKI_VK_SELF(GrUpscalerImpl);
-	self.upscale(cmdb, srcRt, dstRt, mvRt, depthRt, exposure, resetAccumulation, jitterOffset, mVScale);
+	return self.initInternal();
 }
 }
 
 
 } // end namespace anki
 } // end namespace anki

+ 5 - 77
AnKi/Gr/Vulkan/GrUpscalerImpl.cpp

@@ -35,11 +35,9 @@ GrUpscalerImpl::~GrUpscalerImpl()
 	shutdown();
 	shutdown();
 }
 }
 
 
-Error GrUpscalerImpl::init(const GrUpscalerInitInfo& init)
+Error GrUpscalerImpl::initInternal()
 {
 {
-	m_initInfo = init;
-
-	if(init.m_type != UpscalerType::DLSS_2)
+	if(m_initInfo.m_upscalerType != UpscalerType::DLSS_2)
 	{
 	{
 		ANKI_LOGE("Currently only DLSS supported");
 		ANKI_LOGE("Currently only DLSS supported");
 		return Error::FUNCTION_FAILED;
 		return Error::FUNCTION_FAILED;
@@ -47,78 +45,6 @@ Error GrUpscalerImpl::init(const GrUpscalerInitInfo& init)
 	return initAsDLSS();
 	return initAsDLSS();
 }
 }
 
 
-static NVSDK_NGX_Resource_VK getNGXResourceFromAnkiTexture(const TextureViewImpl& tex, Bool isUAV)
-{
-	NVSDK_NGX_Resource_VK resourceVK = {};
-	VkImageView imageView = tex.getHandle();
-	VkFormat format = convertFormat(tex.getTextureImpl().getFormat());
-	VkImage image = tex.getTextureImpl().m_imageHandle;
-	VkImageSubresourceRange subresourceRange = tex.getVkImageSubresourceRange();
-
-	return NVSDK_NGX_Create_ImageView_Resource_VK(imageView, image, subresourceRange, format,
-												  tex.getTextureImpl().getWidth(), tex.getTextureImpl().getHeight(),
-												  isUAV);
-}
-
-void GrUpscalerImpl::upscale(CommandBufferPtr cmdb, const TextureViewPtr& srcRt, const TextureViewPtr& dstRt,
-							 const TextureViewPtr& mvRt, const TextureViewPtr& depthRt, const TextureViewPtr& exposure,
-							 const Bool resetAccumulation, const Vec2& jitterOffset, const Vec2& mVScale)
-{
-	if(!isNgxInitialized())
-	{
-		ANKI_VK_LOGE("Attempt to upscale an image without NGX being initialized.");
-		return;
-	}
-
-	const TextureViewImpl& srcViewImpl = static_cast<const TextureViewImpl&>(*srcRt);
-	const TextureViewImpl& dstViewImpl = static_cast<const TextureViewImpl&>(*dstRt);
-	const TextureViewImpl& mvViewImpl = static_cast<const TextureViewImpl&>(*mvRt);
-	const TextureViewImpl& depthViewImpl = static_cast<const TextureViewImpl&>(*depthRt);
-	const TextureViewImpl& exposureViewImpl = static_cast<const TextureViewImpl&>(*exposure);
-
-	NVSDK_NGX_Resource_VK srcResVk = getNGXResourceFromAnkiTexture(srcViewImpl, false);
-	NVSDK_NGX_Resource_VK dstResVk = getNGXResourceFromAnkiTexture(dstViewImpl, true);
-	NVSDK_NGX_Resource_VK mvResVk = getNGXResourceFromAnkiTexture(mvViewImpl, false);
-	NVSDK_NGX_Resource_VK depthResVk = getNGXResourceFromAnkiTexture(depthViewImpl, false);
-	NVSDK_NGX_Resource_VK exposureResVk = getNGXResourceFromAnkiTexture(exposureViewImpl, true);
-
-	NVSDK_NGX_Coordinates renderingOffset = {0, 0};
-	NVSDK_NGX_Dimensions renderingSize = {srcViewImpl.getTextureImpl().getWidth(),
-										  srcViewImpl.getTextureImpl().getHeight()};
-
-	NVSDK_NGX_VK_DLSS_Eval_Params vkDlssEvalParams;
-	memset(&vkDlssEvalParams, 0, sizeof(vkDlssEvalParams));
-	vkDlssEvalParams.Feature.pInColor = &srcResVk;
-	vkDlssEvalParams.Feature.pInOutput = &dstResVk;
-	vkDlssEvalParams.pInDepth = &depthResVk;
-	vkDlssEvalParams.pInMotionVectors = &mvResVk;
-	vkDlssEvalParams.pInExposureTexture = &exposureResVk;
-	vkDlssEvalParams.InJitterOffsetX = jitterOffset.x();
-	vkDlssEvalParams.InJitterOffsetY = jitterOffset.y();
-	vkDlssEvalParams.Feature.InSharpness = m_recommendedSettings.m_recommendedSharpness;
-	vkDlssEvalParams.InReset = resetAccumulation;
-	vkDlssEvalParams.InMVScaleX = mVScale.x();
-	vkDlssEvalParams.InMVScaleY = mVScale.y();
-	vkDlssEvalParams.InColorSubrectBase = renderingOffset;
-	vkDlssEvalParams.InDepthSubrectBase = renderingOffset;
-	vkDlssEvalParams.InTranslucencySubrectBase = renderingOffset;
-	vkDlssEvalParams.InMVSubrectBase = renderingOffset;
-	vkDlssEvalParams.InRenderSubrectDimensions = renderingSize;
-
-	CommandBufferImpl& cmdbImpl = static_cast<CommandBufferImpl&>(*cmdb);
-
-	getGrManagerImpl().beginMarker(cmdbImpl.getHandle(), "DLSS");
-	NVSDK_NGX_Result result =
-		NGX_VULKAN_EVALUATE_DLSS_EXT(cmdbImpl.getHandle(), m_dlssFeature, m_ngxParameters, &vkDlssEvalParams);
-	getGrManagerImpl().endMarker(cmdbImpl.getHandle());
-
-	if(NVSDK_NGX_FAILED(result))
-	{
-		ANKI_LOGE("Failed to NVSDK_NGX_VULKAN_EvaluateFeature for DLSS, code = 0x%08x, info: %ls", result,
-				  GetNGXResultAsString(result));
-	}
-}
-
 void GrUpscalerImpl::shutdown()
 void GrUpscalerImpl::shutdown()
 {
 {
 	shutdownDLSS();
 	shutdownDLSS();
@@ -224,7 +150,9 @@ Error GrUpscalerImpl::initAsDLSS()
 	}
 	}
 
 
 	// Create the feature
 	// Create the feature
-	if(createDLSSFeature(m_initInfo.m_srcRes, m_initInfo.m_dstRes, m_initInfo.m_dlssInitInfo.m_mode) != Error::NONE)
+	if(createDLSSFeature(m_initInfo.m_sourceImageResolution, m_initInfo.m_targetImageResolution,
+						 m_initInfo.m_dlssInitInfo.m_mode)
+	   != Error::NONE)
 	{
 	{
 		ANKI_VK_LOGE("Failed to create DLSS feature");
 		ANKI_VK_LOGE("Failed to create DLSS feature");
 		shutdown();
 		shutdown();

+ 20 - 6
AnKi/Gr/Vulkan/GrUpscalerImpl.h

@@ -41,16 +41,32 @@ public:
 
 
 	~GrUpscalerImpl();
 	~GrUpscalerImpl();
 
 
-	[[nodiscard]] Error init(const GrUpscalerInitInfo& init);
+	[[nodiscard]] Error initInternal();
 
 
 	Bool isNgxInitialized() const
 	Bool isNgxInitialized() const
 	{
 	{
 		return m_ngxInitialized;
 		return m_ngxInitialized;
 	}
 	}
 
 
-	void upscale(CommandBufferPtr cmdb, const TextureViewPtr& srcRt, const TextureViewPtr& dstRt,
-				 const TextureViewPtr& mvRt, const TextureViewPtr& depthRt, const TextureViewPtr& exposure,
-				 const Bool resetAccumulation, const Vec2& jitterOffset, const Vec2& mVScale);
+	/// @name DLSS data accessors
+	/// @{
+
+	NVSDK_NGX_Parameter* getParameters() const
+	{
+		return m_ngxParameters;
+	}
+
+	NVSDK_NGX_Handle* getFeature() const
+	{
+		return m_dlssFeature;
+	}
+
+	const DLSSRecommendedSettings& getRecommendedSettings() const
+	{
+		return m_recommendedSettings;
+	}
+
+	/// @}
 
 
 private:
 private:
 	Error initAsDLSS();
 	Error initAsDLSS();
@@ -66,8 +82,6 @@ private:
 	Error queryOptimalSettings(const UVec2& displayRes, const DLSSQualityMode mode,
 	Error queryOptimalSettings(const UVec2& displayRes, const DLSSQualityMode mode,
 							   DLSSRecommendedSettings* outRecommendedSettings);
 							   DLSSRecommendedSettings* outRecommendedSettings);
 
 
-	GrUpscalerInitInfo m_initInfo;
-
 	// DLSS related
 	// DLSS related
 	Bool m_ngxInitialized;
 	Bool m_ngxInitialized;
 	NVSDK_NGX_Parameter* m_ngxParameters;
 	NVSDK_NGX_Parameter* m_ngxParameters;

+ 1 - 8
AnKi/Gr/Vulkan/GrUpscalerImplDummy.cpp

@@ -15,16 +15,9 @@ GrUpscalerImpl::~GrUpscalerImpl()
 	// TODO:
 	// TODO:
 }
 }
 
 
-Error GrUpscalerImpl::init(const GrUpscalerInitInfo& init)
+Error GrUpscalerImpl::initInternal()
 {
 {
 	return Error::NONE;
 	return Error::NONE;
 }
 }
 
 
-void GrUpscalerImpl::upscale(CommandBufferPtr cmdb, const TextureViewPtr& srcRt, const TextureViewPtr& dstRt,
-							 const TextureViewPtr& mvRt, const TextureViewPtr& depthRt, const TextureViewPtr& exposure,
-							 const Bool resetAccumulation, const Vec2& jitterOffset, const Vec2& mVScale)
-{
-	ANKI_VK_LOGE("Trying to use DLSS when not supported");
-}
-
 } // end namespace anki
 } // end namespace anki

+ 1 - 1
AnKi/Renderer/Renderer.cpp

@@ -63,7 +63,7 @@ Renderer::~Renderer()
 Bool Renderer::getUsingDLSS() const
 Bool Renderer::getUsingDLSS() const
 {
 {
 	Bool needsScaling = getPostProcessResolution() != getInternalResolution();
 	Bool needsScaling = getPostProcessResolution() != getInternalResolution();
-	return needsScaling && (getConfig().getRDlss() != 0) && m_gr->getDeviceCapabilities().m_dlssSupport;
+	return needsScaling && (getConfig().getRDlss() != 0) && m_gr->getDeviceCapabilities().m_dlss;
 }
 }
 
 
 Error Renderer::init(ThreadHive* hive, ResourceManager* resources, GrManager* gl, StagingGpuMemoryPool* stagingMem,
 Error Renderer::init(ThreadHive* hive, ResourceManager* resources, GrManager* gl, StagingGpuMemoryPool* stagingMem,

+ 7 - 5
CMakeLists.txt

@@ -35,7 +35,7 @@ macro(anki_new_executable)
 endmacro()
 endmacro()
 
 
 macro(add_AnkiNgx_dependencies)
 macro(add_AnkiNgx_dependencies)
-    if(DLSS_SUPPORT)
+    if(ANKI_DLSS)
         # Copy required DLLs
         # Copy required DLLs
         get_target_property(lib_type AnkiNgx TYPE)
         get_target_property(lib_type AnkiNgx TYPE)
         if ("${lib_type}" STREQUAL "SHARED_LIBRARY")
         if ("${lib_type}" STREQUAL "SHARED_LIBRARY")
@@ -46,7 +46,7 @@ macro(add_AnkiNgx_dependencies)
             STRING(REGEX REPLACE "\\\\" "/" ANKINGX_DLL ${ANKINGX_DLL})
             STRING(REGEX REPLACE "\\\\" "/" ANKINGX_DLL ${ANKINGX_DLL})
             install(FILES ${ANKINGX_DLL} DESTINATION ${CMAKE_INSTALL_BINDIR})
             install(FILES ${ANKINGX_DLL} DESTINATION ${CMAKE_INSTALL_BINDIR})
         else()
         else()
-            get_property(__NGX_DLLS_LIST TARGET AnkiNgx PROPERTY EXTRA_DLLS)
+            get_property(__NGX_DLLS_LIST TARGET AnkiNgx PROPERTY ANKINGX_EXTRA_DLLS)
             foreach(dll_path ${__NGX_DLLS_LIST})
             foreach(dll_path ${__NGX_DLLS_LIST})
                 file(GLOB dll_files "${dll_path}")
                 file(GLOB dll_files "${dll_path}")
                 foreach(dll_file ${dll_files})
                 foreach(dll_file ${dll_files})
@@ -155,6 +155,7 @@ option(ANKI_ADDRESS_SANITIZER "Enable address sanitizer (-fsanitize=address)" OF
 option(ANKI_HEADLESS "Build a headless application" OFF)
 option(ANKI_HEADLESS "Build a headless application" OFF)
 option(ANKI_SHADER_FULL_PRECISION "Build shaders with full precision" OFF)
 option(ANKI_SHADER_FULL_PRECISION "Build shaders with full precision" OFF)
 set(ANKI_OVERRIDE_SHADER_COMPILER "" CACHE FILEPATH "Set the ShaderCompiler to be used to compile all shaders")
 set(ANKI_OVERRIDE_SHADER_COMPILER "" CACHE FILEPATH "Set the ShaderCompiler to be used to compile all shaders")
+option(ANKI_DLSS "Integrate DLSS if supported" ON)
 
 
 # Take a wild guess on the windowing system
 # Take a wild guess on the windowing system
 if(ANKI_HEADLESS)
 if(ANKI_HEADLESS)
@@ -322,10 +323,11 @@ if(ANDROID)
 endif()
 endif()
 
 
 # DLSS
 # DLSS
-if((LINUX OR WINDOWS) AND VULKAN)
-	add_compile_definitions(DLSS_SUPPORT=1)
-	set(DLSS_SUPPORT TRUE)
+if(ANKI_DLSS AND (LINUX OR WINDOWS) AND VULKAN)
+	set(_ANKI_ENABLE_DLSS 1)
 	add_subdirectory(ThirdParty/nvngx_dlss_sdk)
 	add_subdirectory(ThirdParty/nvngx_dlss_sdk)
+elseif(ANKI_DLSS)
+	set(ANKI_DLSS OFF)
 endif()
 endif()
 
 
 ################################################################################
 ################################################################################

+ 0 - 27
CMakeSettings.json

@@ -1,27 +0,0 @@
-{
-  "configurations": [
-    {
-      "name": "x64-Debug",
-      "generator": "Ninja",
-      "configurationType": "Debug",
-      "inheritEnvironments": [ "msvc_x64_x64" ],
-      "buildRoot": "${projectDir}\\out\\build\\${name}",
-      "installRoot": "${projectDir}\\out\\install\\${name}",
-      "cmakeCommandArgs": "",
-      "buildCommandArgs": "",
-      "ctestCommandArgs": ""
-    },
-    {
-      "name": "x64-Release",
-      "generator": "Ninja",
-      "configurationType": "RelWithDebInfo",
-      "buildRoot": "${projectDir}\\out\\build\\${name}",
-      "installRoot": "${projectDir}\\out\\install\\${name}",
-      "cmakeCommandArgs": "",
-      "buildCommandArgs": "",
-      "ctestCommandArgs": "",
-      "inheritEnvironments": [ "msvc_x64_x64" ],
-      "variables": []
-    }
-  ]
-}

+ 9 - 10
ThirdParty/nvngx_dlss_sdk/CMakeLists.txt

@@ -1,30 +1,29 @@
 # Create AnkiNgx
 # Create AnkiNgx
-if(DLSS_SUPPORT)
+if(ANKI_DLSS)
     set(NGX_SDK_ROOT "${CMAKE_CURRENT_LIST_DIR}/sdk")
     set(NGX_SDK_ROOT "${CMAKE_CURRENT_LIST_DIR}/sdk")
-
-    if (WIN32)
+    # Only Linux and Windows support working with Nvidia SDK (NGX)
+    if (WINDOWS)
         add_library(AnkiNgx IMPORTED SHARED GLOBAL)
         add_library(AnkiNgx IMPORTED SHARED GLOBAL)
         set_property(TARGET AnkiNgx APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
         set_property(TARGET AnkiNgx APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
         set_property(TARGET AnkiNgx APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
         set_property(TARGET AnkiNgx APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
-        set_target_properties(AnkiNgx PROPERTIES IMPORTED_IMPLIB_DEBUG ${NGX_SDK_ROOT}/lib/Windows_x86_64/x86_64/nvsdk_ngx_d.lib)
+        set_target_properties(AnkiNgx PROPERTIES IMPORTED_IMPLIB_DEBUG ${NGX_SDK_ROOT}/lib/Windows_x86_64/x86_64/nvsdk_ngx_d_dbg.lib)
         set_target_properties(AnkiNgx PROPERTIES IMPORTED_IMPLIB_RELEASE ${NGX_SDK_ROOT}/lib/Windows_x86_64/x86_64/nvsdk_ngx_d.lib)
         set_target_properties(AnkiNgx PROPERTIES IMPORTED_IMPLIB_RELEASE ${NGX_SDK_ROOT}/lib/Windows_x86_64/x86_64/nvsdk_ngx_d.lib)
         set_target_properties(AnkiNgx PROPERTIES
         set_target_properties(AnkiNgx PROPERTIES
             MAP_IMPORTED_CONFIG_MINSIZEREL Release
             MAP_IMPORTED_CONFIG_MINSIZEREL Release
             MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release
             MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release
         )
         )
         set_target_properties(AnkiNgx PROPERTIES IMPORTED_LOCATION "${NGX_SDK_ROOT}/lib/Windows_x86_64/rel/nvngx_dlss.dll")
         set_target_properties(AnkiNgx PROPERTIES IMPORTED_LOCATION "${NGX_SDK_ROOT}/lib/Windows_x86_64/rel/nvngx_dlss.dll")
-    else ()
+    elseif (LINUX)
         add_library(AnkiNgx IMPORTED STATIC GLOBAL)
         add_library(AnkiNgx IMPORTED STATIC GLOBAL)
-
         set_property(TARGET AnkiNgx APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
         set_property(TARGET AnkiNgx APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
         set_property(TARGET AnkiNgx APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
         set_property(TARGET AnkiNgx APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
-        set_target_properties(AnkiNgx PROPERTIES IMPORTED_LOCATION ${NGX_SDK_ROOT}/lib/Linux_x86_64/libnvsdk_ngx.a)
-
+        set_property(TARGET AnkiNgx PROPERTY IMPORTED_LOCATION ${NGX_SDK_ROOT}/lib/Linux_x86_64/libnvsdk_ngx.a)
         # set the list of DLLs that need copying to target folder of application
         # set the list of DLLs that need copying to target folder of application
         set(__NGX_DLLS_LIST "${NGX_SDK_ROOT}/lib/Linux_x86_64/rel/libnvidia-ngx-*.so.*")
         set(__NGX_DLLS_LIST "${NGX_SDK_ROOT}/lib/Linux_x86_64/rel/libnvidia-ngx-*.so.*")
+    else()
+		message(FATAL_ERROR "Trying to use NGX for invalid platform")
     endif()
     endif()
 
 
-    set_property(TARGET AnkiNgx APPEND PROPERTY EXTRA_DLLS "${__NGX_DLLS_LIST}")
-
+    set_property(TARGET AnkiNgx APPEND PROPERTY ANKINGX_EXTRA_DLLS "${__NGX_DLLS_LIST}")
     target_include_directories(AnkiNgx INTERFACE ${NGX_SDK_ROOT}/include)
     target_include_directories(AnkiNgx INTERFACE ${NGX_SDK_ROOT}/include)
 endif()
 endif()

BIN
ThirdParty/nvngx_dlss_sdk/sdk/lib/Windows_x86_64/x86_64/nvsdk_ngx_d_dbg.lib