diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 81e8cd28be8..093c2885299 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -1893,6 +1893,11 @@ void QRhiGles2::setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline cbD->currentGraphicsPipeline = ps; cbD->currentComputePipeline = nullptr; cbD->currentPipelineGeneration = psD->generation; + if (psD->lastUsedInFrameNo != frameNo) { + psD->lastUsedInFrameNo = frameNo; + psD->currentSrb = nullptr; + psD->currentSrbGeneration = 0; + } QGles2CommandBuffer::Command &cmd(cbD->commands.get()); cmd.cmd = QGles2CommandBuffer::Command::BindGraphicsPipeline; @@ -2288,6 +2293,7 @@ QRhi::FrameOpResult QRhiGles2::beginFrame(QRhiSwapChain *swapChain, QRhi::BeginF executeDeferredReleases(); swapChainD->cb.resetState(); + frameNo += 1; if (swapChainD->timestamps.active[swapChainD->currentTimestampPairIndex]) { double elapsedSec = 0; @@ -2331,7 +2337,6 @@ QRhi::FrameOpResult QRhiGles2::endFrame(QRhiSwapChain *swapChain, QRhi::EndFrame f->glFlush(); } - swapChainD->frameCount += 1; currentSwapChain = nullptr; ctx->handle()->endFrame(); @@ -4906,6 +4911,11 @@ void QRhiGles2::setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *p cbD->currentGraphicsPipeline = nullptr; cbD->currentComputePipeline = ps; cbD->currentPipelineGeneration = psD->generation; + if (psD->lastUsedInFrameNo != frameNo) { + psD->lastUsedInFrameNo = frameNo; + psD->currentSrb = nullptr; + psD->currentSrbGeneration = 0; + } QGles2CommandBuffer::Command &cmd(cbD->commands.get()); cmd.cmd = QGles2CommandBuffer::Command::BindComputePipeline; @@ -6862,8 +6872,6 @@ bool QGles2SwapChain::createOrResize() rtRight.d.stereoTarget = QRhiSwapChain::RightBuffer; } - frameCount = 0; - QRHI_RES_RHI(QRhiGles2); if (rhiD->rhiFlags.testFlag(QRhi::EnableTimestamps) && rhiD->caps.timestamps) timestamps.prepare(rhiD); diff --git a/src/gui/rhi/qrhigles2_p.h b/src/gui/rhi/qrhigles2_p.h index 72048fe34dd..1efef16af66 100644 --- a/src/gui/rhi/qrhigles2_p.h +++ b/src/gui/rhi/qrhigles2_p.h @@ -279,6 +279,7 @@ struct QGles2GraphicsPipeline : public QRhiGraphicsPipeline QGles2UniformState uniformState[QGles2UniformState::MAX_TRACKED_LOCATION + 1]; QRhiShaderResourceBindings *currentSrb = nullptr; uint currentSrbGeneration = 0; + uint lastUsedInFrameNo = 0; uint generation = 0; friend class QRhiGles2; }; @@ -296,6 +297,7 @@ struct QGles2ComputePipeline : public QRhiComputePipeline QGles2UniformState uniformState[QGles2UniformState::MAX_TRACKED_LOCATION + 1]; QRhiShaderResourceBindings *currentSrb = nullptr; uint currentSrbGeneration = 0; + uint lastUsedInFrameNo = 0; uint generation = 0; friend class QRhiGles2; }; @@ -754,7 +756,6 @@ struct QGles2SwapChain : public QRhiSwapChain QGles2SwapChainRenderTarget rtLeft; QGles2SwapChainRenderTarget rtRight; QGles2CommandBuffer cb; - int frameCount = 0; QGles2SwapChainTimestamps timestamps; int currentTimestampPairIndex = 0; }; @@ -1096,6 +1097,7 @@ public: QRhiGles2NativeHandles nativeHandlesStruct; QRhiDriverInfo driverInfoStruct; mutable bool contextLost = false; + uint frameNo = 0; struct DeferredReleaseEntry { enum Type {