当前位置:网站首页><山东大学项目实训>渲染引擎系统(二)
<山东大学项目实训>渲染引擎系统(二)
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();边栏推荐
- Axure RP 9 for Mac(交互式产品原型设计工具)中文版
- Page class of puppeter
- Batch --04--- moving components
- Saga体系结构模式:微服务架构下跨服务事务的实现
- In 2020, the demand for strain sensors in China will reach 9.006 million, and the market scale will reach 2.292 billion yuan [figure]
- Project training of Software College of Shandong University rendering engine system radiation pre calculation (VIII)
- < 山东大学软件学院项目实训 > 渲染引擎系统——辐射预计算(八)
- What is fintech? How fintech can help small businesses succeed
- acwing 2816. 判断子序列
- 5-5 configuring MySQL replication log point based replication
猜你喜欢
![Development status of China's pig breeding industry in 2021 and comparative analysis of key enterprises: 671million pigs were sold [figure]](/img/fd/5462c8c6deafeb7d7728716eb4db74.jpg)
Development status of China's pig breeding industry in 2021 and comparative analysis of key enterprises: 671million pigs were sold [figure]

Applet: how to get the user's mobile number in the plug-in

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

acwing 798二维差分(差分矩阵)
![[browser principle] variable promotion](/img/19/f6b26d97c6024893a21dd40e2bbc47.jpg)
[browser principle] variable promotion
![[tool recommendation] personal local markdown knowledge map software](/img/a2/5607df183ab37f32ae3fcd984d228e.png)
[tool recommendation] personal local markdown knowledge map software

【工具推荐】个人本地 markdown 知识图谱软件 Obsidian

办公室VR黄片,骚操作!微软HoloLens之父辞职!

小程序:如何在插件中获取用户手机号
![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]](/img/3e/b54b7f15c4a6326d8c7c4433388a3a.jpg)
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]
随机推荐
The C Programming Language(第 2 版) 笔记 / 8 UNIX 系统接口 / 8.5 实例(fopen 和 getc 函数的实现)
acwing 801. 二进制中1的个数(位运算)
acwing788. 逆序对的数量
鼻孔插灯,智商上升,风靡硅谷,3万就成
Development practice of ag1280q48 in domestic CPLD
Thread pool execution process
【周赛复盘】LeetCode第80场双周赛
大规模实时分位数计算——Quantile Sketches 简史
Object.keys遍历一个对象
Multimix: small amount of supervision from medical images, interpretable multi task learning
MySQL blob and text types
acwing 802. Interval sum (discretization)
【工具推荐】个人本地 markdown 知识图谱软件 Obsidian
< 山东大学软件学院项目实训 > 渲染引擎系统——基础渲染器(五)
< 山东大学软件学院项目实训 > 渲染引擎系统——基础渲染器(三)
acwing795 前缀和(一维)
Browsercontext class of puppeter
联通网管协议框图
批量--03---CmdUtil
< 山东大学软件学院项目实训 > 渲染引擎系统——辐射预计算(九)