| 3813 | } |
| 3814 | |
| 3815 | void Scene::bindShaderDataForRaytracing(RenderContext* pRenderContext, const ShaderVar& sceneVar, uint32_t rayTypeCount) |
| 3816 | { |
| 3817 | // On first execution or if BLASes need to be rebuilt, create BLASes for all geometries. |
| 3818 | if (!mBlasDataValid) |
| 3819 | { |
| 3820 | initGeomDesc(pRenderContext); |
| 3821 | buildBlas(pRenderContext); |
| 3822 | } |
| 3823 | |
| 3824 | // Find any valid TLAS, if none found, create it for rayTypeCount == 1 |
| 3825 | if (rayTypeCount == 0) |
| 3826 | rayTypeCount = mTlasLastBuiltRayCount; |
| 3827 | if (rayTypeCount == 0) |
| 3828 | rayTypeCount = 1; |
| 3829 | |
| 3830 | // On first execution, when meshes have moved, when there's a new ray type count, or when a BLAS has changed, create/update the TLAS |
| 3831 | // |
| 3832 | // The raytracing shader table has one hit record per ray type and geometry. We need to know the ray type count in order to setup the indexing properly. |
| 3833 | // Note that for DXR 1.1 ray queries, the shader table is not used and the ray type count doesn't matter and can be set to zero. |
| 3834 | // |
| 3835 | auto tlasIt = mTlasCache.find(rayTypeCount); |
| 3836 | if (tlasIt == mTlasCache.end() || !tlasIt->second.pTlasObject) |
| 3837 | { |
| 3838 | // We need a hit entry per mesh right now to pass GeometryIndex() |
| 3839 | buildTlas(pRenderContext, rayTypeCount, true); |
| 3840 | |
| 3841 | // If new TLAS was just created, get it so the iterator is valid |
| 3842 | if (tlasIt == mTlasCache.end()) tlasIt = mTlasCache.find(rayTypeCount); |
| 3843 | } |
| 3844 | FALCOR_ASSERT(mpSceneBlock); |
| 3845 | |
| 3846 | // Bind TLAS. |
| 3847 | FALCOR_ASSERT(tlasIt != mTlasCache.end() && tlasIt->second.pTlasObject) |
| 3848 | mpSceneBlock->getRootVar()["rtAccel"].setAccelerationStructure(tlasIt->second.pTlasObject); |
| 3849 | |
| 3850 | // Bind Scene parameter block. |
| 3851 | getCamera()->bindShaderData(mpSceneBlock->getRootVar()[kCamera]); // TODO REMOVE: Shouldn't be needed anymore? |
| 3852 | sceneVar = mpSceneBlock; |
| 3853 | } |
| 3854 | |
| 3855 | std::vector<uint32_t> Scene::getMeshBlasIDs() const |
| 3856 | { |
no test coverage detected