From 85a1663eb15cd85f91fe1f6dd924588d9cc7c2a8 Mon Sep 17 00:00:00 2001 From: Ben Fletcher Date: Sun, 30 Oct 2022 12:19:38 -0700 Subject: RHI: Add support for 1D textures Support for 1D textures on Vulkan, OpenGL, Metal, and D3D. Change-Id: Ie74ec103da9cfcbf83fa78588cf8cfc1bd6e104f Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhimetal.mm | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/gui/rhi/qrhimetal.mm') diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 61b12ad46d..45bb1296b0 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -772,6 +772,10 @@ bool QRhiMetal::isFeatureSupported(QRhi::Feature feature) const return false; case QRhi::NonFillPolygonMode: return true; + case QRhi::OneDimensionalTextures: + return true; + case QRhi::OneDimensionalTextureMipmaps: + return false; default: Q_UNREACHABLE(); return false; @@ -3414,11 +3418,14 @@ bool QMetalTexture::prepareCreate(QSize *adjustedSize) if (d->tex) destroy(); - const QSize size = m_pixelSize.isEmpty() ? QSize(1, 1) : m_pixelSize; const bool isCube = m_flags.testFlag(CubeMap); const bool is3D = m_flags.testFlag(ThreeDimensional); const bool isArray = m_flags.testFlag(TextureArray); const bool hasMipMaps = m_flags.testFlag(MipMapped); + const bool is1D = m_flags.testFlag(OneDimensional); + + const QSize size = is1D ? QSize(qMax(1, m_pixelSize.width()), 1) + : (m_pixelSize.isEmpty() ? QSize(1, 1) : m_pixelSize); QRHI_RES_RHI(QRhiMetal); d->format = toMetalTextureFormat(m_format, m_flags, rhiD); @@ -3446,6 +3453,14 @@ bool QMetalTexture::prepareCreate(QSize *adjustedSize) qWarning("Texture cannot be both array and 3D"); return false; } + if (is1D && is3D) { + qWarning("Texture cannot be both 1D and 3D"); + return false; + } + if (is1D && isCube) { + qWarning("Texture cannot be both 1D and cube"); + return false; + } m_depth = qMax(1, m_depth); if (m_depth > 1 && !is3D) { qWarning("Texture cannot have a depth of %d when it is not 3D", m_depth); @@ -3478,10 +3493,13 @@ bool QMetalTexture::create() const bool isCube = m_flags.testFlag(CubeMap); const bool is3D = m_flags.testFlag(ThreeDimensional); const bool isArray = m_flags.testFlag(TextureArray); + const bool is1D = m_flags.testFlag(OneDimensional); if (isCube) { desc.textureType = MTLTextureTypeCube; } else if (is3D) { desc.textureType = MTLTextureType3D; + } else if (is1D) { + desc.textureType = isArray ? MTLTextureType1DArray : MTLTextureType1D; } else if (isArray) { #ifdef Q_OS_IOS if (samples > 1) { -- cgit v1.2.3