summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/llvmpipe/lp_rast.c
diff options
context:
space:
mode:
authorKeith Whitwell <keithw@vmware.com>2010-06-17 21:19:09 +0100
committerJosé Fonseca <jfonseca@vmware.com>2010-07-13 17:23:49 +0100
commitd4b64167b56f780d0dea73193c345622888fbc16 (patch)
treec2039d6e06eb248c2da9660e95b9cb9e62b97423 /src/gallium/drivers/llvmpipe/lp_rast.c
parent3bd9aedbac79eec16bfe6f5fc6f6a021eebe769a (diff)
llvmpipe: pass mask into fragment shader
Move this code back out to C for now, will generate separately. Shader now takes a mask parameter instead of C0/C1/C2/etc. Shader does not currently use that parameter and rasterizes whole pixel stamps always.
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_rast.c')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast.c126
1 files changed, 69 insertions, 57 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c
index 1dde327836..0130e39fd8 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -28,6 +28,7 @@
#include <limits.h>
#include "util/u_memory.h"
#include "util/u_math.h"
+#include "util/u_rect.h"
#include "util/u_surface.h"
#include "lp_scene_queue.h"
@@ -136,7 +137,6 @@ lp_rast_tile_begin(struct lp_rasterizer_task *task,
struct lp_rasterizer *rast = task->rast;
struct lp_scene *scene = rast->curr_scene;
enum lp_texture_usage usage;
- unsigned buf;
LP_DBG(DEBUG_RAST, "%s %d,%d\n", __FUNCTION__, x, y);
@@ -146,24 +146,8 @@ lp_rast_tile_begin(struct lp_rasterizer_task *task,
task->x = x;
task->y = y;
- if (scene->has_color_clear)
- usage = LP_TEX_USAGE_WRITE_ALL;
- else
- usage = LP_TEX_USAGE_READ_WRITE;
-
- /* get pointers to color tile(s) */
- for (buf = 0; buf < rast->state.nr_cbufs; buf++) {
- struct pipe_surface *cbuf = rast->curr_scene->fb.cbufs[buf];
- struct llvmpipe_resource *lpt;
- assert(cbuf);
- lpt = llvmpipe_resource(cbuf->texture);
- task->color_tiles[buf] = llvmpipe_get_texture_tile(lpt,
- cbuf->face + cbuf->zslice,
- cbuf->level,
- usage,
- x, y);
- assert(task->color_tiles[buf]);
- }
+ /* reset pointers to color tile(s) */
+ memset(task->color_tiles, 0, sizeof(task->color_tiles));
/* get pointer to depth/stencil tile */
{
@@ -222,7 +206,8 @@ lp_rast_clear_color(struct lp_rasterizer_task *task,
clear_color[2] == clear_color[3]) {
/* clear to grayscale value {x, x, x, x} */
for (i = 0; i < rast->state.nr_cbufs; i++) {
- uint8_t *ptr = task->color_tiles[i];
+ uint8_t *ptr =
+ lp_rast_get_color_tile_pointer(task, i, LP_TEX_USAGE_WRITE_ALL);
memset(ptr, clear_color[0], TILE_SIZE * TILE_SIZE * 4);
}
}
@@ -234,7 +219,8 @@ lp_rast_clear_color(struct lp_rasterizer_task *task,
*/
const unsigned chunk = TILE_SIZE / 4;
for (i = 0; i < rast->state.nr_cbufs; i++) {
- uint8_t *c = task->color_tiles[i];
+ uint8_t *c =
+ lp_rast_get_color_tile_pointer(task, i, LP_TEX_USAGE_WRITE_ALL);
unsigned j;
for (j = 0; j < 4 * TILE_SIZE; j++) {
@@ -378,8 +364,8 @@ lp_rast_load_color(struct lp_rasterizer_task *task,
* This is a bin command which is stored in all bins.
*/
void
-lp_rast_store_color( struct lp_rasterizer_task *task,
- const union lp_rast_cmd_arg arg)
+lp_rast_store_linear_color( struct lp_rasterizer_task *task,
+ const union lp_rast_cmd_arg arg)
{
struct lp_rasterizer *rast = task->rast;
struct lp_scene *scene = rast->curr_scene;
@@ -448,30 +434,54 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task,
/* run shader on 4x4 block */
variant->jit_function[RAST_WHOLE]( &state->jit_context,
- tile_x + x, tile_y + y,
- inputs->facing,
- inputs->a0,
- inputs->dadx,
- inputs->dady,
- color,
- depth,
- INT_MIN, INT_MIN, INT_MIN,
- NULL, NULL, NULL, &task->vis_counter);
+ tile_x + x, tile_y + y,
+ inputs->facing,
+ inputs->a0,
+ inputs->dadx,
+ inputs->dady,
+ color,
+ depth,
+ 0xffff,
+ &task->vis_counter);
}
}
}
/**
- * Compute shading for a 4x4 block of pixels.
+ * Run the shader on all blocks in a tile. This is used when a tile is
+ * completely contained inside a triangle, and the shader is opaque.
+ * This is a bin command called during bin processing.
+ */
+void
+lp_rast_shade_tile_opaque(struct lp_rasterizer_task *task,
+ const union lp_rast_cmd_arg arg)
+{
+ struct lp_rasterizer *rast = task->rast;
+ unsigned i;
+
+ LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
+
+ /* this will prevent converting the layout from tiled to linear */
+ for (i = 0; i < rast->state.nr_cbufs; i++) {
+ (void)lp_rast_get_color_tile_pointer(task, i, LP_TEX_USAGE_WRITE_ALL);
+ }
+
+ lp_rast_shade_tile(task, arg);
+}
+
+
+/**
+ * Compute shading for a 4x4 block of pixels inside a triangle.
* This is a bin command called during bin processing.
* \param x X position of quad in window coords
* \param y Y position of quad in window coords
*/
-void lp_rast_shade_quads( struct lp_rasterizer_task *task,
- const struct lp_rast_shader_inputs *inputs,
- unsigned x, unsigned y,
- int32_t c1, int32_t c2, int32_t c3)
+void
+lp_rast_shade_quads_mask(struct lp_rasterizer_task *task,
+ const struct lp_rast_shader_inputs *inputs,
+ unsigned x, unsigned y,
+ unsigned mask)
{
const struct lp_rast_state *state = task->current_state;
struct lp_fragment_shader_variant *variant = state->variant;
@@ -501,27 +511,21 @@ void lp_rast_shade_quads( struct lp_rasterizer_task *task,
assert(lp_check_alignment(state->jit_context.blend_color, 16));
- assert(lp_check_alignment(inputs->step[0], 16));
- assert(lp_check_alignment(inputs->step[1], 16));
- assert(lp_check_alignment(inputs->step[2], 16));
-
/* run shader on 4x4 block */
- variant->jit_function[RAST_EDGE_TEST]( &state->jit_context,
- x, y,
- inputs->facing,
- inputs->a0,
- inputs->dadx,
- inputs->dady,
- color,
- depth,
- c1, c2, c3,
- inputs->step[0],
- inputs->step[1],
- inputs->step[2],
- &task->vis_counter);
+ variant->jit_function[RAST_EDGE_TEST](&state->jit_context,
+ x, y,
+ inputs->facing,
+ inputs->a0,
+ inputs->dadx,
+ inputs->dady,
+ color,
+ depth,
+ mask,
+ &task->vis_counter);
}
+
/**
* Set top row and left column of the tile's pixels to white. For debugging.
*/
@@ -717,10 +721,17 @@ static struct {
{
RAST(clear_color),
RAST(clear_zstencil),
- RAST(triangle),
+ RAST(triangle_1),
+ RAST(triangle_2),
+ RAST(triangle_3),
+ RAST(triangle_4),
+ RAST(triangle_5),
+ RAST(triangle_6),
+ RAST(triangle_7),
RAST(shade_tile),
+ RAST(shade_tile_opaque),
RAST(set_state),
- RAST(store_color),
+ RAST(store_linear_color),
RAST(fence),
RAST(begin_query),
RAST(end_query),
@@ -775,7 +786,8 @@ is_empty_bin( const struct cmd_bin *bin )
}
for (i = 0; i < head->count; i++)
- if (head->cmd[i] != lp_rast_set_state) {
+ if (head->cmd[i] != lp_rast_set_state &&
+ head->cmd[i] != lp_rast_store_linear_color) {
return FALSE;
}