summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVaL Doroshchuk <valentyn.doroshchuk@qt.io>2020-05-25 11:57:57 +0200
committerVaL Doroshchuk <valentyn.doroshchuk@qt.io>2020-05-25 14:21:03 +0200
commit0ffef9cb8da7682b42f595c683d7ef9cb22dabd7 (patch)
tree3bf51b51cc03cc246ed73d52a3a17a4f1c62bec5 /src
parentecca816ea1d2b98a500cc621ff1bd5e34771f7af (diff)
RHI: Introduce QRhiTexture::RG8
Change-Id: I58f35b2629bd6464f08cba66e852215472fcbe2a Fixes: QTBUG-84384 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/gui/rhi/qrhi.cpp5
-rw-r--r--src/gui/rhi/qrhi_p.h1
-rw-r--r--src/gui/rhi/qrhid3d11.cpp4
-rw-r--r--src/gui/rhi/qrhigles2.cpp17
-rw-r--r--src/gui/rhi/qrhimetal.mm6
-rw-r--r--src/gui/rhi/qrhivulkan.cpp8
6 files changed, 41 insertions, 0 deletions
diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp
index 64d1d5a017..798c5e1a8a 100644
--- a/src/gui/rhi/qrhi.cpp
+++ b/src/gui/rhi/qrhi.cpp
@@ -2213,6 +2213,8 @@ QRhiResource::Type QRhiRenderBuffer::resourceType() const
\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 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:
bpc = 1;
break;
+ case QRhiTexture::RG8:
+ bpc = 2;
+ break;
case QRhiTexture::R16:
bpc = 2;
break;
diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h
index 12a294e8c2..928d708624 100644
--- a/src/gui/rhi/qrhi_p.h
+++ b/src/gui/rhi/qrhi_p.h
@@ -738,6 +738,7 @@ public:
RGBA8,
BGRA8,
R8,
+ RG8,
R16,
RED_OR_ALPHA8,
diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp
index 97294669f7..d1d4745bc8 100644
--- a/src/gui/rhi/qrhid3d11.cpp
+++ b/src/gui/rhi/qrhid3d11.cpp
@@ -1138,6 +1138,8 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex
return srgb ? DXGI_FORMAT_B8G8R8A8_UNORM_SRGB : DXGI_FORMAT_B8G8R8A8_UNORM;
case QRhiTexture::R8:
return DXGI_FORMAT_R8_UNORM;
+ case QRhiTexture::RG8:
+ return DXGI_FORMAT_R8G8_UNORM;
case QRhiTexture::R16:
return DXGI_FORMAT_R16_UNORM;
case QRhiTexture::RED_OR_ALPHA8:
@@ -1218,6 +1220,8 @@ static inline QRhiTexture::Format colorTextureFormatFromDxgiFormat(DXGI_FORMAT f
return QRhiTexture::BGRA8;
case DXGI_FORMAT_R8_UNORM:
return QRhiTexture::R8;
+ case DXGI_FORMAT_R8G8_UNORM:
+ return QRhiTexture::RG8;
case DXGI_FORMAT_R16_UNORM:
return QRhiTexture::R16;
default: // this cannot assert, must warn and return unknown
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp
index 2e57ed1b80..25931bfb80 100644
--- a/src/gui/rhi/qrhigles2.cpp
+++ b/src/gui/rhi/qrhigles2.cpp
@@ -145,6 +145,14 @@ QT_BEGIN_NAMESPACE
#define GL_R8 0x8229
#endif
+#ifndef GL_RG8
+#define GL_RG8 0x822B
+#endif
+
+#ifndef GL_RG
+#define GL_RG 0x8227
+#endif
+
#ifndef GL_R16
#define GL_R16 0x822A
#endif
@@ -719,6 +727,12 @@ static inline void toGlTextureFormat(QRhiTexture::Format format, const QRhiGles2
*glformat = GL_RED;
*gltype = GL_UNSIGNED_BYTE;
break;
+ case QRhiTexture::RG8:
+ *glintformat = GL_RG8;
+ *glsizedintformat = *glintformat;
+ *glformat = GL_RG;
+ *gltype = GL_UNSIGNED_BYTE;
+ break;
case QRhiTexture::RED_OR_ALPHA8:
*glintformat = caps.coreProfile ? GL_R8 : GL_ALPHA;
*glsizedintformat = *glintformat;
@@ -787,6 +801,9 @@ bool QRhiGles2::isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture
case QRhiTexture::R8:
return caps.r8Format;
+ case QRhiTexture::RG8:
+ return caps.r8Format;
+
case QRhiTexture::R16:
return caps.r16Format;
diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm
index 5d94b481a6..33fe389892 100644
--- a/src/gui/rhi/qrhimetal.mm
+++ b/src/gui/rhi/qrhimetal.mm
@@ -2247,6 +2247,12 @@ static inline MTLPixelFormat toMetalTextureFormat(QRhiTexture::Format format, QR
#else
return srgb ? MTLPixelFormatR8Unorm_sRGB : MTLPixelFormatR8Unorm;
#endif
+ case QRhiTexture::RG8:
+#ifdef Q_OS_MACOS
+ return MTLPixelFormatRG8Unorm;
+#else
+ return srgb ? MTLPixelFormatRG8Unorm_sRGB : MTLPixelFormatRG8Unorm;
+#endif
case QRhiTexture::R16:
return MTLPixelFormatR16Unorm;
case QRhiTexture::RED_OR_ALPHA8:
diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp
index 1591829cac..164d596d74 100644
--- a/src/gui/rhi/qrhivulkan.cpp
+++ b/src/gui/rhi/qrhivulkan.cpp
@@ -791,6 +791,8 @@ static inline VkFormat toVkTextureFormat(QRhiTexture::Format format, QRhiTexture
return srgb ? VK_FORMAT_B8G8R8A8_SRGB : VK_FORMAT_B8G8R8A8_UNORM;
case QRhiTexture::R8:
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:
return VK_FORMAT_R16_UNORM;
case QRhiTexture::RED_OR_ALPHA8:
@@ -884,10 +886,16 @@ static inline QRhiTexture::Format colorTextureFormatFromVkFormat(VkFormat format
return QRhiTexture::BGRA8;
case VK_FORMAT_R8_UNORM:
return QRhiTexture::R8;
+ case VK_FORMAT_R8G8_UNORM:
+ return QRhiTexture::RG8;
case VK_FORMAT_R8_SRGB:
if (flags)
(*flags) |= QRhiTexture::sRGB;
return QRhiTexture::R8;
+ case VK_FORMAT_R8G8_SRGB:
+ if (flags)
+ (*flags) |= QRhiTexture::sRGB;
+ return QRhiTexture::RG8;
case VK_FORMAT_R16_UNORM:
return QRhiTexture::R16;
default: // this cannot assert, must warn and return unknown