Op 29-10-18 om 18:06 schreef Bill Spitzak:
> I think an indicator for float can double as indicating the size is
> multiplied by 8. All float formats I am familiar with take a mulitple of 8
> bits, including an 8-bit format that is sometimes used in CG.
What about this, then?
->8
Pixman is already using the floating point formats internally, expose
this capability in case someone wants to support higher bit per
component formats.
This is useful for igt which depends on cairo to do the rendering.
It can use it to convert floats internally to planar Y'CbCr formats,
or to F16.
Changes since v1:
- Use RGBA 128 bits and RGB 96 bits memory layouts, to better match the opengl
format.
Changes since v2:
- Add asserts in accessor and for strides to force alignment.
- Move test changes to their own commit.
Changes since v3:
- Define 32bpc as PIXMAN_FORMAT_PACKED_C32
- Rename pixman accessors from rgb*_float_float to rgb*f_float
Changes since v4:
- Create a new PIXMAN_FORMAT_BYTE for fitting up to 64 bits per component.
(based on Siarhei Siamashka's suggestion)
- Use new format type PIXMAN_TYPE_RGBA_FLOAT
Signed-off-by: Maarten Lankhorst
Reviewed-by: Chris Wilson #v4
---
pixman/pixman-access.c | 128 -
pixman/pixman-bits-image.c | 3 +
pixman/pixman-image.c | 4 ++
pixman/pixman.c| 5 ++
pixman/pixman.h| 35 +++---
5 files changed, 166 insertions(+), 9 deletions(-)
diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c
index 4f0642d77785..8dfd35f45063 100644
--- a/pixman/pixman-access.c
+++ b/pixman/pixman-access.c
@@ -642,6 +642,48 @@ fetch_scanline_a2r10g10b10_float (bits_image_t * image,
}
/* Expects a float buffer */
+#ifndef PIXMAN_FB_ACCESSORS
+static void
+fetch_scanline_rgbf_float (bits_image_t *image,
+ int x,
+ int y,
+ int width,
+ uint32_t * b,
+ const uint32_t *mask)
+{
+const float *bits = (float *)image->bits + y * image->rowstride;
+const float *pixel = bits + x * 3;
+argb_t *buffer = (argb_t *)b;
+
+for (; width--; buffer++) {
+ buffer->r = *pixel++;
+ buffer->g = *pixel++;
+ buffer->b = *pixel++;
+ buffer->a = 1.f;
+}
+}
+
+static void
+fetch_scanline_rgbaf_float (bits_image_t *image,
+ int x,
+ int y,
+ int width,
+ uint32_t * b,
+ const uint32_t *mask)
+{
+const float *bits = (float *)image->bits + y * image->rowstride;
+const float *pixel = bits + x * 4;
+argb_t *buffer = (argb_t *)b;
+
+for (; width--; buffer++) {
+ buffer->r = *pixel++;
+ buffer->g = *pixel++;
+ buffer->b = *pixel++;
+ buffer->a = *pixel++;
+}
+}
+#endif
+
static void
fetch_scanline_x2r10g10b10_float (bits_image_t *image,
int x,
@@ -805,6 +847,40 @@ fetch_scanline_yv12 (bits_image_t *image,
/ Pixel wise fetching
*/
+#ifndef PIXMAN_FB_ACCESSORS
+static argb_t
+fetch_pixel_rgbf_float (bits_image_t *image,
+ int offset,
+ int line)
+{
+float *bits = (float *)image->bits + line * image->rowstride;
+argb_t argb;
+
+argb.r = bits[offset * 3];
+argb.g = bits[offset * 3 + 1];
+argb.b = bits[offset * 3 + 2];
+argb.a = 1.f;
+
+return argb;
+}
+
+static argb_t
+fetch_pixel_rgbaf_float (bits_image_t *image,
+intoffset,
+intline)
+{
+float *bits = (float *)image->bits + line * image->rowstride;
+argb_t argb;
+
+argb.r = bits[offset * 4];
+argb.g = bits[offset * 4 + 1];
+argb.b = bits[offset * 4 + 2];
+argb.a = bits[offset * 4 + 3];
+
+return argb;
+}
+#endif
+
static argb_t
fetch_pixel_x2r10g10b10_float (bits_image_t *image,
int offset,
@@ -962,6 +1038,45 @@ fetch_pixel_yv12 (bits_image_t *image,
/*** Store
/
+#ifndef PIXMAN_FB_ACCESSORS
+static void
+store_scanline_rgbaf_float (bits_image_t * image,
+ int x,
+ int y,
+ int width,
+ const uint32_t *v)
+{
+float *bits = (float *)image->bits + image->rowstride * y + 4 * x;
+const argb_t *values = (argb_t *)v;
+
+for (; width; width--, values++)
+{
+ *bits++ = values->r;
+ *bits++ = values->g;
+ *bits++ = values->b;
+ *bits++ = values->a;
+}
+}
+
+static void