Details
Description
One common usage of glBlitFramebuffer is to copy regions between textures. In plain GL code this is often done by creating more or less temporary framebuffer objects that have the textures in question as their color attachment.
Trying to reproduce the same with the BlitFramebuffer framegraph node fails since the implementation is not prepared for the case when the input and/or output QRenderTarget has no FBO associated with it:
void GraphicsContext::blitFramebuffer(Qt3DCore::QNodeId inputRenderTarget, Qt3DCore::QNodeId outputRenderTarget, QRect inputRect, QRect outputRect, uint defaultFboId, QRenderTargetOutput::AttachmentPoint inputAttachmentPoint, QRenderTargetOutput::AttachmentPoint outputAttachmentPoint, QBlitFramebuffer::InterpolationMethod interpolationMethod) { //Find the context side name for the render targets const GLuint inputFboId = m_renderTargets[inputRenderTarget]; GLuint outputFboId = defaultFboId; bool outputBufferIsDefault = true; if (!outputRenderTarget.isNull() && m_renderTargets.contains(outputRenderTarget)) { outputFboId = m_renderTargets[outputRenderTarget]; outputBufferIsDefault = false; }
The simple m_renderTargets access and check are wrong. Consider application code like this:
Qt3DRender::QBlitFramebuffer *bgBlit = new Qt3DRender::QBlitFramebuffer(...); Qt3DRender::QRenderTarget *tempTexRt = new Qt3DRender::QRenderTarget(...); Qt3DRender::QRenderTargetOutput *tempTexOutput = new Qt3DRender::QRenderTargetOutput; tempTexOutput->setAttachmentPoint(Qt3DRender::QRenderTargetOutput::Color0); tempTexOutput->setTexture(data->advBlend.tempTexture); tempTexRt->addOutput(tempTexOutput); bgBlit->setSource(screenTexRt); bgBlit->setDestination(tempTexRt); bgBlit->setSourceRect(...); bgBlit->setDestinationRect(...); new Qt3DRender::QNoDraw(bgBlit);
Here the destination QRenderTarget (tempTexRt) is not something that is ever "activated" from the GraphicsContext's point of view. Yet the blitframebuffer is expected to work. Right now it will silently fall back to FBO 0 as the destination...
Same applies to the source. If screenTexRt is something another section of the framegraph renders to, then it works fine. If not then bad things happen.