summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-08-24 13:17:08 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-08-24 18:08:23 -0600
commit59e7bfa1de77ab03ca174bdf82fe33ab36050ce7 (patch)
tree2f3eed29f2e83a82fa8a137930d16a0a3bf2ea70 /src/mesa
parent4fd7bc00f06a98e1db2ad886a13566f19895e3c0 (diff)
Add support for more surface types in sp_surface.c
replace PIPE_FORMAT_U_L8_A8 with PIPE_FORMAT_U_A8_L8
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/pipe/i915simple/i915_state_sampler.c2
-rw-r--r--src/mesa/pipe/p_defines.h2
-rwxr-xr-xsrc/mesa/pipe/softpipe/sp_surface.c364
-rw-r--r--src/mesa/state_tracker/st_atom_vs.c2
-rw-r--r--src/mesa/state_tracker/st_format.c12
5 files changed, 378 insertions, 4 deletions
diff --git a/src/mesa/pipe/i915simple/i915_state_sampler.c b/src/mesa/pipe/i915simple/i915_state_sampler.c
index e4d7fec27b..7a595d1022 100644
--- a/src/mesa/pipe/i915simple/i915_state_sampler.c
+++ b/src/mesa/pipe/i915simple/i915_state_sampler.c
@@ -295,7 +295,7 @@ translate_texture_format(uint pipeFormat)
return MAPSURF_8BIT | MT_8BIT_I8;
case PIPE_FORMAT_U_A8:
return MAPSURF_8BIT | MT_8BIT_A8;
- case PIPE_FORMAT_U_L8_A8:
+ case PIPE_FORMAT_U_A8_L8:
return MAPSURF_16BIT | MT_16BIT_AY88;
case PIPE_FORMAT_U_R5_G6_B5:
return MAPSURF_16BIT | MT_16BIT_RGB565;
diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h
index 636711938c..c1164c5c08 100644
--- a/src/mesa/pipe/p_defines.h
+++ b/src/mesa/pipe/p_defines.h
@@ -178,7 +178,7 @@
#define PIPE_FORMAT_U_L8 6 /**< ubyte luminance */
#define PIPE_FORMAT_U_A8 7 /**< ubyte alpha */
#define PIPE_FORMAT_U_I8 8 /**< ubyte intensity */
-#define PIPE_FORMAT_U_L8_A8 9 /**< ubyte luminance, alpha */
+#define PIPE_FORMAT_U_A8_L8 9 /**< ubyte alpha, luminance */
#define PIPE_FORMAT_S_R16_G16_B16_A16 10 /**< signed 16-bit RGBA (accum) */
#define PIPE_FORMAT_YCBCR 11
#define PIPE_FORMAT_YCBCR_REV 12
diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c
index 84d02f91e7..75e36e3e3f 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;
diff --git a/src/mesa/state_tracker/st_atom_vs.c b/src/mesa/state_tracker/st_atom_vs.c
index a326c12608..7f11533f74 100644
--- a/src/mesa/state_tracker/st_atom_vs.c
+++ b/src/mesa/state_tracker/st_atom_vs.c
@@ -162,8 +162,10 @@ const struct st_tracked_state st_update_vs = {
*/
static void update_tnl( struct st_context *st )
{
+ uint before = st->ctx->NewState;
if (st->ctx->VertexProgram._MaintainTnlProgram)
_tnl_UpdateFixedFunctionProgram( st->ctx );
+ assert(before == st->ctx->NewState);
}
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index a89dfb10fb..84e6a2d5fd 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -115,6 +115,14 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat)
case MESA_FORMAT_ARGB8888_REV:
case MESA_FORMAT_ARGB8888:
return PIPE_FORMAT_U_A8_R8_G8_B8;
+ case MESA_FORMAT_AL88:
+ return PIPE_FORMAT_U_A8_L8;
+ case MESA_FORMAT_A8:
+ return PIPE_FORMAT_U_A8;
+ case MESA_FORMAT_L8:
+ return PIPE_FORMAT_U_L8;
+ case MESA_FORMAT_I8:
+ return PIPE_FORMAT_U_I8;
default:
assert(0);
return 0;
@@ -277,8 +285,8 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat,
case GL_LUMINANCE12_ALPHA12:
case GL_LUMINANCE16_ALPHA16:
case GL_COMPRESSED_LUMINANCE_ALPHA:
- if (allow[PIPE_FORMAT_U_L8_A8])
- return PIPE_FORMAT_U_L8_A8;
+ if (allow[PIPE_FORMAT_U_A8_L8])
+ return PIPE_FORMAT_U_A8_L8;
return default_rgba_format(supported, n);
case GL_INTENSITY: