llvmpipe: Complete more rasterizer methods..
This commit is contained in:
parent
35a90e67eb
commit
ab76b2a8b8
|
@ -50,14 +50,14 @@ struct lp_rasterizer *lp_rast_create( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
void lp_rast_bind_surfaces( struct lp_rasterizer *rast,
|
void lp_rast_bind_surfaces( struct lp_rasterizer *rast,
|
||||||
struct pipe_surface *color,
|
struct pipe_surface *cbuf,
|
||||||
struct pipe_surface *zstencil,
|
struct pipe_surface *zsbuf,
|
||||||
const float *clear_color,
|
const float *clear_color,
|
||||||
double clear_depth,
|
double clear_depth,
|
||||||
unsigned clear_stencil)
|
unsigned clear_stencil)
|
||||||
{
|
{
|
||||||
pipe_surface_reference(&rast->state.color, color);
|
pipe_surface_reference(&rast->state.cbuf, cbuf);
|
||||||
pipe_surface_reference(&rast->state.depth, depth);
|
pipe_surface_reference(&rast->state.zsbuf, zsbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,12 +93,12 @@ void lp_rast_clear_color( struct lp_rasterizer *rast,
|
||||||
void lp_rast_clear_zstencil( struct lp_rasterizer *rast,
|
void lp_rast_clear_zstencil( struct lp_rasterizer *rast,
|
||||||
const union lp_rast_cmd_arg *arg)
|
const union lp_rast_cmd_arg *arg)
|
||||||
{
|
{
|
||||||
const unsigned clear_color = arg->clear.clear_zstencil;
|
const unsigned clear_zstencil = arg->clear.clear_zstencil;
|
||||||
unsigned i, j;
|
unsigned i, j;
|
||||||
|
|
||||||
for (i = 0; i < TILE_SIZE; i++)
|
for (i = 0; i < TILE_SIZE; i++)
|
||||||
for (j = 0; j < TILE_SIZE; j++)
|
for (j = 0; j < TILE_SIZE; j++)
|
||||||
rast->tile.depth[i][j] = clear_depth;
|
rast->tile.depth[i*TILE_SIZE + j] = clear_zstencil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ void lp_rast_load_zstencil( struct lp_rasterizer *rast,
|
||||||
void lp_rast_set_state( struct lp_rasterizer *rast,
|
void lp_rast_set_state( struct lp_rasterizer *rast,
|
||||||
const union lp_rast_cmd_arg *arg )
|
const union lp_rast_cmd_arg *arg )
|
||||||
{
|
{
|
||||||
rast->shader_state = arg->state;
|
rast->shader_state = arg->set_state;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,36 +128,24 @@ void lp_rast_shade_tile( struct lp_rasterizer *rast,
|
||||||
const union lp_rast_cmd_arg *arg,
|
const union lp_rast_cmd_arg *arg,
|
||||||
const struct lp_rast_shader_inputs *inputs )
|
const struct lp_rast_shader_inputs *inputs )
|
||||||
{
|
{
|
||||||
unsigned i;
|
const uint32_t masks[4] = {~0, ~0, ~0, ~0};
|
||||||
|
unsigned i, j;
|
||||||
/* 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:
|
/* Use the existing preference for 8x2 (four quads) shading:
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < TILE_SIZE; i += 8) {
|
for (i = 0; i < TILE_SIZE; i += 8)
|
||||||
for (j = 0; j < TILE_SIZE; j += 2) {
|
for (j = 0; j < TILE_SIZE; j += 2)
|
||||||
rast->shader_state.shade( inputs->jc,
|
lp_rast_shade_quads( rast, inputs, i, j, &masks);
|
||||||
rast->x + i,
|
|
||||||
rast->y + j,
|
|
||||||
rast->quads, 4 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void lp_rast_shade_quads( const struct lp_rast_state *state,
|
void lp_rast_shade_quads( struct lp_rasterizer *rast,
|
||||||
struct lp_rast_tile *tile,
|
const struct lp_rast_shader_inputs *inputs,
|
||||||
struct quad_header **quads,
|
unsigned x, unsigned y,
|
||||||
unsigned nr )
|
const unsigned *masks)
|
||||||
{
|
{
|
||||||
struct quad_header *quad = quads[0];
|
const struct lp_rast_state *state = rast->shader_state;
|
||||||
const unsigned x = quad->input.x0;
|
struct lp_rast_tile *tile = &rast->tile;
|
||||||
const unsigned y = quad->input.y0;
|
|
||||||
uint8_t *color;
|
uint8_t *color;
|
||||||
uint8_t *depth;
|
uint8_t *depth;
|
||||||
uint32_t ALIGN16_ATTRIB mask[4][NUM_CHANNELS];
|
uint32_t ALIGN16_ATTRIB mask[4][NUM_CHANNELS];
|
||||||
|
@ -165,18 +153,13 @@ void lp_rast_shade_quads( const struct lp_rast_state *state,
|
||||||
unsigned q;
|
unsigned q;
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
assert(nr * QUAD_SIZE == TILE_VECTOR_HEIGHT * TILE_VECTOR_WIDTH);
|
|
||||||
assert(x % TILE_VECTOR_WIDTH == 0);
|
assert(x % TILE_VECTOR_WIDTH == 0);
|
||||||
assert(y % TILE_VECTOR_HEIGHT == 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 */
|
/* mask */
|
||||||
for (q = 0; q < 4; ++q)
|
for (q = 0; q < 4; ++q)
|
||||||
for (chan_index = 0; chan_index < NUM_CHANNELS; ++chan_index)
|
for (chan_index = 0; chan_index < NUM_CHANNELS; ++chan_index)
|
||||||
mask[q][chan_index] = quads[q]->inout.mask & (1 << chan_index) ? ~0 : 0;
|
mask[q][chan_index] = masks[q] & (1 << chan_index) ? ~0 : 0;
|
||||||
|
|
||||||
/* color buffer */
|
/* color buffer */
|
||||||
color = &TILE_PIXEL(tile->color, x, y, 0);
|
color = &TILE_PIXEL(tile->color, x, y, 0);
|
||||||
|
@ -184,7 +167,7 @@ void lp_rast_shade_quads( const struct lp_rast_state *state,
|
||||||
/* depth buffer */
|
/* depth buffer */
|
||||||
assert((x % 2) == 0);
|
assert((x % 2) == 0);
|
||||||
assert((y % 2) == 0);
|
assert((y % 2) == 0);
|
||||||
depth = (uint8_t *)tile->depth + y*TILE_SIZE*4 + 2*x*4;
|
depth = tile->depth + y*TILE_SIZE + 2*x;
|
||||||
|
|
||||||
/* XXX: This will most likely fail on 32bit x86 without -mstackrealign */
|
/* XXX: This will most likely fail on 32bit x86 without -mstackrealign */
|
||||||
assert(lp_check_alignment(mask, 16));
|
assert(lp_check_alignment(mask, 16));
|
||||||
|
@ -196,9 +179,9 @@ void lp_rast_shade_quads( const struct lp_rast_state *state,
|
||||||
/* run shader */
|
/* run shader */
|
||||||
state->shader( &state->jc,
|
state->shader( &state->jc,
|
||||||
x, y,
|
x, y,
|
||||||
quad->coef->a0,
|
inputs->a0,
|
||||||
quad->coef->dadx,
|
inputs->dadx,
|
||||||
quad->coef->dady,
|
inputs->dady,
|
||||||
&mask[0][0],
|
&mask[0][0],
|
||||||
color,
|
color,
|
||||||
depth);
|
depth);
|
||||||
|
@ -220,8 +203,9 @@ void lp_rast_end_tile( struct lp_rasterizer *rast,
|
||||||
const unsigned y = rast->y;
|
const unsigned y = rast->y;
|
||||||
unsigned w = TILE_SIZE;
|
unsigned w = TILE_SIZE;
|
||||||
unsigned h = TILE_SIZE;
|
unsigned h = TILE_SIZE;
|
||||||
|
void *map;
|
||||||
|
|
||||||
surface = rast->state.color;
|
surface = rast->state.cbuf;
|
||||||
if(!surface)
|
if(!surface)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -252,7 +236,7 @@ void lp_rast_end_tile( struct lp_rasterizer *rast,
|
||||||
screen->transfer_unmap(screen, transfer);
|
screen->transfer_unmap(screen, transfer);
|
||||||
}
|
}
|
||||||
|
|
||||||
screen->tex_transfer_destroy(screen, transfer);
|
screen->tex_transfer_destroy(transfer);
|
||||||
|
|
||||||
if (write_depth) {
|
if (write_depth) {
|
||||||
/* FIXME: call u_tile func to store depth/stencil to surface */
|
/* FIXME: call u_tile func to store depth/stencil to surface */
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#ifndef LP_RAST_H
|
#ifndef LP_RAST_H
|
||||||
#define LP_RAST_H
|
#define LP_RAST_H
|
||||||
|
|
||||||
|
#include "pipe/p_compiler.h"
|
||||||
#include "lp_jit.h"
|
#include "lp_jit.h"
|
||||||
|
|
||||||
/* Initially create and program a single rasterizer directly. Later
|
/* Initially create and program a single rasterizer directly. Later
|
||||||
|
@ -91,9 +92,6 @@ struct lp_rast_triangle {
|
||||||
float dx12;
|
float dx12;
|
||||||
float dx23;
|
float dx23;
|
||||||
float dx31;
|
float dx31;
|
||||||
|
|
||||||
/* State to run the shader: */
|
|
||||||
struct lp_rast_shader_inputs inputs;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct clear_tile {
|
struct clear_tile {
|
||||||
|
@ -112,8 +110,8 @@ struct load_tile {
|
||||||
struct lp_rasterizer *lp_rast_create( void );
|
struct lp_rasterizer *lp_rast_create( void );
|
||||||
|
|
||||||
void lp_rast_bind_surfaces( struct lp_rasterizer *,
|
void lp_rast_bind_surfaces( struct lp_rasterizer *,
|
||||||
struct pipe_surface *color,
|
struct pipe_surface *cbuf,
|
||||||
struct pipe_surface *zstencil,
|
struct pipe_surface *zsbuf,
|
||||||
const float *clear_color,
|
const float *clear_color,
|
||||||
double clear_depth,
|
double clear_depth,
|
||||||
unsigned clear_stencil);
|
unsigned clear_stencil);
|
||||||
|
@ -154,7 +152,8 @@ void lp_rast_triangle( struct lp_rasterizer *,
|
||||||
const union lp_rast_cmd_arg * );
|
const union lp_rast_cmd_arg * );
|
||||||
|
|
||||||
void lp_rast_shade_tile( struct lp_rasterizer *,
|
void lp_rast_shade_tile( struct lp_rasterizer *,
|
||||||
const union lp_rast_cmd_arg * );
|
const union lp_rast_cmd_arg *,
|
||||||
|
const struct lp_rast_shader_inputs *);
|
||||||
|
|
||||||
void lp_rast_store_color( struct lp_rasterizer *,
|
void lp_rast_store_color( struct lp_rasterizer *,
|
||||||
const union lp_rast_cmd_arg *);
|
const union lp_rast_cmd_arg *);
|
||||||
|
@ -163,6 +162,12 @@ void lp_rast_store_zstencil( struct lp_rasterizer *,
|
||||||
const union lp_rast_cmd_arg *);
|
const union lp_rast_cmd_arg *);
|
||||||
|
|
||||||
|
|
||||||
|
/* End of tile:
|
||||||
|
*/
|
||||||
|
|
||||||
|
void lp_rast_end_tile( struct lp_rasterizer *rast,
|
||||||
|
boolean write_depth );
|
||||||
|
|
||||||
/* Shutdown:
|
/* Shutdown:
|
||||||
*/
|
*/
|
||||||
void lp_rast_destroy( struct lp_rasterizer * );
|
void lp_rast_destroy( struct lp_rasterizer * );
|
||||||
|
|
|
@ -38,7 +38,7 @@ struct lp_rast_tile
|
||||||
{
|
{
|
||||||
uint8_t *color;
|
uint8_t *color;
|
||||||
|
|
||||||
uint8_t *depth;
|
uint32_t *depth;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,12 +55,20 @@ struct lp_rasterizer {
|
||||||
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct pipe_surface *color;
|
struct pipe_surface *cbuf;
|
||||||
struct pipe_surface *zstencil;
|
struct pipe_surface *zsbuf;
|
||||||
unsigned clear_color;
|
unsigned clear_color;
|
||||||
unsigned clear_depth;
|
unsigned clear_depth;
|
||||||
char clear_stencil;
|
char clear_stencil;
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
|
const struct lp_rast_state *shader_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void lp_rast_shade_quads( struct lp_rasterizer *rast,
|
||||||
|
const struct lp_rast_shader_inputs *inputs,
|
||||||
|
unsigned x, unsigned y,
|
||||||
|
const unsigned *masks);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue