diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-04-20 13:00:39 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-04-23 10:19:53 +0200 |
commit | 3ef7a760ff5ae61e4297ec2f271408ac453ca93d (patch) | |
tree | d6512e969023ff87c62e8e4baa16f2f9787735f7 /src | |
parent | 4545eadd3e28be4b04537cc71a8697da4421d918 (diff) |
rhi: Take mip size into account for render target size
Also extend autotesting, both for rendering into a given mip level
and for rendering into a given cubemap face.
Change-Id: Ida94b71150477ceb50a3b5616d8b7be13174558b
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/rhi/qrhi.cpp | 7 | ||||
-rw-r--r-- | src/gui/rhi/qrhi_p.h | 3 | ||||
-rw-r--r-- | src/gui/rhi/qrhid3d11.cpp | 4 | ||||
-rw-r--r-- | src/gui/rhi/qrhigles2.cpp | 4 | ||||
-rw-r--r-- | src/gui/rhi/qrhimetal.mm | 5 | ||||
-rw-r--r-- | src/gui/rhi/qrhinull.cpp | 8 | ||||
-rw-r--r-- | src/gui/rhi/qrhivulkan.cpp | 4 |
7 files changed, 27 insertions, 8 deletions
diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 7d2af37e96..1eb26985bf 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -582,6 +582,13 @@ Q_LOGGING_CATEGORY(QRHI_LOG_INFO, "qt.rhi.general") practice this will be reported as unsupported with OpenGL ES 2.0 and OpenGL 2.x contexts, because GLSL 100 es and versions before 130 do not support this function. + + \value RenderToNonBaseMipLevel Indicates that specifying a mip level other + than 0 is supported when creating a QRhiTextureRenderTarget with a + QRhiTexture as its color attachment. When not supported, build() will fail + whenever the target mip level is not zero. In practice this feature will be + unsupported with OpenGL ES 2.0, while it will likely be supported everywhere + else. */ /*! diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index 5c4cf4a144..5ef415e96c 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -1446,7 +1446,8 @@ public: TriangleFanTopology, ReadBackNonUniformBuffer, ReadBackNonBaseMipLevel, - TexelFetch + TexelFetch, + RenderToNonBaseMipLevel }; enum BeginFrameFlag { diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 0665304a19..c3c40b4cc4 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -470,6 +470,8 @@ bool QRhiD3D11::isFeatureSupported(QRhi::Feature feature) const return true; case QRhi::TexelFetch: return true; + case QRhi::RenderToNonBaseMipLevel: + return true; default: Q_UNREACHABLE(); return false; @@ -3243,7 +3245,7 @@ bool QD3D11TextureRenderTarget::build() } ownsRtv[attIndex] = true; if (attIndex == 0) { - d.pixelSize = texD->pixelSize(); + d.pixelSize = rhiD->q->sizeForMipLevel(colorAtt.level(), texD->pixelSize()); d.sampleCount = int(texD->sampleDesc.Count); } } else if (rb) { diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 227dace90f..1e97d2ed0c 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -769,6 +769,8 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const return caps.nonBaseLevelFramebufferTexture; case QRhi::TexelFetch: return caps.texelFetch; + case QRhi::RenderToNonBaseMipLevel: + return caps.nonBaseLevelFramebufferTexture; default: Q_UNREACHABLE(); return false; @@ -3930,7 +3932,7 @@ bool QGles2TextureRenderTarget::build() rhiD->f->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + uint(attIndex), faceTargetBase + uint(colorAtt.layer()), texD->texture, colorAtt.level()); if (attIndex == 0) { - d.pixelSize = texD->pixelSize(); + d.pixelSize = rhiD->q->sizeForMipLevel(colorAtt.level(), texD->pixelSize()); d.sampleCount = 1; } } else if (renderBuffer) { diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 0806c8a052..f021e78097 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -564,6 +564,8 @@ bool QRhiMetal::isFeatureSupported(QRhi::Feature feature) const return true; case QRhi::TexelFetch: return true; + case QRhi::RenderToNonBaseMipLevel: + return true; default: Q_UNREACHABLE(); return false; @@ -2863,6 +2865,7 @@ QRhiRenderPassDescriptor *QMetalTextureRenderTarget::newCompatibleRenderPassDesc bool QMetalTextureRenderTarget::build() { + QRHI_RES_RHI(QRhiMetal); const bool hasColorAttachments = m_desc.cbeginColorAttachments() != m_desc.cendColorAttachments(); Q_ASSERT(hasColorAttachments || m_desc.depthTexture()); Q_ASSERT(!m_desc.depthStencilBuffer() || !m_desc.depthTexture()); @@ -2879,7 +2882,7 @@ bool QMetalTextureRenderTarget::build() if (texD) { dst = texD->d->tex; if (attIndex == 0) { - d->pixelSize = texD->pixelSize(); + d->pixelSize = rhiD->q->sizeForMipLevel(it->level(), texD->pixelSize()); d->sampleCount = texD->samples; } } else if (rbD) { diff --git a/src/gui/rhi/qrhinull.cpp b/src/gui/rhi/qrhinull.cpp index 8c07e09b32..7b18c9156b 100644 --- a/src/gui/rhi/qrhinull.cpp +++ b/src/gui/rhi/qrhinull.cpp @@ -740,11 +740,13 @@ QRhiRenderPassDescriptor *QNullTextureRenderTarget::newCompatibleRenderPassDescr bool QNullTextureRenderTarget::build() { + QRHI_RES_RHI(QRhiNull); d.rp = QRHI_RES(QNullRenderPassDescriptor, m_renderPassDesc); if (m_desc.cbeginColorAttachments() != m_desc.cendColorAttachments()) { - QRhiTexture *tex = m_desc.cbeginColorAttachments()->texture(); - QRhiRenderBuffer *rb = m_desc.cbeginColorAttachments()->renderBuffer(); - d.pixelSize = tex ? tex->pixelSize() : rb->pixelSize(); + const QRhiColorAttachment *colorAtt = m_desc.cbeginColorAttachments(); + QRhiTexture *tex = colorAtt->texture(); + QRhiRenderBuffer *rb = colorAtt->renderBuffer(); + d.pixelSize = tex ? rhiD->q->sizeForMipLevel(colorAtt->level(), tex->pixelSize()) : rb->pixelSize(); } else if (m_desc.depthStencilBuffer()) { d.pixelSize = m_desc.depthStencilBuffer()->pixelSize(); } else if (m_desc.depthTexture()) { diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 211ee195e5..49e634e248 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -4023,6 +4023,8 @@ bool QRhiVulkan::isFeatureSupported(QRhi::Feature feature) const return true; case QRhi::TexelFetch: return true; + case QRhi::RenderToNonBaseMipLevel: + return true; default: Q_UNREACHABLE(); return false; @@ -5911,7 +5913,7 @@ bool QVkTextureRenderTarget::build() } views.append(rtv[attIndex]); if (attIndex == 0) { - d.pixelSize = texD->pixelSize(); + d.pixelSize = rhiD->q->sizeForMipLevel(it->level(), texD->pixelSize()); d.sampleCount = texD->samples; } } else if (rbD) { |