nvsdk_ngx.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. /*
  2. * Copyright (c) 2018 NVIDIA CORPORATION. All rights reserved.
  3. *
  4. * NVIDIA Corporation and its licensors retain all intellectual property and proprietary
  5. * rights in and to this software, related documentation and any modifications thereto.
  6. * Any use, reproduction, disclosure or distribution of this software and related
  7. * documentation without an express license agreement from NVIDIA Corporation is strictly
  8. * prohibited.
  9. *
  10. * TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
  11. * AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
  12. * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  13. * PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
  14. * SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
  15. * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
  16. * BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
  17. * INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
  18. * SUCH DAMAGES.
  19. */
  20. /*
  21. * HOW TO USE:
  22. *
  23. * IMPORTANT: FOR DLSS/DLISP PLEASE SEE THE PROGRAMMING GUIDE
  24. *
  25. * IMPORTANT: Methods in this library are NOT thread safe. It is up to the
  26. * client to ensure that thread safety is enforced as needed.
  27. *
  28. * 1) Call NVSDK_CONV NVSDK_NGX_D3D11/D3D12/CUDA_Init and pass your app Id
  29. * and other parameters. This will initialize SDK or return an error code
  30. * if SDK cannot run on target machine. Depending on error user might
  31. * need to update drivers. Please note that application Id is provided
  32. * by NVIDIA so if you do not have one please contact us.
  33. *
  34. * 2) Call NVSDK_NGX_D3D11/D3D12/CUDA_GetCapabilityParameters to obtain pointer
  35. * to interface used to pass parameters to SDK. Interface instance is
  36. * allocated and released by SDK so there is no need to do any memory
  37. * management on client side.
  38. *
  39. * 3) Set key parameters for the feature you want to use. For example,
  40. * width and height are required for all features and they can be
  41. * set like this:
  42. * Params->Set(NVSDK_NGX_Parameter_Width,MY_WIDTH);
  43. * Params->Set(NVSDK_NGX_Parameter_Height,MY_HEIGHT);
  44. *
  45. * You can also provide hints like NVSDK_NGX_Parameter_Hint_HDR to tell
  46. * SDK that it should expect HDR color space is needed. Please refer to
  47. * samples since different features need different parameters and hints.
  48. *
  49. * 4) Call NVSDK_NGX_D3D11/D3D12/CUDA_GetScratchBufferSize to obtain size of
  50. * the scratch buffer needed by specific feature. This D3D or CUDA buffer
  51. * should be allocated by client and passed as:
  52. * Params->Set(NVSDK_NGX_Parameter_Scratch,MY_SCRATCH_POINTER)
  53. * Params->Set(NVSDK_NGX_Parameter_Scratch_SizeInBytes,MY_SCRATCH_SIZE_IN_BYTES)
  54. * NOTE: Returned size can be 0 if feature does not use any scratch buffer.
  55. * It is OK to use bigger buffer or reuse buffers across features as long
  56. * as minimum size requirement is met.
  57. *
  58. * 5) Call NVSDK_NGX_D3D11/D3D12/CUDA_CreateFeature to create feature you need.
  59. * On success SDK will return a handle which must be used in any successive
  60. * calls to SDK which require feature handle. SDK will use all parameters
  61. * and hints provided by client to generate feature. If feature with the same
  62. * parameters already exists and error code will be returned.
  63. *
  64. * 6) Call NVSDK_NGX_D3D11/D3D12/CUDA_EvaluateFeature to invoke execution of
  65. * specific feature. Before feature can be evaluated input parameters must
  66. * be specified (like for example color/albedo buffer, motion vectors etc)
  67. *
  68. * 6) Call NVSDK_NGX_D3D11/D3D12/CUDA_ReleaseFeature when feature is no longer
  69. * needed. After this call feature handle becomes invalid and cannot be used.
  70. *
  71. * 7) Call NVSDK_NGX_D3D11/D3D12/CUDA_Shutdown when SDK is no longer needed to
  72. * release all resources.
  73. * Contact: [email protected]
  74. */
  75. #ifndef NVSDK_NGX_H
  76. #define NVSDK_NGX_H
  77. #include <stddef.h> // For size_t
  78. #include "nvsdk_ngx_defs.h"
  79. #include "nvsdk_ngx_params.h"
  80. #ifndef __cplusplus
  81. #include <stdbool.h>
  82. #include <wchar.h>
  83. #endif
  84. #ifdef __cplusplus
  85. extern "C"
  86. {
  87. #endif
  88. typedef struct IUnknown IUnknown;
  89. typedef struct ID3D11Device ID3D11Device;
  90. typedef struct ID3D11Resource ID3D11Resource;
  91. typedef struct ID3D11DeviceContext ID3D11DeviceContext;
  92. typedef struct D3D11_TEXTURE2D_DESC D3D11_TEXTURE2D_DESC;
  93. typedef struct D3D11_BUFFER_DESC D3D11_BUFFER_DESC;
  94. typedef struct ID3D11Buffer ID3D11Buffer;
  95. typedef struct ID3D11Texture2D ID3D11Texture2D;
  96. typedef struct ID3D12Device ID3D12Device;
  97. typedef struct ID3D12Resource ID3D12Resource;
  98. typedef struct ID3D12GraphicsCommandList ID3D12GraphicsCommandList;
  99. typedef struct D3D12_RESOURCE_DESC D3D12_RESOURCE_DESC;
  100. typedef struct CD3DX12_HEAP_PROPERTIES CD3DX12_HEAP_PROPERTIES;
  101. typedef void (NVSDK_CONV *PFN_NVSDK_NGX_D3D12_ResourceAllocCallback)(D3D12_RESOURCE_DESC *InDesc, int InState, CD3DX12_HEAP_PROPERTIES *InHeap, ID3D12Resource **OutResource);
  102. typedef void (NVSDK_CONV *PFN_NVSDK_NGX_D3D11_BufferAllocCallback)(D3D11_BUFFER_DESC *InDesc, ID3D11Buffer **OutResource);
  103. typedef void (NVSDK_CONV *PFN_NVSDK_NGX_D3D11_Tex2DAllocCallback)(D3D11_TEXTURE2D_DESC *InDesc, ID3D11Texture2D **OutResource);
  104. typedef void (NVSDK_CONV *PFN_NVSDK_NGX_ResourceReleaseCallback)(IUnknown *InResource);
  105. typedef unsigned long long CUtexObject;
  106. ///////////////////////////////////////////////////////////////////////////////////////////////////
  107. // NVSDK_NGX_Init
  108. // -------------------------------------
  109. //
  110. // InApplicationId:
  111. // Unique Id provided by NVIDIA
  112. //
  113. // InApplicationDataPath:
  114. // Folder to store logs and other temporary files (write access required),
  115. // Normally this would be a location in Documents or ProgramData.
  116. //
  117. // InDevice: [d3d11/12 only]
  118. // DirectX device to use
  119. //
  120. // InFeatureInfo:
  121. // Contains information common to all features, presently only a list of all paths
  122. // feature dlls can be located in, other than the default path - application directory.
  123. //
  124. // DESCRIPTION:
  125. // Initializes new SDK instance.
  126. //
  127. #ifdef __cplusplus
  128. 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);
  129. 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);
  130. 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);
  131. #else
  132. 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);
  133. 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);
  134. 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);
  135. #endif
  136. ///////////////////////////////////////////////////////////////////////////////////////////////////
  137. // NVSDK_NGX_Init_with_ProjectID
  138. // -------------------------------------
  139. //
  140. // InProjectId:
  141. // Unique Id provided by the rendering engine used
  142. //
  143. // InEngineType:
  144. // Rendering engine used by the application / plugin.
  145. // Use NVSDK_NGX_ENGINE_TYPE_CUSTOM if the specific engine type is not supported explicitly
  146. //
  147. // InEngineVersion:
  148. // Version number of the rendering engine used by the application / plugin.
  149. //
  150. // InApplicationDataPath:
  151. // Folder to store logs and other temporary files (write access required),
  152. // Normally this would be a location in Documents or ProgramData.
  153. //
  154. // InDevice: [d3d11/12 only]
  155. // DirectX device to use
  156. //
  157. // InFeatureInfo:
  158. // Contains information common to all features, presently only a list of all paths
  159. // feature dlls can be located in, other than the default path - application directory.
  160. //
  161. // DESCRIPTION:
  162. // Initializes new SDK instance.
  163. //
  164. #ifdef __cplusplus
  165. 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);
  166. 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);
  167. 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);
  168. #else
  169. 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);
  170. 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);
  171. 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);
  172. #endif
  173. ////////////////////////////////////////////////////////////////////////////////////////////////////
  174. // NVSDK_NGX_Shutdown
  175. // -------------------------------------
  176. //
  177. // DESCRIPTION:
  178. // Shuts down the current SDK instance and releases all resources.
  179. // Shutdown1(Device) only affects specified device
  180. // Shutdown1(nullptr) = Shutdown() and shuts down all devices
  181. //
  182. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_Shutdown(void);
  183. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_Shutdown1(ID3D11Device *InDevice);
  184. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_Shutdown(void);
  185. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_Shutdown1(ID3D12Device *InDevice);
  186. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_Shutdown(void);
  187. #ifdef NGX_ENABLE_DEPRECATED_GET_PARAMETERS
  188. ////////////////////////////////////////////////////////////////////////////////////////////////////
  189. // NVSDK_NGX_GetParameters
  190. // ----------------------------------------------------------
  191. //
  192. // OutParameters:
  193. // Parameters interface used to set any parameter needed by the SDK
  194. //
  195. // DESCRIPTION:
  196. // This interface allows simple parameter setup using named fields.
  197. // For example one can set width by calling Set(NVSDK_NGX_Parameter_Denoiser_Width,100) or
  198. // provide CUDA buffer pointer by calling Set(NVSDK_NGX_Parameter_Denoiser_Color,cudaBuffer)
  199. // For more details please see sample code. Please note that allocated memory
  200. // will be freed by NGX so free/delete operator should NOT be called.
  201. // Parameter maps output by NVSDK_NGX_GetParameters are also pre-populated
  202. // with NGX capabilities and available features.
  203. // Unlike with NVSDK_NGX_AllocateParameters, parameter maps output by NVSDK_NGX_GetParameters
  204. // have their lifetimes managed by NGX, and must not
  205. // be destroyed by the app using NVSDK_NGX_DestroyParameters.
  206. // NVSDK_NGX_GetParameters is deprecated and apps should move to using
  207. // NVSDK_NGX_AllocateParameters and NVSDK_NGX_GetCapabilityParameters when possible.
  208. // Nevertheless, due to the possibility that the user will be using an older driver version,
  209. // NVSDK_NGX_GetParameters may still be used as a fallback if NVSDK_NGX_AllocateParameters
  210. // or NVSDK_NGX_GetCapabilityParameters return NVSDK_NGX_Result_FAIL_OutOfDate.
  211. //
  212. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_GetParameters(NVSDK_NGX_Parameter **OutParameters);
  213. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_GetParameters(NVSDK_NGX_Parameter **OutParameters);
  214. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_GetParameters(NVSDK_NGX_Parameter **OutParameters);
  215. #endif // NGX_ENABLE_DEPRECATED_GET_PARAMETERS
  216. ////////////////////////////////////////////////////////////////////////////////////////////////////
  217. // NVSDK_NGX_AllocateParameters
  218. // ----------------------------------------------------------
  219. //
  220. // OutParameters:
  221. // Parameters interface used to set any parameter needed by the SDK
  222. //
  223. // DESCRIPTION:
  224. // This interface allows allocating a simple parameter setup using named fields, whose
  225. // lifetime the app must manage.
  226. // For example one can set width by calling Set(NVSDK_NGX_Parameter_Denoiser_Width,100) or
  227. // provide CUDA buffer pointer by calling Set(NVSDK_NGX_Parameter_Denoiser_Color,cudaBuffer)
  228. // For more details please see sample code.
  229. // Parameter maps output by NVSDK_NGX_AllocateParameters must NOT be freed using
  230. // the free/delete operator; to free a parameter map
  231. // output by NVSDK_NGX_AllocateParameters, NVSDK_NGX_DestroyParameters should be used.
  232. // Unlike with NVSDK_NGX_GetParameters, parameter maps allocated with NVSDK_NGX_AllocateParameters
  233. // must be destroyed by the app using NVSDK_NGX_DestroyParameters.
  234. // Also unlike with NVSDK_NGX_GetParameters, parameter maps output by NVSDK_NGX_AllocateParameters
  235. // do not come pre-populated with NGX capabilities and available features.
  236. // To create a new parameter map pre-populated with such information, NVSDK_NGX_GetCapabilityParameters
  237. // should be used.
  238. // This function may return NVSDK_NGX_Result_FAIL_OutOfDate if an older driver, which
  239. // does not support this API call is being used. In such a case, NVSDK_NGX_GetParameters
  240. // may be used as a fallback.
  241. // This function may only be called after a successful call into NVSDK_NGX_Init.
  242. //
  243. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_AllocateParameters(NVSDK_NGX_Parameter** OutParameters);
  244. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_AllocateParameters(NVSDK_NGX_Parameter** OutParameters);
  245. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_AllocateParameters(NVSDK_NGX_Parameter** OutParameters);
  246. ////////////////////////////////////////////////////////////////////////////////////////////////////
  247. // NVSDK_NGX_GetCapabilityParameters
  248. // ----------------------------------------------------------
  249. //
  250. // OutParameters:
  251. // The parameters interface populated with NGX and feature capabilities
  252. //
  253. // DESCRIPTION:
  254. // This interface allows the app to create a new parameter map
  255. // pre-populated with NGX capabilities and available features.
  256. // The output parameter map can also be used for any purpose
  257. // parameter maps output by NVSDK_NGX_AllocateParameters can be used for
  258. // but it is not recommended to use NVSDK_NGX_GetCapabilityParameters
  259. // unless querying NGX capabilities and available features
  260. // due to the overhead associated with pre-populating the parameter map.
  261. // Parameter maps output by NVSDK_NGX_GetCapabilityParameters must NOT be freed using
  262. // the free/delete operator; to free a parameter map
  263. // output by NVSDK_NGX_GetCapabilityParameters, NVSDK_NGX_DestroyParameters should be used.
  264. // Unlike with NVSDK_NGX_GetParameters, parameter maps allocated with NVSDK_NGX_GetCapabilityParameters
  265. // must be destroyed by the app using NVSDK_NGX_DestroyParameters.
  266. // This function may return NVSDK_NGX_Result_FAIL_OutOfDate if an older driver, which
  267. // does not support this API call is being used. This function may only be called
  268. // after a successful call into NVSDK_NGX_Init.
  269. // If NVSDK_NGX_GetCapabilityParameters fails with NVSDK_NGX_Result_FAIL_OutOfDate,
  270. // NVSDK_NGX_GetParameters may be used as a fallback, to get a parameter map pre-populated
  271. // with NGX capabilities and available features.
  272. //
  273. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_GetCapabilityParameters(NVSDK_NGX_Parameter** OutParameters);
  274. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_GetCapabilityParameters(NVSDK_NGX_Parameter** OutParameters);
  275. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_GetCapabilityParameters(NVSDK_NGX_Parameter** OutParameters);
  276. ////////////////////////////////////////////////////////////////////////////////////////////////////
  277. // NVSDK_NGX_DestroyParameters
  278. // ----------------------------------------------------------
  279. //
  280. // InParameters:
  281. // The parameters interface to be destroyed
  282. //
  283. // DESCRIPTION:
  284. // This interface allows the app to destroy the parameter map passed in. Once
  285. // NVSDK_NGX_DestroyParameters is called on a parameter map, it
  286. // must not be used again.
  287. // NVSDK_NGX_DestroyParameters must not be called on any parameter map returned
  288. // by NVSDK_NGX_GetParameters; NGX will manage the lifetime of those
  289. // parameter maps.
  290. // This function may return NVSDK_NGX_Result_FAIL_OutOfDate if an older driver, which
  291. // does not support this API call is being used. This function may only be called
  292. // after a successful call into NVSDK_NGX_Init.
  293. //
  294. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_DestroyParameters(NVSDK_NGX_Parameter* InParameters);
  295. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_DestroyParameters(NVSDK_NGX_Parameter* InParameters);
  296. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_DestroyParameters(NVSDK_NGX_Parameter* InParameters);
  297. ////////////////////////////////////////////////////////////////////////////////////////////////////
  298. // NVSDK_NGX_GetScratchBufferSize
  299. // ----------------------------------------------------------
  300. //
  301. // InFeatureId:
  302. // AI feature in question
  303. //
  304. // InParameters:
  305. // Parameters used by the feature to help estimate scratch buffer size
  306. //
  307. // OutSizeInBytes:
  308. // Number of bytes needed for the scratch buffer for the specified feature.
  309. //
  310. // DESCRIPTION:
  311. // SDK needs a buffer of a certain size provided by the client in
  312. // order to initialize AI feature. Once feature is no longer
  313. // needed buffer can be released. It is safe to reuse the same
  314. // scratch buffer for different features as long as minimum size
  315. // requirement is met for all features. Please note that some
  316. // features might not need a scratch buffer so return size of 0
  317. // is completely valid.
  318. //
  319. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_GetScratchBufferSize(NVSDK_NGX_Feature InFeatureId, const NVSDK_NGX_Parameter *InParameters, size_t *OutSizeInBytes);
  320. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_GetScratchBufferSize(NVSDK_NGX_Feature InFeatureId, const NVSDK_NGX_Parameter *InParameters, size_t *OutSizeInBytes);
  321. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_GetScratchBufferSize(NVSDK_NGX_Feature InFeatureId, const NVSDK_NGX_Parameter *InParameters, size_t *OutSizeInBytes);
  322. /////////////////////////////////////////////////////////////////////////
  323. // NVSDK_NGX_CreateFeature
  324. // -------------------------------------
  325. //
  326. // InCmdList:[d3d12 only]
  327. // Command list to use to execute GPU commands. Must be:
  328. // - Open and recording
  329. // - With node mask including the device provided in NVSDK_NGX_D3D12_Init
  330. // - Execute on non-copy command queue.
  331. // InDevCtx: [d3d11 only]
  332. // Device context to use to execute GPU commands
  333. //
  334. // InFeatureID:
  335. // AI feature to initialize
  336. //
  337. // InParameters:
  338. // List of parameters
  339. //
  340. // OutHandle:
  341. // Handle which uniquely identifies the feature. If feature with
  342. // provided parameters already exists the "already exists" error code is returned.
  343. //
  344. // DESCRIPTION:
  345. // Each feature needs to be created before it can be used.
  346. // Refer to the sample code to find out which input parameters
  347. // are needed to create specific feature.
  348. //
  349. 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);
  350. 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);
  351. 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);
  352. /////////////////////////////////////////////////////////////////////////
  353. // NVSDK_NGX_Release
  354. // -------------------------------------
  355. //
  356. // InHandle:
  357. // Handle to feature to be released
  358. //
  359. // DESCRIPTION:
  360. // Releases feature with a given handle.
  361. // Handles are not reference counted so
  362. // after this call it is invalid to use provided handle.
  363. //
  364. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_ReleaseFeature(NVSDK_NGX_Handle *InHandle);
  365. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_ReleaseFeature(NVSDK_NGX_Handle *InHandle);
  366. NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_ReleaseFeature(NVSDK_NGX_Handle *InHandle);
  367. /////////////////////////////////////////////////////////////////////////
  368. // NVSDK_NGX_EvaluateFeature
  369. // -------------------------------------
  370. //
  371. // InCmdList:[d3d12 only]
  372. // Command list to use to execute GPU commands. Must be:
  373. // - Open and recording
  374. // - With node mask including the device provided in NVSDK_NGX_D3D12_Init
  375. // - Execute on non-copy command queue.
  376. // InDevCtx: [d3d11 only]
  377. // Device context to use to execute GPU commands
  378. //
  379. // InFeatureHandle:
  380. // Handle representing feature to be evaluated
  381. //
  382. // InParameters:
  383. // List of parameters required to evaluate feature
  384. //
  385. // InCallback:
  386. // Optional callback for features which might take longer
  387. // to execture. If specified SDK will call it with progress
  388. // values in range 0.0f - 1.0f
  389. //
  390. // DESCRIPTION:
  391. // Evaluates given feature using the provided parameters and
  392. // pre-trained NN. Please note that for most features
  393. // it can be benefitials to pass as many input buffers and parameters
  394. // as possible (for example provide all render targets like color, albedo, normals, depth etc)
  395. //
  396. #ifdef __cplusplus
  397. typedef void (NVSDK_CONV *PFN_NVSDK_NGX_ProgressCallback)(float InCurrentProgress, bool &OutShouldCancel);
  398. 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);
  399. 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);
  400. 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);
  401. #endif
  402. typedef void (NVSDK_CONV *PFN_NVSDK_NGX_ProgressCallback_C)(float InCurrentProgress, bool *OutShouldCancel);
  403. 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);
  404. 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);
  405. 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);
  406. // NGX return-code conversion-to-string utility only as a helper for debugging/logging - not for official use.
  407. const wchar_t* NVSDK_CONV GetNGXResultAsString(NVSDK_NGX_Result InNGXResult);
  408. #ifdef __cplusplus
  409. } // extern "C"
  410. #endif
  411. #endif // #define NVSDK_NGX_H