当前位置:网站首页><山东大学项目实训>渲染引擎系统(二)
<山东大学项目实训>渲染引擎系统(二)
2022-06-12 16:16:00 【Grey Cluster】
目录
项目介绍
NRD
全名Nvidia Real-time Denoiser ,是英伟达正在研发的一个时空双域降噪库,旨在处理低的RPP(ray per pixel)信号。
该技术的图形 API 环境是:DirectX11、DirectX12 以及 Vulkun。其集成方法有三种,其中一种可以是利用 Nvidia 的 NRI(NVIDIA Rendering Interface)包装上述三个 API,进行集成。
项目目标
在Falcor框架下集成nrd。
当前工作内容
根据官方伪代码设计集成思路
官方伪代码
//====================================================================================================================
// 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();边栏推荐
- 批量--03---CmdUtil
- Development practice of ag1280q48 in domestic CPLD
- (4) Googlenet replay
- 从斐波那契数列求和想到的俗手、本手和妙手
- Scanpy (VI) analysis and visualization of spatial transcriptome data
- acwing794 高精度除法
- 写代码也有本手俗手之分,而我们要善于发现妙手!
- Global and Chinese market for material injection 2022-2028: Research Report on technology, participants, trends, market size and share
- Scanpy(六)空间转录组数据的分析与可视化
- D structure as index of multidimensional array
猜你喜欢

Apache kylin Adventure

< 山东大学软件学院项目实训 > 渲染引擎系统——基础渲染器(五)

acwing794 高精度除法

Read MHD and raw images, slice, normalize and save them

RTOS rt-thread裸机系统与多线程系统

Project training of Software College of Shandong University rendering engine system basic renderer (V)

< 山东大学软件学院项目实训 > 渲染引擎系统——基础渲染器(四)

Solution to idea Chinese prism garbled code error -- console Chinese output prism garbled code

Saga architecture pattern: implementation of cross service transactions under microservice architecture

acwing 801. 二进制中1的个数(位运算)
随机推荐
acwing 797 差分
Sha6 of D to large integer
从斐波那契数列求和想到的俗手、本手和妙手
华为设备配置CE双归属
联通网管协议框图
学习记录[email protected]一文搞懂canvas
With a lamp inserted in the nostril, the IQ has risen and become popular in Silicon Valley. 30000 yuan is enough
Acwing 797 differential
Office VR porn, coquettish operation! The father of Microsoft hololens resigns!
< 山东大学软件学院项目实训 > 渲染引擎系统——基础渲染器(五)
IDEA中文棱形乱码错误解决方法--控制台中文输出棱形乱码
RTOS rt-thread裸机系统与多线程系统
Analysis of global and Chinese shipbuilding market in 2021: the global shipbuilding new orders reached 119.85 million dwt, with China, Japan and South Korea accounting for 96.58%[figure]
Data analysis | kmeans data analysis
Difference between tinyint and int
< 山东大学软件学院项目实训 > 渲染引擎系统——基础渲染器(四)
Analysis on the development status and direction of China's cultural tourism real estate industry in 2021: the average transaction price has increased, and cultural tourism projects continue to innova
连续八年包装饮用水市占率第一,这个品牌DTC是如何持续增长的?
Writing code can also be classified as "manual" or "vulgar", and we should be good at finding good hands!
d的sha6转大整