mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-14 21:39:41 +00:00
update render targets during update instead of draw thread -- fixes a bug with <1 size ratios
This commit is contained in:
parent
090c65c017
commit
f849b0c90f
2 changed files with 6 additions and 22 deletions
apps/openmw/mwrender
|
@ -278,25 +278,6 @@ namespace MWRender
|
|||
|
||||
if (pass.mRenderTarget)
|
||||
{
|
||||
if (mDirtyAttachments.size() > 0)
|
||||
{
|
||||
const auto [w, h]
|
||||
= pass.mSize.get(mTextureScene->getTextureWidth(), mTextureScene->getTextureHeight());
|
||||
|
||||
// Custom render targets must be shared between frame ids, so it's impossible to double buffer
|
||||
// without expensive copies. That means the only thread-safe place to resize is in the draw
|
||||
// thread.
|
||||
osg::Texture2D* texture = const_cast<osg::Texture2D*>(dynamic_cast<const osg::Texture2D*>(
|
||||
pass.mRenderTarget->getAttachment(osg::FrameBufferObject::BufferComponent::COLOR_BUFFER0)
|
||||
.getTexture()));
|
||||
|
||||
assert(texture != nullptr);
|
||||
|
||||
texture->setTextureSize(w, h);
|
||||
texture->setNumMipmapLevels(pass.mRenderTexture->getNumMipmapLevels());
|
||||
texture->dirtyTextureObject();
|
||||
}
|
||||
|
||||
pass.mRenderTarget->apply(state, osg::FrameBufferObject::DRAW_FRAMEBUFFER);
|
||||
|
||||
if (pass.mRenderTexture->getNumMipmapLevels() > 0)
|
||||
|
|
|
@ -650,13 +650,16 @@ namespace MWRender
|
|||
subPass.mRenderTexture = renderTarget.mTarget;
|
||||
subPass.mMipMap = renderTarget.mMipMap;
|
||||
|
||||
const auto [w, h] = renderTarget.mSize.get(renderWidth(), renderHeight());
|
||||
subPass.mStateSet->setAttributeAndModes(new osg::Viewport(0, 0, w, h));
|
||||
|
||||
subPass.mRenderTexture->setTextureSize(w, h);
|
||||
subPass.mRenderTexture->dirtyTextureObject();
|
||||
|
||||
subPass.mRenderTarget = new osg::FrameBufferObject;
|
||||
subPass.mRenderTarget->setAttachment(osg::FrameBufferObject::BufferComponent::COLOR_BUFFER0,
|
||||
osg::FrameBufferAttachment(subPass.mRenderTexture));
|
||||
|
||||
const auto [w, h] = renderTarget.mSize.get(renderWidth(), renderHeight());
|
||||
subPass.mStateSet->setAttributeAndModes(new osg::Viewport(0, 0, w, h));
|
||||
|
||||
if (std::find_if(attachmentsToDirty.cbegin(), attachmentsToDirty.cend(),
|
||||
[renderTarget](const auto& rt) { return renderTarget.mTarget == rt.mTarget; })
|
||||
== attachmentsToDirty.cend())
|
||||
|
|
Loading…
Reference in a new issue