Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.9, 5.10, 5.11
-
None
Description
Have a QRenderTargetOutput, set a texture. Then later on, e.g. in a frame action, change it to another texture. The second texture should have the same size as the first (which is a pretty common case in techniques where one plays ping pong with two textures)
This has no effect: in practice the output gets unchanged.
Looking at GraphicsContext::activateRenderTarget the code looks suspicious (at first glance): there is nothing saying we hit the needsResize branch at the end when the texture (i.e. attachment.m_textureUuid) but not the size changes.
} else { fboId = m_renderTargets.value(renderTargetNodeId); // We need to check if one of the attachment was resized bool needsResize = !m_renderTargetsSize.contains(fboId); // not even initialized yet? if (!needsResize) { // render target exists, has attachment been resized? GLTextureManager *glTextureManager = m_renderer->nodeManagers()->glTextureManager(); const QSize s = m_renderTargetsSize[fboId]; const auto attachments_ = attachments.attachments(); for (const Attachment &attachment : attachments_) { GLTexture *rTex = glTextureManager->lookupResource(attachment.m_textureUuid); needsResize |= (rTex != nullptr && rTex->size() != s); if (attachment.m_point == QRenderTargetOutput::Color0) m_renderTargetFormat = rTex->properties().format; } } if (needsResize) { m_glHelper->bindFrameBufferObject(fboId, GraphicsHelperInterface::FBODraw); bindFrameBufferAttachmentHelper(fboId, attachments); } }
Could probably be worked on application side around by changing the entire QRenderTarget in the QRenderTargetSelector. (and that would likely be more efficient since we then just switch FBOs then instead of altering the framebuffer attachments all the time) Still, would be good to handle this somehow on QRenderTargetOutput level too.
Update: Actually, there are very valid use cases when a texture changes and it is more appropriate to update that one attachment only, not create a whole new FBO (i.e. QRenderTarget). Think a technique that (infrequently) needs to steal the texture belonging to a QRenderTargetOutput, replacing it with a new one.
Attachments
Issue Links
- relates to
-
QT3DS-660 Qt 3D bugs and features required for Runtime 2
- Withdrawn
Gerrit Reviews
For Gerrit Dashboard: QTBUG-64757 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
290570,2 | Fix and improve FBO handling | 5.15 | qt/qt3d | Status: MERGED | +2 | 0 |
290574,2 | Fix and improve FBO handling | 5.14 | qt/qt3d | Status: MERGED | +2 | 0 |
290591,2 | Fix and improve FBO handling | 5.12 | qt/qt3d | Status: MERGED | +2 | 0 |