Adds everything

This commit is contained in:
2022-09-18 00:48:56 +02:00
parent da7398c21e
commit 2f879fc333
4928 changed files with 25215 additions and 60 deletions

View File

@@ -0,0 +1,437 @@
/*
* Copyright (c) 2018 NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property and proprietary
* rights in and to this software, related documentation and any modifications thereto.
* Any use, reproduction, disclosure or distribution of this software and related
* documentation without an express license agreement from NVIDIA Corporation is strictly
* prohibited.
*
* TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
* INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
* SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
* BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
* INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES.
*/
/*
* HOW TO USE:
*
* IMPORTANT: FOR DLSS/DLISP PLEASE SEE THE PROGRAMMING GUIDE
*
* IMPORTANT: Methods in this library are NOT thread safe. It is up to the
* client to ensure that thread safety is enforced as needed.
*
* 1) Call NVSDK_CONV NVSDK_NGX_D3D11/D3D12/CUDA_Init and pass your app Id
* and other parameters. This will initialize SDK or return an error code
* if SDK cannot run on target machine. Depending on error user might
* need to update drivers. Please note that application Id is provided
* by NVIDIA so if you do not have one please contact us.
*
* 2) Call NVSDK_NGX_D3D11/D3D12/CUDA_GetParameters to obtain pointer to
* interface used to pass parameters to SDK. Interface instance is
* allocated and released by SDK so there is no need to do any memory
* management on client side.
*
* 3) Set key parameters for the feature you want to use. For example,
* width and height are required for all features and they can be
* set like this:
* Params->Set(NVSDK_NGX_Parameter_Width,MY_WIDTH);
* Params->Set(NVSDK_NGX_Parameter_Height,MY_HEIGHT);
*
* You can also provide hints like NVSDK_NGX_Parameter_Hint_HDR to tell
* SDK that it should expect HDR color space is needed. Please refer to
* samples since different features need different parameters and hints.
*
* 4) Call NVSDK_NGX_D3D11/D3D12/CUDA_GetScratchBufferSize to obtain size of
* the scratch buffer needed by specific feature. This D3D or CUDA buffer
* should be allocated by client and passed as:
* Params->Set(NVSDK_NGX_Parameter_Scratch,MY_SCRATCH_POINTER)
* Params->Set(NVSDK_NGX_Parameter_Scratch_SizeInBytes,MY_SCRATCH_SIZE_IN_BYTES)
* NOTE: Returned size can be 0 if feature does not use any scratch buffer.
* It is OK to use bigger buffer or reuse buffers across features as long
* as minimum size requirement is met.
*
* 5) Call NVSDK_NGX_D3D11/D3D12/CUDA_CreateFeature to create feature you need.
* On success SDK will return a handle which must be used in any successive
* calls to SDK which require feature handle. SDK will use all parameters
* and hints provided by client to generate feature. If feature with the same
* parameters already exists and error code will be returned.
*
* 6) Call NVSDK_NGX_D3D11/D3D12/CUDA_EvaluateFeature to invoke execution of
* specific feature. Before feature can be evaluated input parameters must
* be specified (like for example color/albedo buffer, motion vectors etc)
*
* 6) Call NVSDK_NGX_D3D11/D3D12/CUDA_ReleaseFeature when feature is no longer
* needed. After this call feature handle becomes invalid and cannot be used.
*
* 7) Call NVSDK_NGX_D3D11/D3D12/CUDA_Shutdown when SDK is no longer needed to
* release all resources.
* Contact: ngxsupport@nvidia.com
*/
#ifndef NVSDK_NGX_H
#define NVSDK_NGX_H
#include <stddef.h> // For size_t
#include "nvsdk_ngx_defs.h"
#include "nvsdk_ngx_params.h"
#ifndef __cplusplus
#include <stdbool.h>
#include <wchar.h>
#endif
#ifdef __cplusplus
extern "C"
{
#endif
typedef struct IUnknown IUnknown;
typedef struct ID3D11Device ID3D11Device;
typedef struct ID3D11Resource ID3D11Resource;
typedef struct ID3D11DeviceContext ID3D11DeviceContext;
typedef struct D3D11_TEXTURE2D_DESC D3D11_TEXTURE2D_DESC;
typedef struct D3D11_BUFFER_DESC D3D11_BUFFER_DESC;
typedef struct ID3D11Buffer ID3D11Buffer;
typedef struct ID3D11Texture2D ID3D11Texture2D;
typedef struct ID3D12Device ID3D12Device;
typedef struct ID3D12Resource ID3D12Resource;
typedef struct ID3D12GraphicsCommandList ID3D12GraphicsCommandList;
typedef struct D3D12_RESOURCE_DESC D3D12_RESOURCE_DESC;
typedef struct CD3DX12_HEAP_PROPERTIES CD3DX12_HEAP_PROPERTIES;
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_D3D12_ResourceAllocCallback)(D3D12_RESOURCE_DESC *InDesc, int InState, CD3DX12_HEAP_PROPERTIES *InHeap, ID3D12Resource **OutResource);
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_D3D11_BufferAllocCallback)(D3D11_BUFFER_DESC *InDesc, ID3D11Buffer **OutResource);
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_D3D11_Tex2DAllocCallback)(D3D11_TEXTURE2D_DESC *InDesc, ID3D11Texture2D **OutResource);
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_ResourceReleaseCallback)(IUnknown *InResource);
typedef unsigned long long CUtexObject;
///////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_Init
// -------------------------------------
//
// InApplicationId:
// Unique Id provided by NVIDIA
//
// InApplicationDataPath:
// Folder to store logs and other temporary files (write access required),
// Normally this would be a location in Documents or ProgramData.
//
// InDevice: [d3d11/12 only]
// DirectX device to use
//
// InFeatureInfo:
// Contains information common to all features, presently only a list of all paths
// feature dlls can be located in, other than the default path - application directory.
//
// DESCRIPTION:
// Initializes new SDK instance.
//
#ifdef __cplusplus
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_Init(unsigned long long InApplicationId, const wchar_t *InApplicationDataPath, ID3D11Device *InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo = nullptr, NVSDK_NGX_Version InSDKVersion = NVSDK_NGX_Version_API);
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_Init(unsigned long long InApplicationId, const wchar_t *InApplicationDataPath, ID3D12Device *InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo = nullptr, NVSDK_NGX_Version InSDKVersion = NVSDK_NGX_Version_API);
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_Init(unsigned long long InApplicationId, const wchar_t *InApplicationDataPath, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo = nullptr, NVSDK_NGX_Version InSDKVersion = NVSDK_NGX_Version_API);
#else
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_Init(unsigned long long InApplicationId, const wchar_t *InApplicationDataPath, ID3D11Device *InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_Init(unsigned long long InApplicationId, const wchar_t *InApplicationDataPath, ID3D12Device *InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_Init(unsigned long long InApplicationId, const wchar_t *InApplicationDataPath, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
#endif
///////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_Init_with_ProjectID
// -------------------------------------
//
// InProjectId:
// Unique Id provided by the rendering engine used
//
// InEngineType:
// Rendering engine used by the application / plugin.
// Use NVSDK_NGX_ENGINE_TYPE_CUSTOM if the specific engine type is not supported explicitly
//
// InEngineVersion:
// Version number of the rendering engine used by the application / plugin.
//
// InApplicationDataPath:
// Folder to store logs and other temporary files (write access required),
// Normally this would be a location in Documents or ProgramData.
//
// InDevice: [d3d11/12 only]
// DirectX device to use
//
// InFeatureInfo:
// Contains information common to all features, presently only a list of all paths
// feature dlls can be located in, other than the default path - application directory.
//
// DESCRIPTION:
// Initializes new SDK instance.
//
#ifdef __cplusplus
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_Init_with_ProjectID(const char *InProjectId, NVSDK_NGX_EngineType InEngineType, const char *InEngineVersion, const wchar_t *InApplicationDataPath, ID3D11Device *InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo = nullptr, NVSDK_NGX_Version InSDKVersion = NVSDK_NGX_Version_API);
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_Init_with_ProjectID(const char *InProjectId, NVSDK_NGX_EngineType InEngineType, const char *InEngineVersion, const wchar_t *InApplicationDataPath, ID3D12Device *InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo = nullptr, NVSDK_NGX_Version InSDKVersion = NVSDK_NGX_Version_API);
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_Init_with_ProjectID(const char *InProjectId, NVSDK_NGX_EngineType InEngineType, const char *InEngineVersion, const wchar_t *InApplicationDataPath, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo = nullptr, NVSDK_NGX_Version InSDKVersion = NVSDK_NGX_Version_API);
#else
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_Init_with_ProjectID(const char *InProjectId, NVSDK_NGX_EngineType InEngineType, const char *InEngineVersion, const wchar_t *InApplicationDataPath, ID3D11Device *InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_Init_with_ProjectID(const char *InProjectId, NVSDK_NGX_EngineType InEngineType, const char *InEngineVersion, const wchar_t *InApplicationDataPath, ID3D12Device *InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_Init_with_ProjectID(const char *InProjectId, NVSDK_NGX_EngineType InEngineType, const char *InEngineVersion, const wchar_t *InApplicationDataPath, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_Shutdown
// -------------------------------------
//
// DESCRIPTION:
// Shuts down the current SDK instance and releases all resources.
// Shutdown1(Device) only affects specified device
// Shutdown1(nullptr) = Shutdown() and shuts down all devices
//
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_Shutdown(void);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_Shutdown1(ID3D11Device *InDevice);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_Shutdown(void);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_Shutdown1(ID3D12Device *InDevice);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_Shutdown(void);
////////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_GetParameters
// ----------------------------------------------------------
//
// OutParameters:
// Parameters interface used to set any parameter needed by the SDK
//
// DESCRIPTION:
// This interface allows simple parameter setup using named fields.
// For example one can set width by calling Set(NVSDK_NGX_Parameter_Denoiser_Width,100) or
// provide CUDA buffer pointer by calling Set(NVSDK_NGX_Parameter_Denoiser_Color,cudaBuffer)
// For more details please see sample code. Please note that allocated memory
// will be freed by NGX so free/delete operator should NOT be called.
// Parameter maps output by NVSDK_NGX_GetParameters are also pre-populated
// with NGX capabilities and available features.
// Unlike with NVSDK_NGX_AllocateParameters, parameter maps output by NVSDK_NGX_GetParameters
// have their lifetimes managed by NGX, and must not
// be destroyed by the app using NVSDK_NGX_DestroyParameters.
// NVSDK_NGX_GetParameters is soon to be deprecated and apps should move to using
// NVSDK_NGX_AllocateParameters and NVSDK_NGX_GetCapabilityParameters when possible.
// Nevertheless, due to the possibility that the user will be using an older driver version,
// NVSDK_NGX_GetParameters should still be used as a fallback if NVSDK_NGX_AllocateParameters
// or NVSDK_NGX_GetCapabilityParameters return NVSDK_NGX_Result_FAIL_OutOfDate.
//
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_GetParameters(NVSDK_NGX_Parameter **OutParameters);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_GetParameters(NVSDK_NGX_Parameter **OutParameters);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_GetParameters(NVSDK_NGX_Parameter **OutParameters);
////////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_AllocateParameters
// ----------------------------------------------------------
//
// OutParameters:
// Parameters interface used to set any parameter needed by the SDK
//
// DESCRIPTION:
// This interface allows allocating a simple parameter setup using named fields, whose
// lifetime the app must manage.
// For example one can set width by calling Set(NVSDK_NGX_Parameter_Denoiser_Width,100) or
// provide CUDA buffer pointer by calling Set(NVSDK_NGX_Parameter_Denoiser_Color,cudaBuffer)
// For more details please see sample code.
// Parameter maps output by NVSDK_NGX_AllocateParameters must NOT be freed using
// the free/delete operator; to free a parameter map
// output by NVSDK_NGX_AllocateParameters, NVSDK_NGX_DestroyParameters should be used.
// Unlike with NVSDK_NGX_GetParameters, parameter maps allocated with NVSDK_NGX_AllocateParameters
// must be destroyed by the app using NVSDK_NGX_DestroyParameters.
// Also unlike with NVSDK_NGX_GetParameters, parameter maps output by NVSDK_NGX_AllocateParameters
// do not come pre-populated with NGX capabilities and available features.
// To create a new parameter map pre-populated with such information, NVSDK_NGX_GetCapabilityParameters
// should be used.
// This function may return NVSDK_NGX_Result_FAIL_OutOfDate if an older driver, which
// does not support this API call is being used. In such a case, NVSDK_NGX_GetParameters
// may be used as a fallback.
// This function may only be called after a successful call into NVSDK_NGX_Init.
//
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_AllocateParameters(NVSDK_NGX_Parameter** OutParameters);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_AllocateParameters(NVSDK_NGX_Parameter** OutParameters);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_AllocateParameters(NVSDK_NGX_Parameter** OutParameters);
////////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_GetCapabilityParameters
// ----------------------------------------------------------
//
// OutParameters:
// The parameters interface populated with NGX and feature capabilities
//
// DESCRIPTION:
// This interface allows the app to create a new parameter map
// pre-populated with NGX capabilities and available features.
// The output parameter map can also be used for any purpose
// parameter maps output by NVSDK_NGX_AllocateParameters can be used for
// but it is not recommended to use NVSDK_NGX_GetCapabilityParameters
// unless querying NGX capabilities and available features
// due to the overhead associated with pre-populating the parameter map.
// Parameter maps output by NVSDK_NGX_GetCapabilityParameters must NOT be freed using
// the free/delete operator; to free a parameter map
// output by NVSDK_NGX_GetCapabilityParameters, NVSDK_NGX_DestroyParameters should be used.
// Unlike with NVSDK_NGX_GetParameters, parameter maps allocated with NVSDK_NGX_GetCapabilityParameters
// must be destroyed by the app using NVSDK_NGX_DestroyParameters.
// This function may return NVSDK_NGX_Result_FAIL_OutOfDate if an older driver, which
// does not support this API call is being used. This function may only be called
// after a successful call into NVSDK_NGX_Init.
// If NVSDK_NGX_GetCapabilityParameters fails with NVSDK_NGX_Result_FAIL_OutOfDate,
// NVSDK_NGX_GetParameters may be used as a fallback, to get a parameter map pre-populated
// with NGX capabilities and available features.
//
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_GetCapabilityParameters(NVSDK_NGX_Parameter** OutParameters);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_GetCapabilityParameters(NVSDK_NGX_Parameter** OutParameters);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_GetCapabilityParameters(NVSDK_NGX_Parameter** OutParameters);
////////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_DestroyParameters
// ----------------------------------------------------------
//
// InParameters:
// The parameters interface to be destroyed
//
// DESCRIPTION:
// This interface allows the app to destroy the parameter map passed in. Once
// NVSDK_NGX_DestroyParameters is called on a parameter map, it
// must not be used again.
// NVSDK_NGX_DestroyParameters must not be called on any parameter map returned
// by NVSDK_NGX_GetParameters; NGX will manage the lifetime of those
// parameter maps.
// This function may return NVSDK_NGX_Result_FAIL_OutOfDate if an older driver, which
// does not support this API call is being used. This function may only be called
// after a successful call into NVSDK_NGX_Init.
//
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_DestroyParameters(NVSDK_NGX_Parameter* InParameters);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_DestroyParameters(NVSDK_NGX_Parameter* InParameters);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_DestroyParameters(NVSDK_NGX_Parameter* InParameters);
////////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_GetScratchBufferSize
// ----------------------------------------------------------
//
// InFeatureId:
// AI feature in question
//
// InParameters:
// Parameters used by the feature to help estimate scratch buffer size
//
// OutSizeInBytes:
// Number of bytes needed for the scratch buffer for the specified feature.
//
// DESCRIPTION:
// SDK needs a buffer of a certain size provided by the client in
// order to initialize AI feature. Once feature is no longer
// needed buffer can be released. It is safe to reuse the same
// scratch buffer for different features as long as minimum size
// requirement is met for all features. Please note that some
// features might not need a scratch buffer so return size of 0
// is completely valid.
//
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_GetScratchBufferSize(NVSDK_NGX_Feature InFeatureId, const NVSDK_NGX_Parameter *InParameters, size_t *OutSizeInBytes);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_GetScratchBufferSize(NVSDK_NGX_Feature InFeatureId, const NVSDK_NGX_Parameter *InParameters, size_t *OutSizeInBytes);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_GetScratchBufferSize(NVSDK_NGX_Feature InFeatureId, const NVSDK_NGX_Parameter *InParameters, size_t *OutSizeInBytes);
/////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_CreateFeature
// -------------------------------------
//
// InCmdList:[d3d12 only]
// Command list to use to execute GPU commands. Must be:
// - Open and recording
// - With node mask including the device provided in NVSDK_NGX_D3D12_Init
// - Execute on non-copy command queue.
// InDevCtx: [d3d11 only]
// Device context to use to execute GPU commands
//
// InFeatureID:
// AI feature to initialize
//
// InParameters:
// List of parameters
//
// OutHandle:
// Handle which uniquely identifies the feature. If feature with
// provided parameters already exists the "already exists" error code is returned.
//
// DESCRIPTION:
// Each feature needs to be created before it can be used.
// Refer to the sample code to find out which input parameters
// are needed to create specific feature.
//
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_CreateFeature(ID3D11DeviceContext *InDevCtx, NVSDK_NGX_Feature InFeatureID, const NVSDK_NGX_Parameter *InParameters, NVSDK_NGX_Handle **OutHandle);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_CreateFeature(ID3D12GraphicsCommandList *InCmdList, NVSDK_NGX_Feature InFeatureID, const NVSDK_NGX_Parameter *InParameters, NVSDK_NGX_Handle **OutHandle);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_CreateFeature(NVSDK_NGX_Feature InFeatureID, const NVSDK_NGX_Parameter *InParameters, NVSDK_NGX_Handle **OutHandle);
/////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_Release
// -------------------------------------
//
// InHandle:
// Handle to feature to be released
//
// DESCRIPTION:
// Releases feature with a given handle.
// Handles are not reference counted so
// after this call it is invalid to use provided handle.
//
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_ReleaseFeature(NVSDK_NGX_Handle *InHandle);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_ReleaseFeature(NVSDK_NGX_Handle *InHandle);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_ReleaseFeature(NVSDK_NGX_Handle *InHandle);
/////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_EvaluateFeature
// -------------------------------------
//
// InCmdList:[d3d12 only]
// Command list to use to execute GPU commands. Must be:
// - Open and recording
// - With node mask including the device provided in NVSDK_NGX_D3D12_Init
// - Execute on non-copy command queue.
// InDevCtx: [d3d11 only]
// Device context to use to execute GPU commands
//
// InFeatureHandle:
// Handle representing feature to be evaluated
//
// InParameters:
// List of parameters required to evaluate feature
//
// InCallback:
// Optional callback for features which might take longer
// to execture. If specified SDK will call it with progress
// values in range 0.0f - 1.0f
//
// DESCRIPTION:
// Evaluates given feature using the provided parameters and
// pre-trained NN. Please note that for most features
// it can be benefitials to pass as many input buffers and parameters
// as possible (for example provide all render targets like color, albedo, normals, depth etc)
//
#ifdef __cplusplus
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_ProgressCallback)(float InCurrentProgress, bool &OutShouldCancel);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_EvaluateFeature(ID3D11DeviceContext *InDevCtx, const NVSDK_NGX_Handle *InFeatureHandle, const NVSDK_NGX_Parameter *InParameters, PFN_NVSDK_NGX_ProgressCallback InCallback = NULL);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCommandList *InCmdList, const NVSDK_NGX_Handle *InFeatureHandle, const NVSDK_NGX_Parameter *InParameters, PFN_NVSDK_NGX_ProgressCallback InCallback = NULL);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_EvaluateFeature(const NVSDK_NGX_Handle *InFeatureHandle, const NVSDK_NGX_Parameter *InParameters, PFN_NVSDK_NGX_ProgressCallback InCallback = NULL);
#endif
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_ProgressCallback_C)(float InCurrentProgress, bool *OutShouldCancel);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_EvaluateFeature_C(ID3D11DeviceContext *InDevCtx, const NVSDK_NGX_Handle *InFeatureHandle, const NVSDK_NGX_Parameter *InParameters, PFN_NVSDK_NGX_ProgressCallback_C InCallback);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_EvaluateFeature_C(ID3D12GraphicsCommandList *InCmdList, const NVSDK_NGX_Handle *InFeatureHandle, const NVSDK_NGX_Parameter *InParameters, PFN_NVSDK_NGX_ProgressCallback_C InCallback);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_EvaluateFeature_C(const NVSDK_NGX_Handle *InFeatureHandle, const NVSDK_NGX_Parameter *InParameters, PFN_NVSDK_NGX_ProgressCallback_C InCallback);
// NGX return-code conversion-to-string utility only as a helper for debugging/logging - not for official use.
const wchar_t* NVSDK_CONV GetNGXResultAsString(NVSDK_NGX_Result InNGXResult);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // #define NVSDK_NGX_H

View File

@@ -0,0 +1,597 @@
/*
* Copyright (c) 2018 NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property and proprietary
* rights in and to this software, related documentation and any modifications thereto.
* Any use, reproduction, disclosure or distribution of this software and related
* documentation without an express license agreement from NVIDIA Corporation is strictly
* prohibited.
*
* TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
* INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
* SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
* BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
* INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES.
*/
#ifndef NVSDK_NGX_DEFS_H
#define NVSDK_NGX_DEFS_H
#pragma once
#ifndef __cplusplus
#include <stddef.h> // For size_t
#include <stdbool.h>
#include <wchar.h>
#endif
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef __cplusplus
#if defined(NVSDK_NGX) && defined(NV_WINDOWS)
#define NVSDK_NGX_API extern "C" __declspec(dllexport)
#else
#define NVSDK_NGX_API extern "C"
#endif
#else
#if defined(NVSDK_NGX) && defined(NV_WINDOWS)
#define NVSDK_NGX_API __declspec(dllexport)
#else
#define NVSDK_NGX_API
#endif
#endif
#ifdef __GNUC__
#define NVSDK_CONV
#else
#define NVSDK_CONV __cdecl
#endif
#define NVSDK_NGX_ARRAY_LEN(a) (sizeof(a) / sizeof((a)[0]))
// Version Notes:
// Version 0x0000014:
// * Added a logging callback that the app may pass in on init
// * Added ability for the app to override the logging level
// Version 0x0000015:
// * Support multiple GPUs (bug 3270533)
#define NVSDK_NGX_VERSION_API_MACRO 0x0000014 // NGX_VERSION_DOT 1.4.0
typedef struct NVSDK_NGX_FeatureCommonInfo_Internal NVSDK_NGX_FeatureCommonInfo_Internal;
typedef enum NVSDK_NGX_Version { NVSDK_NGX_Version_API = NVSDK_NGX_VERSION_API_MACRO } NVSDK_NGX_Version;
typedef enum NVSDK_NGX_Result
{
NVSDK_NGX_Result_Success = 0x1,
NVSDK_NGX_Result_Fail = 0xBAD00000,
// Feature is not supported on current hardware
NVSDK_NGX_Result_FAIL_FeatureNotSupported = NVSDK_NGX_Result_Fail | 1,
// Platform error - for example - check d3d12 debug layer log for more information
NVSDK_NGX_Result_FAIL_PlatformError = NVSDK_NGX_Result_Fail | 2,
// Feature with given parameters already exists
NVSDK_NGX_Result_FAIL_FeatureAlreadyExists = NVSDK_NGX_Result_Fail | 3,
// Feature with provided handle does not exist
NVSDK_NGX_Result_FAIL_FeatureNotFound = NVSDK_NGX_Result_Fail | 4,
// Invalid parameter was provided
NVSDK_NGX_Result_FAIL_InvalidParameter = NVSDK_NGX_Result_Fail | 5,
// Provided buffer is too small, please use size provided by NVSDK_NGX_GetScratchBufferSize
NVSDK_NGX_Result_FAIL_ScratchBufferTooSmall = NVSDK_NGX_Result_Fail | 6,
// SDK was not initialized properly
NVSDK_NGX_Result_FAIL_NotInitialized = NVSDK_NGX_Result_Fail | 7,
// Unsupported format used for input/output buffers
NVSDK_NGX_Result_FAIL_UnsupportedInputFormat = NVSDK_NGX_Result_Fail | 8,
// Feature input/output needs RW access (UAV) (d3d11/d3d12 specific)
NVSDK_NGX_Result_FAIL_RWFlagMissing = NVSDK_NGX_Result_Fail | 9,
// Feature was created with specific input but none is provided at evaluation
NVSDK_NGX_Result_FAIL_MissingInput = NVSDK_NGX_Result_Fail | 10,
// Feature is not available on the system
NVSDK_NGX_Result_FAIL_UnableToInitializeFeature = NVSDK_NGX_Result_Fail | 11,
// NGX system libraries are old and need an update
NVSDK_NGX_Result_FAIL_OutOfDate = NVSDK_NGX_Result_Fail | 12,
// Feature requires more GPU memory than it is available on system
NVSDK_NGX_Result_FAIL_OutOfGPUMemory = NVSDK_NGX_Result_Fail | 13,
// Format used in input buffer(s) is not supported by feature
NVSDK_NGX_Result_FAIL_UnsupportedFormat = NVSDK_NGX_Result_Fail | 14,
// Path provided in InApplicationDataPath cannot be written to
NVSDK_NGX_Result_FAIL_UnableToWriteToAppDataPath = NVSDK_NGX_Result_Fail | 15,
// Unsupported parameter was provided (e.g. specific scaling factor is unsupported)
NVSDK_NGX_Result_FAIL_UnsupportedParameter = NVSDK_NGX_Result_Fail | 16,
// The feature or application was denied (contact NVIDIA for further details)
NVSDK_NGX_Result_FAIL_Denied = NVSDK_NGX_Result_Fail | 17
} NVSDK_NGX_Result;
#define NVSDK_NGX_SUCCEED(value) (((value) & 0xFFF00000) != NVSDK_NGX_Result_Fail)
#define NVSDK_NGX_FAILED(value) (((value) & 0xFFF00000) == NVSDK_NGX_Result_Fail)
typedef enum NVSDK_NGX_Feature
{
NVSDK_NGX_Feature_Reserved0,
NVSDK_NGX_Feature_SuperSampling,
NVSDK_NGX_Feature_InPainting,
NVSDK_NGX_Feature_ImageSuperResolution,
NVSDK_NGX_Feature_SlowMotion,
NVSDK_NGX_Feature_VideoSuperResolution,
NVSDK_NGX_Feature_Reserved1,
NVSDK_NGX_Feature_Reserved2,
NVSDK_NGX_Feature_Reserved3,
NVSDK_NGX_Feature_ImageSignalProcessing,
NVSDK_NGX_Feature_DeepResolve,
NVSDK_NGX_Feature_Reserved4,
// New features go here
NVSDK_NGX_Feature_Count,
// These members are not strictly NGX features, but are
// components of the NGX system, and it may sometimes
// be useful to identify them using the same enum
NVSDK_NGX_Feature_Reserved_SDK = 32764,
NVSDK_NGX_Feature_Reserved_Core,
NVSDK_NGX_Feature_Reserved_Unknown
} NVSDK_NGX_Feature;
//TODO create grayscale format (R32F?)
typedef enum NVSDK_NGX_Buffer_Format
{
NVSDK_NGX_Buffer_Format_Unknown,
NVSDK_NGX_Buffer_Format_RGB8UI,
NVSDK_NGX_Buffer_Format_RGB16F,
NVSDK_NGX_Buffer_Format_RGB32F,
NVSDK_NGX_Buffer_Format_RGBA8UI,
NVSDK_NGX_Buffer_Format_RGBA16F,
NVSDK_NGX_Buffer_Format_RGBA32F,
} NVSDK_NGX_Buffer_Format;
typedef enum NVSDK_NGX_PerfQuality_Value
{
NVSDK_NGX_PerfQuality_Value_MaxPerf,
NVSDK_NGX_PerfQuality_Value_Balanced,
NVSDK_NGX_PerfQuality_Value_MaxQuality,
// Extended PerfQuality modes
NVSDK_NGX_PerfQuality_Value_UltraPerformance,
NVSDK_NGX_PerfQuality_Value_UltraQuality,
} NVSDK_NGX_PerfQuality_Value;
typedef enum NVSDK_NGX_RTX_Value
{
NVSDK_NGX_RTX_Value_Off,
NVSDK_NGX_RTX_Value_On,
} NVSDK_NGX_RTX_Value;
typedef enum NVSDK_NGX_DLSS_Mode
{
NVSDK_NGX_DLSS_Mode_Off, // use existing in-engine AA + upscale solution
NVSDK_NGX_DLSS_Mode_DLSS_DLISP,
NVSDK_NGX_DLSS_Mode_DLISP_Only, // use existing in-engine AA solution
NVSDK_NGX_DLSS_Mode_DLSS, // DLSS will apply AA and upsample at the same time
} NVSDK_NGX_DLSS_Mode;
typedef struct NVSDK_NGX_Handle { unsigned int Id; } NVSDK_NGX_Handle;
typedef enum NSDK_NGX_GPU_Arch
{
NVSDK_NGX_GPU_Arch_NotSupported = 0,
// Match NvAPI's NV_GPU_ARCHITECTURE_ID values for GV100 and TU100 for
// backwards compatibility with snippets built against NvAPI
NVSDK_NGX_GPU_Arch_Volta = 0x0140,
NVSDK_NGX_GPU_Arch_Turing = 0x0160,
// Presumably something newer
NVSDK_NGX_GPU_Arch_Unknown = 0x7FFFFFF
} NVSDK_NGX_GPU_Arch;
typedef enum NVSDK_NGX_DLSS_Feature_Flags
{
NVSDK_NGX_DLSS_Feature_Flags_IsInvalid = 1 << 31,
NVSDK_NGX_DLSS_Feature_Flags_None = 0,
NVSDK_NGX_DLSS_Feature_Flags_IsHDR = 1 << 0,
NVSDK_NGX_DLSS_Feature_Flags_MVLowRes = 1 << 1,
NVSDK_NGX_DLSS_Feature_Flags_MVJittered = 1 << 2,
NVSDK_NGX_DLSS_Feature_Flags_DepthInverted = 1 << 3,
NVSDK_NGX_DLSS_Feature_Flags_Reserved_0 = 1 << 4,
NVSDK_NGX_DLSS_Feature_Flags_DoSharpening = 1 << 5,
NVSDK_NGX_DLSS_Feature_Flags_AutoExposure = 1 << 6,
} NVSDK_NGX_DLSS_Feature_Flags;
typedef enum NVSDK_NGX_ToneMapperType
{
NVSDK_NGX_TONEMAPPER_STRING = 0,
NVSDK_NGX_TONEMAPPER_REINHARD,
NVSDK_NGX_TONEMAPPER_ONEOVERLUMA,
NVSDK_NGX_TONEMAPPER_ACES,
NVSDK_NGX_TONEMAPPERTYPE_NUM
} NVSDK_NGX_ToneMapperType;
typedef enum NVSDK_NGX_GBufferType
{
NVSDK_NGX_GBUFFER_ALBEDO = 0,
NVSDK_NGX_GBUFFER_ROUGHNESS,
NVSDK_NGX_GBUFFER_METALLIC,
NVSDK_NGX_GBUFFER_SPECULAR,
NVSDK_NGX_GBUFFER_SUBSURFACE,
NVSDK_NGX_GBUFFER_NORMALS,
NVSDK_NGX_GBUFFER_SHADINGMODELID, /* unique identifier for drawn object or how the object is drawn */
NVSDK_NGX_GBUFFER_MATERIALID, /* unique identifier for material */
NVSDK_NGX_GBUFFERTYPE_NUM = 16
} NVSDK_NGX_GBufferType;
typedef struct NVSDK_NGX_Coordinates
{
unsigned int X;
unsigned int Y;
} NVSDK_NGX_Coordinates;
typedef struct NVSDK_NGX_Dimensions
{
unsigned int Width;
unsigned int Height;
} NVSDK_NGX_Dimensions;
typedef struct NVSDK_NGX_PathListInfo
{
wchar_t **Path;
// Path-list length
unsigned int Length;
} NVSDK_NGX_PathListInfo;
typedef enum NVSDK_NGX_Logging_Level
{
NVSDK_NGX_LOGGING_LEVEL_OFF = 0,
NVSDK_NGX_LOGGING_LEVEL_ON,
NVSDK_NGX_LOGGING_LEVEL_VERBOSE,
NVSDK_NGX_LOGGING_LEVEL_NUM
} NVSDK_NGX_Logging_Level;
// A logging callback provided by the app to allow piping log lines back to the app.
// Please take careful note of the signature and calling convention.
// The callback must be able to be called from any thread.
// It must also be fully thread-safe and any number of threads may call into it concurrently.
// It must fully process message by the time it returns, and there is no guarantee that
// message will still be valid or allocated after it returns.
// message will be a null-terminated string and may contain multibyte characters.
#if defined(__GNUC__) || defined(__clang__)
typedef void NVSDK_CONV(*NVSDK_NGX_AppLogCallback)(const char* message, NVSDK_NGX_Logging_Level loggingLevel, NVSDK_NGX_Feature sourceComponent);
#else
typedef void(NVSDK_CONV* NVSDK_NGX_AppLogCallback)(const char* message, NVSDK_NGX_Logging_Level loggingLevel, NVSDK_NGX_Feature sourceComponent);
#endif
typedef struct NGSDK_NGX_LoggingInfo
{
// Fields below were introduced in SDK version 0x0000014
// App-provided logging callback
NVSDK_NGX_AppLogCallback LoggingCallback;
// The minimum logging level to use. If this is higher
// than the logging level otherwise configured, this will override
// that logging level. Otherwise, that logging level will be used.
NVSDK_NGX_Logging_Level MinimumLoggingLevel;
// Whether or not to disable writing log lines to sinks other than the app log callback. This
// may be useful if the app provides a logging callback. LoggingCallback must be non-null and point
// to a valid logging callback if this is set to true.
bool DisableOtherLoggingSinks;
} NGSDK_NGX_LoggingInfo;
typedef struct NVSDK_NGX_FeatureCommonInfo
{
// List of all paths in descending order of search sequence to locate a feature dll in, other than the default path - application folder.
NVSDK_NGX_PathListInfo PathListInfo;
// Used internally by NGX
NVSDK_NGX_FeatureCommonInfo_Internal* InternalData; // Introduced in SDK version 0x0000013
// Fields below were introduced in SDK version 0x0000014
NGSDK_NGX_LoggingInfo LoggingInfo;
} NVSDK_NGX_FeatureCommonInfo;
typedef enum NVSDK_NGX_Resource_VK_Type
{
NVSDK_NGX_RESOURCE_VK_TYPE_VK_IMAGEVIEW,
NVSDK_NGX_RESOURCE_VK_TYPE_VK_BUFFER
} NVSDK_NGX_Resource_VK_Type;
typedef enum NVSDK_NGX_Opt_Level
{
NVSDK_NGX_OPT_LEVEL_UNDEFINED = 0,
NVSDK_NGX_OPT_LEVEL_DEBUG = 20,
NVSDK_NGX_OPT_LEVEL_DEVELOP = 30,
NVSDK_NGX_OPT_LEVEL_RELEASE = 40
} NVSDK_NGX_Opt_Level;
typedef enum NVSDK_NGX_EngineType
{
NVSDK_NGX_ENGINE_TYPE_CUSTOM = 0,
NVSDK_NGX_ENGINE_TYPE_UNREAL,
NVSDK_NGX_ENGINE_TYPE_UNITY,
NVSDK_NGX_ENGINE_TYPE_OMNIVERSE,
NVSDK_NGX_ENGINE_COUNT
} NVSDK_NGX_EngineType;
// Read-only parameters provided by NGX
#define NVSDK_NGX_EParameter_Reserved00 "#\x00"
#define NVSDK_NGX_EParameter_SuperSampling_Available "#\x01"
#define NVSDK_NGX_EParameter_InPainting_Available "#\x02"
#define NVSDK_NGX_EParameter_ImageSuperResolution_Available "#\x03"
#define NVSDK_NGX_EParameter_SlowMotion_Available "#\x04"
#define NVSDK_NGX_EParameter_VideoSuperResolution_Available "#\x05"
#define NVSDK_NGX_EParameter_Reserved06 "#\x06"
#define NVSDK_NGX_EParameter_Reserved07 "#\x07"
#define NVSDK_NGX_EParameter_Reserved08 "#\x08"
#define NVSDK_NGX_EParameter_ImageSignalProcessing_Available "#\x09"
#define NVSDK_NGX_EParameter_ImageSuperResolution_ScaleFactor_2_1 "#\x0a"
#define NVSDK_NGX_EParameter_ImageSuperResolution_ScaleFactor_3_1 "#\x0b"
#define NVSDK_NGX_EParameter_ImageSuperResolution_ScaleFactor_3_2 "#\x0c"
#define NVSDK_NGX_EParameter_ImageSuperResolution_ScaleFactor_4_3 "#\x0d"
#define NVSDK_NGX_EParameter_NumFrames "#\x0e"
#define NVSDK_NGX_EParameter_Scale "#\x0f"
#define NVSDK_NGX_EParameter_Width "#\x10"
#define NVSDK_NGX_EParameter_Height "#\x11"
#define NVSDK_NGX_EParameter_OutWidth "#\x12"
#define NVSDK_NGX_EParameter_OutHeight "#\x13"
#define NVSDK_NGX_EParameter_Sharpness "#\x14"
#define NVSDK_NGX_EParameter_Scratch "#\x15"
#define NVSDK_NGX_EParameter_Scratch_SizeInBytes "#\x16"
#define NVSDK_NGX_EParameter_Deprecated_17 "#\x17"
#define NVSDK_NGX_EParameter_Input1 "#\x18"
#define NVSDK_NGX_EParameter_Input1_Format "#\x19"
#define NVSDK_NGX_EParameter_Input1_SizeInBytes "#\x1a"
#define NVSDK_NGX_EParameter_Input2 "#\x1b"
#define NVSDK_NGX_EParameter_Input2_Format "#\x1c"
#define NVSDK_NGX_EParameter_Input2_SizeInBytes "#\x1d"
#define NVSDK_NGX_EParameter_Color "#\x1e"
#define NVSDK_NGX_EParameter_Color_Format "#\x1f"
#define NVSDK_NGX_EParameter_Color_SizeInBytes "#\x20"
#define NVSDK_NGX_EParameter_Albedo "#\x21"
#define NVSDK_NGX_EParameter_Output "#\x22"
#define NVSDK_NGX_EParameter_Output_Format "#\x23"
#define NVSDK_NGX_EParameter_Output_SizeInBytes "#\x24"
#define NVSDK_NGX_EParameter_Reset "#\x25"
#define NVSDK_NGX_EParameter_BlendFactor "#\x26"
#define NVSDK_NGX_EParameter_MotionVectors "#\x27"
#define NVSDK_NGX_EParameter_Rect_X "#\x28"
#define NVSDK_NGX_EParameter_Rect_Y "#\x29"
#define NVSDK_NGX_EParameter_Rect_W "#\x2a"
#define NVSDK_NGX_EParameter_Rect_H "#\x2b"
#define NVSDK_NGX_EParameter_MV_Scale_X "#\x2c"
#define NVSDK_NGX_EParameter_MV_Scale_Y "#\x2d"
#define NVSDK_NGX_EParameter_Model "#\x2e"
#define NVSDK_NGX_EParameter_Format "#\x2f"
#define NVSDK_NGX_EParameter_SizeInBytes "#\x30"
#define NVSDK_NGX_EParameter_ResourceAllocCallback "#\x31"
#define NVSDK_NGX_EParameter_BufferAllocCallback "#\x32"
#define NVSDK_NGX_EParameter_Tex2DAllocCallback "#\x33"
#define NVSDK_NGX_EParameter_ResourceReleaseCallback "#\x34"
#define NVSDK_NGX_EParameter_CreationNodeMask "#\x35"
#define NVSDK_NGX_EParameter_VisibilityNodeMask "#\x36"
#define NVSDK_NGX_EParameter_PreviousOutput "#\x37"
#define NVSDK_NGX_EParameter_MV_Offset_X "#\x38"
#define NVSDK_NGX_EParameter_MV_Offset_Y "#\x39"
#define NVSDK_NGX_EParameter_Hint_UseFireflySwatter "#\x3a"
#define NVSDK_NGX_EParameter_Resource_Width "#\x3b"
#define NVSDK_NGX_EParameter_Resource_Height "#\x3c"
#define NVSDK_NGX_EParameter_Depth "#\x3d"
#define NVSDK_NGX_EParameter_DLSSOptimalSettingsCallback "#\x3e"
#define NVSDK_NGX_EParameter_PerfQualityValue "#\x3f"
#define NVSDK_NGX_EParameter_RTXValue "#\x40"
#define NVSDK_NGX_EParameter_DLSSMode "#\x41"
#define NVSDK_NGX_EParameter_DeepResolve_Available "#\x42"
#define NVSDK_NGX_EParameter_Deprecated_43 "#\x43"
#define NVSDK_NGX_EParameter_OptLevel "#\x44"
#define NVSDK_NGX_EParameter_IsDevSnippetBranch "#\x45"
#define NVSDK_NGX_Parameter_OptLevel "Snippet.OptLevel"
#define NVSDK_NGX_Parameter_IsDevSnippetBranch "Snippet.IsDevBranch"
#define NVSDK_NGX_Parameter_SuperSampling_ScaleFactor "SuperSampling.ScaleFactor"
#define NVSDK_NGX_Parameter_ImageSignalProcessing_ScaleFactor "ImageSignalProcessing.ScaleFactor"
#define NVSDK_NGX_Parameter_SuperSampling_Available "SuperSampling.Available"
#define NVSDK_NGX_Parameter_InPainting_Available "InPainting.Available"
#define NVSDK_NGX_Parameter_ImageSuperResolution_Available "ImageSuperResolution.Available"
#define NVSDK_NGX_Parameter_SlowMotion_Available "SlowMotion.Available"
#define NVSDK_NGX_Parameter_VideoSuperResolution_Available "VideoSuperResolution.Available"
#define NVSDK_NGX_Parameter_ImageSignalProcessing_Available "ImageSignalProcessing.Available"
#define NVSDK_NGX_Parameter_DeepResolve_Available "DeepResolve.Available"
#define NVSDK_NGX_Parameter_SuperSampling_NeedsUpdatedDriver "SuperSampling.NeedsUpdatedDriver"
#define NVSDK_NGX_Parameter_InPainting_NeedsUpdatedDriver "InPainting.NeedsUpdatedDriver"
#define NVSDK_NGX_Parameter_ImageSuperResolution_NeedsUpdatedDriver "ImageSuperResolution.NeedsUpdatedDriver"
#define NVSDK_NGX_Parameter_SlowMotion_NeedsUpdatedDriver "SlowMotion.NeedsUpdatedDriver"
#define NVSDK_NGX_Parameter_VideoSuperResolution_NeedsUpdatedDriver "VideoSuperResolution.NeedsUpdatedDriver"
#define NVSDK_NGX_Parameter_ImageSignalProcessing_NeedsUpdatedDriver "ImageSignalProcessing.NeedsUpdatedDriver"
#define NVSDK_NGX_Parameter_DeepResolve_NeedsUpdatedDriver "DeepResolve.NeedsUpdatedDriver"
#define NVSDK_NGX_Parameter_FrameInterpolation_NeedsUpdatedDriver "FrameInterpolation.NeedsUpdatedDriver"
#define NVSDK_NGX_Parameter_SuperSampling_MinDriverVersionMajor "SuperSampling.MinDriverVersionMajor"
#define NVSDK_NGX_Parameter_InPainting_MinDriverVersionMajor "InPainting.MinDriverVersionMajor"
#define NVSDK_NGX_Parameter_ImageSuperResolution_MinDriverVersionMajor "ImageSuperResolution.MinDriverVersionMajor"
#define NVSDK_NGX_Parameter_SlowMotion_MinDriverVersionMajor "SlowMotion.MinDriverVersionMajor"
#define NVSDK_NGX_Parameter_VideoSuperResolution_MinDriverVersionMajor "VideoSuperResolution.MinDriverVersionMajor"
#define NVSDK_NGX_Parameter_ImageSignalProcessing_MinDriverVersionMajor "ImageSignalProcessing.MinDriverVersionMajor"
#define NVSDK_NGX_Parameter_DeepResolve_MinDriverVersionMajor "DeepResolve.MinDriverVersionMajor"
#define NVSDK_NGX_Parameter_FrameInterpolation_MinDriverVersionMajor "FrameInterpolation.MinDriverVersionMajor"
#define NVSDK_NGX_Parameter_SuperSampling_MinDriverVersionMinor "SuperSampling.MinDriverVersionMinor"
#define NVSDK_NGX_Parameter_InPainting_MinDriverVersionMinor "InPainting.MinDriverVersionMinor"
#define NVSDK_NGX_Parameter_ImageSuperResolution_MinDriverVersionMinor "ImageSuperResolution.MinDriverVersionMinor"
#define NVSDK_NGX_Parameter_SlowMotion_MinDriverVersionMinor "SlowMotion.MinDriverVersionMinor"
#define NVSDK_NGX_Parameter_VideoSuperResolution_MinDriverVersionMinor "VideoSuperResolution.MinDriverVersionMinor"
#define NVSDK_NGX_Parameter_ImageSignalProcessing_MinDriverVersionMinor "ImageSignalProcessing.MinDriverVersionMinor"
#define NVSDK_NGX_Parameter_DeepResolve_MinDriverVersionMinor "DeepResolve.MinDriverVersionMinor"
#define NVSDK_NGX_Parameter_SuperSampling_FeatureInitResult "SuperSampling.FeatureInitResult"
#define NVSDK_NGX_Parameter_InPainting_FeatureInitResult "InPainting.FeatureInitResult"
#define NVSDK_NGX_Parameter_ImageSuperResolution_FeatureInitResult "ImageSuperResolution.FeatureInitResult"
#define NVSDK_NGX_Parameter_SlowMotion_FeatureInitResult "SlowMotion.FeatureInitResult"
#define NVSDK_NGX_Parameter_VideoSuperResolution_FeatureInitResult "VideoSuperResolution.FeatureInitResult"
#define NVSDK_NGX_Parameter_ImageSignalProcessing_FeatureInitResult "ImageSignalProcessing.FeatureInitResult"
#define NVSDK_NGX_Parameter_DeepResolve_FeatureInitResult "DeepResolve.FeatureInitResult"
#define NVSDK_NGX_Parameter_FrameInterpolation_FeatureInitResult "FrameInterpolation.FeatureInitResult"
#define NVSDK_NGX_Parameter_ImageSuperResolution_ScaleFactor_2_1 "ImageSuperResolution.ScaleFactor.2.1"
#define NVSDK_NGX_Parameter_ImageSuperResolution_ScaleFactor_3_1 "ImageSuperResolution.ScaleFactor.3.1"
#define NVSDK_NGX_Parameter_ImageSuperResolution_ScaleFactor_3_2 "ImageSuperResolution.ScaleFactor.3.2"
#define NVSDK_NGX_Parameter_ImageSuperResolution_ScaleFactor_4_3 "ImageSuperResolution.ScaleFactor.4.3"
#define NVSDK_NGX_Parameter_NumFrames "NumFrames"
#define NVSDK_NGX_Parameter_Scale "Scale"
#define NVSDK_NGX_Parameter_Width "Width"
#define NVSDK_NGX_Parameter_Height "Height"
#define NVSDK_NGX_Parameter_OutWidth "OutWidth"
#define NVSDK_NGX_Parameter_OutHeight "OutHeight"
#define NVSDK_NGX_Parameter_Sharpness "Sharpness"
#define NVSDK_NGX_Parameter_Scratch "Scratch"
#define NVSDK_NGX_Parameter_Scratch_SizeInBytes "Scratch.SizeInBytes"
#define NVSDK_NGX_Parameter_Input1 "Input1"
#define NVSDK_NGX_Parameter_Input1_Format "Input1.Format"
#define NVSDK_NGX_Parameter_Input1_SizeInBytes "Input1.SizeInBytes"
#define NVSDK_NGX_Parameter_Input2 "Input2"
#define NVSDK_NGX_Parameter_Input2_Format "Input2.Format"
#define NVSDK_NGX_Parameter_Input2_SizeInBytes "Input2.SizeInBytes"
#define NVSDK_NGX_Parameter_Color "Color"
#define NVSDK_NGX_Parameter_Color_Format "Color.Format"
#define NVSDK_NGX_Parameter_Color_SizeInBytes "Color.SizeInBytes"
#define NVSDK_NGX_Parameter_FI_Color1 "Color1"
#define NVSDK_NGX_Parameter_FI_Color2 "Color2"
#define NVSDK_NGX_Parameter_Albedo "Albedo"
#define NVSDK_NGX_Parameter_Output "Output"
#define NVSDK_NGX_Parameter_Output_SizeInBytes "Output.SizeInBytes"
#define NVSDK_NGX_Parameter_FI_Output1 "Output1"
#define NVSDK_NGX_Parameter_FI_Output2 "Output2"
#define NVSDK_NGX_Parameter_FI_Output3 "Output3"
#define NVSDK_NGX_Parameter_Reset "Reset"
#define NVSDK_NGX_Parameter_BlendFactor "BlendFactor"
#define NVSDK_NGX_Parameter_MotionVectors "MotionVectors"
#define NVSDK_NGX_Parameter_FI_MotionVectors1 "MotionVectors1"
#define NVSDK_NGX_Parameter_FI_MotionVectors2 "MotionVectors2"
#define NVSDK_NGX_Parameter_Rect_X "Rect.X"
#define NVSDK_NGX_Parameter_Rect_Y "Rect.Y"
#define NVSDK_NGX_Parameter_Rect_W "Rect.W"
#define NVSDK_NGX_Parameter_Rect_H "Rect.H"
#define NVSDK_NGX_Parameter_MV_Scale_X "MV.Scale.X"
#define NVSDK_NGX_Parameter_MV_Scale_Y "MV.Scale.Y"
#define NVSDK_NGX_Parameter_Model "Model"
#define NVSDK_NGX_Parameter_Format "Format"
#define NVSDK_NGX_Parameter_SizeInBytes "SizeInBytes"
#define NVSDK_NGX_Parameter_ResourceAllocCallback "ResourceAllocCallback"
#define NVSDK_NGX_Parameter_BufferAllocCallback "BufferAllocCallback"
#define NVSDK_NGX_Parameter_Tex2DAllocCallback "Tex2DAllocCallback"
#define NVSDK_NGX_Parameter_ResourceReleaseCallback "ResourceReleaseCallback"
#define NVSDK_NGX_Parameter_CreationNodeMask "CreationNodeMask"
#define NVSDK_NGX_Parameter_VisibilityNodeMask "VisibilityNodeMask"
#define NVSDK_NGX_Parameter_MV_Offset_X "MV.Offset.X"
#define NVSDK_NGX_Parameter_MV_Offset_Y "MV.Offset.Y"
#define NVSDK_NGX_Parameter_Hint_UseFireflySwatter "Hint.UseFireflySwatter"
#define NVSDK_NGX_Parameter_Resource_Width "ResourceWidth"
#define NVSDK_NGX_Parameter_Resource_Height "ResourceHeight"
#define NVSDK_NGX_Parameter_Resource_OutWidth "ResourceOutWidth"
#define NVSDK_NGX_Parameter_Resource_OutHeight "ResourceOutHeight"
#define NVSDK_NGX_Parameter_Depth "Depth"
#define NVSDK_NGX_Parameter_FI_Depth1 "Depth1"
#define NVSDK_NGX_Parameter_FI_Depth2 "Depth2"
#define NVSDK_NGX_Parameter_DLSSOptimalSettingsCallback "DLSSOptimalSettingsCallback"
#define NVSDK_NGX_Parameter_DLSSGetStatsCallback "DLSSGetStatsCallback"
#define NVSDK_NGX_Parameter_PerfQualityValue "PerfQualityValue"
#define NVSDK_NGX_Parameter_RTXValue "RTXValue"
#define NVSDK_NGX_Parameter_DLSSMode "DLSSMode"
#define NVSDK_NGX_Parameter_FI_Mode "FIMode"
#define NVSDK_NGX_Parameter_FI_OF_Preset "FIOFPreset"
#define NVSDK_NGX_Parameter_FI_OF_GridSize "FIOFGridSize"
#define NVSDK_NGX_Parameter_Jitter_Offset_X "Jitter.Offset.X"
#define NVSDK_NGX_Parameter_Jitter_Offset_Y "Jitter.Offset.Y"
#define NVSDK_NGX_Parameter_Denoise "Denoise"
#define NVSDK_NGX_Parameter_TransparencyMask "TransparencyMask"
#define NVSDK_NGX_Parameter_ExposureTexture "ExposureTexture" // a 1x1 texture containing the final exposure scale
#define NVSDK_NGX_Parameter_DLSS_Feature_Create_Flags "DLSS.Feature.Create.Flags"
#define NVSDK_NGX_Parameter_DLSS_Checkerboard_Jitter_Hack "DLSS.Checkerboard.Jitter.Hack"
#define NVSDK_NGX_Parameter_GBuffer_Albedo "GBuffer.Albedo"
#define NVSDK_NGX_Parameter_GBuffer_Roughness "GBuffer.Roughness"
#define NVSDK_NGX_Parameter_GBuffer_Metallic "GBuffer.Metallic"
#define NVSDK_NGX_Parameter_GBuffer_Specular "GBuffer.Specular"
#define NVSDK_NGX_Parameter_GBuffer_Subsurface "GBuffer.Subsurface"
#define NVSDK_NGX_Parameter_GBuffer_Normals "GBuffer.Normals"
#define NVSDK_NGX_Parameter_GBuffer_ShadingModelId "GBuffer.ShadingModelId"
#define NVSDK_NGX_Parameter_GBuffer_MaterialId "GBuffer.MaterialId"
#define NVSDK_NGX_Parameter_GBuffer_Atrrib_8 "GBuffer.Attrib.8"
#define NVSDK_NGX_Parameter_GBuffer_Atrrib_9 "GBuffer.Attrib.9"
#define NVSDK_NGX_Parameter_GBuffer_Atrrib_10 "GBuffer.Attrib.10"
#define NVSDK_NGX_Parameter_GBuffer_Atrrib_11 "GBuffer.Attrib.11"
#define NVSDK_NGX_Parameter_GBuffer_Atrrib_12 "GBuffer.Attrib.12"
#define NVSDK_NGX_Parameter_GBuffer_Atrrib_13 "GBuffer.Attrib.13"
#define NVSDK_NGX_Parameter_GBuffer_Atrrib_14 "GBuffer.Attrib.14"
#define NVSDK_NGX_Parameter_GBuffer_Atrrib_15 "GBuffer.Attrib.15"
#define NVSDK_NGX_Parameter_TonemapperType "TonemapperType"
#define NVSDK_NGX_Parameter_FreeMemOnReleaseFeature "FreeMemOnReleaseFeature"
#define NVSDK_NGX_Parameter_MotionVectors3D "MotionVectors3D"
#define NVSDK_NGX_Parameter_IsParticleMask "IsParticleMask"
#define NVSDK_NGX_Parameter_AnimatedTextureMask "AnimatedTextureMask"
#define NVSDK_NGX_Parameter_DepthHighRes "DepthHighRes"
#define NVSDK_NGX_Parameter_Position_ViewSpace "Position.ViewSpace"
#define NVSDK_NGX_Parameter_FrameTimeDeltaInMsec "FrameTimeDeltaInMsec"
#define NVSDK_NGX_Parameter_RayTracingHitDistance "RayTracingHitDistance"
#define NVSDK_NGX_Parameter_MotionVectorsReflection "MotionVectorsReflection"
#define NVSDK_NGX_Parameter_DLSS_Enable_Output_Subrects "DLSS.Enable.Output.Subrects"
#define NVSDK_NGX_Parameter_DLSS_Input_Color_Subrect_Base_X "DLSS.Input.Color.Subrect.Base.X"
#define NVSDK_NGX_Parameter_DLSS_Input_Color_Subrect_Base_Y "DLSS.Input.Color.Subrect.Base.Y"
#define NVSDK_NGX_Parameter_DLSS_Input_Depth_Subrect_Base_X "DLSS.Input.Depth.Subrect.Base.X"
#define NVSDK_NGX_Parameter_DLSS_Input_Depth_Subrect_Base_Y "DLSS.Input.Depth.Subrect.Base.Y"
#define NVSDK_NGX_Parameter_DLSS_Input_MV_SubrectBase_X "DLSS.Input.MV.Subrect.Base.X"
#define NVSDK_NGX_Parameter_DLSS_Input_MV_SubrectBase_Y "DLSS.Input.MV.Subrect.Base.Y"
#define NVSDK_NGX_Parameter_DLSS_Input_Translucency_SubrectBase_X "DLSS.Input.Translucency.Subrect.Base.X"
#define NVSDK_NGX_Parameter_DLSS_Input_Translucency_SubrectBase_Y "DLSS.Input.Translucency.Subrect.Base.Y"
#define NVSDK_NGX_Parameter_DLSS_Output_Subrect_Base_X "DLSS.Output.Subrect.Base.X"
#define NVSDK_NGX_Parameter_DLSS_Output_Subrect_Base_Y "DLSS.Output.Subrect.Base.Y"
#define NVSDK_NGX_Parameter_DLSS_Render_Subrect_Dimensions_Width "DLSS.Render.Subrect.Dimensions.Width"
#define NVSDK_NGX_Parameter_DLSS_Render_Subrect_Dimensions_Height "DLSS.Render.Subrect.Dimensions.Height"
#define NVSDK_NGX_Parameter_DLSS_Pre_Exposure "DLSS.Pre.Exposure"
#define NVSDK_NGX_Parameter_DLSS_Exposure_Scale "DLSS.Exposure.Scale"
#define NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_Mask "DLSS.Input.Bias.Current.Color.Mask"
#define NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_SubrectBase_X "DLSS.Input.Bias.Current.Color.Subrect.Base.X"
#define NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_SubrectBase_Y "DLSS.Input.Bias.Current.Color.Subrect.Base.Y"
#define NVSDK_NGX_Parameter_DLSS_Indicator_Invert_Y_Axis "DLSS.Indicator.Invert.Y.Axis"
#define NVSDK_NGX_Parameter_DLSS_Indicator_Invert_X_Axis "DLSS.Indicator.Invert.X.Axis"
#define NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Max_Render_Width "DLSS.Get.Dynamic.Max.Render.Width"
#define NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Max_Render_Height "DLSS.Get.Dynamic.Max.Render.Height"
#define NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Min_Render_Width "DLSS.Get.Dynamic.Min.Render.Width"
#define NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Min_Render_Height "DLSS.Get.Dynamic.Min.Render.Height"
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View File

@@ -0,0 +1,629 @@
/*
* Copyright (c) 2018 NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property and proprietary
* rights in and to this software, related documentation and any modifications thereto.
* Any use, reproduction, disclosure or distribution of this software and related
* documentation without an express license agreement from NVIDIA Corporation is strictly
* prohibited.
*
* TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
* INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
* SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
* BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
* INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES.
*/
#ifndef NVSDK_NGX_HELPERS_H
#define NVSDK_NGX_HELPERS_H
#pragma once
#include "nvsdk_ngx.h"
#include "nvsdk_ngx_defs.h"
typedef NVSDK_NGX_Result(NVSDK_CONV *PFN_NVSDK_NGX_DLSS_GetStatsCallback)(NVSDK_NGX_Parameter *InParams);
static inline NVSDK_NGX_Result NGX_DLSS_GET_STATS_2(
NVSDK_NGX_Parameter *pInParams,
unsigned long long *pVRAMAllocatedBytes,
unsigned int *pOptLevel, unsigned int *IsDevSnippetBranch)
{
void *Callback = NULL;
NVSDK_NGX_Parameter_GetVoidPointer(pInParams, NVSDK_NGX_Parameter_DLSSGetStatsCallback, &Callback);
if (!Callback)
{
// Possible reasons for this:
// - Installed DLSS is out of date and does not support the feature we need
// - You used NVSDK_NGX_AllocateParameters() for creating InParams. Try using NVSDK_NGX_GetCapabilityParameters() instead
return NVSDK_NGX_Result_FAIL_OutOfDate;
}
NVSDK_NGX_Result Res = NVSDK_NGX_Result_Success;
PFN_NVSDK_NGX_DLSS_GetStatsCallback PFNCallback = (PFN_NVSDK_NGX_DLSS_GetStatsCallback)Callback;
Res = PFNCallback(pInParams);
if (NVSDK_NGX_FAILED(Res))
{
return Res;
}
NVSDK_NGX_Parameter_GetULL(pInParams, NVSDK_NGX_Parameter_SizeInBytes, pVRAMAllocatedBytes);
NVSDK_NGX_Parameter_GetUI(pInParams, NVSDK_NGX_EParameter_OptLevel, pOptLevel);
NVSDK_NGX_Parameter_GetUI(pInParams, NVSDK_NGX_EParameter_IsDevSnippetBranch, IsDevSnippetBranch);
return Res;
}
static inline NVSDK_NGX_Result NGX_DLSS_GET_STATS_1(
NVSDK_NGX_Parameter *pInParams,
unsigned long long *pVRAMAllocatedBytes,
unsigned int *pOptLevel)
{
unsigned int dummy = 0;
return NGX_DLSS_GET_STATS_2(pInParams, pVRAMAllocatedBytes, pOptLevel, &dummy);
}
static inline NVSDK_NGX_Result NGX_DLSS_GET_STATS(
NVSDK_NGX_Parameter *pInParams,
unsigned long long *pVRAMAllocatedBytes)
{
unsigned int dummy = 0;
return NGX_DLSS_GET_STATS_2(pInParams, pVRAMAllocatedBytes, &dummy, &dummy);
}
typedef NVSDK_NGX_Result(NVSDK_CONV *PFN_NVSDK_NGX_DLSS_GetOptimalSettingsCallback)(NVSDK_NGX_Parameter *InParams);
static inline NVSDK_NGX_Result NGX_DLSS_GET_OPTIMAL_SETTINGS(
NVSDK_NGX_Parameter *pInParams,
unsigned int InUserSelectedWidth,
unsigned int InUserSelectedHeight,
NVSDK_NGX_PerfQuality_Value InPerfQualityValue,
unsigned int *pOutRenderOptimalWidth,
unsigned int *pOutRenderOptimalHeight,
unsigned int *pOutRenderMaxWidth,
unsigned int *pOutRenderMaxHeight,
unsigned int *pOutRenderMinWidth,
unsigned int *pOutRenderMinHeight,
float *pOutSharpness)
{
void *Callback = NULL;
NVSDK_NGX_Parameter_GetVoidPointer(pInParams, NVSDK_NGX_Parameter_DLSSOptimalSettingsCallback, &Callback);
if (!Callback)
{
// Possible reasons for this:
// - Installed DLSS is out of date and does not support the feature we need
// - You used NVSDK_NGX_AllocateParameters() for creating InParams. Try using NVSDK_NGX_GetCapabilityParameters() instead
return NVSDK_NGX_Result_FAIL_OutOfDate;
}
// These are selections made by user in UI
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, InUserSelectedWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, InUserSelectedHeight);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_PerfQualityValue, InPerfQualityValue);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_RTXValue, false); // Some older DLSS dlls still expect this value to be set
NVSDK_NGX_Result Res = NVSDK_NGX_Result_Success;
PFN_NVSDK_NGX_DLSS_GetOptimalSettingsCallback PFNCallback = (PFN_NVSDK_NGX_DLSS_GetOptimalSettingsCallback)Callback;
Res = PFNCallback(pInParams);
if (NVSDK_NGX_FAILED(Res))
{
return Res;
}
NVSDK_NGX_Parameter_GetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pOutRenderOptimalWidth);
NVSDK_NGX_Parameter_GetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pOutRenderOptimalHeight);
// If we have an older DLSS Dll those might need to be set to the optimal dimensions instead
*pOutRenderMaxWidth = *pOutRenderOptimalWidth;
*pOutRenderMaxHeight = *pOutRenderOptimalHeight;
*pOutRenderMinWidth = *pOutRenderOptimalWidth;
*pOutRenderMinHeight = *pOutRenderOptimalHeight;
NVSDK_NGX_Parameter_GetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Max_Render_Width, pOutRenderMaxWidth);
NVSDK_NGX_Parameter_GetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Max_Render_Height, pOutRenderMaxHeight);
NVSDK_NGX_Parameter_GetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Min_Render_Width, pOutRenderMinWidth);
NVSDK_NGX_Parameter_GetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Min_Render_Height, pOutRenderMinHeight);
NVSDK_NGX_Parameter_GetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pOutSharpness);
return Res;
}
/*** D3D11 ***/
typedef struct NVSDK_NGX_D3D11_Feature_Eval_Params
{
ID3D11Resource* pInColor;
ID3D11Resource* pInOutput;
/*** OPTIONAL for DLSS ***/
float InSharpness;
} NVSDK_NGX_D3D11_Feature_Eval_Params;
typedef struct NVSDK_NGX_CUDA_Feature_Eval_Params
{
CUtexObject* pInColor;
CUtexObject* pInOutput;
/*** OPTIONAL for DLSS ***/
float InSharpness;
} NVSDK_NGX_CUDA_Feature_Eval_Params;
typedef struct NVSDK_NGX_D3D11_GBuffer
{
ID3D11Resource* pInAttrib[NVSDK_NGX_GBUFFERTYPE_NUM];
} NVSDK_NGX_D3D11_GBuffer;
typedef struct NVSDK_NGX_D3D11_DLSS_Eval_Params
{
NVSDK_NGX_D3D11_Feature_Eval_Params Feature;
ID3D11Resource* pInDepth;
ID3D11Resource* pInMotionVectors;
float InJitterOffsetX; /* Jitter offset must be in input/render pixel space */
float InJitterOffsetY;
NVSDK_NGX_Dimensions InRenderSubrectDimensions;
/*** OPTIONAL - leave to 0/0.0f if unused ***/
int InReset; /* Set to 1 when scene changes completely (new level etc) */
float InMVScaleX; /* If MVs need custom scaling to convert to pixel space */
float InMVScaleY;
ID3D11Resource* pInTransparencyMask; /* Unused/Reserved for future use */
ID3D11Resource* pInExposureTexture;
ID3D11Resource* pInBiasCurrentColorMask;
NVSDK_NGX_Coordinates InColorSubrectBase;
NVSDK_NGX_Coordinates InDepthSubrectBase;
NVSDK_NGX_Coordinates InMVSubrectBase;
NVSDK_NGX_Coordinates InTranslucencySubrectBase;
NVSDK_NGX_Coordinates InBiasCurrentColorSubrectBase;
NVSDK_NGX_Coordinates InOutputSubrectBase;
float InPreExposure;
int InIndicatorInvertXAxis;
int InIndicatorInvertYAxis;
/*** OPTIONAL - only for research purposes ***/
NVSDK_NGX_D3D11_GBuffer GBufferSurface;
NVSDK_NGX_ToneMapperType InToneMapperType;
ID3D11Resource* pInMotionVectors3D;
ID3D11Resource* pInIsParticleMask; /* to identify which pixels contains particles, essentially that are not drawn as part of base pass */
ID3D11Resource* pInAnimatedTextureMask; /* a binary mask covering pixels occupied by animated textures */
ID3D11Resource* pInDepthHighRes;
ID3D11Resource* pInPositionViewSpace;
float InFrameTimeDeltaInMsec; /* helps in determining the amount to denoise or anti-alias based on the speed of the object from motion vector magnitudes and fps as determined by this delta */
ID3D11Resource* pInRayTracingHitDistance; /* for each effect - approximation to the amount of noise in a ray-traced color */
ID3D11Resource* pInMotionVectorsReflections; /* motion vectors of reflected objects like for mirrored surfaces */
} NVSDK_NGX_D3D11_DLSS_Eval_Params;
typedef struct NVSDK_NGX_D3D11_DLISP_Eval_Params
{
NVSDK_NGX_D3D11_Feature_Eval_Params Feature;
/*** OPTIONAL - leave to 0/0.0f if unused ***/
unsigned int InRectX;
unsigned int InRectY;
unsigned int InRectW;
unsigned int InRectH;
float InDenoise;
} NVSDK_NGX_D3D11_DLISP_Eval_Params;
typedef struct NVSDK_NGX_CUDA_DLISP_Eval_Params
{
NVSDK_NGX_CUDA_Feature_Eval_Params Feature;
/*** OPTIONAL - leave to 0/0.0f if unused ***/
unsigned int InRectX;
unsigned int InRectY;
unsigned int InRectW;
unsigned int InRectH;
float InDenoise;
} NVSDK_NGX_CUDA_DLISP_Eval_Params;
static inline NVSDK_NGX_Result NGX_D3D11_CREATE_DLSS_EXT(
ID3D11DeviceContext *pInCtx,
NVSDK_NGX_Handle **ppOutHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_DLSS_Create_Params *pInDlssCreateParams)
{
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pInDlssCreateParams->Feature.InWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pInDlssCreateParams->Feature.InHeight);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pInDlssCreateParams->Feature.InTargetWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pInDlssCreateParams->Feature.InTargetHeight);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_PerfQualityValue, pInDlssCreateParams->Feature.InPerfQualityValue);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Feature_Create_Flags, pInDlssCreateParams->InFeatureCreateFlags);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Enable_Output_Subrects, pInDlssCreateParams->InEnableOutputSubrects ? 1 : 0);
return NVSDK_NGX_D3D11_CreateFeature(pInCtx, NVSDK_NGX_Feature_SuperSampling, pInParams, ppOutHandle);
}
static inline NVSDK_NGX_Result NGX_D3D11_EVALUATE_DLSS_EXT(
ID3D11DeviceContext *pInCtx,
NVSDK_NGX_Handle *pInHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_D3D11_DLSS_Eval_Params *pInDlssEvalParams)
{
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_Color, pInDlssEvalParams->Feature.pInColor);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_Output, pInDlssEvalParams->Feature.pInOutput);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_Depth, pInDlssEvalParams->pInDepth);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_MotionVectors, pInDlssEvalParams->pInMotionVectors);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Jitter_Offset_X, pInDlssEvalParams->InJitterOffsetX);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Jitter_Offset_Y, pInDlssEvalParams->InJitterOffsetY);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pInDlssEvalParams->Feature.InSharpness);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_Reset, pInDlssEvalParams->InReset);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_MV_Scale_X, pInDlssEvalParams->InMVScaleX == 0.0f ? 1.0f : pInDlssEvalParams->InMVScaleX);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_MV_Scale_Y, pInDlssEvalParams->InMVScaleY == 0.0f ? 1.0f : pInDlssEvalParams->InMVScaleY);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_TransparencyMask, pInDlssEvalParams->pInTransparencyMask);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_ExposureTexture, pInDlssEvalParams->pInExposureTexture);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_Mask, pInDlssEvalParams->pInBiasCurrentColorMask);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Albedo, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_ALBEDO]);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Roughness, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_ROUGHNESS]);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Metallic, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_METALLIC]);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Specular, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_SPECULAR]);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Subsurface, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_SUBSURFACE]);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Normals, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_NORMALS]);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_ShadingModelId, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_SHADINGMODELID]);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_MaterialId, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_MATERIALID]);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_8, pInDlssEvalParams->GBufferSurface.pInAttrib[8]);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_9, pInDlssEvalParams->GBufferSurface.pInAttrib[9]);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_10, pInDlssEvalParams->GBufferSurface.pInAttrib[10]);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_11, pInDlssEvalParams->GBufferSurface.pInAttrib[11]);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_12, pInDlssEvalParams->GBufferSurface.pInAttrib[12]);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_13, pInDlssEvalParams->GBufferSurface.pInAttrib[13]);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_14, pInDlssEvalParams->GBufferSurface.pInAttrib[14]);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_15, pInDlssEvalParams->GBufferSurface.pInAttrib[15]);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_TonemapperType, pInDlssEvalParams->InToneMapperType);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_MotionVectors3D, pInDlssEvalParams->pInMotionVectors3D);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_IsParticleMask, pInDlssEvalParams->pInIsParticleMask);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_AnimatedTextureMask, pInDlssEvalParams->pInAnimatedTextureMask);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_DepthHighRes, pInDlssEvalParams->pInDepthHighRes);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_Position_ViewSpace, pInDlssEvalParams->pInPositionViewSpace);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_FrameTimeDeltaInMsec, pInDlssEvalParams->InFrameTimeDeltaInMsec);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_RayTracingHitDistance, pInDlssEvalParams->pInRayTracingHitDistance);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_MotionVectorsReflection, pInDlssEvalParams->pInMotionVectorsReflections);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Color_Subrect_Base_X, pInDlssEvalParams->InColorSubrectBase.X);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Color_Subrect_Base_Y, pInDlssEvalParams->InColorSubrectBase.Y);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Depth_Subrect_Base_X, pInDlssEvalParams->InDepthSubrectBase.X);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Depth_Subrect_Base_Y, pInDlssEvalParams->InDepthSubrectBase.Y);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_MV_SubrectBase_X, pInDlssEvalParams->InMVSubrectBase.X);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_MV_SubrectBase_Y, pInDlssEvalParams->InMVSubrectBase.Y);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Translucency_SubrectBase_X, pInDlssEvalParams->InTranslucencySubrectBase.X);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Translucency_SubrectBase_Y, pInDlssEvalParams->InTranslucencySubrectBase.Y);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_SubrectBase_X, pInDlssEvalParams->InBiasCurrentColorSubrectBase.X);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_SubrectBase_Y, pInDlssEvalParams->InBiasCurrentColorSubrectBase.Y);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Output_Subrect_Base_X, pInDlssEvalParams->InOutputSubrectBase.X);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Output_Subrect_Base_Y, pInDlssEvalParams->InOutputSubrectBase.Y);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Render_Subrect_Dimensions_Width , pInDlssEvalParams->InRenderSubrectDimensions.Width);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Render_Subrect_Dimensions_Height, pInDlssEvalParams->InRenderSubrectDimensions.Height);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_DLSS_Pre_Exposure, pInDlssEvalParams->InPreExposure == 0.0f ? 1.0f : pInDlssEvalParams->InPreExposure);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Indicator_Invert_X_Axis, pInDlssEvalParams->InIndicatorInvertXAxis);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Indicator_Invert_Y_Axis, pInDlssEvalParams->InIndicatorInvertYAxis);
return NVSDK_NGX_D3D11_EvaluateFeature_C(pInCtx, pInHandle, pInParams, NULL);
}
static inline NVSDK_NGX_Result NGX_D3D11_CREATE_DLISP_EXT(
ID3D11DeviceContext *pInCtx,
NVSDK_NGX_Handle **ppOutHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_Feature_Create_Params *pDlispCreateParams)
{
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pDlispCreateParams->InWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pDlispCreateParams->InHeight);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pDlispCreateParams->InTargetWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pDlispCreateParams->InTargetHeight);
return NVSDK_NGX_D3D11_CreateFeature(pInCtx, NVSDK_NGX_Feature_ImageSignalProcessing, pInParams, ppOutHandle);
}
static inline NVSDK_NGX_Result NGX_CUDA_CREATE_DLISP_EXT(
NVSDK_NGX_Handle** ppOutHandle,
NVSDK_NGX_Parameter* pInParams,
NVSDK_NGX_Feature_Create_Params* pDlispCreateParams)
{
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pDlispCreateParams->InWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pDlispCreateParams->InHeight);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pDlispCreateParams->InTargetWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pDlispCreateParams->InTargetHeight);
return NVSDK_NGX_CUDA_CreateFeature(NVSDK_NGX_Feature_ImageSignalProcessing, pInParams, ppOutHandle);
}
static inline NVSDK_NGX_Result NGX_D3D11_EVALUATE_DLISP_EXT(
ID3D11DeviceContext *pInCtx,
NVSDK_NGX_Handle *pInHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_D3D11_DLISP_Eval_Params *pDlispEvalParams)
{
if (pDlispEvalParams->Feature.InSharpness < 0.0f || pDlispEvalParams->Feature.InSharpness > 1.0f || pDlispEvalParams->InDenoise < 0.0f || pDlispEvalParams->InDenoise > 1.0f)
{
return NVSDK_NGX_Result_FAIL_InvalidParameter;
}
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_Color, pDlispEvalParams->Feature.pInColor);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_Output, pDlispEvalParams->Feature.pInOutput);
// Both sharpness and denoise in range [0.0f,1.0f]
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pDlispEvalParams->Feature.InSharpness);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Denoise, pDlispEvalParams->InDenoise);
// If input is atlas - use RECT to upscale only the required area
if (pDlispEvalParams->InRectW)
{
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_X, pDlispEvalParams->InRectX);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_Y, pDlispEvalParams->InRectY);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_W, pDlispEvalParams->InRectW);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_H, pDlispEvalParams->InRectH);
}
return NVSDK_NGX_D3D11_EvaluateFeature_C(pInCtx, pInHandle, pInParams, NULL);
}
static inline NVSDK_NGX_Result NGX_CUDA_EVALUATE_DLISP_EXT(
NVSDK_NGX_Handle *pInHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_CUDA_DLISP_Eval_Params *pDlispEvalParams)
{
if (pDlispEvalParams->Feature.InSharpness < 0.0f || pDlispEvalParams->Feature.InSharpness > 1.0f || pDlispEvalParams->InDenoise < 0.0f || pDlispEvalParams->InDenoise > 1.0f)
{
return NVSDK_NGX_Result_FAIL_InvalidParameter;
}
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Color, pDlispEvalParams->Feature.pInColor);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Output, pDlispEvalParams->Feature.pInOutput);
// Both sharpness and denoise in range [0.0f,1.0f]
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pDlispEvalParams->Feature.InSharpness);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Denoise, pDlispEvalParams->InDenoise);
// If input is atlas - use RECT to upscale only the required area
if (pDlispEvalParams->InRectW)
{
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_X, pDlispEvalParams->InRectX);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_Y, pDlispEvalParams->InRectY);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_W, pDlispEvalParams->InRectW);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_H, pDlispEvalParams->InRectH);
}
return NVSDK_NGX_CUDA_EvaluateFeature_C(pInHandle, pInParams, NULL);
}
static inline NVSDK_NGX_Result NGX_D3D11_CREATE_DLRESOLVE_EXT(
ID3D11DeviceContext *pInCtx,
NVSDK_NGX_Handle **ppOutHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_Feature_Create_Params *pDlresolveCreateParams)
{
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pDlresolveCreateParams->InWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pDlresolveCreateParams->InHeight);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pDlresolveCreateParams->InTargetWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pDlresolveCreateParams->InTargetHeight);
return NVSDK_NGX_D3D11_CreateFeature(pInCtx, NVSDK_NGX_Feature_DeepResolve, pInParams, ppOutHandle);
}
static inline NVSDK_NGX_Result NGX_D3D11_EVALUATE_DLRESOLVE_EXT(
ID3D11DeviceContext *pInCtx,
NVSDK_NGX_Handle *InHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_D3D11_Feature_Eval_Params *pDlresolveEvalParams)
{
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_Color, pDlresolveEvalParams->pInColor);
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_Output, pDlresolveEvalParams->pInOutput);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pDlresolveEvalParams->InSharpness);
return NVSDK_NGX_D3D11_EvaluateFeature_C(pInCtx, InHandle, pInParams, NULL);
}
/*** D3D12 ***/
typedef struct NVSDK_NGX_D3D12_Feature_Eval_Params
{
ID3D12Resource* pInColor;
ID3D12Resource* pInOutput;
/*** OPTIONAL for DLSS ***/
float InSharpness;
} NVSDK_NGX_D3D12_Feature_Eval_Params;
typedef struct NVSDK_NGX_D3D12_GBuffer
{
ID3D12Resource* pInAttrib[NVSDK_NGX_GBUFFERTYPE_NUM];
} NVSDK_NGX_D3D12_GBuffer;
typedef struct NVSDK_NGX_D3D12_DLSS_Eval_Params
{
NVSDK_NGX_D3D12_Feature_Eval_Params Feature;
ID3D12Resource* pInDepth;
ID3D12Resource* pInMotionVectors;
float InJitterOffsetX; /* Jitter offset must be in input/render pixel space */
float InJitterOffsetY;
NVSDK_NGX_Dimensions InRenderSubrectDimensions;
/*** OPTIONAL - leave to 0/0.0f if unused ***/
int InReset; /* Set to 1 when scene changes completely (new level etc) */
float InMVScaleX; /* If MVs need custom scaling to convert to pixel space */
float InMVScaleY;
ID3D12Resource* pInTransparencyMask; /* Unused/Reserved for future use */
ID3D12Resource* pInExposureTexture;
ID3D12Resource* pInBiasCurrentColorMask;
NVSDK_NGX_Coordinates InColorSubrectBase;
NVSDK_NGX_Coordinates InDepthSubrectBase;
NVSDK_NGX_Coordinates InMVSubrectBase;
NVSDK_NGX_Coordinates InTranslucencySubrectBase;
NVSDK_NGX_Coordinates InBiasCurrentColorSubrectBase;
NVSDK_NGX_Coordinates InOutputSubrectBase;
float InPreExposure;
int InIndicatorInvertXAxis;
int InIndicatorInvertYAxis;
/*** OPTIONAL - only for research purposes ***/
NVSDK_NGX_D3D12_GBuffer GBufferSurface;
NVSDK_NGX_ToneMapperType InToneMapperType;
ID3D12Resource* pInMotionVectors3D;
ID3D12Resource* pInIsParticleMask; /* to identify which pixels contains particles, essentially that are not drawn as part of base pass */
ID3D12Resource* pInAnimatedTextureMask; /* a binary mask covering pixels occupied by animated textures */
ID3D12Resource* pInDepthHighRes;
ID3D12Resource* pInPositionViewSpace;
float InFrameTimeDeltaInMsec; /* helps in determining the amount to denoise or anti-alias based on the speed of the object from motion vector magnitudes and fps as determined by this delta */
ID3D12Resource* pInRayTracingHitDistance; /* for each effect - approximation to the amount of noise in a ray-traced color */
ID3D12Resource* pInMotionVectorsReflections; /* motion vectors of reflected objects like for mirrored surfaces */
} NVSDK_NGX_D3D12_DLSS_Eval_Params;
typedef struct NVSDK_NGX_D3D12_DLISP_Eval_Params
{
NVSDK_NGX_D3D12_Feature_Eval_Params Feature;
/*** OPTIONAL ***/
unsigned int InRectX;
unsigned int InRectY;
unsigned int InRectW;
unsigned int InRectH;
float InDenoise;
} NVSDK_NGX_D3D12_DLISP_Eval_Params;
static inline NVSDK_NGX_Result NGX_D3D12_CREATE_DLSS_EXT(
ID3D12GraphicsCommandList *pInCmdList,
unsigned int InCreationNodeMask,
unsigned int InVisibilityNodeMask,
NVSDK_NGX_Handle **ppOutHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_DLSS_Create_Params *pInDlssCreateParams)
{
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_CreationNodeMask, InCreationNodeMask);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_VisibilityNodeMask, InVisibilityNodeMask);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pInDlssCreateParams->Feature.InWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pInDlssCreateParams->Feature.InHeight);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pInDlssCreateParams->Feature.InTargetWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pInDlssCreateParams->Feature.InTargetHeight);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_PerfQualityValue, pInDlssCreateParams->Feature.InPerfQualityValue);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Feature_Create_Flags, pInDlssCreateParams->InFeatureCreateFlags);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Enable_Output_Subrects, pInDlssCreateParams->InEnableOutputSubrects ? 1 : 0);
return NVSDK_NGX_D3D12_CreateFeature(pInCmdList, NVSDK_NGX_Feature_SuperSampling, pInParams, ppOutHandle);
}
static inline NVSDK_NGX_Result NGX_D3D12_EVALUATE_DLSS_EXT(
ID3D12GraphicsCommandList *pInCmdList,
NVSDK_NGX_Handle *pInHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_D3D12_DLSS_Eval_Params *pInDlssEvalParams)
{
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_Color, pInDlssEvalParams->Feature.pInColor);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_Output, pInDlssEvalParams->Feature.pInOutput);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_Depth, pInDlssEvalParams->pInDepth);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_MotionVectors, pInDlssEvalParams->pInMotionVectors);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Jitter_Offset_X, pInDlssEvalParams->InJitterOffsetX);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Jitter_Offset_Y, pInDlssEvalParams->InJitterOffsetY);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pInDlssEvalParams->Feature.InSharpness);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_Reset, pInDlssEvalParams->InReset);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_MV_Scale_X, pInDlssEvalParams->InMVScaleX == 0.0f ? 1.0f : pInDlssEvalParams->InMVScaleX);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_MV_Scale_Y, pInDlssEvalParams->InMVScaleY == 0.0f ? 1.0f : pInDlssEvalParams->InMVScaleY);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_TransparencyMask, pInDlssEvalParams->pInTransparencyMask);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_ExposureTexture, pInDlssEvalParams->pInExposureTexture);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_Mask, pInDlssEvalParams->pInBiasCurrentColorMask);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Albedo, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_ALBEDO]);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Roughness, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_ROUGHNESS]);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Metallic, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_METALLIC]);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Specular, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_SPECULAR]);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Subsurface, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_SUBSURFACE]);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Normals, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_NORMALS]);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_ShadingModelId, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_SHADINGMODELID]);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_MaterialId, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_MATERIALID]);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_8, pInDlssEvalParams->GBufferSurface.pInAttrib[8]);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_9, pInDlssEvalParams->GBufferSurface.pInAttrib[9]);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_10, pInDlssEvalParams->GBufferSurface.pInAttrib[10]);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_11, pInDlssEvalParams->GBufferSurface.pInAttrib[11]);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_12, pInDlssEvalParams->GBufferSurface.pInAttrib[12]);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_13, pInDlssEvalParams->GBufferSurface.pInAttrib[13]);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_14, pInDlssEvalParams->GBufferSurface.pInAttrib[14]);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_15, pInDlssEvalParams->GBufferSurface.pInAttrib[15]);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_TonemapperType, pInDlssEvalParams->InToneMapperType);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_MotionVectors3D, pInDlssEvalParams->pInMotionVectors3D);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_IsParticleMask, pInDlssEvalParams->pInIsParticleMask);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_AnimatedTextureMask, pInDlssEvalParams->pInAnimatedTextureMask);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_DepthHighRes, pInDlssEvalParams->pInDepthHighRes);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_Position_ViewSpace, pInDlssEvalParams->pInPositionViewSpace);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_FrameTimeDeltaInMsec, pInDlssEvalParams->InFrameTimeDeltaInMsec);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_RayTracingHitDistance, pInDlssEvalParams->pInRayTracingHitDistance);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_MotionVectorsReflection, pInDlssEvalParams->pInMotionVectorsReflections);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Color_Subrect_Base_X, pInDlssEvalParams->InColorSubrectBase.X);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Color_Subrect_Base_Y, pInDlssEvalParams->InColorSubrectBase.Y);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Depth_Subrect_Base_X, pInDlssEvalParams->InDepthSubrectBase.X);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Depth_Subrect_Base_Y, pInDlssEvalParams->InDepthSubrectBase.Y);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_MV_SubrectBase_X, pInDlssEvalParams->InMVSubrectBase.X);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_MV_SubrectBase_Y, pInDlssEvalParams->InMVSubrectBase.Y);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Translucency_SubrectBase_X, pInDlssEvalParams->InTranslucencySubrectBase.X);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Translucency_SubrectBase_Y, pInDlssEvalParams->InTranslucencySubrectBase.Y);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_SubrectBase_X, pInDlssEvalParams->InBiasCurrentColorSubrectBase.X);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_SubrectBase_Y, pInDlssEvalParams->InBiasCurrentColorSubrectBase.Y);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Output_Subrect_Base_X, pInDlssEvalParams->InOutputSubrectBase.X);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Output_Subrect_Base_Y, pInDlssEvalParams->InOutputSubrectBase.Y);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Render_Subrect_Dimensions_Width , pInDlssEvalParams->InRenderSubrectDimensions.Width);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Render_Subrect_Dimensions_Height, pInDlssEvalParams->InRenderSubrectDimensions.Height);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_DLSS_Pre_Exposure, pInDlssEvalParams->InPreExposure == 0.0f ? 1.0f : pInDlssEvalParams->InPreExposure);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Indicator_Invert_X_Axis, pInDlssEvalParams->InIndicatorInvertXAxis);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Indicator_Invert_Y_Axis, pInDlssEvalParams->InIndicatorInvertYAxis);
return NVSDK_NGX_D3D12_EvaluateFeature_C(pInCmdList, pInHandle, pInParams, NULL);
}
static inline NVSDK_NGX_Result NGX_D3D12_CREATE_DLISP_EXT(
ID3D12GraphicsCommandList *InCmdList,
unsigned int InCreationNodeMask,
unsigned int InVisibilityNodeMask,
NVSDK_NGX_Handle **ppOutHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_Feature_Create_Params *pDlispCreateParams)
{
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_CreationNodeMask, InCreationNodeMask);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_VisibilityNodeMask, InVisibilityNodeMask);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pDlispCreateParams->InWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pDlispCreateParams->InHeight);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pDlispCreateParams->InTargetWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pDlispCreateParams->InTargetHeight);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_PerfQualityValue, pDlispCreateParams->InPerfQualityValue);
return NVSDK_NGX_D3D12_CreateFeature(InCmdList, NVSDK_NGX_Feature_ImageSignalProcessing, pInParams, ppOutHandle);
}
static inline NVSDK_NGX_Result NGX_D3D12_EVALUATE_DLISP_EXT(
ID3D12GraphicsCommandList *pInCmdList,
NVSDK_NGX_Handle *pInHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_D3D12_DLISP_Eval_Params *pDlispEvalParams)
{
if (pDlispEvalParams->Feature.InSharpness < 0.0f || pDlispEvalParams->Feature.InSharpness > 1.0f || pDlispEvalParams->InDenoise < 0.0f || pDlispEvalParams->InDenoise > 1.0f)
{
return NVSDK_NGX_Result_FAIL_InvalidParameter;
}
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_Color, pDlispEvalParams->Feature.pInColor);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_Output, pDlispEvalParams->Feature.pInOutput);
// Both sharpness and denoise in range [0.0f,1.0f]
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pDlispEvalParams->Feature.InSharpness);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Denoise, pDlispEvalParams->InDenoise);
// If input is atlas - use RECT to upscale only the required area
if (pDlispEvalParams->InRectW)
{
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_X, pDlispEvalParams->InRectX);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_Y, pDlispEvalParams->InRectY);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_W, pDlispEvalParams->InRectW);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_H, pDlispEvalParams->InRectH);
}
return NVSDK_NGX_D3D12_EvaluateFeature_C(pInCmdList, pInHandle, pInParams, NULL);
}
static inline NVSDK_NGX_Result NGX_D3D12_CREATE_DLRESOLVE_EXT(
ID3D12GraphicsCommandList *pInCmdList,
unsigned int InCreationNodeMask,
unsigned int InVisibilityNodeMask,
NVSDK_NGX_Handle **ppOutHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_Feature_Create_Params *pDlresolveCreateParams)
{
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_CreationNodeMask, InCreationNodeMask);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_VisibilityNodeMask, InVisibilityNodeMask);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pDlresolveCreateParams->InWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pDlresolveCreateParams->InHeight);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pDlresolveCreateParams->InTargetWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pDlresolveCreateParams->InTargetHeight);
return NVSDK_NGX_D3D12_CreateFeature(pInCmdList, NVSDK_NGX_Feature_DeepResolve, pInParams, ppOutHandle);
}
static inline NVSDK_NGX_Result NGX_D3D12_EVALUATE_DLRESOLVE_EXT(
ID3D12GraphicsCommandList *pInCmdList,
NVSDK_NGX_Handle *pInHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_D3D12_Feature_Eval_Params *pDlresolveEvalParams)
{
// This call to NVSDK_NGX_Parameter_SetXXX() is equivalent to the Params->Set below functionally
// but to work around the lack of virtual functions and polymorphism in a C only project
// we introduced this new way to set params.
// The test should enforce that both paths work.
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_Color, pDlresolveEvalParams->pInColor);
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_Output, pDlresolveEvalParams->pInOutput);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pDlresolveEvalParams->InSharpness);
return NVSDK_NGX_D3D12_EvaluateFeature_C(pInCmdList, pInHandle, pInParams, NULL);
}
#endif

View File

@@ -0,0 +1,318 @@
/*
* Copyright (c) 2018 NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property and proprietary
* rights in and to this software, related documentation and any modifications thereto.
* Any use, reproduction, disclosure or distribution of this software and related
* documentation without an express license agreement from NVIDIA Corporation is strictly
* prohibited.
*
* TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
* INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
* SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
* BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
* INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES.
*/
#ifndef NVSDK_NGX_HELPERS_VK_H
#define NVSDK_NGX_HELPERS_VK_H
#pragma once
#include "nvsdk_ngx_vk.h"
#define NVSDK_NGX_ENSURE_VK_IMAGEVIEW(InResource) if ((InResource) && (InResource)->Type != NVSDK_NGX_RESOURCE_VK_TYPE_VK_IMAGEVIEW) { return NVSDK_NGX_Result_FAIL_InvalidParameter; }
static inline NVSDK_NGX_Resource_VK NVSDK_NGX_Create_ImageView_Resource_VK(VkImageView imageView, VkImage image, VkImageSubresourceRange subresourceRange, VkFormat format, unsigned int width, unsigned int height, bool readWrite)
{
NVSDK_NGX_Resource_VK resourceVK = {0};
resourceVK.Type = NVSDK_NGX_RESOURCE_VK_TYPE_VK_IMAGEVIEW;
resourceVK.Resource.ImageViewInfo.ImageView = imageView;
resourceVK.Resource.ImageViewInfo.Image = image;
resourceVK.Resource.ImageViewInfo.SubresourceRange = subresourceRange;
resourceVK.Resource.ImageViewInfo.Height = height;
resourceVK.Resource.ImageViewInfo.Width = width;
resourceVK.Resource.ImageViewInfo.Format = format;
resourceVK.ReadWrite = readWrite;
return resourceVK;
}
static inline NVSDK_NGX_Resource_VK NVSDK_NGX_Create_Buffer_Resource_VK(VkBuffer buffer, unsigned int sizeInBytes, bool readWrite)
{
NVSDK_NGX_Resource_VK resourceVK = {0};
resourceVK.Type = NVSDK_NGX_RESOURCE_VK_TYPE_VK_BUFFER;
resourceVK.Resource.BufferInfo.Buffer = buffer;
resourceVK.Resource.BufferInfo.SizeInBytes = sizeInBytes;
resourceVK.ReadWrite = readWrite;
return resourceVK;
}
typedef struct NVSDK_NGX_VK_Feature_Eval_Params
{
NVSDK_NGX_Resource_VK *pInColor;
NVSDK_NGX_Resource_VK *pInOutput;
/*** OPTIONAL for DLSS ***/
float InSharpness;
} NVSDK_NGX_VK_Feature_Eval_Params;
typedef struct NVSDK_NGX_VK_GBuffer
{
NVSDK_NGX_Resource_VK *pInAttrib[NVSDK_NGX_GBUFFERTYPE_NUM];
} NVSDK_NGX_VK_GBuffer;
typedef struct NVSDK_NGX_Coordinates_VK
{
unsigned int X;
unsigned int Y;
} NVSDK_NGX_Coordinates_VK;
typedef struct NVSDK_NGX_VK_DLSS_Eval_Params
{
NVSDK_NGX_VK_Feature_Eval_Params Feature;
NVSDK_NGX_Resource_VK * pInDepth;
NVSDK_NGX_Resource_VK * pInMotionVectors;
float InJitterOffsetX; /* Jitter offset must be in input/render pixel space */
float InJitterOffsetY;
NVSDK_NGX_Dimensions InRenderSubrectDimensions;
/*** OPTIONAL - leave to 0/0.0f if unused ***/
int InReset; /* Set to 1 when scene changes completely (new level etc) */
float InMVScaleX; /* If MVs need custom scaling to convert to pixel space */
float InMVScaleY;
NVSDK_NGX_Resource_VK * pInTransparencyMask; /* Unused/Reserved for future use */
NVSDK_NGX_Resource_VK * pInExposureTexture;
NVSDK_NGX_Resource_VK * pInBiasCurrentColorMask;
NVSDK_NGX_Coordinates InColorSubrectBase;
NVSDK_NGX_Coordinates InDepthSubrectBase;
NVSDK_NGX_Coordinates InMVSubrectBase;
NVSDK_NGX_Coordinates InTranslucencySubrectBase;
NVSDK_NGX_Coordinates InBiasCurrentColorSubrectBase;
NVSDK_NGX_Coordinates InOutputSubrectBase;
float InPreExposure;
int InIndicatorInvertXAxis;
int InIndicatorInvertYAxis;
/*** OPTIONAL - only for research purposes ***/
NVSDK_NGX_VK_GBuffer GBufferSurface;
NVSDK_NGX_ToneMapperType InToneMapperType;
NVSDK_NGX_Resource_VK * pInMotionVectors3D;
NVSDK_NGX_Resource_VK * pInIsParticleMask; /* to identify which pixels contains particles, essentially that are not drawn as part of base pass */
NVSDK_NGX_Resource_VK * pInAnimatedTextureMask; /* a binary mask covering pixels occupied by animated textures */
NVSDK_NGX_Resource_VK * pInDepthHighRes;
NVSDK_NGX_Resource_VK * pInPositionViewSpace;
float InFrameTimeDeltaInMsec; /* helps in determining the amount to denoise or anti-alias based on the speed of the object from motion vector magnitudes and fps as determined by this delta */
NVSDK_NGX_Resource_VK * pInRayTracingHitDistance; /* for each effect - approximation to the amount of noise in a ray-traced color */
NVSDK_NGX_Resource_VK * pInMotionVectorsReflections; /* motion vectors of reflected objects like for mirrored surfaces */
} NVSDK_NGX_VK_DLSS_Eval_Params;
typedef struct NVSDK_NGX_VK_DLISP_Eval_Params
{
NVSDK_NGX_VK_Feature_Eval_Params Feature;
/*** OPTIONAL - leave to 0/0.0f if unused ***/
unsigned int InRectX;
unsigned int InRectY;
unsigned int InRectW;
unsigned int InRectH;
float InDenoise;
} NVSDK_NGX_VK_DLISP_Eval_Params;
static inline NVSDK_NGX_Result NGX_VULKAN_CREATE_DLSS_EXT1(
VkDevice InDevice,
VkCommandBuffer InCmdList,
unsigned int InCreationNodeMask,
unsigned int InVisibilityNodeMask,
NVSDK_NGX_Handle **ppOutHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_DLSS_Create_Params *pInDlssCreateParams)
{
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_CreationNodeMask, InCreationNodeMask);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_VisibilityNodeMask, InVisibilityNodeMask);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pInDlssCreateParams->Feature.InWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pInDlssCreateParams->Feature.InHeight);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pInDlssCreateParams->Feature.InTargetWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pInDlssCreateParams->Feature.InTargetHeight);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_PerfQualityValue, pInDlssCreateParams->Feature.InPerfQualityValue);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Feature_Create_Flags, pInDlssCreateParams->InFeatureCreateFlags);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Enable_Output_Subrects, pInDlssCreateParams->InEnableOutputSubrects ? 1 : 0);
if (InDevice) return NVSDK_NGX_VULKAN_CreateFeature1(InDevice, InCmdList, NVSDK_NGX_Feature_SuperSampling, pInParams, ppOutHandle);
else return NVSDK_NGX_VULKAN_CreateFeature(InCmdList, NVSDK_NGX_Feature_SuperSampling, pInParams, ppOutHandle);
}
static inline NVSDK_NGX_Result NGX_VULKAN_CREATE_DLSS_EXT(
VkCommandBuffer InCmdList,
unsigned int InCreationNodeMask,
unsigned int InVisibilityNodeMask,
NVSDK_NGX_Handle **ppOutHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_DLSS_Create_Params *pInDlssCreateParams)
{
return NGX_VULKAN_CREATE_DLSS_EXT1(NULL, InCmdList, InCreationNodeMask, InVisibilityNodeMask, ppOutHandle, pInParams, pInDlssCreateParams);
}
static inline NVSDK_NGX_Result NGX_VULKAN_EVALUATE_DLSS_EXT(
VkCommandBuffer InCmdList,
NVSDK_NGX_Handle *pInHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_VK_DLSS_Eval_Params *pInDlssEvalParams)
{
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->Feature.pInColor);
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInMotionVectors);
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->Feature.pInOutput);
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInDepth);
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInTransparencyMask);
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInExposureTexture);
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInBiasCurrentColorMask);
for (size_t i = 0; i <= 15; i++)
{
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->GBufferSurface.pInAttrib[i]);
}
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInMotionVectors3D);
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInIsParticleMask);
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInAnimatedTextureMask);
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInDepthHighRes);
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInPositionViewSpace);
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInRayTracingHitDistance);
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInMotionVectorsReflections);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Color, pInDlssEvalParams->Feature.pInColor);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Output, pInDlssEvalParams->Feature.pInOutput);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Depth, pInDlssEvalParams->pInDepth);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_MotionVectors, pInDlssEvalParams->pInMotionVectors);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Jitter_Offset_X, pInDlssEvalParams->InJitterOffsetX);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Jitter_Offset_Y, pInDlssEvalParams->InJitterOffsetY);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pInDlssEvalParams->Feature.InSharpness);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_Reset, pInDlssEvalParams->InReset);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_MV_Scale_X, pInDlssEvalParams->InMVScaleX == 0.0f ? 1.0f : pInDlssEvalParams->InMVScaleX);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_MV_Scale_Y, pInDlssEvalParams->InMVScaleY == 0.0f ? 1.0f : pInDlssEvalParams->InMVScaleY);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_TransparencyMask, pInDlssEvalParams->pInTransparencyMask);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_ExposureTexture, pInDlssEvalParams->pInExposureTexture);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_Mask, pInDlssEvalParams->pInBiasCurrentColorMask);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Albedo, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_ALBEDO]);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Roughness, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_ROUGHNESS]);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Metallic, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_METALLIC]);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Specular, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_SPECULAR]);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Subsurface, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_SUBSURFACE]);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Normals, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_NORMALS]);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_ShadingModelId, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_SHADINGMODELID]);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_MaterialId, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_MATERIALID]);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_8, pInDlssEvalParams->GBufferSurface.pInAttrib[8]);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_9, pInDlssEvalParams->GBufferSurface.pInAttrib[9]);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_10, pInDlssEvalParams->GBufferSurface.pInAttrib[10]);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_11, pInDlssEvalParams->GBufferSurface.pInAttrib[11]);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_12, pInDlssEvalParams->GBufferSurface.pInAttrib[12]);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_13, pInDlssEvalParams->GBufferSurface.pInAttrib[13]);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_14, pInDlssEvalParams->GBufferSurface.pInAttrib[14]);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_15, pInDlssEvalParams->GBufferSurface.pInAttrib[15]);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_TonemapperType, pInDlssEvalParams->InToneMapperType);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_MotionVectors3D, pInDlssEvalParams->pInMotionVectors3D);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_IsParticleMask, pInDlssEvalParams->pInIsParticleMask);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_AnimatedTextureMask, pInDlssEvalParams->pInAnimatedTextureMask);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_DepthHighRes, pInDlssEvalParams->pInDepthHighRes);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Position_ViewSpace, pInDlssEvalParams->pInPositionViewSpace);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_FrameTimeDeltaInMsec, pInDlssEvalParams->InFrameTimeDeltaInMsec);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_RayTracingHitDistance, pInDlssEvalParams->pInRayTracingHitDistance);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_MotionVectorsReflection, pInDlssEvalParams->pInMotionVectorsReflections);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Color_Subrect_Base_X, pInDlssEvalParams->InColorSubrectBase.X);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Color_Subrect_Base_Y, pInDlssEvalParams->InColorSubrectBase.Y);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Depth_Subrect_Base_X, pInDlssEvalParams->InDepthSubrectBase.X);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Depth_Subrect_Base_Y, pInDlssEvalParams->InDepthSubrectBase.Y);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_MV_SubrectBase_X, pInDlssEvalParams->InMVSubrectBase.X);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_MV_SubrectBase_Y, pInDlssEvalParams->InMVSubrectBase.Y);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Translucency_SubrectBase_X, pInDlssEvalParams->InTranslucencySubrectBase.X);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Translucency_SubrectBase_Y, pInDlssEvalParams->InTranslucencySubrectBase.Y);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_SubrectBase_X, pInDlssEvalParams->InBiasCurrentColorSubrectBase.X);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_SubrectBase_Y, pInDlssEvalParams->InBiasCurrentColorSubrectBase.Y);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Output_Subrect_Base_X, pInDlssEvalParams->InOutputSubrectBase.X);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Output_Subrect_Base_Y, pInDlssEvalParams->InOutputSubrectBase.Y);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Render_Subrect_Dimensions_Width , pInDlssEvalParams->InRenderSubrectDimensions.Width);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Render_Subrect_Dimensions_Height, pInDlssEvalParams->InRenderSubrectDimensions.Height);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_DLSS_Pre_Exposure, pInDlssEvalParams->InPreExposure == 0.0f ? 1.0f : pInDlssEvalParams->InPreExposure);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Indicator_Invert_X_Axis, pInDlssEvalParams->InIndicatorInvertXAxis);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Indicator_Invert_Y_Axis, pInDlssEvalParams->InIndicatorInvertYAxis);
return NVSDK_NGX_VULKAN_EvaluateFeature_C(InCmdList, pInHandle, pInParams, NULL);
}
static inline NVSDK_NGX_Result NGX_VULKAN_CREATE_DLISP_EXT(
VkCommandBuffer InCmdList,
unsigned int InCreationNodeMask,
unsigned int InVisibilityNodeMask,
NVSDK_NGX_Handle **ppOutHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_Feature_Create_Params *pInDlispCreateParams)
{
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_CreationNodeMask, InCreationNodeMask);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_VisibilityNodeMask, InVisibilityNodeMask);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pInDlispCreateParams->InWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pInDlispCreateParams->InHeight);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pInDlispCreateParams->InTargetWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pInDlispCreateParams->InTargetHeight);
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_PerfQualityValue, pInDlispCreateParams->InPerfQualityValue);
return NVSDK_NGX_VULKAN_CreateFeature(InCmdList, NVSDK_NGX_Feature_ImageSignalProcessing, pInParams, ppOutHandle);
}
static inline NVSDK_NGX_Result NGX_VULKAN_EVALUATE_DLISP_EXT(
VkCommandBuffer InCmdList,
NVSDK_NGX_Handle *InHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_VK_DLISP_Eval_Params *pInDlispEvalParams)
{
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlispEvalParams->Feature.pInColor);
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlispEvalParams->Feature.pInOutput);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Color, pInDlispEvalParams->Feature.pInColor);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Output, pInDlispEvalParams->Feature.pInOutput);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pInDlispEvalParams->Feature.InSharpness);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Denoise, pInDlispEvalParams->InDenoise);
// If input is atlas - use RECT to upscale only the required area
if (pInDlispEvalParams->InRectW)
{
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_X, pInDlispEvalParams->InRectX);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_Y, pInDlispEvalParams->InRectY);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_W, pInDlispEvalParams->InRectW);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_H, pInDlispEvalParams->InRectH);
}
return NVSDK_NGX_VULKAN_EvaluateFeature_C(InCmdList, InHandle, pInParams, NULL);
}
static inline NVSDK_NGX_Result NGX_VULKAN_CREATE_DLRESOLVE_EXT(
VkCommandBuffer InCmdList,
unsigned int InCreationNodeMask,
unsigned int InVisibilityNodeMask,
NVSDK_NGX_Handle **ppOutHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_Feature_Create_Params *pInDlresolveCreateParams)
{
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_CreationNodeMask, InCreationNodeMask);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_VisibilityNodeMask, InVisibilityNodeMask);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pInDlresolveCreateParams->InWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pInDlresolveCreateParams->InHeight);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pInDlresolveCreateParams->InTargetWidth);
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pInDlresolveCreateParams->InTargetHeight);
return NVSDK_NGX_VULKAN_CreateFeature(InCmdList, NVSDK_NGX_Feature_DeepResolve, pInParams, ppOutHandle);
}
static inline NVSDK_NGX_Result NGX_VULKAN_EVALUATE_DLRESOLVE_EXT(
VkCommandBuffer InCmdList,
NVSDK_NGX_Handle *pInHandle,
NVSDK_NGX_Parameter *pInParams,
NVSDK_NGX_VK_Feature_Eval_Params *pInDlresolveEvalParams)
{
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlresolveEvalParams->pInColor);
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlresolveEvalParams->pInOutput);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Color, pInDlresolveEvalParams->pInColor);
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Output, pInDlresolveEvalParams->pInOutput);
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pInDlresolveEvalParams->InSharpness);
return NVSDK_NGX_VULKAN_EvaluateFeature_C(InCmdList, pInHandle, pInParams, NULL);
}
#endif // NVSDK_NGX_HELPERS_VK_H

View File

@@ -0,0 +1,117 @@
/*
* Copyright (c) 2018 NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property and proprietary
* rights in and to this software, related documentation and any modifications thereto.
* Any use, reproduction, disclosure or distribution of this software and related
* documentation without an express license agreement from NVIDIA Corporation is strictly
* prohibited.
*
* TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
* INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
* SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
* BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
* INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES.
*/
#ifndef NVSDK_NGX_PARAMS_H
#define NVSDK_NGX_PARAMS_H
#include "nvsdk_ngx_defs.h"
#ifdef __cplusplus
extern "C"
{
#endif
typedef struct ID3D11Resource ID3D11Resource;
typedef struct ID3D12Resource ID3D12Resource;
typedef struct NVSDK_NGX_Feature_Create_Params
{
unsigned int InWidth;
unsigned int InHeight;
unsigned int InTargetWidth;
unsigned int InTargetHeight;
/*** OPTIONAL ***/
NVSDK_NGX_PerfQuality_Value InPerfQualityValue;
} NVSDK_NGX_Feature_Create_Params;
typedef struct NVSDK_NGX_DLSS_Create_Params
{
NVSDK_NGX_Feature_Create_Params Feature;
/*** OPTIONAL ***/
int InFeatureCreateFlags;
bool InEnableOutputSubrects;
} NVSDK_NGX_DLSS_Create_Params;
#ifdef __cplusplus
typedef struct NVSDK_NGX_Parameter
{
virtual void Set(const char * InName, unsigned long long InValue) = 0;
virtual void Set(const char * InName, float InValue) = 0;
virtual void Set(const char * InName, double InValue) = 0;
virtual void Set(const char * InName, unsigned int InValue) = 0;
virtual void Set(const char * InName, int InValue) = 0;
virtual void Set(const char * InName, ID3D11Resource *InValue) = 0;
virtual void Set(const char * InName, ID3D12Resource *InValue) = 0;
virtual void Set(const char * InName, void *InValue) = 0;
virtual NVSDK_NGX_Result Get(const char * InName, unsigned long long *OutValue) const = 0;
virtual NVSDK_NGX_Result Get(const char * InName, float *OutValue) const = 0;
virtual NVSDK_NGX_Result Get(const char * InName, double *OutValue) const = 0;
virtual NVSDK_NGX_Result Get(const char * InName, unsigned int *OutValue) const = 0;
virtual NVSDK_NGX_Result Get(const char * InName, int *OutValue) const = 0;
virtual NVSDK_NGX_Result Get(const char * InName, ID3D11Resource **OutValue) const = 0;
virtual NVSDK_NGX_Result Get(const char * InName, ID3D12Resource **OutValue) const = 0;
virtual NVSDK_NGX_Result Get(const char * InName, void **OutValue) const = 0;
virtual void Reset() = 0;
} NVSDK_NGX_Parameter;
#else
typedef struct NVSDK_NGX_Parameter NVSDK_NGX_Parameter;
#endif // _cplusplus
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_SetULL)(NVSDK_NGX_Parameter *InParameter, const char * InName, unsigned long long InValue);
NVSDK_NGX_API void NVSDK_CONV NVSDK_NGX_Parameter_SetULL(NVSDK_NGX_Parameter *InParameter, const char * InName, unsigned long long InValue);
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_SetF)(NVSDK_NGX_Parameter *InParameter, const char * InName, float InValue);
NVSDK_NGX_API void NVSDK_CONV NVSDK_NGX_Parameter_SetF(NVSDK_NGX_Parameter *InParameter, const char * InName, float InValue);
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_SetD)(NVSDK_NGX_Parameter *InParameter, const char * InName, double InValue);
NVSDK_NGX_API void NVSDK_CONV NVSDK_NGX_Parameter_SetD(NVSDK_NGX_Parameter *InParameter, const char * InName, double InValue);
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_SetUI)(NVSDK_NGX_Parameter *InParameter, const char * InName, unsigned int InValue);
NVSDK_NGX_API void NVSDK_CONV NVSDK_NGX_Parameter_SetUI(NVSDK_NGX_Parameter *InParameter, const char * InName, unsigned int InValue);
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_SetI)(NVSDK_NGX_Parameter *InParameter, const char * InName, int InValue);
NVSDK_NGX_API void NVSDK_CONV NVSDK_NGX_Parameter_SetI(NVSDK_NGX_Parameter *InParameter, const char * InName, int InValue);
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_SetD3d11Resource)(NVSDK_NGX_Parameter *InParameter, const char * InName, ID3D11Resource *InValue);
NVSDK_NGX_API void NVSDK_CONV NVSDK_NGX_Parameter_SetD3d11Resource(NVSDK_NGX_Parameter *InParameter, const char * InName, ID3D11Resource *InValue);
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_SetD3d12Resource)(NVSDK_NGX_Parameter *InParameter, const char * InName, ID3D12Resource *InValue);
NVSDK_NGX_API void NVSDK_CONV NVSDK_NGX_Parameter_SetD3d12Resource(NVSDK_NGX_Parameter *InParameter, const char * InName, ID3D12Resource *InValue);
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_SetVoidPointer)(NVSDK_NGX_Parameter *InParameter, const char * InName, void *InValue);
NVSDK_NGX_API void NVSDK_CONV NVSDK_NGX_Parameter_SetVoidPointer(NVSDK_NGX_Parameter *InParameter, const char * InName, void *InValue);
typedef NVSDK_NGX_Result (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_GetULL)(NVSDK_NGX_Parameter *InParameter, const char * InName, unsigned long long *OutValue);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_Parameter_GetULL(NVSDK_NGX_Parameter *InParameter, const char * InName, unsigned long long *OutValue);
typedef NVSDK_NGX_Result (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_GetF)(NVSDK_NGX_Parameter *InParameter, const char * InName, float *OutValue);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_Parameter_GetF(NVSDK_NGX_Parameter *InParameter, const char * InName, float *OutValue);
typedef NVSDK_NGX_Result (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_GetD)(NVSDK_NGX_Parameter *InParameter, const char * InName, double *OutValue);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_Parameter_GetD(NVSDK_NGX_Parameter *InParameter, const char * InName, double *OutValue);
typedef NVSDK_NGX_Result (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_GetUI)(NVSDK_NGX_Parameter *InParameter, const char * InName, unsigned int *OutValue);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_Parameter_GetUI(NVSDK_NGX_Parameter *InParameter, const char * InName, unsigned int *OutValue);
typedef NVSDK_NGX_Result (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_GetI)(NVSDK_NGX_Parameter *InParameter, const char * InName, int *OutValue);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_Parameter_GetI(NVSDK_NGX_Parameter *InParameter, const char * InName, int *OutValue);
typedef NVSDK_NGX_Result (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_GetD3d11Resource)(NVSDK_NGX_Parameter *InParameter, const char * InName, ID3D11Resource **OutValue);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_Parameter_GetD3d11Resource(NVSDK_NGX_Parameter *InParameter, const char * InName, ID3D11Resource **OutValue);
typedef NVSDK_NGX_Result (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_GetD3d12Resource)(NVSDK_NGX_Parameter *InParameter, const char * InName, ID3D12Resource **OutValue);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_Parameter_GetD3d12Resource(NVSDK_NGX_Parameter *InParameter, const char * InName, ID3D12Resource **OutValue);
typedef NVSDK_NGX_Result (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_GetVoidPointer)(NVSDK_NGX_Parameter *InParameter, const char * InName, void **OutValue);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_Parameter_GetVoidPointer(NVSDK_NGX_Parameter *InParameter, const char * InName, void **OutValue);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // #define NVSDK_NGX_PARAMS_H

View File

@@ -0,0 +1,462 @@
/*
* Copyright (c) 2018 NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property and proprietary
* rights in and to this software, related documentation and any modifications thereto.
* Any use, reproduction, disclosure or distribution of this software and related
* documentation without an express license agreement from NVIDIA Corporation is strictly
* prohibited.
*
* TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
* INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
* SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
* BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
* INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES.
*/
/*
* HOW TO USE:
*
* IMPORTANT: Methods in this library are NOT thread safe. It is up to the
* client to ensure that thread safety is enforced as needed.
*
* 1) Call NVSDK_CONV NVSDK_NGX_D3D11/D3D12/CUDA_Init and pass your app Id
* and other parameters. This will initialize SDK or return an error code
* if SDK cannot run on target machine. Depending on error user might
* need to update drivers. Please note that application Id is provided
* by NVIDIA so if you do not have one please contact us.
*
* 2) Call NVSDK_NGX_D3D11/D3D12/CUDA_GetParameters to obtain pointer to
* interface used to pass parameters to SDK. Interface instance is
* allocated and released by SDK so there is no need to do any memory
* management on client side.
*
* 3) Set key parameters for the feature you want to use. For example,
* width and height are required for all features and they can be
* set like this:
* Params->Set(NVSDK_NGX_Parameter_Width,MY_WIDTH);
* Params->Set(NVSDK_NGX_Parameter_Height,MY_HEIGHT);
*
* You can also provide hints like NVSDK_NGX_Parameter_Hint_HDR to tell
* SDK that it should expect HDR color space is needed. Please refer to
* samples since different features need different parameters and hints.
*
* 4) Call NVSDK_NGX_D3D11/D3D12/CUDA_GetScratchBufferSize to obtain size of
* the scratch buffer needed by specific feature. This D3D or CUDA buffer
* should be allocated by client and passed as:
* Params->Set(NVSDK_NGX_Parameter_Scratch,MY_SCRATCH_POINTER)
* Params->Set(NVSDK_NGX_Parameter_Scratch_SizeInBytes,MY_SCRATCH_SIZE_IN_BYTES)
* NOTE: Returned size can be 0 if feature does not use any scratch buffer.
* It is OK to use bigger buffer or reuse buffers across features as long
* as minimum size requirement is met.
*
* 5) Call NVSDK_NGX_D3D11/D3D12/CUDA_CreateFeature to create feature you need.
* On success SDK will return a handle which must be used in any successive
* calls to SDK which require feature handle. SDK will use all parameters
* and hints provided by client to generate feature. If feature with the same
* parameters already exists and error code will be returned.
*
* 6) Call NVSDK_NGX_D3D11/D3D12/CUDA_EvaluateFeature to invoke execution of
* specific feature. Before feature can be evaluated input parameters must
* be specified (like for example color/albedo buffer, motion vectors etc)
*
* 6) Call NVSDK_NGX_D3D11/D3D12/CUDA_ReleaseFeature when feature is no longer
* needed. After this call feature handle becomes invalid and cannot be used.
*
* 7) Call NVSDK_NGX_D3D11/D3D12/CUDA_Shutdown when SDK is no longer needed to
* release all resources.
* Contact: ngxsupport@nvidia.com
*/
#ifndef NVSDK_NGX_VK_H
#define NVSDK_NGX_VK_H
#include "nvsdk_ngx_defs.h"
#include "nvsdk_ngx_params.h"
#ifndef __cplusplus
#include <stdbool.h>
#include <wchar.h>
#endif
#ifdef __cplusplus
extern "C"
{
#endif
///////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_ImageViewInfo_VK [Vulkan only]
// Contains ImageView-specific metadata.
// ImageView:
// The VkImageView resource.
//
// Image:
// The VkImage associated to this VkImageView.
//
// SubresourceRange:
// The VkImageSubresourceRange associated to this VkImageView.
//
// Format:
// The format of the resource.
//
// Width:
// The width of the resource.
//
// Height:
// The height of the resource.
//
typedef struct NVSDK_NGX_ImageViewInfo_VK {
VkImageView ImageView;
VkImage Image;
VkImageSubresourceRange SubresourceRange;
VkFormat Format;
unsigned int Width;
unsigned int Height;
} NVSDK_NGX_ImageViewInfo_VK;
///////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_BufferInfo_VK [Vulkan only]
// Contains Buffer-specific metadata.
// Buffer
// The VkBuffer resource.
//
// SizeInBytes:
// The size of the resource (in bytes).
//
typedef struct NVSDK_NGX_BufferInfo_VK {
VkBuffer Buffer;
unsigned int SizeInBytes;
} NVSDK_NGX_BufferInfo_VK;
///////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_Resource_VK [Vulkan only]
//
// ImageViewInfo:
// The VkImageView resource, and VkImageView-specific metadata. A NVSDK_NGX_Resource_VK can only have one of ImageViewInfo or BufferInfo.
//
// BufferInfo:
// The VkBuffer Resource, and VkBuffer-specific metadata. A NVSDK_NGX_Resource_VK can only have one of ImageViewInfo or BufferInfo.
//
// Type:
// Whether or this resource is a VkImageView or a VkBuffer.
//
// ReadWrite:
// True if the resource is available for read and write access.
// For VkBuffer resources: VkBufferUsageFlags includes VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT or VK_BUFFER_USAGE_STORAGE_BUFFER_BIT
// For VkImage resources: VkImageUsageFlags for associated VkImage includes VK_IMAGE_USAGE_STORAGE_BIT
//
typedef struct NVSDK_NGX_Resource_VK {
union {
NVSDK_NGX_ImageViewInfo_VK ImageViewInfo;
NVSDK_NGX_BufferInfo_VK BufferInfo;
} Resource;
NVSDK_NGX_Resource_VK_Type Type;
bool ReadWrite;
} NVSDK_NGX_Resource_VK;
///////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_RequiredExtensions [Vulkan only]
//
// OutInstanceExtCount:
// Returns the number of instance extensions NGX requires
//
// OutInstanceExts:
// Returns a pointer to *OutInstanceExtCount strings of instance extensions
//
// OutDeviceExtCount:
// Returns the number of device extensions NGX requires
//
// OutDeviceExts:
// Returns a pointer to *OutDeviceExtCount strings of device extensions
//
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_RequiredExtensions(unsigned int *OutInstanceExtCount, const char *** OutInstanceExts, unsigned int *OutDeviceExtCount, const char *** OutDeviceExts);
///////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_Init
// -------------------------------------
//
// InApplicationId:
// Unique Id provided by NVIDIA
//
// InApplicationDataPath:
// Folder to store logs and other temporary files (write access required),
// Normally this would be a location in Documents or ProgramData.
//
// InDevice: [d3d11/12 only]
// DirectX device to use
//
// DESCRIPTION:
// Initializes new SDK instance.
//
#ifdef __cplusplus
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_Init(unsigned long long InApplicationId, const wchar_t *InApplicationDataPath, VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo = nullptr, NVSDK_NGX_Version InSDKVersion = NVSDK_NGX_Version_API);
#else
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_Init(unsigned long long InApplicationId, const wchar_t *InApplicationDataPath, VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
#endif
///////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_Init_with_ProjectID
// -------------------------------------
//
// InParojectId:
// Unique Id provided by the rendering engine used
//
// InEngineType:
// Rendering engine used by the application / plugin.
// Use NVSDK_NGX_ENGINE_TYPE_CUSTOM if the specific engine type is not supported explicitly
//
// InEngineVersion:
// Version number of the rendering engine used by the application / plugin.
//
// InApplicationDataPath:
// Folder to store logs and other temporary files (write access required),
// Normally this would be a location in Documents or ProgramData.
//
// InDevice: [d3d11/12 only]
// DirectX device to use
//
// InFeatureInfo:
// Contains information common to all features, presently only a list of all paths
// feature dlls can be located in, other than the default path - application directory.
//
// DESCRIPTION:
// Initializes new SDK instance.
//
#ifdef __cplusplus
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_Init_with_ProjectID(const char *InProjectId, NVSDK_NGX_EngineType InEngineType, const char *InEngineVersion, const wchar_t *InApplicationDataPath, VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo = nullptr, NVSDK_NGX_Version InSDKVersion = NVSDK_NGX_Version_API);
#else
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_Init_with_ProjectID(const char *InProjectId, NVSDK_NGX_EngineType InEngineType, const char *InEngineVersion, const wchar_t *InApplicationDataPath, VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_Shutdown
// -------------------------------------
//
// DESCRIPTION:
// Shuts down the current SDK instance and releases all resources.
// Shutdown1(Device) only affects specified device
// Shutdown1(nullptr) = Shutdown() and shuts down all devices
//
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_Shutdown(void);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_Shutdown1(VkDevice InDevice);
////////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_GetParameters
// ----------------------------------------------------------
//
// OutParameters:
// Parameters interface used to set any parameter needed by the SDK
//
// DESCRIPTION:
// This interface allows simple parameter setup using named fields.
// For example one can set width by calling Set(NVSDK_NGX_Parameter_Denoiser_Width,100) or
// provide CUDA buffer pointer by calling Set(NVSDK_NGX_Parameter_Denoiser_Color,cudaBuffer)
// For more details please see sample code. Please note that allocated memory
// will be freed by NGX so free/delete operator should NOT be called.
// Parameter maps output by NVSDK_NGX_GetParameters are also pre-populated
// with NGX capabilities and available features.
// Unlike with NVSDK_NGX_AllocateParameters, parameter maps output by NVSDK_NGX_GetParameters
// have their lifetimes managed by NGX, and must not
// be destroyed by the app using NVSDK_NGX_DestroyParameters.
// NVSDK_NGX_GetParameters is soon to be deprecated and apps should move to using
// NVSDK_NGX_AllocateParameters and NVSDK_NGX_GetCapabilityParameters when possible.
// Nevertheless, due to the possibility that the user will be using an older driver version,
// NVSDK_NGX_GetParameters should still be used as a fallback if NVSDK_NGX_AllocateParameters
// or NVSDK_NGX_GetCapabilityParameters return NVSDK_NGX_Result_FAIL_OutOfDate.
//
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_GetParameters(NVSDK_NGX_Parameter **OutParameters);
////////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_AllocateParameters
// ----------------------------------------------------------
//
// OutParameters:
// Parameters interface used to set any parameter needed by the SDK
//
// DESCRIPTION:
// This interface allows allocating a simple parameter setup using named fields, whose
// lifetime the app must manage.
// For example one can set width by calling Set(NVSDK_NGX_Parameter_Denoiser_Width,100) or
// provide CUDA buffer pointer by calling Set(NVSDK_NGX_Parameter_Denoiser_Color,cudaBuffer)
// For more details please see sample code.
// Parameter maps output by NVSDK_NGX_AllocateParameters must NOT be freed using
// the free/delete operator; to free a parameter map
// output by NVSDK_NGX_AllocateParameters, NVSDK_NGX_DestroyParameters should be used.
// Unlike with NVSDK_NGX_GetParameters, parameter maps allocated with NVSDK_NGX_AllocateParameters
// must be destroyed by the app using NVSDK_NGX_DestroyParameters.
// Also unlike with NVSDK_NGX_GetParameters, parameter maps output by NVSDK_NGX_AllocateParameters
// do not come pre-populated with NGX capabilities and available features.
// To create a new parameter map pre-populated with such information, NVSDK_NGX_GetCapabilityParameters
// should be used.
// This function may return NVSDK_NGX_Result_FAIL_OutOfDate if an older driver, which
// does not support this API call is being used. In such a case, NVSDK_NGX_GetParameters
// may be used as a fallback.
// This function may only be called after a successful call into NVSDK_NGX_Init.
//
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_AllocateParameters(NVSDK_NGX_Parameter** OutParameters);
////////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_GetCapabilityParameters
// ----------------------------------------------------------
//
// OutParameters:
// The parameters interface populated with NGX and feature capabilities
//
// DESCRIPTION:
// This interface allows the app to create a new parameter map
// pre-populated with NGX capabilities and available features.
// The output parameter map can also be used for any purpose
// parameter maps output by NVSDK_NGX_AllocateParameters can be used for
// but it is not recommended to use NVSDK_NGX_GetCapabilityParameters
// unless querying NGX capabilities and available features
// due to the overhead associated with pre-populating the parameter map.
// Parameter maps output by NVSDK_NGX_GetCapabilityParameters must NOT be freed using
// the free/delete operator; to free a parameter map
// output by NVSDK_NGX_GetCapabilityParameters, NVSDK_NGX_DestroyParameters should be used.
// Unlike with NVSDK_NGX_GetParameters, parameter maps allocated with NVSDK_NGX_GetCapabilityParameters
// must be destroyed by the app using NVSDK_NGX_DestroyParameters.
// This function may return NVSDK_NGX_Result_FAIL_OutOfDate if an older driver, which
// does not support this API call is being used. This function may only be called
// after a successful call into NVSDK_NGX_Init.
// If NVSDK_NGX_GetCapabilityParameters fails with NVSDK_NGX_Result_FAIL_OutOfDate,
// NVSDK_NGX_GetParameters may be used as a fallback, to get a parameter map pre-populated
// with NGX capabilities and available features.
//
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_GetCapabilityParameters(NVSDK_NGX_Parameter** OutParameters);
////////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_DestroyParameters
// ----------------------------------------------------------
//
// InParameters:
// The parameters interface to be destroyed
//
// DESCRIPTION:
// This interface allows the app to destroy the parameter map passed in. Once
// NVSDK_NGX_DestroyParameters is called on a parameter map, it
// must not be used again.
// NVSDK_NGX_DestroyParameters must not be called on any parameter map returned
// by NVSDK_NGX_GetParameters; NGX will manage the lifetime of those
// parameter maps.
// This function may return NVSDK_NGX_Result_FAIL_OutOfDate if an older driver, which
// does not support this API call is being used. This function may only be called
// after a successful call into NVSDK_NGX_Init.
//
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_DestroyParameters(NVSDK_NGX_Parameter* InParameters);
////////////////////////////////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_GetScratchBufferSize
// ----------------------------------------------------------
//
// InFeatureId:
// AI feature in question
//
// InParameters:
// Parameters used by the feature to help estimate scratch buffer size
//
// OutSizeInBytes:
// Number of bytes needed for the scratch buffer for the specified feature.
//
// DESCRIPTION:
// SDK needs a buffer of a certain size provided by the client in
// order to initialize AI feature. Once feature is no longer
// needed buffer can be released. It is safe to reuse the same
// scratch buffer for different features as long as minimum size
// requirement is met for all features. Please note that some
// features might not need a scratch buffer so return size of 0
// is completely valid.
//
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_GetScratchBufferSize(NVSDK_NGX_Feature InFeatureId, const NVSDK_NGX_Parameter *InParameters, size_t *OutSizeInBytes);
/////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_CreateFeature
// -------------------------------------
//
// InCmdBuffer:
// Command buffer to use to execute GPU commands. Must be:
// - Open and recording
// InFeatureID:
// AI feature to initialize
//
// InParameters:
// List of parameters
//
// OutHandle:
// Handle which uniquely identifies the feature. If feature with
// provided parameters already exists the "already exists" error code is returned.
//
// DESCRIPTION:
// Each feature needs to be created before it can be used.
// Refer to the sample code to find out which input parameters
// are needed to create specific feature.
// CreateFeature() creates feature on single existing Device
// CreateFeature1() creates feature on the specified Device
//
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_CreateFeature(VkCommandBuffer InCmdBuffer, NVSDK_NGX_Feature InFeatureID, const NVSDK_NGX_Parameter *InParameters, NVSDK_NGX_Handle **OutHandle);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_CreateFeature1(VkDevice InDevice, VkCommandBuffer InCmdList, NVSDK_NGX_Feature InFeatureID, const NVSDK_NGX_Parameter *InParameters, NVSDK_NGX_Handle **OutHandle);
/////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_Release
// -------------------------------------
//
// InHandle:
// Handle to feature to be released
//
// DESCRIPTION:
// Releases feature with a given handle.
// Handles are not reference counted so
// after this call it is invalid to use provided handle.
//
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_ReleaseFeature(NVSDK_NGX_Handle *InHandle);
/////////////////////////////////////////////////////////////////////////
// NVSDK_NGX_EvaluateFeature
// -------------------------------------
//
// InCmdList:[d3d12 only]
// Command list to use to execute GPU commands. Must be:
// - Open and recording
// - With node mask including the device provided in NVSDK_NGX_D3D12_Init
// - Execute on non-copy command queue.
// InDevCtx: [d3d11 only]
// Device context to use to execute GPU commands
//
// InFeatureHandle:
// Handle representing feature to be evaluated
//
// InParameters:
// List of parameters required to evaluate feature
//
// InCallback:
// Optional callback for features which might take longer
// to execture. If specified SDK will call it with progress
// values in range 0.0f - 1.0f
//
// DESCRIPTION:
// Evaluates given feature using the provided parameters and
// pre-trained NN. Please note that for most features
// it can be benefitials to pass as many input buffers and parameters
// as possible (for example provide all render targets like color, albedo, normals, depth etc)
//
#ifdef __cplusplus
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_ProgressCallback)(float InCurrentProgress, bool &OutShouldCancel);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_EvaluateFeature(VkCommandBuffer InCmdList, const NVSDK_NGX_Handle *InFeatureHandle, const NVSDK_NGX_Parameter *InParameters, PFN_NVSDK_NGX_ProgressCallback InCallback = NULL);
#endif
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_ProgressCallback_C)(float InCurrentProgress, bool *OutShouldCancel);
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_EvaluateFeature_C(VkCommandBuffer InCmdList, const NVSDK_NGX_Handle *InFeatureHandle, const NVSDK_NGX_Parameter *InParameters, PFN_NVSDK_NGX_ProgressCallback_C InCallback);
// NGX return-code conversion-to-string utility only as a helper for debugging/logging - not for official use.
const wchar_t* NVSDK_CONV GetNGXResultAsString(NVSDK_NGX_Result InNGXResult);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // #define NVSDK_NGX_VK_H