diff --git a/src/core/compositor/delegated_frame_node.cpp b/src/core/compositor/delegated_frame_node.cpp
index 4fb05051bcc8a532f603e69adea04e39097d7713..5f474cbfb1fc53decd0528eb35ceb0ce578976c3 100644
--- a/src/core/compositor/delegated_frame_node.cpp
+++ b/src/core/compositor/delegated_frame_node.cpp
@@ -1019,6 +1019,7 @@ QSGTexture *DelegatedFrameNode::initAndHoldTexture(const CompositorResource *res
         texture->setFiltering(filtering);
         return texture.data();
     } else {
+#if QT_CONFIG(opengl)
         QSharedPointer<MailboxTexture> &texture =
             findTexture(m_sgObjects.mailboxTextures, m_previousSGObjects.mailboxTextures, resource->id);
         if (texture)
@@ -1026,6 +1027,10 @@ QSGTexture *DelegatedFrameNode::initAndHoldTexture(const CompositorResource *res
         texture = createMailboxTexture(resource, hasAlphaChannel, target);
         texture->setFiltering(filtering);
         return texture.data();
+#else
+        Q_UNREACHABLE();
+        return nullptr;
+#endif
     }
 }