mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-01 06:17:58 +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
|
@ -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;
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ namespace fx
|
|||
mValueLabel->setCaption(std::to_string(mValue));
|
||||
|
||||
float range = 0.f;
|
||||
float min = 0.f;
|
||||
|
||||
if (auto uniform = mUniform.lock())
|
||||
{
|
||||
|
@ -94,6 +95,7 @@ namespace fx
|
|||
{
|
||||
uniform->template setValue<UType>(mValue);
|
||||
range = uniform->template getMax<UType>() - uniform->template getMin<UType>();
|
||||
min = uniform->template getMin<UType>();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -101,10 +103,11 @@ namespace fx
|
|||
uvalue[mIndex] = mValue;
|
||||
uniform->template setValue<UType>(uvalue);
|
||||
range = uniform->template getMax<UType>()[mIndex] - uniform->template getMin<UType>()[mIndex];
|
||||
min = uniform->template getMin<UType>()[mIndex];
|
||||
}
|
||||
}
|
||||
|
||||
float fill = (range == 0.f) ? 1.f : mValue / range;
|
||||
float fill = (range == 0.f) ? 1.f : (mValue - min) / range;
|
||||
mFill->setRealSize(fill, 1.0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue