Commit 9b18d1b8 authored by Laszlo Agocs's avatar Laszlo Agocs

Correct inconsistency in effective size getter naming

parent ae02ee6a
......@@ -404,7 +404,7 @@ void Window::resizeSwapChain()
m_elapsedMs = 0;
m_elapsedCount = 0;
const QSize outputSizeInPixels = m_sc->effectiveSizeInPixels();
const QSize outputSizeInPixels = m_sc->effectivePixelSize();
m_proj = m_r->clipSpaceCorrMatrix();
m_proj.perspective(45.0f, outputSizeInPixels.width() / (float) outputSizeInPixels.height(), 0.01f, 100.0f);
m_proj.translate(0, 0, -4);
......@@ -474,7 +474,7 @@ void Window::render()
u->updateDynamicBuffer(m_ubuf, 64, 4, &m_opacity);
QRhiCommandBuffer *cb = m_sc->currentFrameCommandBuffer();
const QSize outputSizeInPixels = m_sc->effectiveSizeInPixels();
const QSize outputSizeInPixels = m_sc->effectivePixelSize();
// Apply buffer/texture updates, clear, queue the renderpass begin (where applicable).
m_r->beginPass(m_sc->currentFrameRenderTarget(), cb, { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
......
......@@ -213,15 +213,16 @@ void ExampleWindow::render()
return;
}
const QSize outputSize = m_sc->effectivePixelSize();
if (m_resizedSwapChain) {
m_resizedSwapChain = false;
m_triRenderer.resize(m_sc->effectiveSizeInPixels());
m_triRenderer.resize(outputSize);
if (!m_triangleOnly) {
m_quadRenderer.resize(m_sc->effectiveSizeInPixels());
m_cubeRenderer.resize(m_sc->effectiveSizeInPixels());
m_quadRenderer.resize(outputSize);
m_cubeRenderer.resize(outputSize);
}
if (!m_onScreenOnly)
m_liveTexCubeRenderer.resize(m_sc->effectiveSizeInPixels());
m_liveTexCubeRenderer.resize(outputSize);
}
QRhiCommandBuffer *cb = m_sc->currentFrameCommandBuffer();
......@@ -238,13 +239,13 @@ void ExampleWindow::render()
m_liveTexCubeRenderer.queueResourceUpdates(u);
m_r->beginPass(m_sc->currentFrameRenderTarget(), cb, { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
m_triRenderer.queueDraw(cb, m_sc->effectiveSizeInPixels());
m_triRenderer.queueDraw(cb, outputSize);
if (!m_triangleOnly) {
m_quadRenderer.queueDraw(cb, m_sc->effectiveSizeInPixels());
m_cubeRenderer.queueDraw(cb, m_sc->effectiveSizeInPixels());
m_quadRenderer.queueDraw(cb, outputSize);
m_cubeRenderer.queueDraw(cb, outputSize);
}
if (!m_onScreenOnly)
m_liveTexCubeRenderer.queueDraw(cb, m_sc->effectiveSizeInPixels());
m_liveTexCubeRenderer.queueDraw(cb, outputSize);
m_r->endPass(cb);
m_r->endFrame(m_sc);
......
......@@ -88,7 +88,7 @@ void Renderer::initSwapChainResources()
// had to defer init until we can query the imported renderpass
m_triRenderer.initResources(m_sc->renderPassDescriptor());
}
m_triRenderer.resize(m_sc->effectiveSizeInPixels());
m_triRenderer.resize(m_sc->effectivePixelSize());
}
void Renderer::releaseSwapChainResources()
......@@ -116,7 +116,7 @@ void Renderer::startNextFrame()
m_triRenderer.queueResourceUpdates(u);
m_r->beginPass(m_sc->currentFrameRenderTarget(), cb, { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
m_triRenderer.queueDraw(cb, m_sc->effectiveSizeInPixels());
m_triRenderer.queueDraw(cb, m_sc->effectivePixelSize());
m_r->endPass(cb);
m_r->endFrame(m_sc);
......
......@@ -759,12 +759,14 @@ public:
virtual QRhiCommandBuffer *currentFrameCommandBuffer() = 0;
virtual QRhiRenderTarget *currentFrameRenderTarget() = 0;
// Some backends use the requested size, others ignore it and get the actual
// size on their own. Keep track of both - application logic will need the
// requested size (to do their "if qwindow->size() * dpr != req.size then
// resize_swapchain" logic) and the actual size as well (for all graphics
// calculations like viewport).
virtual QSize effectiveSizeInPixels() const = 0;
// Applications are expected to use requestedPixelSize() for logic like "if
// qwindow->size() * qwindow->dpr() != requestedPixelSize() then
// resize_swapchain", and effectivePixelSize() for all graphics
// calculations, like the viewport. On some platforms they may not be the
// same, e.g. some Vulkan implementations on Windows were observed to make
// the swapchain buffers' height off by one on high dpi screens, this is
// then reflected in the effective size.
virtual QSize effectivePixelSize() const = 0;
// To be called before build() with relevant parameters like depthStencil and sampleCount set.
// (things like the window or the size of depthStencil are irrelevant here)
......
......@@ -1813,7 +1813,7 @@ QRhiRenderTarget *QD3D11SwapChain::currentFrameRenderTarget()
return &rt;
}
QSize QD3D11SwapChain::effectiveSizeInPixels() const
QSize QD3D11SwapChain::effectivePixelSize() const
{
return pixelSize;
}
......
......@@ -360,7 +360,7 @@ struct QD3D11SwapChain : public QRhiSwapChain
QRhiCommandBuffer *currentFrameCommandBuffer() override;
QRhiRenderTarget *currentFrameRenderTarget() override;
QSize effectiveSizeInPixels() const override;
QSize effectivePixelSize() const override;
QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override;
bool buildOrResize();
......
......@@ -1537,7 +1537,7 @@ QRhiRenderTarget *QGles2SwapChain::currentFrameRenderTarget()
return &rt;
}
QSize QGles2SwapChain::effectiveSizeInPixels() const
QSize QGles2SwapChain::effectivePixelSize() const
{
return pixelSize;
}
......
......@@ -293,7 +293,7 @@ struct QGles2SwapChain : public QRhiSwapChain
QRhiCommandBuffer *currentFrameCommandBuffer() override;
QRhiRenderTarget *currentFrameRenderTarget() override;
QSize effectiveSizeInPixels() const override;
QSize effectivePixelSize() const override;
QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override;
bool buildOrResize() override;
......
......@@ -1238,7 +1238,7 @@ QRhiRenderTarget *QMetalSwapChain::currentFrameRenderTarget()
return &rtWrapper;
}
QSize QMetalSwapChain::effectiveSizeInPixels() const
QSize QMetalSwapChain::effectivePixelSize() const
{
return effectivePixelSize;
}
......
......@@ -205,7 +205,7 @@ struct QMetalSwapChain : public QRhiSwapChain
QRhiCommandBuffer *currentFrameCommandBuffer() override;
QRhiRenderTarget *currentFrameRenderTarget() override;
QSize effectiveSizeInPixels() const override;
QSize effectivePixelSize() const override;
QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override;
......
......@@ -791,8 +791,8 @@ bool QRhiVulkan::recreateSwapChain(VkSurfaceKHR surface, const QSize &pixelSize,
bufferSize.height = swapChainD->m_requestedPixelSize.height();
}
swapChainD->effectivePixelSize = QSize(bufferSize.width, bufferSize.height);
if (swapChainD->effectivePixelSize.isEmpty())
swapChainD->pixelSize = QSize(bufferSize.width, bufferSize.height);
if (swapChainD->pixelSize.isEmpty())
return false;
VkSurfaceTransformFlagBitsKHR preTransform =
......@@ -878,7 +878,7 @@ bool QRhiVulkan::recreateSwapChain(VkSurfaceKHR surface, const QSize &pixelSize,
VkImageView msaaViews[QVkSwapChain::MAX_BUFFER_COUNT];
if (swapChainD->sampleCount > VK_SAMPLE_COUNT_1_BIT) {
if (!createTransientImage(swapChainD->colorFormat,
swapChainD->effectivePixelSize,
swapChainD->pixelSize,
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
VK_IMAGE_ASPECT_COLOR_BIT,
swapChainD->sampleCount,
......@@ -1055,7 +1055,7 @@ QRhi::FrameOpResult QRhiVulkan::beginWrapperFrame(QRhiSwapChain *swapChain)
swapChainD->cbWrapper.cb = w->currentCommandBuffer();
swapChainD->rtWrapper.d.fb = w->currentFramebuffer();
swapChainD->m_requestedPixelSize = swapChainD->effectivePixelSize = swapChainD->rtWrapper.d.pixelSize = w->swapChainImageSize();
swapChainD->m_requestedPixelSize = swapChainD->pixelSize = swapChainD->rtWrapper.d.pixelSize = w->swapChainImageSize();
currentFrameSlot = w->currentFrame();
......@@ -3235,9 +3235,9 @@ QRhiRenderTarget *QVkSwapChain::currentFrameRenderTarget()
return &rtWrapper;
}
QSize QVkSwapChain::effectiveSizeInPixels() const
QSize QVkSwapChain::effectivePixelSize() const
{
return effectivePixelSize;
return pixelSize;
}
QRhiRenderPassDescriptor *QVkSwapChain::newCompatibleRenderPassDescriptor()
......@@ -3261,7 +3261,7 @@ bool QVkSwapChain::buildOrResize()
rtWrapper.d.rp = new QVkRenderPassDescriptor(rhi);
rtWrapper.d.rp->rp = vkw->defaultRenderPass();
m_renderPassDesc = rtWrapper.d.rp;
m_requestedPixelSize = effectivePixelSize = rtWrapper.d.pixelSize = vkw->swapChainImageSize();
m_requestedPixelSize = pixelSize = rtWrapper.d.pixelSize = vkw->swapChainImageSize();
rtWrapper.d.colorAttCount = 1;
rtWrapper.d.dsAttCount = 1;
rtWrapper.d.msaaAttCount = vkw->sampleCountFlagBits() > VK_SAMPLE_COUNT_1_BIT ? 1 : 0;
......@@ -3320,7 +3320,7 @@ bool QVkSwapChain::buildOrResize()
rtWrapper.d.rp = QRHI_RES(QVkRenderPassDescriptor, m_renderPassDesc);
Q_ASSERT(rtWrapper.d.rp && rtWrapper.d.rp->rp);
rtWrapper.d.pixelSize = effectivePixelSize;
rtWrapper.d.pixelSize = pixelSize;
rtWrapper.d.colorAttCount = 1;
if (m_depthStencil) {
rtWrapper.d.dsAttCount = 1;
......@@ -3348,8 +3348,8 @@ bool QVkSwapChain::buildOrResize()
fbInfo.renderPass = rtWrapper.d.rp->rp;
fbInfo.attachmentCount = rtWrapper.d.colorAttCount + rtWrapper.d.dsAttCount + rtWrapper.d.msaaAttCount;
fbInfo.pAttachments = views;
fbInfo.width = effectivePixelSize.width();
fbInfo.height = effectivePixelSize.height();
fbInfo.width = pixelSize.width();
fbInfo.height = pixelSize.height();
fbInfo.layers = 1;
VkResult err = rhiD->df->vkCreateFramebuffer(rhiD->dev, &fbInfo, nullptr, &image.fb);
if (err != VK_SUCCESS) {
......
......@@ -249,7 +249,7 @@ struct QVkSwapChain : public QRhiSwapChain
QRhiCommandBuffer *currentFrameCommandBuffer() override;
QRhiRenderTarget *currentFrameRenderTarget() override;
QSize effectiveSizeInPixels() const override;
QSize effectivePixelSize() const override;
QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override;
bool buildOrResize() override;
......@@ -258,7 +258,7 @@ struct QVkSwapChain : public QRhiSwapChain
static const int MAX_BUFFER_COUNT = 3;
QVulkanWindow *wrapWindow = nullptr;
QSize effectivePixelSize;
QSize pixelSize;
bool supportsReadback = false;
VkSwapchainKHR sc = VK_NULL_HANDLE;
int bufferCount = 0;
......
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