[Mesa-dev] [PATCH 08/13] dri: Add fp16 formats
Kevin Strasser
kevin.strasser at intel.com
Mon Jan 28 18:42:51 UTC 2019
Add dri formats for RGBA ordered 64 bpp IEEE 754 half precision floating
point. Leverage existing offscreen render support for
MESA_FORMAT_RGBA_FLOAT16 and MESA_FORMAT_RGBX_FLOAT16.
Signed-off-by: Kevin Strasser <kevin.strasser at intel.com>
---
include/GL/internal/dri_interface.h | 4 ++++
src/loader/loader_dri3_helper.c | 5 +++++
src/mesa/drivers/dri/common/dri_util.c | 8 ++++++++
src/mesa/drivers/dri/common/utils.c | 12 ++++++++++++
4 files changed, 29 insertions(+)
diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index 6ffb86e..fad9efb 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -1294,6 +1294,8 @@ struct __DRIdri2ExtensionRec {
#define __DRI_IMAGE_FORMAT_XBGR2101010 0x1010
#define __DRI_IMAGE_FORMAT_ABGR2101010 0x1011
#define __DRI_IMAGE_FORMAT_SABGR8 0x1012
+#define __DRI_IMAGE_FORMAT_XBGR16161616F 0x1013
+#define __DRI_IMAGE_FORMAT_ABGR16161616F 0x1014
#define __DRI_IMAGE_USE_SHARE 0x0001
#define __DRI_IMAGE_USE_SCANOUT 0x0002
@@ -1339,6 +1341,8 @@ struct __DRIdri2ExtensionRec {
#define __DRI_IMAGE_FOURCC_RGBX1010102 0x30335852
#define __DRI_IMAGE_FOURCC_BGRA1010102 0x30334142
#define __DRI_IMAGE_FOURCC_BGRX1010102 0x30335842
+#define __DRI_IMAGE_FOURCC_ABGR16161616F 0x48344241
+#define __DRI_IMAGE_FOURCC_XBGR16161616F 0x48344258
#define __DRI_IMAGE_FOURCC_YUV410 0x39565559
#define __DRI_IMAGE_FOURCC_YUV411 0x31315559
#define __DRI_IMAGE_FOURCC_YUV420 0x32315559
diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
index ad9b9d8..32e54c6 100644
--- a/src/loader/loader_dri3_helper.c
+++ b/src/loader/loader_dri3_helper.c
@@ -1120,6 +1120,9 @@ dri3_cpp_for_format(uint32_t format) {
case __DRI_IMAGE_FORMAT_SARGB8:
case __DRI_IMAGE_FORMAT_SABGR8:
return 4;
+ case __DRI_IMAGE_FORMAT_XBGR16161616F:
+ case __DRI_IMAGE_FORMAT_ABGR16161616F:
+ return 8;
case __DRI_IMAGE_FORMAT_NONE:
default:
return 0;
@@ -1178,6 +1181,8 @@ image_format_to_fourcc(int format)
case __DRI_IMAGE_FORMAT_ARGB2101010: return __DRI_IMAGE_FOURCC_ARGB2101010;
case __DRI_IMAGE_FORMAT_XBGR2101010: return __DRI_IMAGE_FOURCC_XBGR2101010;
case __DRI_IMAGE_FORMAT_ABGR2101010: return __DRI_IMAGE_FOURCC_ABGR2101010;
+ case __DRI_IMAGE_FORMAT_XBGR16161616F: return __DRI_IMAGE_FOURCC_XBGR16161616F;
+ case __DRI_IMAGE_FORMAT_ABGR16161616F: return __DRI_IMAGE_FOURCC_ABGR16161616F;
}
return 0;
}
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index ac3a04b..a384cad 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -887,6 +887,14 @@ static const struct {
.mesa_format = MESA_FORMAT_B8G8R8X8_UNORM,
},
{
+ .image_format = __DRI_IMAGE_FORMAT_ABGR16161616F,
+ .mesa_format = MESA_FORMAT_RGBA_FLOAT16,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_XBGR16161616F,
+ .mesa_format = MESA_FORMAT_RGBX_FLOAT16,
+ },
+ {
.image_format = __DRI_IMAGE_FORMAT_ARGB2101010,
.mesa_format = MESA_FORMAT_B10G10R10A2_UNORM,
},
diff --git a/src/mesa/drivers/dri/common/utils.c b/src/mesa/drivers/dri/common/utils.c
index a57033b..65ed0a1 100644
--- a/src/mesa/drivers/dri/common/utils.c
+++ b/src/mesa/drivers/dri/common/utils.c
@@ -223,6 +223,10 @@ driCreateConfigs(mesa_format format,
{ 0, 10, 20, -1 },
/* MESA_FORMAT_R10G10B10A2_UNORM */
{ 0, 10, 20, 30 },
+ /* MESA_FORMAT_RGBX_FLOAT16 */
+ { 0, 16, 32, -1 },
+ /* MESA_FORMAT_RGBA_FLOAT16 */
+ { 0, 16, 32, 48 },
};
const uint32_t * masks;
@@ -271,6 +275,14 @@ driCreateConfigs(mesa_format format,
masks = masks_table[4];
shifts = shifts_table[4];
break;
+ case MESA_FORMAT_RGBX_FLOAT16:
+ masks = masks_table[9];
+ shifts = shifts_table[9];
+ break;
+ case MESA_FORMAT_RGBA_FLOAT16:
+ masks = masks_table[9];
+ shifts = shifts_table[10];
+ break;
case MESA_FORMAT_R10G10B10X2_UNORM:
masks = masks_table[7];
shifts = shifts_table[7];
--
2.7.4
More information about the mesa-dev
mailing list