summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe/softpipe
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/pipe/softpipe')
-rwxr-xr-xsrc/mesa/pipe/softpipe/sp_surface.c364
1 files changed, 364 insertions, 0 deletions
diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c
index 84d02f91e7c..75e36e3e3fb 100755
--- a/src/mesa/pipe/softpipe/sp_surface.c
+++ b/src/mesa/pipe/softpipe/sp_surface.c
@@ -200,6 +200,348 @@ z16_write_quad_z(struct softpipe_surface *sps,
}
+/*** PIPE_FORMAT_U_L8 ***/
+
+static void
+l8_read_quad_f_swz(struct softpipe_surface *sps, int x, int y,
+ float (*rrrr)[QUAD_SIZE])
+{
+ const ubyte *src
+ = ((const ubyte *) (sps->surface.region->map + sps->surface.offset))
+ + y * sps->surface.region->pitch + x;
+ unsigned i, j;
+
+ assert(sps->surface.format == PIPE_FORMAT_U_L8);
+ assert(x < (int) sps->surface.width - 1);
+ assert(y < (int) sps->surface.height - 1);
+
+ for (i = 0; i < 2; i++) { /* loop over pixel row */
+ for (j = 0; j < 2; j++) { /* loop over pixel column */
+ rrrr[0][i * 2 + j] =
+ rrrr[1][i * 2 + j] =
+ rrrr[2][i * 2 + j] = UBYTE_TO_FLOAT(src[j]);
+ rrrr[3][i * 2 + j] = 1.0F;
+ }
+ src += sps->surface.region->pitch;
+ }
+}
+
+static void
+l8_write_quad_f_swz(struct softpipe_surface *sps, int x, int y,
+ float (*rrrr)[QUAD_SIZE])
+{
+ ubyte *dst
+ = ((ubyte *) (sps->surface.region->map + sps->surface.offset))
+ + y * sps->surface.region->pitch + x;
+ unsigned i, j;
+
+ assert(sps->surface.format == PIPE_FORMAT_U_L8);
+
+ for (i = 0; i < 2; i++) { /* loop over pixel row */
+ for (j = 0; j < 2; j++) { /* loop over pixel column */
+ ubyte r;
+ UNCLAMPED_FLOAT_TO_UBYTE(r, rrrr[0][i * 2 + j]); /*R*/
+ dst[j] = r;
+ }
+ dst += sps->surface.region->pitch;
+ }
+}
+
+static void
+l8_get_tile(struct pipe_surface *ps,
+ unsigned x, unsigned y, unsigned w, unsigned h, float *p)
+{
+ const ubyte *src
+ = ((const ubyte *) (ps->region->map + ps->offset))
+ + y * ps->region->pitch + x;
+ unsigned i, j;
+ unsigned w0 = w;
+
+ assert(ps->format == PIPE_FORMAT_U_L8);
+
+#if 0
+ assert(x + w <= ps->width);
+ assert(y + h <= ps->height);
+#else
+ /* temp clipping hack */
+ if (x + w > ps->width)
+ w = ps->width - x;
+ if (y + h > ps->height)
+ h = ps->height -y;
+#endif
+ for (i = 0; i < h; i++) {
+ float *pRow = p;
+ for (j = 0; j < w; j++) {
+ pRow[0] =
+ pRow[1] =
+ pRow[2] = UBYTE_TO_FLOAT(src[j]);
+ pRow[3] = 1.0;
+ pRow += 4;
+ }
+ src += ps->region->pitch;
+ p += w0 * 4;
+ }
+}
+
+
+/*** PIPE_FORMAT_U_A8 ***/
+
+static void
+a8_read_quad_f_swz(struct softpipe_surface *sps, int x, int y,
+ float (*rrrr)[QUAD_SIZE])
+{
+ const ubyte *src
+ = ((const ubyte *) (sps->surface.region->map + sps->surface.offset))
+ + y * sps->surface.region->pitch + x;
+ unsigned i, j;
+
+ assert(sps->surface.format == PIPE_FORMAT_U_A8);
+ assert(x < (int) sps->surface.width - 1);
+ assert(y < (int) sps->surface.height - 1);
+
+ for (i = 0; i < 2; i++) { /* loop over pixel row */
+ for (j = 0; j < 2; j++) { /* loop over pixel column */
+ rrrr[0][i * 2 + j] =
+ rrrr[1][i * 2 + j] =
+ rrrr[2][i * 2 + j] = 0.0F;
+ rrrr[3][i * 2 + j] = UBYTE_TO_FLOAT(src[j]);
+ }
+ src += sps->surface.region->pitch;
+ }
+}
+
+static void
+a8_write_quad_f_swz(struct softpipe_surface *sps, int x, int y,
+ float (*rrrr)[QUAD_SIZE])
+{
+ ubyte *dst
+ = ((ubyte *) (sps->surface.region->map + sps->surface.offset))
+ + y * sps->surface.region->pitch + x;
+ unsigned i, j;
+
+ assert(sps->surface.format == PIPE_FORMAT_U_A8);
+
+ for (i = 0; i < 2; i++) { /* loop over pixel row */
+ for (j = 0; j < 2; j++) { /* loop over pixel column */
+ ubyte r;
+ UNCLAMPED_FLOAT_TO_UBYTE(r, rrrr[3][i * 2 + j]); /*A*/
+ dst[j] = r;
+ }
+ dst += sps->surface.region->pitch;
+ }
+}
+
+static void
+a8_get_tile(struct pipe_surface *ps,
+ unsigned x, unsigned y, unsigned w, unsigned h, float *p)
+{
+ const ubyte *src
+ = ((const ubyte *) (ps->region->map + ps->offset))
+ + y * ps->region->pitch + x;
+ unsigned i, j;
+ unsigned w0 = w;
+
+ assert(ps->format == PIPE_FORMAT_U_A8);
+
+#if 0
+ assert(x + w <= ps->width);
+ assert(y + h <= ps->height);
+#else
+ /* temp clipping hack */
+ if (x + w > ps->width)
+ w = ps->width - x;
+ if (y + h > ps->height)
+ h = ps->height -y;
+#endif
+ for (i = 0; i < h; i++) {
+ float *pRow = p;
+ for (j = 0; j < w; j++) {
+ pRow[0] =
+ pRow[1] =
+ pRow[2] = 0.0;
+ pRow[3] = UBYTE_TO_FLOAT(src[j]);
+ pRow += 4;
+ }
+ src += ps->region->pitch;
+ p += w0 * 4;
+ }
+}
+
+
+
+/*** PIPE_FORMAT_U_I8 ***/
+
+static void
+i8_read_quad_f_swz(struct softpipe_surface *sps, int x, int y,
+ float (*rrrr)[QUAD_SIZE])
+{
+ const ubyte *src
+ = ((const ubyte *) (sps->surface.region->map + sps->surface.offset))
+ + y * sps->surface.region->pitch + x;
+ unsigned i, j;
+
+ assert(sps->surface.format == PIPE_FORMAT_U_I8);
+ assert(x < (int) sps->surface.width - 1);
+ assert(y < (int) sps->surface.height - 1);
+
+ for (i = 0; i < 2; i++) { /* loop over pixel row */
+ for (j = 0; j < 2; j++) { /* loop over pixel column */
+ rrrr[0][i * 2 + j] =
+ rrrr[1][i * 2 + j] =
+ rrrr[2][i * 2 + j] =
+ rrrr[3][i * 2 + j] = UBYTE_TO_FLOAT(src[j]);
+ }
+ src += sps->surface.region->pitch;
+ }
+}
+
+static void
+i8_write_quad_f_swz(struct softpipe_surface *sps, int x, int y,
+ float (*rrrr)[QUAD_SIZE])
+{
+ ubyte *dst
+ = ((ubyte *) (sps->surface.region->map + sps->surface.offset))
+ + y * sps->surface.region->pitch + x;
+ unsigned i, j;
+
+ assert(sps->surface.format == PIPE_FORMAT_U_I8);
+
+ for (i = 0; i < 2; i++) { /* loop over pixel row */
+ for (j = 0; j < 2; j++) { /* loop over pixel column */
+ ubyte r;
+ UNCLAMPED_FLOAT_TO_UBYTE(r, rrrr[0][i * 2 + j]); /*R*/
+ dst[j] = r;
+ }
+ dst += sps->surface.region->pitch;
+ }
+}
+
+static void
+i8_get_tile(struct pipe_surface *ps,
+ unsigned x, unsigned y, unsigned w, unsigned h, float *p)
+{
+ const ubyte *src
+ = ((const ubyte *) (ps->region->map + ps->offset))
+ + y * ps->region->pitch + x;
+ unsigned i, j;
+ unsigned w0 = w;
+
+ assert(ps->format == PIPE_FORMAT_U_I8);
+
+#if 0
+ assert(x + w <= ps->width);
+ assert(y + h <= ps->height);
+#else
+ /* temp clipping hack */
+ if (x + w > ps->width)
+ w = ps->width - x;
+ if (y + h > ps->height)
+ h = ps->height -y;
+#endif
+ for (i = 0; i < h; i++) {
+ float *pRow = p;
+ for (j = 0; j < w; j++) {
+ pRow[0] =
+ pRow[1] =
+ pRow[2] =
+ pRow[3] = UBYTE_TO_FLOAT(src[j]);
+ pRow += 4;
+ }
+ src += ps->region->pitch;
+ p += w0 * 4;
+ }
+}
+
+
+/*** PIPE_FORMAT_U_A8_L8 ***/
+
+static void
+a8_l8_read_quad_f_swz(struct softpipe_surface *sps, int x, int y,
+ float (*rrrr)[QUAD_SIZE])
+{
+ const ushort *src
+ = ((const ushort *) (sps->surface.region->map + sps->surface.offset))
+ + y * sps->surface.region->pitch + x;
+ unsigned i, j;
+
+ assert(sps->surface.format == PIPE_FORMAT_U_A8_L8);
+ assert(x < (int) sps->surface.width - 1);
+ assert(y < (int) sps->surface.height - 1);
+
+ for (i = 0; i < 2; i++) { /* loop over pixel row */
+ for (j = 0; j < 2; j++) { /* loop over pixel column */
+ const ushort p = src[j];
+ rrrr[0][i * 2 + j] =
+ rrrr[1][i * 2 + j] =
+ rrrr[2][i * 2 + j] = UBYTE_TO_FLOAT(p >> 8);
+ rrrr[3][i * 2 + j] = UBYTE_TO_FLOAT(p & 0xff);
+ }
+ src += sps->surface.region->pitch;
+ }
+}
+
+static void
+a8_l8_write_quad_f_swz(struct softpipe_surface *sps, int x, int y,
+ float (*rrrr)[QUAD_SIZE])
+{
+ ushort *dst
+ = ((ushort *) (sps->surface.region->map + sps->surface.offset))
+ + y * sps->surface.region->pitch + x;
+ unsigned i, j;
+
+ assert(sps->surface.format == PIPE_FORMAT_U_A8_L8);
+
+ for (i = 0; i < 2; i++) { /* loop over pixel row */
+ for (j = 0; j < 2; j++) { /* loop over pixel column */
+ ubyte l, a;
+ UNCLAMPED_FLOAT_TO_UBYTE(l, rrrr[0][i * 2 + j]); /*R*/
+ UNCLAMPED_FLOAT_TO_UBYTE(a, rrrr[3][i * 2 + j]); /*A*/
+ dst[j] = (l << 8) | a;
+ }
+ dst += sps->surface.region->pitch;
+ }
+}
+
+static void
+a8_l8_get_tile(struct pipe_surface *ps,
+ unsigned x, unsigned y, unsigned w, unsigned h, float *p)
+{
+ const ushort *src
+ = ((const ushort *) (ps->region->map + ps->offset))
+ + y * ps->region->pitch + x;
+ unsigned i, j;
+ unsigned w0 = w;
+
+ assert(ps->format == PIPE_FORMAT_U_A8_L8);
+
+#if 0
+ assert(x + w <= ps->width);
+ assert(y + h <= ps->height);
+#else
+ /* temp clipping hack */
+ if (x + w > ps->width)
+ w = ps->width - x;
+ if (y + h > ps->height)
+ h = ps->height -y;
+#endif
+ for (i = 0; i < h; i++) {
+ float *pRow = p;
+ for (j = 0; j < w; j++) {
+ const ushort p = src[j];
+ pRow[0] =
+ pRow[1] =
+ pRow[2] = UBYTE_TO_FLOAT(p & 0xff);
+ pRow[3] = UBYTE_TO_FLOAT(p >> 8);
+ pRow += 4;
+ }
+ src += ps->region->pitch;
+ p += w0 * 4;
+ }
+}
+
+
+
+
/*** PIPE_FORMAT_U_Z32 ***/
static void
@@ -367,6 +709,27 @@ softpipe_init_surface_funcs(struct softpipe_surface *sps)
case PIPE_FORMAT_U_A1_R5_G5_B5:
sps->surface.get_tile = a1r5g5b5_get_tile;
break;
+ case PIPE_FORMAT_U_L8:
+ sps->read_quad_f_swz = l8_read_quad_f_swz;
+ sps->write_quad_f_swz = l8_write_quad_f_swz;
+ sps->surface.get_tile = l8_get_tile;
+ break;
+ case PIPE_FORMAT_U_A8:
+ sps->read_quad_f_swz = a8_read_quad_f_swz;
+ sps->write_quad_f_swz = a8_write_quad_f_swz;
+ sps->surface.get_tile = a8_get_tile;
+ break;
+ case PIPE_FORMAT_U_I8:
+ sps->read_quad_f_swz = i8_read_quad_f_swz;
+ sps->write_quad_f_swz = i8_write_quad_f_swz;
+ sps->surface.get_tile = i8_get_tile;
+ break;
+ case PIPE_FORMAT_U_A8_L8:
+ sps->read_quad_f_swz = a8_l8_read_quad_f_swz;
+ sps->write_quad_f_swz = a8_l8_write_quad_f_swz;
+ sps->surface.get_tile = a8_l8_get_tile;
+ break;
+
case PIPE_FORMAT_U_Z16:
sps->read_quad_z = z16_read_quad_z;
sps->write_quad_z = z16_write_quad_z;
@@ -381,6 +744,7 @@ softpipe_init_surface_funcs(struct softpipe_surface *sps)
sps->read_quad_stencil = s8z24_read_quad_stencil;
sps->write_quad_stencil = s8z24_write_quad_stencil;
break;
+
case PIPE_FORMAT_U_S8:
sps->read_quad_stencil = s8_read_quad_stencil;
sps->write_quad_stencil = s8_write_quad_stencil;