fix threading issue when dispatching frame dependent data

This commit is contained in:
glassmancody.info 2022-06-05 15:46:25 -07:00
parent c7449dc272
commit acc209c294
6 changed files with 34 additions and 34 deletions

View file

@ -59,9 +59,11 @@ namespace fx
osg::ref_ptr<osg::StateSet> mStateSet = new osg::StateSet;
osg::ref_ptr<osg::FrameBufferObject> mRenderTarget;
osg::ref_ptr<osg::Texture2D> mRenderTexture;
bool mResolve = false;
SubPass(const SubPass& other, const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY)
: mStateSet(new osg::StateSet(*other.mStateSet, copyOp))
, mResolve(other.mResolve)
{
if (other.mRenderTarget)
mRenderTarget = new osg::FrameBufferObject(*other.mRenderTarget, copyOp);
@ -70,6 +72,18 @@ namespace fx
}
};
void compile()
{
for (auto rit = mPasses.rbegin(); rit != mPasses.rend(); ++rit)
{
if (!rit->mRenderTarget)
{
rit->mResolve = true;
break;
}
}
}
// not safe to read/write in draw thread
std::shared_ptr<fx::Technique> mHandle = nullptr;