Commit df6df15d authored by Laszlo Agocs's avatar Laszlo Agocs
Browse files

imgui: Avoid recalculating the mvp every frame

parent c47c3655
......@@ -113,9 +113,12 @@ bool QRhiImgui::imguiPass(QRhiCommandBuffer *cb, QRhiRenderTarget *rt, QRhiRende
resUpd->updateDynamicBuffer(d->ubuf, 64, 4, &opacity);
}
QMatrix4x4 mvp = d->rhi->clipSpaceCorrMatrix();
mvp.ortho(0, io.DisplaySize.x, io.DisplaySize.y, 0, 1, -1);
resUpd->updateDynamicBuffer(d->ubuf, 0, 64, mvp.constData());
if (d->lastOutputSize.width() != io.DisplaySize.x || d->lastOutputSize.height() != io.DisplaySize.y) {
QMatrix4x4 mvp = d->rhi->clipSpaceCorrMatrix();
mvp.ortho(0, io.DisplaySize.x, io.DisplaySize.y, 0, 1, -1);
resUpd->updateDynamicBuffer(d->ubuf, 0, 64, mvp.constData());
d->lastOutputSize = QSizeF(io.DisplaySize.x, io.DisplaySize.y);
}
if (!d->sampler) {
d->sampler = d->rhi->newSampler(QRhiSampler::Linear, QRhiSampler::Linear, QRhiSampler::None,
......@@ -273,6 +276,7 @@ bool QRhiImgui::imguiPass(QRhiCommandBuffer *cb, QRhiRenderTarget *rt, QRhiRende
void QRhiImgui::initialize(QRhi *rhi)
{
d->rhi = rhi;
d->lastOutputSize = QSizeF();
}
void QRhiImgui::releaseResources()
......
......@@ -95,6 +95,7 @@ public:
QRhiGraphicsPipeline *ps = nullptr;
QRhiSampler *sampler = nullptr;
QVector<QRhiResource *> releasePool;
QSizeF lastOutputSize;
QRhiImGuiInputEventFilter *inputEventFilter = nullptr;
QObject *inputEventSource = nullptr;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment