summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-10-08 12:44:30 +0100
committerJosé Fonseca <jfonseca@vmware.com>2009-10-08 12:44:30 +0100
commita6676d896ed18426ed3d7e6340347974c1694ca2 (patch)
treeb5c51f2325a5ffd079edf130119c60540594220b
parent5e13dfe6181952f0f538a77b8a9f91c1d7601ceb (diff)
downloadexternal_mesa3d-a6676d896ed18426ed3d7e6340347974c1694ca2.zip
external_mesa3d-a6676d896ed18426ed3d7e6340347974c1694ca2.tar.gz
external_mesa3d-a6676d896ed18426ed3d7e6340347974c1694ca2.tar.bz2
llvmpipe: Add the rast -> jit shader glue.
Ugly code. Will eventually be reduced to a very thin inlined function.
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast.c58
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast.h5
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast_priv.h18
3 files changed, 73 insertions, 8 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c
index 4771f82..58ef108 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -98,6 +98,64 @@ void lp_rast_shade_tile( struct lp_rasterizer *rast,
}
}
+
+void lp_rast_shade_quads( const struct lp_rast_state *state,
+ struct lp_rast_tile *tile,
+ struct quad_header **quads,
+ unsigned nr )
+{
+ struct lp_fragment_shader *fs = llvmpipe->fs;
+ struct quad_header *quad = quads[0];
+ const unsigned x = quad->input.x0;
+ const unsigned y = quad->input.y0;
+ uint8_t *color;
+ uint8_t *depth;
+ uint32_t ALIGN16_ATTRIB mask[4][NUM_CHANNELS];
+ unsigned chan_index;
+ unsigned q;
+
+ /* Sanity checks */
+ assert(nr * QUAD_SIZE == TILE_VECTOR_HEIGHT * TILE_VECTOR_WIDTH);
+ assert(x % TILE_VECTOR_WIDTH == 0);
+ assert(y % TILE_VECTOR_HEIGHT == 0);
+ for (q = 0; q < nr; ++q) {
+ assert(quads[q]->input.x0 == x + q*2);
+ assert(quads[q]->input.y0 == y);
+ }
+
+ /* mask */
+ for (q = 0; q < 4; ++q)
+ for (chan_index = 0; chan_index < NUM_CHANNELS; ++chan_index)
+ mask[q][chan_index] = quads[q]->inout.mask & (1 << chan_index) ? ~0 : 0;
+
+ /* color buffer */
+ color = &TILE_PIXEL(tile->color, x, y, 0);
+
+ /* depth buffer */
+ assert((x % 2) == 0);
+ assert((y % 2) == 0);
+ depth = (uint8_t)*tile->depth + y*TILE_SIZE*4 + 2*x*4;
+
+ /* XXX: This will most likely fail on 32bit x86 without -mstackrealign */
+ assert(lp_check_alignment(mask, 16));
+
+ assert(lp_check_alignment(depth, 16));
+ assert(lp_check_alignment(color, 16));
+ assert(lp_check_alignment(state->jc.blend_color, 16));
+
+ /* run shader */
+ state->jit_function( &state->jc,
+ x, y,
+ quad->coef->a0,
+ quad->coef->dadx,
+ quad->coef->dady,
+ &mask[0][0],
+ color,
+ depth);
+
+}
+
+
/* End of tile:
*/
void lp_rast_store_color( struct lp_rasterizer *rast )
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h b/src/gallium/drivers/llvmpipe/lp_rast.h
index 8f4bd52..e417be9 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast.h
@@ -17,9 +17,8 @@ struct lp_rast_state {
/* The shader itself. Probably we also need to pass a pointer to
* the tile color/z/stencil data somehow:
*/
- void (*run)( struct lp_jit_context *jc,
- struct quad_header **quads,
- unsigned nr );
+ lp_jit_frag_func shader;
+
};
/* Coefficients necessary to run the shader at a given location:
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
index 538ec22..7eced38 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
@@ -3,16 +3,24 @@
#include "lp_rast.h"
+
+/* We can choose whatever layout for the internal tile storage we
+ * prefer:
+ */
+struct lp_rast_tile
+{
+ uint8_t *color;
+
+ uint8_t *depth;
+};
+
+
struct lp_rasterizer {
/* We can choose whatever layout for the internal tile storage we
* prefer:
*/
- struct {
- unsigned color[TILESIZE][TILESIZE];
- unsigned depth[TILESIZE][TILESIZE];
- char stencil[TILESIZE][TILESIZE];
- } tile;
+ struct lp_rast_tile tile;
unsigned x;