Commit e03929b8 authored by Laszlo Agocs's avatar Laszlo Agocs

Add the rgba float tex formats

These may be used by Q3DS for HDR images (IBL).
parent 28b47897
......@@ -1811,6 +1811,12 @@ QRhiRenderBuffer::QRhiRenderBuffer(QRhiImplementation *rhi, Type type_, const QS
Regardless of the return value, calling release() is always safe.
*/
/*!
\fn QRhiTexture::Format QRhiRenderBuffer::backingFormat() const
\internal
*/
/*!
\class QRhiTexture
\inmodule QtRhi
......@@ -1873,6 +1879,10 @@ QRhiRenderBuffer::QRhiRenderBuffer(QRhiImplementation *rhi, Type type_, const QS
\value RED_OR_ALPHA8 Either same as R8, or is a similar format with the component swizzled to alpha,
depending on \l{QRhi::RedOrAlpha8IsRed}{RedOrAlpha8IsRed}.
\value RGBA16F Four components, 16-bit float per component.
\value RGBA32F Four components, 32-bit float per component.
\value D16 16-bit depth (normalized unsigned integer)
\value D32 32-bit depth (32-bit float)
......@@ -3222,6 +3232,16 @@ void QRhiImplementation::textureFormatInfo(QRhiTexture::Format format, const QSi
case QRhiTexture::R16:
bpc = 2;
break;
case QRhiTexture::RED_OR_ALPHA8:
bpc = 1;
break;
case QRhiTexture::RGBA16F:
bpc = 8;
break;
case QRhiTexture::RGBA32F:
bpc = 16;
break;
case QRhiTexture::D16:
bpc = 2;
......
......@@ -643,6 +643,9 @@ public:
R16,
RED_OR_ALPHA8,
RGBA16F,
RGBA32F,
D16,
D32,
......
......@@ -868,6 +868,11 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex
case QRhiTexture::RED_OR_ALPHA8:
return DXGI_FORMAT_R8_UNORM;
case QRhiTexture::RGBA16F:
return DXGI_FORMAT_R16G16B16A16_FLOAT;
case QRhiTexture::RGBA32F:
return DXGI_FORMAT_R32G32B32A32_FLOAT;
case QRhiTexture::D16:
return DXGI_FORMAT_R16_TYPELESS;
case QRhiTexture::D32:
......
......@@ -172,6 +172,14 @@ QT_BEGIN_NAMESPACE
#define GL_RED 0x1903
#endif
#ifndef GL_RGBA32F
#define GL_RGBA32F 0x8814
#endif
#ifndef GL_RGBA16F
#define GL_RGBA16F 0x881A
#endif
#ifndef GL_PRIMITIVE_RESTART_FIXED_INDEX
#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69
#endif
......@@ -310,6 +318,8 @@ bool QRhiGles2::create(QRhi::Flags flags)
caps.r8Format = f->hasOpenGLFeature(QOpenGLFunctions::TextureRGFormats);
caps.r16Format = f->hasOpenGLExtension(QOpenGLExtensions::Sized16Formats);
caps.floatFormats = actualFormat.version() >= qMakePair(3, 0);
caps.srgbCapableDefaultFramebuffer = f->hasOpenGLExtension(QOpenGLExtensions::SRGBFrameBuffer);
nativeHandlesStruct.context = ctx;
......@@ -468,6 +478,11 @@ bool QRhiGles2::isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture
case QRhiTexture::R16:
return caps.r16Format;
case QRhiTexture::RGBA16F:
Q_FALLTHROUGH();
case QRhiTexture::RGBA32F:
return caps.floatFormats;
default:
break;
}
......@@ -2045,6 +2060,14 @@ bool QGles2Texture::prepareBuild(QSize *adjustedSize)
glintformat = GL_ALPHA;
glformat = GL_ALPHA;
break;
case QRhiTexture::RGBA16F:
glintformat = GL_RGBA16F;
glformat = GL_RGBA;
break;
case QRhiTexture::RGBA32F:
glintformat = GL_RGBA32F;
glformat = GL_RGBA;
break;
default:
Q_UNREACHABLE();
glintformat = GL_RGBA;
......
......@@ -557,6 +557,7 @@ public:
bgraInternalFormat(false),
r8Format(false),
r16Format(false),
floatFormats(false),
srgbCapableDefaultFramebuffer(false)
{ }
int maxTextureSize;
......@@ -570,6 +571,7 @@ public:
uint bgraInternalFormat : 1;
uint r8Format : 1;
uint r16Format : 1;
uint floatFormats : 1;
uint srgbCapableDefaultFramebuffer : 1;
} caps;
bool inFrame = false;
......
......@@ -1844,6 +1844,11 @@ static inline MTLPixelFormat toMetalTextureFormat(QRhiTexture::Format format, QR
case QRhiTexture::RED_OR_ALPHA8:
return MTLPixelFormatR8Unorm;
case QRhiTexture::RGBA16F:
return MTLPixelFormatRGBA16Float;
case QRhiTexture::RGBA32F:
return MTLPixelFormatRGBA32Float;
case QRhiTexture::D16:
return MTLPixelFormatDepth16Unorm;
case QRhiTexture::D32:
......
......@@ -644,6 +644,11 @@ static inline VkFormat toVkTextureFormat(QRhiTexture::Format format, QRhiTexture
case QRhiTexture::RED_OR_ALPHA8:
return VK_FORMAT_R8_UNORM;
case QRhiTexture::RGBA16F:
return VK_FORMAT_R16G16B16A16_SFLOAT;
case QRhiTexture::RGBA32F:
return VK_FORMAT_R32G32B32A32_SFLOAT;
case QRhiTexture::D16:
return VK_FORMAT_D16_UNORM;
case QRhiTexture::D32:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment