Commit 4d39dc62 authored by Laszlo Agocs's avatar Laszlo Agocs

Report dpr from rt

parent 0855a4d2
......@@ -588,6 +588,7 @@ public:
virtual Type type() const = 0;
virtual QSize sizeInPixels() const = 0;
virtual float devicePixelRatio() const = 0;
QRhiRenderPassDescriptor *renderPassDescriptor() const { return m_renderPassDesc; }
void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc) { m_renderPassDesc = desc; }
......
......@@ -477,7 +477,6 @@ QRhi::FrameOpResult QRhiD3D11::beginFrame(QRhiSwapChain *swapChain)
contextState.currentSwapChain = swapChainD;
swapChainD->cb.resetState();
swapChainD->rt.d.pixelSize = swapChainD->pixelSize;
swapChainD->rt.d.rtv[0] = swapChainD->sampleDesc.Count > 1 ?
swapChainD->msaaRtv[swapChainD->currentFrame] : swapChainD->rtv[swapChainD->currentFrame];
swapChainD->rt.d.dsv = swapChainD->ds ? swapChainD->ds->dsv : nullptr;
......@@ -1769,6 +1768,11 @@ QSize QD3D11ReferenceRenderTarget::sizeInPixels() const
return d.pixelSize;
}
float QD3D11ReferenceRenderTarget::devicePixelRatio() const
{
return d.dpr;
}
QD3D11TextureRenderTarget::QD3D11TextureRenderTarget(QRhiImplementation *rhi,
const QRhiTextureRenderTargetDescription &desc,
Flags flags)
......@@ -1858,6 +1862,7 @@ bool QD3D11TextureRenderTarget::build()
Q_UNREACHABLE();
}
}
d.dpr = 1;
if (hasDepthStencil) {
if (m_desc.depthTexture) {
......@@ -1905,6 +1910,11 @@ QSize QD3D11TextureRenderTarget::sizeInPixels() const
return d.pixelSize;
}
float QD3D11TextureRenderTarget::devicePixelRatio() const
{
return d.dpr;
}
QD3D11ShaderResourceBindings::QD3D11ShaderResourceBindings(QRhiImplementation *rhi)
: QRhiShaderResourceBindings(rhi)
{
......@@ -2567,6 +2577,7 @@ bool QD3D11SwapChain::buildOrResize()
QD3D11ReferenceRenderTarget *rtD = QRHI_RES(QD3D11ReferenceRenderTarget, &rt);
rtD->d.rp = QRHI_RES(QD3D11RenderPassDescriptor, m_renderPassDesc);
rtD->d.pixelSize = pixelSize;
rtD->d.dpr = window->devicePixelRatio();
rtD->d.colorAttCount = 1;
rtD->d.dsAttCount = m_depthStencil ? 1 : 0;
......
......@@ -124,6 +124,7 @@ struct QD3D11RenderTargetData
QD3D11RenderPassDescriptor *rp = nullptr;
QSize pixelSize;
float dpr = 1;
int colorAttCount = 0;
int dsAttCount = 0;
......@@ -138,6 +139,7 @@ struct QD3D11ReferenceRenderTarget : public QRhiReferenceRenderTarget
void release() override;
Type type() const override;
QSize sizeInPixels() const override;
float devicePixelRatio() const override;
QD3D11RenderTargetData d;
};
......@@ -149,6 +151,7 @@ struct QD3D11TextureRenderTarget : public QRhiTextureRenderTarget
Type type() const override;
QSize sizeInPixels() const override;
float devicePixelRatio() const override;
QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override;
bool build() override;
......
......@@ -1728,6 +1728,11 @@ QSize QGles2ReferenceRenderTarget::sizeInPixels() const
return d.pixelSize;
}
float QGles2ReferenceRenderTarget::devicePixelRatio() const
{
return d.dpr;
}
QGles2TextureRenderTarget::QGles2TextureRenderTarget(QRhiImplementation *rhi,
const QRhiTextureRenderTargetDescription &desc,
Flags flags)
......@@ -1797,6 +1802,7 @@ bool QGles2TextureRenderTarget::build()
rhiD->f->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbD->renderbuffer);
d.pixelSize = rbD->pixelSize();
}
d.dpr = 1;
if (m_desc.depthStencilBuffer) {
QGles2RenderBuffer *rbD = QRHI_RES(QGles2RenderBuffer, m_desc.depthStencilBuffer);
......@@ -1824,6 +1830,11 @@ QSize QGles2TextureRenderTarget::sizeInPixels() const
return d.pixelSize;
}
float QGles2TextureRenderTarget::devicePixelRatio() const
{
return d.dpr;
}
QGles2ShaderResourceBindings::QGles2ShaderResourceBindings(QRhiImplementation *rhi)
: QRhiShaderResourceBindings(rhi)
{
......@@ -2058,6 +2069,7 @@ bool QGles2SwapChain::buildOrResize()
rt.d.rp = QRHI_RES(QGles2RenderPassDescriptor, m_renderPassDesc);
rt.d.pixelSize = pixelSize;
rt.d.dpr = m_window->devicePixelRatio();
rt.d.attCount = m_depthStencil ? 2 : 1;
return true;
......
......@@ -132,7 +132,8 @@ struct QGles2BasicRenderTargetData
QGles2RenderPassDescriptor *rp = nullptr;
QSize pixelSize;
int attCount;
float dpr = 1;
int attCount = 0;
};
struct QGles2ReferenceRenderTarget : public QRhiReferenceRenderTarget
......@@ -141,6 +142,7 @@ struct QGles2ReferenceRenderTarget : public QRhiReferenceRenderTarget
void release() override;
Type type() const override;
QSize sizeInPixels() const override;
float devicePixelRatio() const override;
QGles2BasicRenderTargetData d;
};
......@@ -152,6 +154,7 @@ struct QGles2TextureRenderTarget : public QRhiTextureRenderTarget
Type type() const override;
QSize sizeInPixels() const override;
float devicePixelRatio() const override;
QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override;
bool build() override;
......
......@@ -162,6 +162,7 @@ struct QMetalCommandBufferData
struct QMetalRenderTargetData
{
QSize pixelSize;
float dpr = 1;
int colorAttCount = 0;
int dsAttCount = 0;
......@@ -1629,6 +1630,11 @@ QSize QMetalReferenceRenderTarget::sizeInPixels() const
return d->pixelSize;
}
float QMetalReferenceRenderTarget::devicePixelRatio() const
{
return d->dpr;
}
QMetalTextureRenderTarget::QMetalTextureRenderTarget(QRhiImplementation *rhi,
const QRhiTextureRenderTargetDescription &desc,
Flags flags)
......@@ -1693,6 +1699,7 @@ bool QMetalTextureRenderTarget::build()
d->fb.colorAtt[i] = { dst, m_desc.colorAttachments[i].layer, m_desc.colorAttachments[i].level,
resDst, m_desc.colorAttachments[i].resolveLayer, m_desc.colorAttachments[i].resolveLevel };
}
d->dpr = 1;
if (hasDepthStencil) {
if (m_desc.depthTexture) {
......@@ -1724,6 +1731,11 @@ QSize QMetalTextureRenderTarget::sizeInPixels() const
return d->pixelSize;
}
float QMetalTextureRenderTarget::devicePixelRatio() const
{
return d->dpr;
}
QMetalShaderResourceBindings::QMetalShaderResourceBindings(QRhiImplementation *rhi)
: QRhiShaderResourceBindings(rhi)
{
......@@ -2370,6 +2382,7 @@ bool QMetalSwapChain::buildOrResize()
}
rtWrapper.d->pixelSize = pixelSize;
rtWrapper.d->dpr = window->devicePixelRatio();
rtWrapper.d->colorAttCount = 1;
rtWrapper.d->dsAttCount = ds ? 1 : 0;
......
......@@ -143,6 +143,7 @@ struct QMetalReferenceRenderTarget : public QRhiReferenceRenderTarget
Type type() const override;
QSize sizeInPixels() const override;
float devicePixelRatio() const override;
QMetalRenderTargetData *d;
};
......@@ -155,6 +156,7 @@ struct QMetalTextureRenderTarget : public QRhiTextureRenderTarget
Type type() const override;
QSize sizeInPixels() const override;
float devicePixelRatio() const override;
QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override;
bool build() override;
......
......@@ -1188,6 +1188,7 @@ QRhi::FrameOpResult QRhiVulkan::beginWrapperFrame(QRhiSwapChain *swapChain)
swapChainD->rtWrapper.d.fb = w->currentFramebuffer();
swapChainD->m_currentPixelSize = swapChainD->pixelSize = swapChainD->rtWrapper.d.pixelSize = w->swapChainImageSize();
swapChainD->rtWrapper.d.dpr = w->devicePixelRatio();
currentFrameSlot = w->currentFrame();
currentSwapChain = swapChainD;
......@@ -3574,6 +3575,11 @@ QSize QVkReferenceRenderTarget::sizeInPixels() const
return d.pixelSize;
}
float QVkReferenceRenderTarget::devicePixelRatio() const
{
return d.dpr;
}
QVkTextureRenderTarget::QVkTextureRenderTarget(QRhiImplementation *rhi,
const QRhiTextureRenderTargetDescription &desc,
Flags flags)
......@@ -3679,6 +3685,7 @@ bool QVkTextureRenderTarget::build()
Q_UNREACHABLE();
}
}
d.dpr = 1;
if (hasDepthStencil) {
d.dsAttCount = 1;
......@@ -3757,6 +3764,11 @@ QSize QVkTextureRenderTarget::sizeInPixels() const
return d.pixelSize;
}
float QVkTextureRenderTarget::devicePixelRatio() const
{
return d.dpr;
}
QVkShaderResourceBindings::QVkShaderResourceBindings(QRhiImplementation *rhi)
: QRhiShaderResourceBindings(rhi)
{
......@@ -4218,6 +4230,7 @@ bool QVkSwapChain::buildOrResize()
rtWrapper.d.rp = QRHI_RES(QVkRenderPassDescriptor, m_renderPassDesc);
Q_ASSERT(rtWrapper.d.rp && rtWrapper.d.rp->rp);
m_currentPixelSize = pixelSize = rtWrapper.d.pixelSize = vkw->swapChainImageSize();
rtWrapper.d.dpr = vkw->devicePixelRatio();
rtWrapper.d.colorAttCount = 1;
rtWrapper.d.dsAttCount = 1;
rtWrapper.d.resolveAttCount = vkw->sampleCountFlagBits() > VK_SAMPLE_COUNT_1_BIT ? 1 : 0;
......@@ -4263,6 +4276,7 @@ bool QVkSwapChain::buildOrResize()
Q_ASSERT(rtWrapper.d.rp && rtWrapper.d.rp->rp);
rtWrapper.d.pixelSize = pixelSize;
rtWrapper.d.dpr = window->devicePixelRatio();
rtWrapper.d.colorAttCount = 1;
if (m_depthStencil) {
rtWrapper.d.dsAttCount = 1;
......
......@@ -146,6 +146,7 @@ struct QVkRenderTargetData
VkFramebuffer fb = VK_NULL_HANDLE;
QVkRenderPassDescriptor *rp = nullptr;
QSize pixelSize;
float dpr = 1;
int colorAttCount = 0;
int dsAttCount = 0;
int resolveAttCount = 0;
......@@ -158,6 +159,7 @@ struct QVkReferenceRenderTarget : public QRhiReferenceRenderTarget
void release() override;
Type type() const override;
QSize sizeInPixels() const override;
float devicePixelRatio() const override;
QVkRenderTargetData d;
};
......@@ -169,6 +171,7 @@ struct QVkTextureRenderTarget : public QRhiTextureRenderTarget
Type type() const override;
QSize sizeInPixels() const override;
float devicePixelRatio() const override;
QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override;
bool build() 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