MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / RtStateObject

Method RtStateObject

Source/Falcor/Core/API/RtStateObject.cpp:36–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34{
35
36RtStateObject::RtStateObject(ref<Device> pDevice, const RtStateObjectDesc& desc) : mpDevice(pDevice), mDesc(desc)
37{
38 auto pKernels = getKernels();
39 gfx::RayTracingPipelineStateDesc rtpDesc = {};
40 std::vector<gfx::HitGroupDesc> hitGroups;
41 // Loop over the hitgroups
42 for (const auto& pEntryPointGroup : pKernels->getUniqueEntryPointGroups())
43 {
44 if (pEntryPointGroup->getType() == EntryPointGroupKernels::Type::RtHitGroup)
45 {
46 const EntryPointKernel* pIntersection = pEntryPointGroup->getKernel(ShaderType::Intersection);
47 const EntryPointKernel* pAhs = pEntryPointGroup->getKernel(ShaderType::AnyHit);
48 const EntryPointKernel* pChs = pEntryPointGroup->getKernel(ShaderType::ClosestHit);
49
50 gfx::HitGroupDesc hitgroupDesc = {};
51 hitgroupDesc.anyHitEntryPoint = pAhs ? pAhs->getEntryPointName().c_str() : nullptr;
52 hitgroupDesc.closestHitEntryPoint = pChs ? pChs->getEntryPointName().c_str() : nullptr;
53 hitgroupDesc.intersectionEntryPoint = pIntersection ? pIntersection->getEntryPointName().c_str() : nullptr;
54 hitgroupDesc.hitGroupName = pEntryPointGroup->getExportName().c_str();
55 hitGroups.push_back(hitgroupDesc);
56 }
57 }
58
59 rtpDesc.hitGroupCount = (uint32_t)hitGroups.size();
60 rtpDesc.hitGroups = hitGroups.data();
61 rtpDesc.maxRecursion = mDesc.maxTraceRecursionDepth;
62
63 static_assert((uint32_t)gfx::RayTracingPipelineFlags::SkipProcedurals == (uint32_t)RtPipelineFlags::SkipProceduralPrimitives);
64 static_assert((uint32_t)gfx::RayTracingPipelineFlags::SkipTriangles == (uint32_t)RtPipelineFlags::SkipTriangles);
65
66 rtpDesc.flags = (gfx::RayTracingPipelineFlags::Enum)mDesc.pipelineFlags;
67 auto rtProgram = dynamic_cast<Program*>(mDesc.pProgramKernels->getProgramVersion()->getProgram());
68 FALCOR_ASSERT(rtProgram);
69 rtpDesc.maxRayPayloadSize = rtProgram->getDesc().maxPayloadSize;
70 rtpDesc.maxAttributeSizeInBytes = rtProgram->getDesc().maxAttributeSize;
71 rtpDesc.program = mDesc.pProgramKernels->getGfxProgram();
72
73 FALCOR_GFX_CALL(mpDevice->getGfxDevice()->createRayTracingPipelineState(rtpDesc, mGfxPipelineState.writeRef()));
74
75 // Get shader identifiers.
76 // In GFX, a shader identifier is just the entry point group name.
77 for (const auto& pEntryPointGroup : pKernels->getUniqueEntryPointGroups())
78 {
79 mEntryPointGroupExportNames.push_back(pEntryPointGroup->getExportName());
80 }
81}
82
83RtStateObject::~RtStateObject()
84{

Callers

nothing calls this directly

Calls 7

getKernelMethod · 0.80
getProgramMethod · 0.80
writeRefMethod · 0.80
getTypeMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected