https://github.com/ConfettiFX/The-Forge/blob/master/CommonRaytracing_3/ThirdParty/DXR/doc/D3D12%20Raytracing%20Functional%20Spec.docx

dxr的spec 好难找

D3D12 Raytracing Functional Spec

https://github.com/NVIDIAGameWorks/Falcor/releases

https://github.com/Microsoft/DirectX-Graphics-Samples/blob/master/Samples/Desktop/D3D12Raytracing/readme.md

https://github.com/Microsoft/DirectX-Graphics-Samples/blob/master/Libraries/D3D12RaytracingFallback/readme.md

http://forums.directxtech.com/index.php?topic=5860.0

初始化拿到device 对rtx开一些特殊设置

fallback是个模拟rtx的库 api和硬件的rtx不太一样要专门写

初始化各种资源 初始化rtx专有资源

pso

as

加速结构 top bottom

top是对bottom的一个transform 数据本身在bottom

可以有一组bottome 每个里面又可以有很多geometry

语法参见        bottomLevelBuildDesc.NumDescs = static_cast<UINT>(geometryDescs.size());

它公用dx12的cmd自己再这个cmd上面建一个rtx的cmd

有五种shader可以写

hit 里面的光照是 光线打到的物体上的光照 比如反射 了abc 是abc物体的光照 而不是反射平面本身的材质光照

从传统光栅化shader到这种hit的光照shader的转换

vs部分的pos normal uv之类的 从hit的结果能拿到

只port ps光照部分即可 返回光照结果

几天没见pix长进了

https://blogs.msdn.microsoft.com/pix/gpu-captures/

看上去不错

https://blogs.msdn.microsoft.com/pix/2018/07/24/pix-1807-19-shader-table-viewer/

dx12和dxr都可以debug 需要把dxr的dll copy到pix.exe的位置

gpu hang的debug

https://blogs.msdn.microsoft.com/pix/tdr-debugging/

https://docs.microsoft.com/zh-cn/windows/desktop/direct3d12/using-d3d12-debug-layer-gpu-based-validation

https://blogs.msdn.microsoft.com/pix/programmatic-capture/

很强大

https://blogs.msdn.microsoft.com/pix/remoting/

远程连接

---------------------------

dx12 rootsignature  ---SRV CBV UAV 初始到各个slot

m_device->CreateConstantBufferView(&cbvDesc, m_cbvHeap->GetCPUDescriptorHandleForHeapStart()); 用这句连

CB--View --descriptorHeap

init 的时候把这些连上

render的时候 用这种方式更新 m_commandList->SetGraphicsRootDescriptorTable(0, m_cbvHeap->GetGPUDescriptorHandleForHeapStart()); 用heap更新slot

update更新了cb本身

dxr里面有shadertable 是upload buffer--committed resource

一条layout是一个shader rootsig mat等等

auto DispatchRays = [&](auto* commandList, auto* stateObject, auto* dispatchDesc)
{
dispatchDesc->HitGroupTable.StartAddress = m_hitGroupShaderTable->GetGPUVirtualAddress();
dispatchDesc->HitGroupTable.SizeInBytes = m_hitGroupShaderTable->GetDesc().Width;
dispatchDesc->HitGroupTable.StrideInBytes = m_hitGroupShaderTableStrideInBytes;
dispatchDesc->MissShaderTable.StartAddress = m_missShaderTable->GetGPUVirtualAddress();
dispatchDesc->MissShaderTable.SizeInBytes = m_missShaderTable->GetDesc().Width;
dispatchDesc->MissShaderTable.StrideInBytes = m_missShaderTableStrideInBytes;
dispatchDesc->RayGenerationShaderRecord.StartAddress = m_rayGenShaderTable->GetGPUVirtualAddress();
dispatchDesc->RayGenerationShaderRecord.SizeInBytes = m_rayGenShaderTable->GetDesc().Width;
dispatchDesc->Width = m_width;
dispatchDesc->Height = m_height;
commandList->DispatchRays(stateObject, dispatchDesc);
};

DispatchRays 可以把三种shader的起始地址连上

cbv之类的更新同dx12

namespace RootSignatureSlots = LocalRootSignature::AABB::Slot;
CD3DX12_ROOT_PARAMETER rootParameters[RootSignatureSlots::Count];
rootParameters[RootSignatureSlots::MaterialConstant].InitAsConstants(SizeOfInUint32(PrimitiveConstantBuffer), 1);
rootParameters[RootSignatureSlots::GeometryIndex].InitAsConstants(SizeOfInUint32(PrimitiveInstanceConstantBuffer), 2);

ThrowIfFailed(D3D12SerializeRootSignature(&desc, D3D_ROOT_SIGNATURE_VERSION_1, &blob, &error), error ? static_cast<wchar_t*>(error->GetBufferPointer()) : nullptr);
ThrowIfFailed(device->CreateRootSignature(1, blob->GetBufferPointer(), blob->GetBufferSize(), IID_PPV_ARGS(&(*rootSig))));

建立的时候 每条shaderrecord里面matID是不一样的 在hitshader里面

uint materialID = MaterialID;
uint triangleID = PrimitiveIndex();

RayTraceMeshInfo info = g_meshInfo[materialID];

const uint3 ii = Load3x16BitIndices(info.m_indexOffsetBytes + PrimitiveIndex() * 3 * 2);
const float2 uv0 = GetUVAttribute(info.m_uvAttributeOffsetBytes + ii.x * info.m_attributeStrideBytes);
const float2 uv1 = GetUVAttribute(info.m_uvAttributeOffsetBytes + ii.y * info.m_attributeStrideBytes);
const float2 uv2 = GetUVAttribute(info.m_uvAttributeOffsetBytes + ii.z * info.m_attributeStrideBytes);

就可以用这种方式matID拿到具体数据

==================

hit之后的顶点信息有两种方式可以获取 gloable /local sig

gloable的方式 需要传matID每次用这个ID从大的buffer(vb包含所有mesh)作为偏移拿到具体 pos uv normal tangent信息

另一种local的方式 每个hit shader传 自己的vb数据(initialze的时候每块mesh来处理 生成不同的 shader和vb)作为cb传入 用hit时的primitiveIndex拿到相应数据

这样hit的mat也都是每块mesh不一样的了

==========

这是些intric val

Values \ shaders

Ray dispatch system values:

uint2 DispatchRaysIndex()

uint2 DispatchRaysDimensions()

Ray system values:

float3 WorldRayOrigin()

float3 WorldRayDirection()

float RayTMin()

float RayTCurrent()

uint RayFlags()

Primitive/object space system values:

uint InstanceIndex()

uint InstanceID()

uint PrimitiveIndex()

float3 ObjectRayOrigin()

float3 ObjectRayDirection()

float3x4 ObjectToWorld()

float3x4 WorldToObject()

Hit specific system values:

uint HitKind()

=========================

draw() rastization

dispatch() compute

dispatchRays() raytracing

invoke

最新文章

  1. 配置子目录Web.config使其消除继承,用虚拟目录创建多个网站的方法
  2. mongoDB3.0 索引 整理
  3. 使用JDBC批量保存数据(JdbcDaoSupport,JdbcTemplete)
  4. Linux Rootkit Learning
  5. codeforces B. New Year Present 解题报告
  6. EF Code First DataAnnotations
  7. GeekPwn2015胸卡ESP8266 12E串口调试
  8. DDoS攻防战(三):ip黑白名单防火墙frdev的原理与实现
  9. Eclipse热部署JSP
  10. BNU10806:请在此处签到
  11. GNU Make 学习系列一:怎样写一个简单的Makefile
  12. KVM 命令行启动第一台虚拟机
  13. Adobe Flash CC 2014 下载及破解
  14. nodejs 后台服务启动
  15. WPF获得全局窗体句柄,并响应全局键盘事件
  16. bzoj3437小P的牧场 斜率优化dp
  17. 最近最久未使用页面淘汰算法———LRU算法(java实现)
  18. CentOS 7下Samba服务安装与配置详解
  19. 如何在eclipse安装apk包
  20. $Djangon admin界面 添加表 增删查改

热门文章

  1. hdu 1026(优先队列+路径输出)
  2. 关于云平台中OFFICE预览与视频预览的解决办法
  3. AC日记——可怜的狗狗 洛谷 P1533
  4. CSS让文字在元素内绝对居中!!!【ie和谷歌】
  5. javascript 对象属性的 get set 方法
  6. 【PHPExcel实例】 php 导出 excel 实例
  7. Codeforces gym102058 J. Rising Sun-简单的计算几何+二分 (2018-2019 XIX Open Cup, Grand Prix of Korea (Division 2))
  8. asp.net mvc 中使用NPOI导出excel
  9. (4) go 运算符
  10. 字符串Hash相关