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

Method updateDisplacement

Source/Falcor/Scene/Scene.cpp:1048–1122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1046 }
1047
1048 IScene::UpdateFlags Scene::updateDisplacement(RenderContext* pRenderContext, bool forceUpdate)
1049 {
1050 if (!hasGeometryType(GeometryType::DisplacedTriangleMesh)) return IScene::UpdateFlags::None;
1051
1052 // For now we assume that displaced meshes are static.
1053 // Create AABB and AABB update task buffers.
1054 if (!mDisplacement.pAABBBuffer)
1055 {
1056 mDisplacement.meshData.resize(mMeshDesc.size());
1057 mDisplacement.updateTasks.clear();
1058
1059 uint32_t AABBOffset = 0;
1060
1061 for (uint32_t meshID = 0; meshID < mMeshDesc.size(); ++meshID)
1062 {
1063 const auto& mesh = mMeshDesc[meshID];
1064
1065 if (!mesh.isDisplaced())
1066 {
1067 mDisplacement.meshData[meshID] = {};
1068 continue;
1069 }
1070
1071 uint32_t AABBCount = mesh.getTriangleCount();
1072 mDisplacement.meshData[meshID] = { AABBOffset, AABBCount };
1073 AABBOffset += AABBCount;
1074
1075 DisplacementUpdateTask task;
1076 task.meshID = meshID;
1077 task.triangleIndex = 0;
1078 task.AABBIndex = mDisplacement.meshData[meshID].AABBOffset;
1079 task.count = mDisplacement.meshData[meshID].AABBCount;
1080 mDisplacement.updateTasks.push_back(task);
1081 }
1082
1083 mDisplacement.pAABBBuffer = mpDevice->createStructuredBuffer(sizeof(RtAABB), AABBOffset, ResourceBindFlags::ShaderResource | ResourceBindFlags::UnorderedAccess);
1084
1085 FALCOR_ASSERT(mDisplacement.updateTasks.size() < std::numeric_limits<uint32_t>::max());
1086 mDisplacement.pUpdateTasksBuffer = mpDevice->createStructuredBuffer((uint32_t)sizeof(DisplacementUpdateTask), (uint32_t)mDisplacement.updateTasks.size(), ResourceBindFlags::ShaderResource, MemoryType::DeviceLocal, mDisplacement.updateTasks.data());
1087 }
1088
1089 FALCOR_ASSERT(!mDisplacement.updateTasks.empty());
1090
1091 // We cannot access the scene parameter block until its finalized.
1092 if (!mFinalized) return IScene::UpdateFlags::None;
1093
1094 // Update the AABB data.
1095 if (!mDisplacement.pUpdatePass)
1096 {
1097 mDisplacement.pUpdatePass = ComputePass::create(mpDevice, "Scene/Displacement/DisplacementUpdate.cs.slang", "main", getSceneDefines());
1098 mDisplacement.needsUpdate = true;
1099 }
1100
1101 if (mDisplacement.needsUpdate)
1102 {
1103 // TODO: Only update objects with modified materials.
1104
1105 FALCOR_PROFILE(pRenderContext, "updateDisplacement");

Callers

nothing calls this directly

Calls 15

hasGeometryTypeFunction · 0.85
isDisplacedMethod · 0.80
getTriangleCountMethod · 0.80
getRootVarMethod · 0.80
maxFunction · 0.50
createFunction · 0.50
resizeMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
push_backMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected