RHI: Introduce QRhiTexture::RG8
Change-Id: I58f35b2629bd6464f08cba66e852215472fcbe2a Fixes: QTBUG-84384 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
ecca816ea1
commit
0ffef9cb8d
@ -2213,6 +2213,8 @@ QRhiResource::Type QRhiRenderBuffer::resourceType() const
|
|||||||
|
|
||||||
\value R8 One component, unsigned normalized 8 bit.
|
\value R8 One component, unsigned normalized 8 bit.
|
||||||
|
|
||||||
|
\value RG8 Two components, unsigned normalized 8 bit.
|
||||||
|
|
||||||
\value R16 One component, unsigned normalized 16 bit.
|
\value R16 One component, unsigned normalized 16 bit.
|
||||||
|
|
||||||
\value RED_OR_ALPHA8 Either same as R8, or is a similar format with the component swizzled to alpha,
|
\value RED_OR_ALPHA8 Either same as R8, or is a similar format with the component swizzled to alpha,
|
||||||
@ -4089,6 +4091,9 @@ void QRhiImplementation::textureFormatInfo(QRhiTexture::Format format, const QSi
|
|||||||
case QRhiTexture::R8:
|
case QRhiTexture::R8:
|
||||||
bpc = 1;
|
bpc = 1;
|
||||||
break;
|
break;
|
||||||
|
case QRhiTexture::RG8:
|
||||||
|
bpc = 2;
|
||||||
|
break;
|
||||||
case QRhiTexture::R16:
|
case QRhiTexture::R16:
|
||||||
bpc = 2;
|
bpc = 2;
|
||||||
break;
|
break;
|
||||||
|
@ -738,6 +738,7 @@ public:
|
|||||||
RGBA8,
|
RGBA8,
|
||||||
BGRA8,
|
BGRA8,
|
||||||
R8,
|
R8,
|
||||||
|
RG8,
|
||||||
R16,
|
R16,
|
||||||
RED_OR_ALPHA8,
|
RED_OR_ALPHA8,
|
||||||
|
|
||||||
|
@ -1138,6 +1138,8 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex
|
|||||||
return srgb ? DXGI_FORMAT_B8G8R8A8_UNORM_SRGB : DXGI_FORMAT_B8G8R8A8_UNORM;
|
return srgb ? DXGI_FORMAT_B8G8R8A8_UNORM_SRGB : DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||||
case QRhiTexture::R8:
|
case QRhiTexture::R8:
|
||||||
return DXGI_FORMAT_R8_UNORM;
|
return DXGI_FORMAT_R8_UNORM;
|
||||||
|
case QRhiTexture::RG8:
|
||||||
|
return DXGI_FORMAT_R8G8_UNORM;
|
||||||
case QRhiTexture::R16:
|
case QRhiTexture::R16:
|
||||||
return DXGI_FORMAT_R16_UNORM;
|
return DXGI_FORMAT_R16_UNORM;
|
||||||
case QRhiTexture::RED_OR_ALPHA8:
|
case QRhiTexture::RED_OR_ALPHA8:
|
||||||
@ -1218,6 +1220,8 @@ static inline QRhiTexture::Format colorTextureFormatFromDxgiFormat(DXGI_FORMAT f
|
|||||||
return QRhiTexture::BGRA8;
|
return QRhiTexture::BGRA8;
|
||||||
case DXGI_FORMAT_R8_UNORM:
|
case DXGI_FORMAT_R8_UNORM:
|
||||||
return QRhiTexture::R8;
|
return QRhiTexture::R8;
|
||||||
|
case DXGI_FORMAT_R8G8_UNORM:
|
||||||
|
return QRhiTexture::RG8;
|
||||||
case DXGI_FORMAT_R16_UNORM:
|
case DXGI_FORMAT_R16_UNORM:
|
||||||
return QRhiTexture::R16;
|
return QRhiTexture::R16;
|
||||||
default: // this cannot assert, must warn and return unknown
|
default: // this cannot assert, must warn and return unknown
|
||||||
|
@ -145,6 +145,14 @@ QT_BEGIN_NAMESPACE
|
|||||||
#define GL_R8 0x8229
|
#define GL_R8 0x8229
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef GL_RG8
|
||||||
|
#define GL_RG8 0x822B
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GL_RG
|
||||||
|
#define GL_RG 0x8227
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef GL_R16
|
#ifndef GL_R16
|
||||||
#define GL_R16 0x822A
|
#define GL_R16 0x822A
|
||||||
#endif
|
#endif
|
||||||
@ -719,6 +727,12 @@ static inline void toGlTextureFormat(QRhiTexture::Format format, const QRhiGles2
|
|||||||
*glformat = GL_RED;
|
*glformat = GL_RED;
|
||||||
*gltype = GL_UNSIGNED_BYTE;
|
*gltype = GL_UNSIGNED_BYTE;
|
||||||
break;
|
break;
|
||||||
|
case QRhiTexture::RG8:
|
||||||
|
*glintformat = GL_RG8;
|
||||||
|
*glsizedintformat = *glintformat;
|
||||||
|
*glformat = GL_RG;
|
||||||
|
*gltype = GL_UNSIGNED_BYTE;
|
||||||
|
break;
|
||||||
case QRhiTexture::RED_OR_ALPHA8:
|
case QRhiTexture::RED_OR_ALPHA8:
|
||||||
*glintformat = caps.coreProfile ? GL_R8 : GL_ALPHA;
|
*glintformat = caps.coreProfile ? GL_R8 : GL_ALPHA;
|
||||||
*glsizedintformat = *glintformat;
|
*glsizedintformat = *glintformat;
|
||||||
@ -787,6 +801,9 @@ bool QRhiGles2::isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture
|
|||||||
case QRhiTexture::R8:
|
case QRhiTexture::R8:
|
||||||
return caps.r8Format;
|
return caps.r8Format;
|
||||||
|
|
||||||
|
case QRhiTexture::RG8:
|
||||||
|
return caps.r8Format;
|
||||||
|
|
||||||
case QRhiTexture::R16:
|
case QRhiTexture::R16:
|
||||||
return caps.r16Format;
|
return caps.r16Format;
|
||||||
|
|
||||||
|
@ -2246,6 +2246,12 @@ static inline MTLPixelFormat toMetalTextureFormat(QRhiTexture::Format format, QR
|
|||||||
return MTLPixelFormatR8Unorm;
|
return MTLPixelFormatR8Unorm;
|
||||||
#else
|
#else
|
||||||
return srgb ? MTLPixelFormatR8Unorm_sRGB : MTLPixelFormatR8Unorm;
|
return srgb ? MTLPixelFormatR8Unorm_sRGB : MTLPixelFormatR8Unorm;
|
||||||
|
#endif
|
||||||
|
case QRhiTexture::RG8:
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
return MTLPixelFormatRG8Unorm;
|
||||||
|
#else
|
||||||
|
return srgb ? MTLPixelFormatRG8Unorm_sRGB : MTLPixelFormatRG8Unorm;
|
||||||
#endif
|
#endif
|
||||||
case QRhiTexture::R16:
|
case QRhiTexture::R16:
|
||||||
return MTLPixelFormatR16Unorm;
|
return MTLPixelFormatR16Unorm;
|
||||||
|
@ -791,6 +791,8 @@ static inline VkFormat toVkTextureFormat(QRhiTexture::Format format, QRhiTexture
|
|||||||
return srgb ? VK_FORMAT_B8G8R8A8_SRGB : VK_FORMAT_B8G8R8A8_UNORM;
|
return srgb ? VK_FORMAT_B8G8R8A8_SRGB : VK_FORMAT_B8G8R8A8_UNORM;
|
||||||
case QRhiTexture::R8:
|
case QRhiTexture::R8:
|
||||||
return srgb ? VK_FORMAT_R8_SRGB : VK_FORMAT_R8_UNORM;
|
return srgb ? VK_FORMAT_R8_SRGB : VK_FORMAT_R8_UNORM;
|
||||||
|
case QRhiTexture::RG8:
|
||||||
|
return srgb ? VK_FORMAT_R8G8_SRGB : VK_FORMAT_R8G8_UNORM;
|
||||||
case QRhiTexture::R16:
|
case QRhiTexture::R16:
|
||||||
return VK_FORMAT_R16_UNORM;
|
return VK_FORMAT_R16_UNORM;
|
||||||
case QRhiTexture::RED_OR_ALPHA8:
|
case QRhiTexture::RED_OR_ALPHA8:
|
||||||
@ -884,10 +886,16 @@ static inline QRhiTexture::Format colorTextureFormatFromVkFormat(VkFormat format
|
|||||||
return QRhiTexture::BGRA8;
|
return QRhiTexture::BGRA8;
|
||||||
case VK_FORMAT_R8_UNORM:
|
case VK_FORMAT_R8_UNORM:
|
||||||
return QRhiTexture::R8;
|
return QRhiTexture::R8;
|
||||||
|
case VK_FORMAT_R8G8_UNORM:
|
||||||
|
return QRhiTexture::RG8;
|
||||||
case VK_FORMAT_R8_SRGB:
|
case VK_FORMAT_R8_SRGB:
|
||||||
if (flags)
|
if (flags)
|
||||||
(*flags) |= QRhiTexture::sRGB;
|
(*flags) |= QRhiTexture::sRGB;
|
||||||
return QRhiTexture::R8;
|
return QRhiTexture::R8;
|
||||||
|
case VK_FORMAT_R8G8_SRGB:
|
||||||
|
if (flags)
|
||||||
|
(*flags) |= QRhiTexture::sRGB;
|
||||||
|
return QRhiTexture::RG8;
|
||||||
case VK_FORMAT_R16_UNORM:
|
case VK_FORMAT_R16_UNORM:
|
||||||
return QRhiTexture::R16;
|
return QRhiTexture::R16;
|
||||||
default: // this cannot assert, must warn and return unknown
|
default: // this cannot assert, must warn and return unknown
|
||||||
|
Loading…
Reference in New Issue
Block a user