summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe/lp_rast.c
blob: 4771f821b3c9499fa45b86ee253d84f39bcb0327 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119

struct lp_rasterizer *lp_rast_create( void )
{
   return CALLOC_STRUCT(lp_rasterizer);
}

void lp_rast_bind_surfaces( struct lp_rasterizer *,
			    struct pipe_surface *color,
			    struct pipe_surface *zstencil,
			    const float *clear_color,
			    double clear_depth,
			    unsigned clear_stencil)
{
   pipe_surface_reference(&rast->state.color, color);
   pipe_surface_reference(&rast->state.depth, depth);
   rast->state.clear_color = util_pack_8888(clear_color);
   rast->state.clear_depth = clear_depth * 0xffffffff;
   rast->state.clear_stencil = clear_stencil;
}

/* Begining of each tile:
 */
void lp_rast_start_tile( struct lp_rasterizer *,
			 unsigned x,
			 unsigned y )
{
   rast->x = x;
   rast->y = y;
}

void lp_rast_clear_color( struct lp_rasterizer *rast )
{
   const unsigned clear_color = rast->state.clear_color;
   unsigned i, j;
   
   for (i = 0; i < TILESIZE; i++)
      for (j = 0; j < TILESIZE; j++)
	 rast->tile[i][j] = clear_color;
}

void lp_rast_clear_depth( struct lp_rasterizer *rast )
{
   const unsigned clear_depth = rast->state.clear_depth;
   unsigned i, j;
   
   for (i = 0; i < TILESIZE; i++)
      for (j = 0; j < TILESIZE; j++)
	 rast->tile[i][j] = clear_depth;
}

void lp_rast_clear_stencil( struct lp_rasterizer *rast )
{
   const unsigned clear_stencil = rast->state.clear_stencil;

   memset(rast->tile.stencil, clear_stencil, sizeof rast->tile.stencil );
}

void lp_rast_load_color( struct lp_rasterizer *rast )
{
   /* call u_tile func to load colors from surface */
}

void lp_rast_load_zstencil( struct lp_rasterizer *rast )
{
   /* call u_tile func to load depth (and stencil?) from surface */
}

/* Within a tile:
 */
void lp_rast_set_state( struct lp_rasterizer *rast,
		       const struct lp_rast_state *state )
{
   rast->shader_state = state;
   lp->quad.first->begin( lp->quad.first );

}


void lp_rast_shade_tile( struct lp_rasterizer *rast,
			 const struct lp_rast_shader_inputs *inputs )
{
   /* Set up the silly quad coef pointers
    */
   for (i = 0; i < 4; i++) {
      rast->quads[i].posCoef = &inputs->posCoef;
      rast->quads[i].coef = inputs->coef;
   }

   /* Use the existing preference for 8x2 (four quads) shading:
    */
   for (i = 0; i < TILESIZE; i += 8) {
      for (j = 0; j < TILESIZE; j += 2) {
	 rast->shader_state.shade( inputs->jc,
				   rast->x + i,
				   rast->y + j,
				   rast->quads, 4 );
      }
   }
}

/* End of tile:
 */
void lp_rast_store_color( struct lp_rasterizer *rast )
{
   /* call u_tile func to store colors to surface */
}

void lp_rast_store_zstencil( struct lp_rasterizer *rast )
{
   /* call u_tile func to store depth/stencil to surface */
}

/* Shutdown:
 */
void lp_rast_destroy( struct lp_rasterizer *rast )
{
   FREE(rast);
}