当前位置:网站首页>Project training of Shandong University rendering engine system (II)
Project training of Shandong University rendering engine system (II)
2022-06-12 16:23:00 【Grey Cluster】
Catalog
Project introduction
NRD
full name Nvidia Real-time Denoiser , It is a spatiotemporal dual domain noise reduction library being developed by NVIDIA , Designed to deal with low RPP(ray per pixel) The signal .
The graphics of this technology API The environment is :DirectX11、DirectX12 as well as Vulkun. There are three integration methods , One way is to use Nvidia Of NRI(NVIDIA Rendering Interface) Package the above three API, To integrate .
Project objectives
stay Falcor Integration under the framework nrd.
Current work content
According to the official pseudo code design integration ideas
Official pseudocode
//====================================================================================================================
// STEP 1 - DECLARATIONS
//====================================================================================================================
#include "NRIDescs.hpp"
#include "Extensions/NRIWrapperD3D12.h"
#include "Extensions/NRIHelper.h"
#include "NRD.h"
NrdIntegration NRD = NrdIntegration(maxNumberOfFramesInFlight);
struct NriInterface
: public nri::CoreInterface
, public nri::HelperInterface
, public nri::WrapperD3D12Interface
{};
NriInterface NRI;
nri::Device* nriDevice = nullptr;
//====================================================================================================================
// STEP 2 - WRAP NATIVE DEVICE
//====================================================================================================================
nri::DeviceCreationD3D12Desc deviceDesc = {};
deviceDesc.d3d12Device = ...;
deviceDesc.d3d12PhysicalAdapter = ...;
deviceDesc.d3d12GraphicsQueue = ...;
deviceDesc.enableNRIValidation = false;
// Wrap the device
nri::Result result = nri::CreateDeviceFromD3D12Device(deviceDesc, nriDevice);
// Get needed functionality
result = nri::GetInterface(*nriDevice, NRI_INTERFACE(nri::CoreInterface), (nri::CoreInterface*)&NRI);
result = nri::GetInterface(*nriDevice, NRI_INTERFACE(nri::HelperInterface), (nri::HelperInterface*)&NRI);
// Get needed "wrapper" extension, XXX - can be D3D11, D3D12 or VULKAN
result = nri::GetInterface(*nriDevice, NRI_INTERFACE(nri::WrapperXXXInterface), (nri::WrapperXXXInterface*)&NRI);
//====================================================================================================================
// STEP 3 - INITIALIZE NRD
//====================================================================================================================
const nrd::MethodDesc methodDescs[] =
{
// put neeeded methods here, like:
{ nrd::Method::REBLUR_DIFFUSE_SPECULAR, renderResolution.x, renderResolution.y },
};
nrd::DenoiserCreationDesc denoiserCreationDesc = {};
denoiserCreationDesc.requestedMethods = methodDescs;
denoiserCreationDesc.requestedMethodNum = methodNum;
bool result = NRD.Initialize(*nriDevice, NRI, NRI, denoiserCreationDesc);
//====================================================================================================================
// STEP 4 - WRAP NATIVE POINTERS
//====================================================================================================================
// Wrap the command buffer
nri::CommandBufferD3D12Desc cmdDesc = {};
cmdDesc.d3d12CommandList = (ID3D12GraphicsCommandList*)&d3d12CommandList;
cmdDesc.d3d12CommandAllocator = nullptr; // Not needed for NRD Integration layer
nri::CommandBuffer* cmdBuffer = nullptr;
NRI.CreateCommandBufferD3D12(*nriDevice, cmdDesc, cmdBuffer);
// Wrap required textures
nri::TextureTransitionBarrierDesc entryDescs[N] = {};
nri::Format entryFormat[N] = {};
for (uint32_t i = 0; i < N; i++)
{
nri::TextureTransitionBarrierDesc& entryDesc = entryDescs[i];
const MyResource& myResource = GetMyResource(i);
nri::TextureD3D12Desc textureDesc = {};
textureDesc.d3d12Resource = myResource->GetNativePointer();
NRI.CreateTextureD3D12(*nriDevice, textureDesc, (nri::Texture*&)entryDesc.texture );
// You need to specify the current state of the resource here, after denoising NRD can modify
// this state. Application must continue state tracking from this point.
// Useful information:
// SRV = nri::AccessBits::SHADER_RESOURCE, nri::TextureLayout::SHADER_RESOURCE
// UAV = nri::AccessBits::SHADER_RESOURCE_STORAGE, nri::TextureLayout::GENERAL
entryDesc.nextAccess = ConvertResourceStateToAccessBits( myResource->GetCurrentState() );
entryDesc.nextLayout = ConvertResourceStateToLayout( myResource->GetCurrentState() );
}
//====================================================================================================================
// STEP 5 - DENOISE
//====================================================================================================================
// Populate common settings
// - for the first time use defaults
// - currently NRD supports only the following view space: X - right, Y - top, Z - forward or backward
nrd::CommonSettings commonSettings = {};
PopulateCommonSettings(commonSettings);
// Set settings for each denoiser
nrd::NrdXxxSettings settings = {};
PopulateDenoiserSettings(settings);
NRD.SetMethodSettings(nrd::Method::NRD_XXX, &settings);
// Fill up the user pool
NrdUserPool userPool =
{
{
// Fill the required inputs and outputs in appropriate slots using entryDescs & entryFormat,
// applying remapping if necessary. Unused slots can be {nullptr, nri::Format::UNKNOWN}
}};
NRD.Denoise(*cmdBuffer, commonSettings, userPool);
// !!! IMPORTANT !!!
// NRD integration layer binds its own descriptor pool, don't forget to re-bind back your own descriptor pool (heap)
//====================================================================================================================
// STEP 6 - CLEANUP
//====================================================================================================================
for (uint32_t i = 0; i < N; i++)
NRI.DestroyTexture(entryDescs[i].texture);
NRI.DestroyCommandBuffer(*cmdBuffer);
//====================================================================================================================
// STEP 7 - DESTROY
//====================================================================================================================
NRD.Destroy();边栏推荐
- acwing 高精度乘法
- <山东大学项目实训>渲染引擎系统(八-完)
- Global and Chinese markets of automatic glue applicators 2022-2028: Research Report on technology, participants, trends, market size and share
- d结构用作多维数组的索引
- acwing796 子矩阵的和
- generate pivot data 1
- RTOS RT thread bare metal system and multi thread system
- Interview: do you understand the packing and unpacking operations?
- Sum of acwing796 submatrix
- Batch --03---cmdutil
猜你喜欢

C packing and unpacking

Step by step steps to create an ABAP program with a custom screen

思考游戏王决斗链接中抽卡概率问题

Thinking about the probability of drawing cards in the duel link of game king

Gopher to rust hot eye grammar ranking

Huawei equipment is configured with CE dual attribution

RTOS RT thread bare metal system and multi thread system

The market share of packaged drinking water has been the first for eight consecutive years. How does this brand DTC continue to grow?

Batch --04--- moving components

Office VR porn, coquettish operation! The father of Microsoft hololens resigns!
随机推荐
use. Net upgrade assistant upgrades the net core 3.1 project to NET 6
Postgresql源码(53)plpgsql语法解析关键流程、函数分析
generate pivot data 2
Understand go modules' go Mod and go sum
Glove word embedding (IMDb film review emotion prediction project practice)
关于组件传值
generate pivot data 0
RTOS rt-thread裸机系统与多线程系统
The C Programming Language(第 2 版) 笔记 / 8 UNIX 系统接口 / 8.7 实例(存储分配程序)
calibration of sth
AssertJ 的异常(Exception )断言
Batch --03---cmdutil
acwing 800. Target and of array elements
Acwing795 prefix sum (one dimension)
Acwing788. number of reverse order pairs
Global and Chinese market of vascular prostheses 2022-2028: Research Report on technology, participants, trends, market size and share
Development status of China's pig breeding industry in 2021 and comparative analysis of key enterprises: 671million pigs were sold [figure]
In 2021, China's lottery sales generally maintained a rapid growth, and the monthly sales generally tended to be stable [figure]
Gopher to rust hot eye grammar ranking
The C Programming Language(第 2 版) 笔记 / 8 UNIX 系统接口 / 8.6 实例(目录列表)