Commit 2f4c4b7a authored by Laszlo Agocs's avatar Laszlo Agocs

API cleanup: rt sizeInPixels->pixelSize

parent d4269c27
...@@ -87,7 +87,7 @@ bool QRhiImgui::prepareFrame(QRhiRenderTarget *rt, QRhiRenderPassDescriptor *rp, ...@@ -87,7 +87,7 @@ bool QRhiImgui::prepareFrame(QRhiRenderTarget *rt, QRhiRenderPassDescriptor *rp,
io.Fonts->SetTexID(reinterpret_cast<ImTextureID>(quintptr(d->textures.count() - 1))); io.Fonts->SetTexID(reinterpret_cast<ImTextureID>(quintptr(d->textures.count() - 1)));
} }
const QSize outputSize = rt->sizeInPixels(); const QSize outputSize = rt->pixelSize();
const float dpr = rt->devicePixelRatio(); const float dpr = rt->devicePixelRatio();
io.DisplaySize.x = outputSize.width() / dpr; io.DisplaySize.x = outputSize.width() / dpr;
io.DisplaySize.y = outputSize.height() / dpr; io.DisplaySize.y = outputSize.height() / dpr;
......
...@@ -191,7 +191,7 @@ void Window::customInit() ...@@ -191,7 +191,7 @@ void Window::customInit()
d.triPs->build(); d.triPs->build();
d.triBaseMvp = m_r->clipSpaceCorrMatrix(); d.triBaseMvp = m_r->clipSpaceCorrMatrix();
d.triBaseMvp.perspective(45.0f, d.rt->sizeInPixels().width() / float(d.rt->sizeInPixels().height()), 0.01f, 1000.0f); d.triBaseMvp.perspective(45.0f, d.rt->pixelSize().width() / float(d.rt->pixelSize().height()), 0.01f, 1000.0f);
d.triBaseMvp.translate(0, 0, -2); d.triBaseMvp.translate(0, 0, -2);
float opacity = 1.0f; float opacity = 1.0f;
d.initialUpdates->updateDynamicBuffer(d.triUbuf, 64, 4, &opacity); d.initialUpdates->updateDynamicBuffer(d.triUbuf, 64, 4, &opacity);
...@@ -214,13 +214,6 @@ void Window::customRender() ...@@ -214,13 +214,6 @@ void Window::customRender()
d.initialUpdates = nullptr; d.initialUpdates = nullptr;
} }
if (d.winProj != m_proj) {
d.winProj = m_proj;
QMatrix4x4 mvp = m_proj;
mvp.scale(2.5f);
u->updateDynamicBuffer(d.ubuf, 0, 64, mvp.constData());
}
QMatrix4x4 triMvp = d.triBaseMvp; QMatrix4x4 triMvp = d.triBaseMvp;
triMvp.rotate(d.triRot, 0, 1, 0); triMvp.rotate(d.triRot, 0, 1, 0);
d.triRot += 1; d.triRot += 1;
...@@ -228,12 +221,19 @@ void Window::customRender() ...@@ -228,12 +221,19 @@ void Window::customRender()
cb->beginPass(d.rt, { 0.5f, 0.2f, 0, 1 }, { 1, 0 }, u); cb->beginPass(d.rt, { 0.5f, 0.2f, 0, 1 }, { 1, 0 }, u);
cb->setGraphicsPipeline(d.triPs); cb->setGraphicsPipeline(d.triPs);
cb->setViewport({ 0, 0, float(d.rt->sizeInPixels().width()), float(d.rt->sizeInPixels().height()) }); cb->setViewport({ 0, 0, float(d.rt->pixelSize().width()), float(d.rt->pixelSize().height()) });
cb->setShaderResources(); cb->setShaderResources();
cb->setVertexInput(0, { { d.vbuf, sizeof(quadVertexData) } }); cb->setVertexInput(0, { { d.vbuf, sizeof(quadVertexData) } });
cb->draw(3); cb->draw(3);
cb->endPass(); cb->endPass();
if (d.winProj != m_proj) {
d.winProj = m_proj;
QMatrix4x4 mvp = m_proj;
mvp.translate(-2, 0, 0);
u->updateDynamicBuffer(d.ubuf, 0, 64, mvp.constData());
}
const QSize outputSizeInPixels = m_sc->currentPixelSize(); const QSize outputSizeInPixels = m_sc->currentPixelSize();
cb->beginPass(m_sc->currentFrameRenderTarget(), { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }); cb->beginPass(m_sc->currentFrameRenderTarget(), { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 });
cb->setGraphicsPipeline(d.ps); cb->setGraphicsPipeline(d.ps);
......
...@@ -2070,7 +2070,7 @@ QRhiRenderTarget::QRhiRenderTarget(QRhiImplementation *rhi) ...@@ -2070,7 +2070,7 @@ QRhiRenderTarget::QRhiRenderTarget(QRhiImplementation *rhi)
*/ */
/*! /*!
\fn QSize QRhiRenderTarget::sizeInPixels() const \fn QSize QRhiRenderTarget::pixelSize() const
\return the size in pixels. \return the size in pixels.
*/ */
......
...@@ -812,7 +812,7 @@ public: ...@@ -812,7 +812,7 @@ public:
}; };
virtual Type type() const = 0; virtual Type type() const = 0;
virtual QSize sizeInPixels() const = 0; virtual QSize pixelSize() const = 0;
virtual float devicePixelRatio() const = 0; virtual float devicePixelRatio() const = 0;
virtual int sampleCount() const = 0; virtual int sampleCount() const = 0;
......
...@@ -611,7 +611,7 @@ void QRhiD3D11::setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) ...@@ -611,7 +611,7 @@ void QRhiD3D11::setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport)
const QVector4D r = viewport.viewport(); const QVector4D r = viewport.viewport();
cmd.args.viewport.x = r.x(); cmd.args.viewport.x = r.x();
// d3d expects top-left, QRhiViewport is bottom-left // d3d expects top-left, QRhiViewport is bottom-left
cmd.args.viewport.y = cbD->currentTarget->sizeInPixels().height() - (r.y() + r.w()); cmd.args.viewport.y = cbD->currentTarget->pixelSize().height() - (r.y() + r.w());
cmd.args.viewport.w = r.z(); cmd.args.viewport.w = r.z();
cmd.args.viewport.h = r.w(); cmd.args.viewport.h = r.w();
cmd.args.viewport.d0 = viewport.minDepth(); cmd.args.viewport.d0 = viewport.minDepth();
...@@ -629,7 +629,7 @@ void QRhiD3D11::setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) ...@@ -629,7 +629,7 @@ void QRhiD3D11::setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor)
const QVector4D r = scissor.scissor(); const QVector4D r = scissor.scissor();
cmd.args.scissor.x = r.x(); cmd.args.scissor.x = r.x();
// d3d expects top-left, QRhiScissor is bottom-left // d3d expects top-left, QRhiScissor is bottom-left
cmd.args.scissor.y = cbD->currentTarget->sizeInPixels().height() - (r.y() + r.w()); cmd.args.scissor.y = cbD->currentTarget->pixelSize().height() - (r.y() + r.w());
cmd.args.scissor.w = r.z(); cmd.args.scissor.w = r.z();
cmd.args.scissor.h = r.w(); cmd.args.scissor.h = r.w();
cbD->commands.append(cmd); cbD->commands.append(cmd);
...@@ -2276,7 +2276,7 @@ QRhiRenderTarget::Type QD3D11ReferenceRenderTarget::type() const ...@@ -2276,7 +2276,7 @@ QRhiRenderTarget::Type QD3D11ReferenceRenderTarget::type() const
return RtRef; return RtRef;
} }
QSize QD3D11ReferenceRenderTarget::sizeInPixels() const QSize QD3D11ReferenceRenderTarget::pixelSize() const
{ {
return d.pixelSize; return d.pixelSize;
} }
...@@ -2436,7 +2436,7 @@ QRhiRenderTarget::Type QD3D11TextureRenderTarget::type() const ...@@ -2436,7 +2436,7 @@ QRhiRenderTarget::Type QD3D11TextureRenderTarget::type() const
return RtTexture; return RtTexture;
} }
QSize QD3D11TextureRenderTarget::sizeInPixels() const QSize QD3D11TextureRenderTarget::pixelSize() const
{ {
return d.pixelSize; return d.pixelSize;
} }
......
...@@ -147,7 +147,7 @@ struct QD3D11ReferenceRenderTarget : public QRhiRenderTarget ...@@ -147,7 +147,7 @@ struct QD3D11ReferenceRenderTarget : public QRhiRenderTarget
void release() override; void release() override;
Type type() const override; Type type() const override;
QSize sizeInPixels() const override; QSize pixelSize() const override;
float devicePixelRatio() const override; float devicePixelRatio() const override;
int sampleCount() const override; int sampleCount() const override;
...@@ -160,7 +160,7 @@ struct QD3D11TextureRenderTarget : public QRhiTextureRenderTarget ...@@ -160,7 +160,7 @@ struct QD3D11TextureRenderTarget : public QRhiTextureRenderTarget
void release() override; void release() override;
Type type() const override; Type type() const override;
QSize sizeInPixels() const override; QSize pixelSize() const override;
float devicePixelRatio() const override; float devicePixelRatio() const override;
int sampleCount() const override; int sampleCount() const override;
......
...@@ -2260,7 +2260,7 @@ QRhiRenderTarget::Type QGles2ReferenceRenderTarget::type() const ...@@ -2260,7 +2260,7 @@ QRhiRenderTarget::Type QGles2ReferenceRenderTarget::type() const
return RtRef; return RtRef;
} }
QSize QGles2ReferenceRenderTarget::sizeInPixels() const QSize QGles2ReferenceRenderTarget::pixelSize() const
{ {
return d.pixelSize; return d.pixelSize;
} }
...@@ -2384,7 +2384,7 @@ QRhiRenderTarget::Type QGles2TextureRenderTarget::type() const ...@@ -2384,7 +2384,7 @@ QRhiRenderTarget::Type QGles2TextureRenderTarget::type() const
return RtTexture; return RtTexture;
} }
QSize QGles2TextureRenderTarget::sizeInPixels() const QSize QGles2TextureRenderTarget::pixelSize() const
{ {
return d.pixelSize; return d.pixelSize;
} }
......
...@@ -143,7 +143,7 @@ struct QGles2ReferenceRenderTarget : public QRhiRenderTarget ...@@ -143,7 +143,7 @@ struct QGles2ReferenceRenderTarget : public QRhiRenderTarget
void release() override; void release() override;
Type type() const override; Type type() const override;
QSize sizeInPixels() const override; QSize pixelSize() const override;
float devicePixelRatio() const override; float devicePixelRatio() const override;
int sampleCount() const override; int sampleCount() const override;
...@@ -156,7 +156,7 @@ struct QGles2TextureRenderTarget : public QRhiTextureRenderTarget ...@@ -156,7 +156,7 @@ struct QGles2TextureRenderTarget : public QRhiTextureRenderTarget
void release() override; void release() override;
Type type() const override; Type type() const override;
QSize sizeInPixels() const override; QSize pixelSize() const override;
float devicePixelRatio() const override; float devicePixelRatio() const override;
int sampleCount() const override; int sampleCount() const override;
......
...@@ -845,7 +845,7 @@ void QRhiMetal::setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) ...@@ -845,7 +845,7 @@ void QRhiMetal::setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport)
Q_ASSERT(inPass); Q_ASSERT(inPass);
QMetalCommandBuffer *cbD = QRHI_RES(QMetalCommandBuffer, cb); QMetalCommandBuffer *cbD = QRHI_RES(QMetalCommandBuffer, cb);
Q_ASSERT(cbD->currentPipeline && cbD->currentTarget); Q_ASSERT(cbD->currentPipeline && cbD->currentTarget);
const QSize outputSize = cbD->currentTarget->sizeInPixels(); const QSize outputSize = cbD->currentTarget->pixelSize();
const MTLViewport vp = toMetalViewport(viewport, outputSize); const MTLViewport vp = toMetalViewport(viewport, outputSize);
[cbD->d->currentPassEncoder setViewport: vp]; [cbD->d->currentPassEncoder setViewport: vp];
...@@ -862,7 +862,7 @@ void QRhiMetal::setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) ...@@ -862,7 +862,7 @@ void QRhiMetal::setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor)
QMetalCommandBuffer *cbD = QRHI_RES(QMetalCommandBuffer, cb); QMetalCommandBuffer *cbD = QRHI_RES(QMetalCommandBuffer, cb);
Q_ASSERT(cbD->currentPipeline && cbD->currentTarget); Q_ASSERT(cbD->currentPipeline && cbD->currentTarget);
Q_ASSERT(QRHI_RES(QMetalGraphicsPipeline, cbD->currentPipeline)->m_flags.testFlag(QRhiGraphicsPipeline::UsesScissor)); Q_ASSERT(QRHI_RES(QMetalGraphicsPipeline, cbD->currentPipeline)->m_flags.testFlag(QRhiGraphicsPipeline::UsesScissor));
const QSize outputSize = cbD->currentTarget->sizeInPixels(); const QSize outputSize = cbD->currentTarget->pixelSize();
const MTLScissorRect s = toMetalScissor(scissor, outputSize); const MTLScissorRect s = toMetalScissor(scissor, outputSize);
[cbD->d->currentPassEncoder setScissorRect: s]; [cbD->d->currentPassEncoder setScissorRect: s];
} }
...@@ -2235,7 +2235,7 @@ QRhiRenderTarget::Type QMetalReferenceRenderTarget::type() const ...@@ -2235,7 +2235,7 @@ QRhiRenderTarget::Type QMetalReferenceRenderTarget::type() const
return RtRef; return RtRef;
} }
QSize QMetalReferenceRenderTarget::sizeInPixels() const QSize QMetalReferenceRenderTarget::pixelSize() const
{ {
return d->pixelSize; return d->pixelSize;
} }
...@@ -2358,7 +2358,7 @@ QRhiRenderTarget::Type QMetalTextureRenderTarget::type() const ...@@ -2358,7 +2358,7 @@ QRhiRenderTarget::Type QMetalTextureRenderTarget::type() const
return RtTexture; return RtTexture;
} }
QSize QMetalTextureRenderTarget::sizeInPixels() const QSize QMetalTextureRenderTarget::pixelSize() const
{ {
return d->pixelSize; return d->pixelSize;
} }
......
...@@ -150,7 +150,7 @@ struct QMetalReferenceRenderTarget : public QRhiRenderTarget ...@@ -150,7 +150,7 @@ struct QMetalReferenceRenderTarget : public QRhiRenderTarget
void release() override; void release() override;
Type type() const override; Type type() const override;
QSize sizeInPixels() const override; QSize pixelSize() const override;
float devicePixelRatio() const override; float devicePixelRatio() const override;
int sampleCount() const override; int sampleCount() const override;
...@@ -164,7 +164,7 @@ struct QMetalTextureRenderTarget : public QRhiTextureRenderTarget ...@@ -164,7 +164,7 @@ struct QMetalTextureRenderTarget : public QRhiTextureRenderTarget
void release() override; void release() override;
Type type() const override; Type type() const override;
QSize sizeInPixels() const override; QSize pixelSize() const override;
float devicePixelRatio() const override; float devicePixelRatio() const override;
int sampleCount() const override; int sampleCount() const override;
......
...@@ -463,7 +463,7 @@ QRhiRenderTarget::Type QNullReferenceRenderTarget::type() const ...@@ -463,7 +463,7 @@ QRhiRenderTarget::Type QNullReferenceRenderTarget::type() const
return RtRef; return RtRef;
} }
QSize QNullReferenceRenderTarget::sizeInPixels() const QSize QNullReferenceRenderTarget::pixelSize() const
{ {
return d.pixelSize; return d.pixelSize;
} }
...@@ -516,7 +516,7 @@ QRhiRenderTarget::Type QNullTextureRenderTarget::type() const ...@@ -516,7 +516,7 @@ QRhiRenderTarget::Type QNullTextureRenderTarget::type() const
return RtTexture; return RtTexture;
} }
QSize QNullTextureRenderTarget::sizeInPixels() const QSize QNullTextureRenderTarget::pixelSize() const
{ {
return d.pixelSize; return d.pixelSize;
} }
......
...@@ -103,7 +103,7 @@ struct QNullReferenceRenderTarget : public QRhiRenderTarget ...@@ -103,7 +103,7 @@ struct QNullReferenceRenderTarget : public QRhiRenderTarget
void release() override; void release() override;
Type type() const override; Type type() const override;
QSize sizeInPixels() const override; QSize pixelSize() const override;
float devicePixelRatio() const override; float devicePixelRatio() const override;
int sampleCount() const override; int sampleCount() const override;
...@@ -116,7 +116,7 @@ struct QNullTextureRenderTarget : public QRhiTextureRenderTarget ...@@ -116,7 +116,7 @@ struct QNullTextureRenderTarget : public QRhiTextureRenderTarget
void release() override; void release() override;
Type type() const override; Type type() const override;
QSize sizeInPixels() const override; QSize pixelSize() const override;
float devicePixelRatio() const override; float devicePixelRatio() const override;
int sampleCount() const override; int sampleCount() const override;
......
...@@ -3277,7 +3277,7 @@ void QRhiVulkan::setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport ...@@ -3277,7 +3277,7 @@ void QRhiVulkan::setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport
Q_ASSERT(inPass); Q_ASSERT(inPass);
QVkCommandBuffer *cbD = QRHI_RES(QVkCommandBuffer, cb); QVkCommandBuffer *cbD = QRHI_RES(QVkCommandBuffer, cb);
Q_ASSERT(cbD->currentPipeline && cbD->currentTarget); Q_ASSERT(cbD->currentPipeline && cbD->currentTarget);
const QSize outputSize = cbD->currentTarget->sizeInPixels(); const QSize outputSize = cbD->currentTarget->pixelSize();
const VkViewport vp = toVkViewport(viewport, outputSize); const VkViewport vp = toVkViewport(viewport, outputSize);
df->vkCmdSetViewport(cbD->cb, 0, 1, &vp); df->vkCmdSetViewport(cbD->cb, 0, 1, &vp);
...@@ -3294,7 +3294,7 @@ void QRhiVulkan::setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) ...@@ -3294,7 +3294,7 @@ void QRhiVulkan::setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor)
QVkCommandBuffer *cbD = QRHI_RES(QVkCommandBuffer, cb); QVkCommandBuffer *cbD = QRHI_RES(QVkCommandBuffer, cb);
Q_ASSERT(cbD->currentPipeline && cbD->currentTarget); Q_ASSERT(cbD->currentPipeline && cbD->currentTarget);
Q_ASSERT(QRHI_RES(QVkGraphicsPipeline, cbD->currentPipeline)->m_flags.testFlag(QRhiGraphicsPipeline::UsesScissor)); Q_ASSERT(QRHI_RES(QVkGraphicsPipeline, cbD->currentPipeline)->m_flags.testFlag(QRhiGraphicsPipeline::UsesScissor));
const VkRect2D s = toVkScissor(scissor, cbD->currentTarget->sizeInPixels()); const VkRect2D s = toVkScissor(scissor, cbD->currentTarget->pixelSize());
df->vkCmdSetScissor(cbD->cb, 0, 1, &s); df->vkCmdSetScissor(cbD->cb, 0, 1, &s);
} }
...@@ -4203,7 +4203,7 @@ QRhiRenderTarget::Type QVkReferenceRenderTarget::type() const ...@@ -4203,7 +4203,7 @@ QRhiRenderTarget::Type QVkReferenceRenderTarget::type() const
return RtRef; // no Vk* are owned directly by the object return RtRef; // no Vk* are owned directly by the object
} }
QSize QVkReferenceRenderTarget::sizeInPixels() const QSize QVkReferenceRenderTarget::pixelSize() const
{ {
return d.pixelSize; return d.pixelSize;
} }
...@@ -4415,7 +4415,7 @@ QRhiRenderTarget::Type QVkTextureRenderTarget::type() const ...@@ -4415,7 +4415,7 @@ QRhiRenderTarget::Type QVkTextureRenderTarget::type() const
return RtTexture; return RtTexture;
} }
QSize QVkTextureRenderTarget::sizeInPixels() const QSize QVkTextureRenderTarget::pixelSize() const
{ {
return d.pixelSize; return d.pixelSize;
} }
......
...@@ -169,7 +169,7 @@ struct QVkReferenceRenderTarget : public QRhiRenderTarget ...@@ -169,7 +169,7 @@ struct QVkReferenceRenderTarget : public QRhiRenderTarget
void release() override; void release() override;
Type type() const override; Type type() const override;
QSize sizeInPixels() const override; QSize pixelSize() const override;
float devicePixelRatio() const override; float devicePixelRatio() const override;
int sampleCount() const override; int sampleCount() const override;
...@@ -182,7 +182,7 @@ struct QVkTextureRenderTarget : public QRhiTextureRenderTarget ...@@ -182,7 +182,7 @@ struct QVkTextureRenderTarget : public QRhiTextureRenderTarget
void release() override; void release() override;
Type type() const override; Type type() const override;
QSize sizeInPixels() const override; QSize pixelSize() const override;
float devicePixelRatio() const override; float devicePixelRatio() const override;
int sampleCount() const override; int sampleCount() const override;
......
Markdown is supported
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