Add R32UI, RG32UI, RGBA32UI texture format

Order indepenedent transparency uses 32-bit integer image formats.

Task-number: QTBUG-125121
Change-Id: I54a43c3c754b59bb3cab7107fdc6adf8a2d27b8a
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Antti Määttä 2024-06-03 13:44:19 +03:00
parent 5921ca95bd
commit 2c035073d0
8 changed files with 85 additions and 0 deletions

View File

@ -4507,6 +4507,9 @@ bool QRhiRenderBuffer::createFrom(NativeRenderBuffer src)
\value ASTC_12x12 \value ASTC_12x12
\value R8UI One component, unsigned 8 bit. \value R8UI One component, unsigned 8 bit.
\value R32UI One component, unsigned 32 bit.
\value RG32UI Two component, unsigned 32 bit.
\value RGBA32UI Four component, unsigned 32 bit.
*/ */
/*! /*!
@ -8559,6 +8562,15 @@ void QRhiImplementation::textureFormatInfo(QRhiTexture::Format format, const QSi
case QRhiTexture::R8UI: case QRhiTexture::R8UI:
bpc = 1; bpc = 1;
break; break;
case QRhiTexture::R32UI:
bpc = 4;
break;
case QRhiTexture::RG32UI:
bpc = 8;
break;
case QRhiTexture::RGBA32UI:
bpc = 16;
break;
default: default:
Q_UNREACHABLE(); Q_UNREACHABLE();

View File

@ -938,6 +938,9 @@ public:
RGB10A2, RGB10A2,
R8UI, R8UI,
R32UI,
RG32UI,
RGBA32UI,
D16, D16,
D24, D24,

View File

@ -1604,6 +1604,13 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex
case QRhiTexture::RGB10A2: case QRhiTexture::RGB10A2:
return DXGI_FORMAT_R10G10B10A2_UNORM; return DXGI_FORMAT_R10G10B10A2_UNORM;
case QRhiTexture::R32UI:
return DXGI_FORMAT_R32_UINT;
case QRhiTexture::RG32UI:
return DXGI_FORMAT_R32G32_UINT;
case QRhiTexture::RGBA32UI:
return DXGI_FORMAT_R32G32B32A32_UINT;
case QRhiTexture::D16: case QRhiTexture::D16:
return DXGI_FORMAT_R16_TYPELESS; return DXGI_FORMAT_R16_TYPELESS;
case QRhiTexture::D24: case QRhiTexture::D24:

View File

@ -4034,6 +4034,13 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex
case QRhiTexture::RGB10A2: case QRhiTexture::RGB10A2:
return DXGI_FORMAT_R10G10B10A2_UNORM; return DXGI_FORMAT_R10G10B10A2_UNORM;
case QRhiTexture::R32UI:
return DXGI_FORMAT_R32_UINT;
case QRhiTexture::RG32UI:
return DXGI_FORMAT_R32G32_UINT;
case QRhiTexture::RGBA32UI:
return DXGI_FORMAT_R32G32B32A32_UINT;
case QRhiTexture::D16: case QRhiTexture::D16:
return DXGI_FORMAT_R16_TYPELESS; return DXGI_FORMAT_R16_TYPELESS;
case QRhiTexture::D24: case QRhiTexture::D24:

View File

@ -166,6 +166,18 @@ QT_BEGIN_NAMESPACE
#define GL_R8UI 0x8232 #define GL_R8UI 0x8232
#endif #endif
#ifndef GL_R32UI
#define GL_R32UI 0x8236
#endif
#ifndef GL_RG32UI
#define GL_RG32UI 0x823C
#endif
#ifndef GL_RGBA32UI
#define GL_RGBA32UI 0x8D70
#endif
#ifndef GL_RG8 #ifndef GL_RG8
#define GL_RG8 0x822B #define GL_RG8 0x822B
#endif #endif
@ -900,6 +912,12 @@ bool QRhiGles2::create(QRhi::Flags flags)
caps.bgraExternalFormat = f->hasOpenGLExtension(QOpenGLExtensions::BGRATextureFormat); caps.bgraExternalFormat = f->hasOpenGLExtension(QOpenGLExtensions::BGRATextureFormat);
caps.bgraInternalFormat = caps.bgraExternalFormat && caps.gles; caps.bgraInternalFormat = caps.bgraExternalFormat && caps.gles;
caps.r8Format = f->hasOpenGLFeature(QOpenGLFunctions::TextureRGFormats); caps.r8Format = f->hasOpenGLFeature(QOpenGLFunctions::TextureRGFormats);
if (caps.gles)
caps.r32uiFormat = (caps.ctxMajor > 3 || (caps.ctxMajor == 3 && caps.ctxMinor >= 1)) && caps.r8Format; // ES 3.1
else
caps.r32uiFormat = true;
caps.r16Format = f->hasOpenGLExtension(QOpenGLExtensions::Sized16Formats); caps.r16Format = f->hasOpenGLExtension(QOpenGLExtensions::Sized16Formats);
caps.floatFormats = caps.ctxMajor >= 3; // 3.0 or ES 3.0 caps.floatFormats = caps.ctxMajor >= 3; // 3.0 or ES 3.0
caps.rgb10Formats = caps.ctxMajor >= 3; // 3.0 or ES 3.0 caps.rgb10Formats = caps.ctxMajor >= 3; // 3.0 or ES 3.0
@ -1327,6 +1345,24 @@ static inline void toGlTextureFormat(QRhiTexture::Format format, const QRhiGles2
*glformat = GL_RGBA; *glformat = GL_RGBA;
*gltype = GL_UNSIGNED_INT_2_10_10_10_REV; *gltype = GL_UNSIGNED_INT_2_10_10_10_REV;
break; break;
case QRhiTexture::R32UI:
*glintformat = GL_R32UI;
*glsizedintformat = *glintformat;
*glformat = GL_RGBA;
*gltype = GL_UNSIGNED_INT;
break;
case QRhiTexture::RG32UI:
*glintformat = GL_RG32UI;
*glsizedintformat = *glintformat;
*glformat = GL_RGBA;
*gltype = GL_UNSIGNED_INT;
break;
case QRhiTexture::RGBA32UI:
*glintformat = GL_RGBA32UI;
*glsizedintformat = *glintformat;
*glformat = GL_RGBA;
*gltype = GL_UNSIGNED_INT;
break;
case QRhiTexture::D16: case QRhiTexture::D16:
*glintformat = GL_DEPTH_COMPONENT16; *glintformat = GL_DEPTH_COMPONENT16;
*glsizedintformat = *glintformat; *glsizedintformat = *glintformat;
@ -1391,6 +1427,11 @@ bool QRhiGles2::isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture
case QRhiTexture::R8UI: case QRhiTexture::R8UI:
return caps.r8Format; return caps.r8Format;
case QRhiTexture::R32UI:
case QRhiTexture::RG32UI:
case QRhiTexture::RGBA32UI:
return caps.r32uiFormat;
case QRhiTexture::RG8: case QRhiTexture::RG8:
return caps.r8Format; return caps.r8Format;

View File

@ -993,6 +993,7 @@ public:
bgraInternalFormat(false), bgraInternalFormat(false),
r8Format(false), r8Format(false),
r16Format(false), r16Format(false),
r32uiFormat(false),
floatFormats(false), floatFormats(false),
rgb10Formats(false), rgb10Formats(false),
depthTexture(false), depthTexture(false),
@ -1053,6 +1054,7 @@ public:
uint bgraInternalFormat : 1; uint bgraInternalFormat : 1;
uint r8Format : 1; uint r8Format : 1;
uint r16Format : 1; uint r16Format : 1;
uint r32uiFormat : 1;
uint floatFormats : 1; uint floatFormats : 1;
uint rgb10Formats : 1; uint rgb10Formats : 1;
uint depthTexture : 1; uint depthTexture : 1;

View File

@ -3492,6 +3492,13 @@ static inline MTLPixelFormat toMetalTextureFormat(QRhiTexture::Format format, QR
case QRhiTexture::RGB10A2: case QRhiTexture::RGB10A2:
return MTLPixelFormatRGB10A2Unorm; return MTLPixelFormatRGB10A2Unorm;
case QRhiTexture::R32UI:
return MTLPixelFormatR32Uint;
case QRhiTexture::RG32UI:
return MTLPixelFormatRG32Uint;
case QRhiTexture::RGBA32UI:
return MTLPixelFormatRGBA32Uint;
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
case QRhiTexture::D16: case QRhiTexture::D16:
return MTLPixelFormatDepth16Unorm; return MTLPixelFormatDepth16Unorm;

View File

@ -1191,6 +1191,12 @@ static inline VkFormat toVkTextureFormat(QRhiTexture::Format format, QRhiTexture
case QRhiTexture::R8UI: case QRhiTexture::R8UI:
return VK_FORMAT_R8_UINT; return VK_FORMAT_R8_UINT;
case QRhiTexture::R32UI:
return VK_FORMAT_R32_UINT;
case QRhiTexture::RG32UI:
return VK_FORMAT_R32G32_UINT;
case QRhiTexture::RGBA32UI:
return VK_FORMAT_R32G32B32A32_UINT;
case QRhiTexture::D16: case QRhiTexture::D16:
return VK_FORMAT_D16_UNORM; return VK_FORMAT_D16_UNORM;