mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-10 20:46:55 +03:00
fix threading issue when dispatching frame dependent data
This commit is contained in:
parent
c7449dc272
commit
acc209c294
6 changed files with 34 additions and 34 deletions
|
@ -9,8 +9,6 @@ namespace MWRender
|
|||
{
|
||||
PingPongCanvas::PingPongCanvas(Shader::ShaderManager& shaderManager)
|
||||
: mFallbackStateSet(new osg::StateSet)
|
||||
, mQueuedDispatchArray(std::nullopt)
|
||||
, mQueuedDispatchFrameId(0)
|
||||
{
|
||||
setUseDisplayList(false);
|
||||
setUseVertexBufferObjects(true);
|
||||
|
@ -37,9 +35,6 @@ namespace MWRender
|
|||
|
||||
void PingPongCanvas::setCurrentFrameData(size_t frameId, fx::DispatchArray&& data)
|
||||
{
|
||||
mQueuedDispatchArray = fx::DispatchArray(data);
|
||||
mQueuedDispatchFrameId = !frameId;
|
||||
|
||||
mBufferData[frameId].data = std::move(data);
|
||||
}
|
||||
|
||||
|
@ -65,20 +60,12 @@ namespace MWRender
|
|||
|
||||
auto& bufferData = mBufferData[frameId];
|
||||
|
||||
if (mQueuedDispatchArray && mQueuedDispatchFrameId == frameId)
|
||||
{
|
||||
mBufferData[frameId].data = std::move(mQueuedDispatchArray.value());
|
||||
mQueuedDispatchArray = std::nullopt;
|
||||
}
|
||||
|
||||
const auto& data = bufferData.data;
|
||||
|
||||
std::vector<size_t> filtered;
|
||||
|
||||
filtered.reserve(data.size());
|
||||
|
||||
const fx::DispatchNode::SubPass* resolvePass = nullptr;
|
||||
|
||||
for (size_t i = 0; i < data.size(); ++i)
|
||||
{
|
||||
const auto& node = data[i];
|
||||
|
@ -86,15 +73,6 @@ namespace MWRender
|
|||
if (bufferData.mask & node.mFlags)
|
||||
continue;
|
||||
|
||||
for (auto it = node.mPasses.crbegin(); it != node.mPasses.crend(); ++it)
|
||||
{
|
||||
if (!(*it).mRenderTarget)
|
||||
{
|
||||
resolvePass = &(*it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
filtered.push_back(i);
|
||||
}
|
||||
|
||||
|
@ -113,10 +91,9 @@ namespace MWRender
|
|||
else
|
||||
mLoggedLastError = false;
|
||||
|
||||
mFallbackStateSet->setTextureAttributeAndModes(0, bufferData.sceneTex);
|
||||
|
||||
state.pushStateSet(mFallbackStateSet);
|
||||
state.apply();
|
||||
state.applyTextureAttribute(0, bufferData.sceneTex);
|
||||
viewport->apply(state);
|
||||
|
||||
drawGeometry(renderInfo);
|
||||
|
@ -223,7 +200,7 @@ namespace MWRender
|
|||
|
||||
lastApplied = pass.mRenderTarget->getHandle(state.getContextID());;
|
||||
}
|
||||
else if (&pass == resolvePass)
|
||||
else if (pass.mResolve && index == filtered.back())
|
||||
{
|
||||
bindDestinationFbo();
|
||||
}
|
||||
|
|
|
@ -80,9 +80,6 @@ namespace MWRender
|
|||
mutable std::array<BufferData, 2> mBufferData;
|
||||
mutable std::array<osg::ref_ptr<osg::FrameBufferObject>, 3> mFbos;
|
||||
|
||||
mutable std::optional<fx::DispatchArray> mQueuedDispatchArray;
|
||||
mutable size_t mQueuedDispatchFrameId;
|
||||
|
||||
mutable bool mLoggedLastError = false;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -419,6 +419,8 @@ namespace MWRender
|
|||
createTexturesAndCamera(frameId);
|
||||
createObjectsForFrame(frameId);
|
||||
mDirty = false;
|
||||
|
||||
mPingPongCanvas->setCurrentFrameData(frameId, fx::DispatchArray(mTemplateData));
|
||||
}
|
||||
|
||||
if ((mNormalsSupported && mNormals != mPrevNormals) || (mPassLights != mPrevPassLights))
|
||||
|
@ -520,7 +522,12 @@ namespace MWRender
|
|||
if (!isEnabled())
|
||||
return;
|
||||
|
||||
fx::DispatchArray data;
|
||||
size_t frameId = frame() % 2;
|
||||
|
||||
mDirty = true;
|
||||
mDirtyFrameId = !frameId;
|
||||
|
||||
mTemplateData = {};
|
||||
|
||||
bool sunglare = true;
|
||||
mHDR = false;
|
||||
|
@ -632,12 +639,12 @@ namespace MWRender
|
|||
node.mPasses.emplace_back(std::move(subPass));
|
||||
}
|
||||
|
||||
data.emplace_back(std::move(node));
|
||||
node.compile();
|
||||
|
||||
mTemplateData.emplace_back(std::move(node));
|
||||
}
|
||||
|
||||
size_t frameId = frame() % 2;
|
||||
|
||||
mPingPongCanvas->setCurrentFrameData(frameId, std::move(data));
|
||||
mPingPongCanvas->setCurrentFrameData(frameId, fx::DispatchArray(mTemplateData));
|
||||
|
||||
if (auto hud = MWBase::Environment::get().getWindowManager()->getPostProcessorHud())
|
||||
hud->updateTechniques();
|
||||
|
|
|
@ -251,6 +251,8 @@ namespace MWRender
|
|||
|
||||
int mWidth;
|
||||
int mHeight;
|
||||
|
||||
fx::DispatchArray mTemplateData;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue