Here is the original code, these function is used in calibration for frame in video.
void CalibrationMaterial::updateTextures(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates)
{
if (!m_frameDirty and !m_calibrationDirty)
return;
if (m_frameDirty) {
// keep the video frames alive until we know that they are not needed anymore
Q_ASSERT(NVideoFrameSlots >= rhi->resourceLimit(QRhi::FramesInFlight));
m_videoFrameSlots[rhi->currentFrameSlot()] = m_currentFrame;
// update and upload texture(s)
m_videoFrameTextures = QVideoTextureHelper::createTextures(m_currentFrame, rhi, resourceUpdates, std::move(m_videoFrameTextures));
if (m_videoFrameTextures) {
m_frameTexture.setData(QRhiTexture::R16, m_currentFrame.size(), nullptr, 0);
m_frameTexture.setRhiTexture(m_videoFrameTextures->texture(0));
m_frameDirty = false;
} else {
qWarning("Failed to create video texture");
}
}
if (m_calibrationDirty) {
m_calibrationRhiTexture.reset(rhi->newTexture(QRhiTexture::RGBA32F, m_calibrationImage.size()));
m_calibrationTexture.setTextureSize(m_calibrationImage.size());
if (m_calibrationRhiTexture->create()) {
QRhiTextureSubresourceUploadDescription subresDesc;
subresDesc.setData(QByteArray::fromRawData(
reinterpret_cast<const char *>(m_calibrationImage.constBits()), m_calibrationImage.sizeInBytes()));
subresDesc.setDataStride(m_calibrationImage.bytesPerLine());
QRhiTextureUploadEntry entry(0, 0, subresDesc);
QRhiTextureUploadDescription desc({ entry });
resourceUpdates->uploadTexture(m_calibrationRhiTexture.get(), desc);
m_calibrationTexture.setTexture(m_calibrationRhiTexture.get());
m_calibrationDirty = false;
} else {
qWarning("Failed to create calibration texture");
}
}
}
//=======================
void updateTextures(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates);
//=======================
The previous one who built this app did that, used the private header and also changed something in it. I don't understand much about that, that why I said it hard to understand especially he is experience one.