diff --git a/src/graphics/stkscenemanager.cpp b/src/graphics/stkscenemanager.cpp index 4dcd691f2..25ad1dc91 100644 --- a/src/graphics/stkscenemanager.cpp +++ b/src/graphics/stkscenemanager.cpp @@ -133,8 +133,6 @@ void FillInstancesGrass(const std::unordered_map > > MeshForSolidPass[MAT_COUNT]; -static std::unordered_map > > MeshForShadowPass[4][MAT_COUNT]; -static std::unordered_map > > MeshForRSMPass[MAT_COUNT]; static std::unordered_map > > MeshForGlowPass; static std::vector DeferredUpdate; @@ -312,12 +310,7 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector *Immed { for (unsigned cascade = 0; cascade < 4; ++cascade) { - if (irr_driver->hasARB_draw_indirect()) - { - for_in(mesh, node->MeshSolidMaterial[Mat]) - MeshForShadowPass[cascade][Mat][mesh->mb].emplace_back(mesh, Node); - } - else + if (!irr_driver->hasARB_draw_indirect()) { if (isCulledFast(shadowcam[cascade], Node)) continue; @@ -362,10 +355,8 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector *Immed { if (irr_driver->hasARB_draw_indirect()) { - for_in(mesh, node->MeshSolidMaterial[Mat]) - if (Mat != MAT_SPLATTING) - MeshForRSMPass[Mat][mesh->mb].emplace_back(mesh, Node); - else + if (Mat == MAT_SPLATTING) + for_in(mesh, node->MeshSolidMaterial[Mat]) { core::matrix4 ModelMatrix = Node->getAbsoluteTransformation(), InvModelMatrix; ModelMatrix.getInverse(InvModelMatrix); @@ -446,7 +437,7 @@ GenDrawCalls(unsigned cascade, std::vector &InstancedList, std::function shadowculling = [&](const scene::ISceneNode *nd) {return dynamic_cast(nd)->isCulledForShadowCam(cascade); }; if (irr_driver->hasARB_draw_indirect()) ShadowPassCmd::getInstance()->Offset[cascade][Mat] = CommandBufferOffset; // Store command buffer offset - FillInstances(MeshForShadowPass[cascade][Mat], InstancedList, InstanceBuffer, CommandBuffer, InstanceBufferOffset, CommandBufferOffset, PolyCount, shadowculling); + FillInstances(MeshForSolidPass[Mat], InstancedList, InstanceBuffer, CommandBuffer, InstanceBufferOffset, CommandBufferOffset, PolyCount, shadowculling); if (UserConfigParams::m_azdo) ShadowPassCmd::getInstance()->Size[cascade][Mat] = CommandBufferOffset - ShadowPassCmd::getInstance()->Offset[cascade][Mat]; } @@ -458,7 +449,7 @@ InstanceData *InstanceBuffer, DrawElementsIndirectCommand *CommandBuffer, size_t std::function shadowculling = [&](const scene::ISceneNode *nd) {return dynamic_cast(nd)->isCulledForShadowCam(cascade); }; if (irr_driver->hasARB_draw_indirect()) ShadowPassCmd::getInstance()->Offset[cascade][Mat] = CommandBufferOffset; // Store command buffer offset - FillInstancesGrass(MeshForShadowPass[cascade][Mat], InstancedList, InstanceBuffer, CommandBuffer, InstanceBufferOffset, CommandBufferOffset, dir, PolyCount, shadowculling); + FillInstancesGrass(MeshForSolidPass[Mat], InstancedList, InstanceBuffer, CommandBuffer, InstanceBufferOffset, CommandBufferOffset, dir, PolyCount, shadowculling); if (UserConfigParams::m_azdo) ShadowPassCmd::getInstance()->Size[cascade][Mat] = CommandBufferOffset - ShadowPassCmd::getInstance()->Offset[cascade][Mat]; } @@ -488,12 +479,7 @@ void IrrDriver::PrepareDrawCalls(scene::ICameraSceneNode *camnode) ListInstancedGlow::getInstance()->clear(); for (unsigned Mat = 0; Mat < MAT_COUNT; ++Mat) - { MeshForSolidPass[Mat].clear(); - MeshForRSMPass[Mat].clear(); - for (unsigned cascade = 0; cascade < 4; ++cascade) - MeshForShadowPass[cascade][Mat].clear(); - } MeshForGlowPass.clear(); DeferredUpdate.clear(); core::list List = m_scene_manager->getRootSceneNode()->getChildren(); @@ -711,23 +697,23 @@ void IrrDriver::PrepareDrawCalls(scene::ICameraSceneNode *camnode) // Default Material RSMPassCmd::getInstance()->Offset[MAT_DEFAULT] = current_cmd; - FillInstances(MeshForRSMPass[MAT_DEFAULT], ListInstancedMatDefault::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); + FillInstances(MeshForSolidPass[MAT_DEFAULT], ListInstancedMatDefault::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); RSMPassCmd::getInstance()->Size[MAT_DEFAULT] = current_cmd - RSMPassCmd::getInstance()->Offset[MAT_DEFAULT]; // Alpha Ref RSMPassCmd::getInstance()->Offset[MAT_ALPHA_REF] = current_cmd; - FillInstances(MeshForRSMPass[MAT_ALPHA_REF], ListInstancedMatAlphaRef::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); + FillInstances(MeshForSolidPass[MAT_ALPHA_REF], ListInstancedMatAlphaRef::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); RSMPassCmd::getInstance()->Size[MAT_ALPHA_REF] = current_cmd - RSMPassCmd::getInstance()->Offset[MAT_ALPHA_REF]; // Unlit RSMPassCmd::getInstance()->Offset[MAT_UNLIT] = current_cmd; - FillInstances(MeshForRSMPass[MAT_UNLIT], ListInstancedMatUnlit::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); + FillInstances(MeshForSolidPass[MAT_UNLIT], ListInstancedMatUnlit::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); RSMPassCmd::getInstance()->Size[MAT_UNLIT] = current_cmd - RSMPassCmd::getInstance()->Offset[MAT_UNLIT]; // Detail RSMPassCmd::getInstance()->Offset[MAT_DETAIL] = current_cmd; - FillInstances(MeshForRSMPass[MAT_DETAIL], ListInstancedMatDetails::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); + FillInstances(MeshForSolidPass[MAT_DETAIL], ListInstancedMatDetails::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); RSMPassCmd::getInstance()->Size[MAT_DETAIL] = current_cmd - RSMPassCmd::getInstance()->Offset[MAT_DETAIL]; // Normal Map RSMPassCmd::getInstance()->Offset[MAT_NORMAL_MAP] = current_cmd; - FillInstances(MeshForRSMPass[MAT_NORMAL_MAP], ListInstancedMatNormalMap::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); + FillInstances(MeshForSolidPass[MAT_NORMAL_MAP], ListInstancedMatNormalMap::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly, rsmcamculling); RSMPassCmd::getInstance()->Size[MAT_NORMAL_MAP] = current_cmd - RSMPassCmd::getInstance()->Offset[MAT_NORMAL_MAP]; if (!irr_driver->hasBufferStorageExtension())