Skip to contentSkip to conversation

drm/fourcc: Add additional float formats

PATCH Applied Rob Clark 2 participants 4 messages Jun 25, 2025 – Jun 26, 2025

Subsystems (3)
lore
Share & tools
lore

Rob Clark

author
#0 lore raw

v2 cover drm/fourcc: Add additional float formats

GPUs support 1/2/3/4 component f16 and f32 formats. Define the missing fourcc's needed to import/export these formats, and/or create with gbm.

Rob Clark (2):
drm/fourcc: Add missing half-float formats
drm/fourcc: Add 32b float formats

 include/uapi/drm/drm_fourcc.h | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
Signature · 1 line
2.49.0
author
#1 lore raw

PATCH v2 1/2 drm/fourcc: Add missing half-float formats

Not something that is likely to be scanned out, but GPUs usually support half-float formats with 1, 2, or possibly 3 components, and it is useful to be able to import/export them with a valid fourcc, and/or use gbm to create them.

These correspond to PIPE_FORMAT_{R16,R16G16,R16G16B16}_FLOAT in mesa.

---
 include/uapi/drm/drm_fourcc.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
include/uapi/drm/drm_fourcc.h +5 -1
index e41a3cec6a9e..3560ca1ffb8b 100644
@@ -218,7 +218,7 @@ extern "C" {
 #define DRM_FORMAT_ABGR16161616	fourcc_code('A', 'B', '4', '8') /* [63:0] A:B:G:R 16:16:16:16 little endian */
 
 /*
- * Floating point 64bpp RGB
+ * Half-Floating point - 16b/component
  * IEEE 754-2008 binary16 half-precision float
  * [15:0] sign:exponent:mantissa 1:5:10
  */
@@ -228,6 +228,10 @@ extern "C" {
 #define DRM_FORMAT_ARGB16161616F fourcc_code('A', 'R', '4', 'H') /* [63:0] A:R:G:B 16:16:16:16 little endian */
 #define DRM_FORMAT_ABGR16161616F fourcc_code('A', 'B', '4', 'H') /* [63:0] A:B:G:R 16:16:16:16 little endian */
 
+#define DRM_FORMAT_R16F          fourcc_code('R', ' ', ' ', 'H') /* [15:0] R 16 little endian */
+#define DRM_FORMAT_GR1616F       fourcc_code('G', 'R', ' ', 'H') /* [31:0] G:R 16:16 little endian */
+#define DRM_FORMAT_BGR161616F    fourcc_code('B', 'G', 'R', 'H') /* [47:0] B:G:R 16:16:16 little endian */
+
 /*
  * RGBA format with 10-bit components packed in 64-bit per pixel, with 6 bits
  * of unused padding per component:
Signature · 1 line
2.49.0
author
#2 lore raw

PATCH v2 2/2 drm/fourcc: Add 32b float formats

In reply to Rob Clark

Add 1, 2, 3, and 4 component 32b float formats, so that buffers with these formats can be imported/exported with fourcc+modifier, and/or created by gbm.

These correspond to PIPE_FORMAT_{R32,R32G32,R32G32B32,R32G32B32A32}_FLOAT in mesa.

v2: Fix comment describing float32 layout [Sima]

---
 include/uapi/drm/drm_fourcc.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
include/uapi/drm/drm_fourcc.h +10 -0
index 3560ca1ffb8b..6a3f1b32cb30 100644
@@ -232,6 +232,16 @@ extern "C" {
 #define DRM_FORMAT_GR1616F       fourcc_code('G', 'R', ' ', 'H') /* [31:0] G:R 16:16 little endian */
 #define DRM_FORMAT_BGR161616F    fourcc_code('B', 'G', 'R', 'H') /* [47:0] B:G:R 16:16:16 little endian */
 
+/*
+ * Floating point - 32b/component
+ * IEEE 754-2008 binary32 float
+ * [31:0] sign:exponent:mantissa 1:8:23
+ */
+#define DRM_FORMAT_R32F          fourcc_code('R', ' ', ' ', 'F') /* [31:0] R 32 little endian */
+#define DRM_FORMAT_GR3232F       fourcc_code('G', 'R', ' ', 'F') /* [63:0] R:G 32:32 little endian */
+#define DRM_FORMAT_BGR323232F    fourcc_code('B', 'G', 'R', 'F') /* [95:0] R:G:B 32:32:32 little endian */
+#define DRM_FORMAT_ABGR32323232F fourcc_code('A', 'B', '8', 'F') /* [127:0] R:G:B:A 32:32:32:32 little endian */
+
 /*
  * RGBA format with 10-bit components packed in 64-bit per pixel, with 6 bits
  * of unused padding per component:
Signature · 1 line
2.49.0
#3 lore raw
In reply to Rob Clark
Quoted 8 lines · Rob Clark

GPUs support 1/2/3/4 component f16 and f32 formats. Define the missing fourcc's needed to import/export these formats, and/or create with gbm.

Rob Clark (2):
drm/fourcc: Add missing half-float formats
drm/fourcc: Add 32b float formats

[...]

Applied to drm-misc-next, thanks!

[1/2] drm/fourcc: Add missing half-float formats

      commit: e04c3521df073b688b9e9e2213cd3c588e3b6e68
[2/2] drm/fourcc: Add 32b float formats
      commit: 3529cb5ab16b4f1f8bbc31dc39a1076a94bd1e38

Best regards,

Signature · 2 lines
With best wishes
Dmitry