1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-26 10:39:43 +00:00

don't recycle statesets for light cullcallback for now

This commit is contained in:
glassmancody.info 2022-08-24 15:07:04 -07:00
parent e0dbe976bc
commit 1f2d9f2280

View file

@ -605,22 +605,22 @@ namespace SceneUtil
if (!lightManager->getUBOManager()) if (!lightManager->getUBOManager())
return; return;
for (size_t i = 0; i < mStateSet.size(); ++i) for (size_t i = 0; i < mUBBs.size(); ++i)
{ {
auto& buffer = lightManager->getUBOManager()->getLightBuffer(i); auto& buffer = lightManager->getUBOManager()->getLightBuffer(i);
osg::ref_ptr<osg::UniformBufferBinding> ubb = new osg::UniformBufferBinding(static_cast<int>(Resource::SceneManager::UBOBinding::LightBuffer), buffer->getData(), 0, buffer->getData()->getTotalDataSize()); mUBBs[i] = new osg::UniformBufferBinding(static_cast<int>(Resource::SceneManager::UBOBinding::LightBuffer), buffer->getData(), 0, buffer->getData()->getTotalDataSize());
mStateSet[i]->setAttributeAndModes(ubb, osg::StateAttribute::ON);
} }
} }
void operator()(LightManager* node, osgUtil::CullVisitor* cv) void operator()(LightManager* node, osgUtil::CullVisitor* cv)
{ {
const size_t frameId = cv->getTraversalNumber() % 2; osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
auto& stateset = mStateSet[frameId];
if (node->getLightingMethod() == LightingMethod::SingleUBO) if (node->getLightingMethod() == LightingMethod::SingleUBO)
{ {
const size_t frameId = cv->getTraversalNumber() % 2;
stateset->setAttributeAndModes(mUBBs[frameId], osg::StateAttribute::ON);
auto& buffer = node->getUBOManager()->getLightBuffer(cv->getTraversalNumber()); auto& buffer = node->getUBOManager()->getLightBuffer(cv->getTraversalNumber());
if (auto sun = node->getSunlight()) if (auto sun = node->getSunlight())
@ -653,7 +653,7 @@ namespace SceneUtil
node->getPPLightsBuffer()->updateCount(cv->getTraversalNumber()); node->getPPLightsBuffer()->updateCount(cv->getTraversalNumber());
} }
std::array<osg::ref_ptr<osg::StateSet>, 2> mStateSet = { new osg::StateSet, new osg::StateSet }; std::array<osg::ref_ptr<osg::UniformBufferBinding>, 2> mUBBs;
}; };
UBOManager::UBOManager(int lightCount) UBOManager::UBOManager(int lightCount)