rhi: Clean up 1D and 3D texture feature flags

Separate 1D mipmap generation support from rendering into an 1D texture.
Those are two independent features, so have a separate feature flag for
both instead of using just one.

This will then be symmetric with the 3D texture features, where now we
have a new flag to report support for generating mipmap for 3D textures.
(whereas 3D texture as a render target is already covered by
RenderTo3DTextureSlice)

Change-Id: Ie5e1f056a7d1c341d90cd7fc522877a3f2da3290
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2023-03-06 16:20:54 +01:00
parent 5bb745f62b
commit 9c84036d4f
8 changed files with 52 additions and 16 deletions

View File

@ -735,10 +735,10 @@ Q_LOGGING_CATEGORY(QRHI_LOG_INFO, "qt.rhi.general")
\value OneDimensionalTextures Indicates that 1D textures are supported.
In practice this feature will be unsupported on OpenGL ES.
\value OneDimensionalTextureMipmaps Indicates that 1D texture mipmaps and
1D texture render targets are supported. In practice this feature will be
unsupported on backends that do not report support for
\l{OneDimensionalTextures}, and Metal.
\value OneDimensionalTextureMipmaps Indicates that generating 1D texture
mipmaps are supported. In practice this feature will be unsupported on
backends that do not report support for
\l{OneDimensionalTextures}, Metal, and Direct 3D 12.
\value HalfAttributes Indicates that specifying input attributes with half
precision (16bit) floating point types for a shader pipeline is supported.
@ -750,6 +750,14 @@ Q_LOGGING_CATEGORY(QRHI_LOG_INFO, "qt.rhi.general")
half3 attributes as half4. To ensure cross platform compatibility, half3
inputs should be padded to 8 bytes.
\value RenderToOneDimensionalTexture Indicates that 1D texture render
targets are supported. In practice this feature will be unsupported on
backends that do not report support for
\l{OneDimensionalTextures}, and Metal.
\value ThreeDimensionalTextureMipmaps Indicates that generating 3D texture
mipmaps are supported. In practice this feature will be unsupported with
Direct 3D 12.
*/
/*!

View File

@ -1820,7 +1820,9 @@ public:
NonFillPolygonMode,
OneDimensionalTextures,
OneDimensionalTextureMipmaps,
HalfAttributes
HalfAttributes,
RenderToOneDimensionalTexture,
ThreeDimensionalTextureMipmaps
};
enum BeginFrameFlag {

View File

@ -530,6 +530,10 @@ bool QRhiD3D11::isFeatureSupported(QRhi::Feature feature) const
return true;
case QRhi::HalfAttributes:
return true;
case QRhi::RenderToOneDimensionalTexture:
return true;
case QRhi::ThreeDimensionalTextureMipmaps:
return true;
default:
Q_UNREACHABLE();
return false;

View File

@ -582,9 +582,13 @@ bool QRhiD3D12::isFeatureSupported(QRhi::Feature feature) const
case QRhi::OneDimensionalTextures:
return true;
case QRhi::OneDimensionalTextureMipmaps:
return false;
return false; // we generate mipmaps ourselves with compute and this is not implemented
case QRhi::HalfAttributes:
return true;
case QRhi::RenderToOneDimensionalTexture:
return true;
case QRhi::ThreeDimensionalTextureMipmaps:
return false; // we generate mipmaps ourselves with compute and this is not implemented
}
return false;
}

View File

@ -1323,6 +1323,10 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const
return caps.texture1D;
case QRhi::HalfAttributes:
return caps.halfAttributes;
case QRhi::RenderToOneDimensionalTexture:
return caps.texture1D;
case QRhi::ThreeDimensionalTextureMipmaps:
return caps.texture3D;
default:
Q_UNREACHABLE_RETURN(false);
}

View File

@ -796,6 +796,10 @@ bool QRhiMetal::isFeatureSupported(QRhi::Feature feature) const
return false;
case QRhi::HalfAttributes:
return true;
case QRhi::RenderToOneDimensionalTexture:
return false;
case QRhi::ThreeDimensionalTextureMipmaps:
return true;
default:
Q_UNREACHABLE();
return false;

View File

@ -4267,6 +4267,10 @@ bool QRhiVulkan::isFeatureSupported(QRhi::Feature feature) const
return true;
case QRhi::HalfAttributes:
return true;
case QRhi::RenderToOneDimensionalTexture:
return true;
case QRhi::ThreeDimensionalTextureMipmaps:
return true;
default:
Q_UNREACHABLE_RETURN(false);
}

View File

@ -410,7 +410,12 @@ void tst_QRhi::create()
QRhi::Tessellation,
QRhi::GeometryShader,
QRhi::TextureArrayRange,
QRhi::NonFillPolygonMode
QRhi::NonFillPolygonMode,
QRhi::OneDimensionalTextures,
QRhi::OneDimensionalTextureMipmaps,
QRhi::HalfAttributes,
QRhi::RenderToOneDimensionalTexture,
QRhi::ThreeDimensionalTextureMipmaps
};
for (size_t i = 0; i <sizeof(features) / sizeof(QRhi::Feature); ++i)
rhi->isFeatureSupported(features[i]);
@ -4758,7 +4763,7 @@ void tst_QRhi::threeDimTexture()
}
// mipmaps
{
if (rhi->isFeatureSupported(QRhi::ThreeDimensionalTextureMipmaps)) {
QScopedPointer<QRhiTexture> texture(rhi->newTexture(QRhiTexture::RGBA8, WIDTH, HEIGHT, DEPTH,
1, QRhiTexture::MipMapped | QRhiTexture::UsedWithGenerateMips));
QVERIFY(texture->create());
@ -4801,11 +4806,10 @@ void tst_QRhi::threeDimTexture()
// Some software-based OpenGL implementations, such as Mesa llvmpipe builds that are
// used both in Qt CI and are shipped with the official Qt binaries also seem to have
// problems with this.
if (impl != QRhi::Null && impl != QRhi::OpenGLES2) {
// temporarily skip for D3D12 as well since 3D texture mipmap generation is not implemented there
if (impl != QRhi::D3D12)
QVERIFY(imageRGBAEquals(result, referenceImage, 2));
}
if (impl != QRhi::Null && impl != QRhi::OpenGLES2)
QVERIFY(imageRGBAEquals(result, referenceImage, 2));
} else {
qDebug("Skipping 3D texture mipmap generation test because it is reported as unsupported");
}
// render target (one slice)
@ -5175,9 +5179,11 @@ void tst_QRhi::oneDimTexture()
}
// mipmaps and 1D render target
if (!rhi->isFeatureSupported(QRhi::OneDimensionalTextureMipmaps))
QSKIP("Skipping testing 1D texture mipmaps and 1D render target because they are reported "
"as unsupported");
if (!rhi->isFeatureSupported(QRhi::OneDimensionalTextureMipmaps)
|| !rhi->isFeatureSupported(QRhi::RenderToOneDimensionalTexture))
{
QSKIP("Skipping testing 1D texture mipmaps and 1D render target because they are reported as unsupported");
}
{
QScopedPointer<QRhiTexture> texture(