diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 642f1cf9376..78ff8ed2725 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -4507,6 +4507,9 @@ bool QRhiRenderBuffer::createFrom(NativeRenderBuffer src) \value ASTC_12x12 \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: bpc = 1; break; + case QRhiTexture::R32UI: + bpc = 4; + break; + case QRhiTexture::RG32UI: + bpc = 8; + break; + case QRhiTexture::RGBA32UI: + bpc = 16; + break; default: Q_UNREACHABLE(); diff --git a/src/gui/rhi/qrhi.h b/src/gui/rhi/qrhi.h index 3f6fe5eb3a0..28607b53e4b 100644 --- a/src/gui/rhi/qrhi.h +++ b/src/gui/rhi/qrhi.h @@ -938,6 +938,9 @@ public: RGB10A2, R8UI, + R32UI, + RG32UI, + RGBA32UI, D16, D24, diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 4518e5bf31b..1e211d98265 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -1604,6 +1604,13 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex case QRhiTexture::RGB10A2: 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: return DXGI_FORMAT_R16_TYPELESS; case QRhiTexture::D24: diff --git a/src/gui/rhi/qrhid3d12.cpp b/src/gui/rhi/qrhid3d12.cpp index 570bb0efb0d..eb7318f5b83 100644 --- a/src/gui/rhi/qrhid3d12.cpp +++ b/src/gui/rhi/qrhid3d12.cpp @@ -4034,6 +4034,13 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex case QRhiTexture::RGB10A2: 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: return DXGI_FORMAT_R16_TYPELESS; case QRhiTexture::D24: diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 50a446fe588..53cad2df9d6 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -166,6 +166,18 @@ QT_BEGIN_NAMESPACE #define GL_R8UI 0x8232 #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 #define GL_RG8 0x822B #endif @@ -900,6 +912,12 @@ bool QRhiGles2::create(QRhi::Flags flags) caps.bgraExternalFormat = f->hasOpenGLExtension(QOpenGLExtensions::BGRATextureFormat); caps.bgraInternalFormat = caps.bgraExternalFormat && caps.gles; 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.floatFormats = 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; *gltype = GL_UNSIGNED_INT_2_10_10_10_REV; 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: *glintformat = GL_DEPTH_COMPONENT16; *glsizedintformat = *glintformat; @@ -1391,6 +1427,11 @@ bool QRhiGles2::isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture case QRhiTexture::R8UI: return caps.r8Format; + case QRhiTexture::R32UI: + case QRhiTexture::RG32UI: + case QRhiTexture::RGBA32UI: + return caps.r32uiFormat; + case QRhiTexture::RG8: return caps.r8Format; diff --git a/src/gui/rhi/qrhigles2_p.h b/src/gui/rhi/qrhigles2_p.h index f183bc5ae60..8341d6da08c 100644 --- a/src/gui/rhi/qrhigles2_p.h +++ b/src/gui/rhi/qrhigles2_p.h @@ -993,6 +993,7 @@ public: bgraInternalFormat(false), r8Format(false), r16Format(false), + r32uiFormat(false), floatFormats(false), rgb10Formats(false), depthTexture(false), @@ -1053,6 +1054,7 @@ public: uint bgraInternalFormat : 1; uint r8Format : 1; uint r16Format : 1; + uint r32uiFormat : 1; uint floatFormats : 1; uint rgb10Formats : 1; uint depthTexture : 1; diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index ca683ce37c4..fc69b6eb4e8 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -3492,6 +3492,13 @@ static inline MTLPixelFormat toMetalTextureFormat(QRhiTexture::Format format, QR case QRhiTexture::RGB10A2: return MTLPixelFormatRGB10A2Unorm; + case QRhiTexture::R32UI: + return MTLPixelFormatR32Uint; + case QRhiTexture::RG32UI: + return MTLPixelFormatRG32Uint; + case QRhiTexture::RGBA32UI: + return MTLPixelFormatRGBA32Uint; + #ifdef Q_OS_MACOS case QRhiTexture::D16: return MTLPixelFormatDepth16Unorm; diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 4ce6a80f325..659506c12d0 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -1191,6 +1191,12 @@ static inline VkFormat toVkTextureFormat(QRhiTexture::Format format, QRhiTexture case QRhiTexture::R8UI: 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: return VK_FORMAT_D16_UNORM;