Browse Source

llvmpipe: Obey rasterization rules.

Replicates softpipe.
tags/mesa-7.9-rc1
José Fonseca 15 years ago
parent
commit
a80e33f407

+ 3
- 1
src/gallium/drivers/llvmpipe/lp_setup.c View File

@@ -337,7 +337,8 @@ void
lp_setup_set_triangle_state( struct lp_setup_context *setup,
unsigned cull_mode,
boolean ccw_is_frontface,
boolean scissor )
boolean scissor,
boolean gl_rasterization_rules)
{
LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__);

@@ -345,6 +346,7 @@ lp_setup_set_triangle_state( struct lp_setup_context *setup,
setup->cullmode = cull_mode;
setup->triangle = first_triangle;
setup->scissor_test = scissor;
setup->pixel_offset = gl_rasterization_rules ? 0.5f : 0.0f;
}



+ 2
- 1
src/gallium/drivers/llvmpipe/lp_setup.h View File

@@ -89,7 +89,8 @@ void
lp_setup_set_triangle_state( struct lp_setup_context *setup,
unsigned cullmode,
boolean front_is_ccw,
boolean scissor );
boolean scissor,
boolean gl_rasterization_rules );

void
lp_setup_set_fs_inputs( struct lp_setup_context *setup,

+ 1
- 0
src/gallium/drivers/llvmpipe/lp_setup_context.h View File

@@ -89,6 +89,7 @@ struct lp_setup_context
boolean ccw_is_frontface;
boolean scissor_test;
unsigned cullmode;
float pixel_offset;

struct pipe_framebuffer_state fb;


+ 32
- 27
src/gallium/drivers/llvmpipe/lp_setup_tri.c View File

@@ -41,7 +41,8 @@
/**
* Compute a0 for a constant-valued coefficient (GL_FLAT shading).
*/
static void constant_coef( struct lp_rast_triangle *tri,
static void constant_coef( struct lp_setup_context *setup,
struct lp_rast_triangle *tri,
unsigned slot,
const float value,
unsigned i )
@@ -56,7 +57,8 @@ static void constant_coef( struct lp_rast_triangle *tri,
* Compute a0, dadx and dady for a linearly interpolated coefficient,
* for a triangle.
*/
static void linear_coef( struct lp_rast_triangle *tri,
static void linear_coef( struct lp_setup_context *setup,
struct lp_rast_triangle *tri,
float oneoverarea,
unsigned slot,
const float (*v1)[4],
@@ -90,8 +92,8 @@ static void linear_coef( struct lp_rast_triangle *tri,
* instead - i'll switch to this later.
*/
tri->inputs.a0[slot][i] = (a1 -
(dadx * (v1[0][0] - 0.5f) +
dady * (v1[0][1] - 0.5f)));
(dadx * (v1[0][0] - setup->pixel_offset) +
dady * (v1[0][1] - setup->pixel_offset)));
}


@@ -103,7 +105,8 @@ static void linear_coef( struct lp_rast_triangle *tri,
* Later, when we compute the value at a particular fragment position we'll
* divide the interpolated value by the interpolated W at that fragment.
*/
static void perspective_coef( struct lp_rast_triangle *tri,
static void perspective_coef( struct lp_setup_context *setup,
struct lp_rast_triangle *tri,
float oneoverarea,
unsigned slot,
const float (*v1)[4],
@@ -125,8 +128,8 @@ static void perspective_coef( struct lp_rast_triangle *tri,
tri->inputs.dadx[slot][i] = dadx;
tri->inputs.dady[slot][i] = dady;
tri->inputs.a0[slot][i] = (a1 -
(dadx * (v1[0][0] - 0.5f) +
dady * (v1[0][1] - 0.5f)));
(dadx * (v1[0][0] - setup->pixel_offset) +
dady * (v1[0][1] - setup->pixel_offset)));
}


@@ -137,7 +140,8 @@ static void perspective_coef( struct lp_rast_triangle *tri,
* We could do a bit less work if we'd examine gl_FragCoord's swizzle mask.
*/
static void
setup_fragcoord_coef(struct lp_rast_triangle *tri,
setup_fragcoord_coef(struct lp_setup_context *setup,
struct lp_rast_triangle *tri,
float oneoverarea,
unsigned slot,
const float (*v1)[4],
@@ -153,20 +157,21 @@ setup_fragcoord_coef(struct lp_rast_triangle *tri,
tri->inputs.dadx[slot][1] = 0.0;
tri->inputs.dady[slot][1] = 1.0;
/*Z*/
linear_coef(tri, oneoverarea, slot, v1, v2, v3, 0, 2);
linear_coef(setup, tri, oneoverarea, slot, v1, v2, v3, 0, 2);
/*W*/
linear_coef(tri, oneoverarea, slot, v1, v2, v3, 0, 3);
linear_coef(setup, tri, oneoverarea, slot, v1, v2, v3, 0, 3);
}


static void setup_facing_coef( struct lp_rast_triangle *tri,
static void setup_facing_coef( struct lp_setup_context *setup,
struct lp_rast_triangle *tri,
unsigned slot,
boolean frontface )
{
constant_coef( tri, slot, 1.0f - frontface, 0 );
constant_coef( tri, slot, 0.0f, 1 ); /* wasted */
constant_coef( tri, slot, 0.0f, 2 ); /* wasted */
constant_coef( tri, slot, 0.0f, 3 ); /* wasted */
constant_coef( setup, tri, slot, 1.0f - frontface, 0 );
constant_coef( setup, tri, slot, 0.0f, 1 ); /* wasted */
constant_coef( setup, tri, slot, 0.0f, 2 ); /* wasted */
constant_coef( setup, tri, slot, 0.0f, 3 ); /* wasted */
}


@@ -185,7 +190,7 @@ static void setup_tri_coefficients( struct lp_setup_context *setup,

/* The internal position input is in slot zero:
*/
setup_fragcoord_coef(tri, oneoverarea, 0, v1, v2, v3);
setup_fragcoord_coef(setup, tri, oneoverarea, 0, v1, v2, v3);

/* setup interpolation for all the remaining attributes:
*/
@@ -196,27 +201,27 @@ static void setup_tri_coefficients( struct lp_setup_context *setup,
switch (setup->fs.input[slot].interp) {
case LP_INTERP_CONSTANT:
for (i = 0; i < NUM_CHANNELS; i++)
constant_coef(tri, slot+1, v3[vert_attr][i], i);
constant_coef(setup, tri, slot+1, v3[vert_attr][i], i);
break;

case LP_INTERP_LINEAR:
for (i = 0; i < NUM_CHANNELS; i++)
linear_coef(tri, oneoverarea, slot+1, v1, v2, v3, vert_attr, i);
linear_coef(setup, tri, oneoverarea, slot+1, v1, v2, v3, vert_attr, i);
break;

case LP_INTERP_PERSPECTIVE:
for (i = 0; i < NUM_CHANNELS; i++)
perspective_coef(tri, oneoverarea, slot+1, v1, v2, v3, vert_attr, i);
perspective_coef(setup, tri, oneoverarea, slot+1, v1, v2, v3, vert_attr, i);
break;

case LP_INTERP_POSITION:
/* XXX: fix me - duplicates the values in slot zero.
*/
setup_fragcoord_coef(tri, oneoverarea, slot+1, v1, v2, v3);
setup_fragcoord_coef(setup, tri, oneoverarea, slot+1, v1, v2, v3);
break;

case LP_INTERP_FACING:
setup_facing_coef(tri, slot+1, frontface);
setup_facing_coef(setup, tri, slot+1, frontface);
break;

default:
@@ -281,12 +286,12 @@ do_triangle_ccw(struct lp_setup_context *setup,
boolean frontfacing )
{
/* x/y positions in fixed point */
const int x1 = subpixel_snap(v1[0][0]);
const int x2 = subpixel_snap(v2[0][0]);
const int x3 = subpixel_snap(v3[0][0]);
const int y1 = subpixel_snap(v1[0][1]);
const int y2 = subpixel_snap(v2[0][1]);
const int y3 = subpixel_snap(v3[0][1]);
const int x1 = subpixel_snap(v1[0][0] + 0.5 - setup->pixel_offset);
const int x2 = subpixel_snap(v2[0][0] + 0.5 - setup->pixel_offset);
const int x3 = subpixel_snap(v3[0][0] + 0.5 - setup->pixel_offset);
const int y1 = subpixel_snap(v1[0][1] + 0.5 - setup->pixel_offset);
const int y2 = subpixel_snap(v2[0][1] + 0.5 - setup->pixel_offset);
const int y3 = subpixel_snap(v3[0][1] + 0.5 - setup->pixel_offset);

struct lp_scene *scene = lp_setup_get_current_scene(setup);
struct lp_rast_triangle *tri;

+ 2
- 1
src/gallium/drivers/llvmpipe/lp_state_rasterizer.c View File

@@ -62,7 +62,8 @@ void llvmpipe_bind_rasterizer_state(struct pipe_context *pipe,
lp_setup_set_triangle_state( llvmpipe->setup,
llvmpipe->rasterizer->cull_mode,
llvmpipe->rasterizer->front_winding == PIPE_WINDING_CCW,
llvmpipe->rasterizer->scissor);
llvmpipe->rasterizer->scissor,
llvmpipe->rasterizer->gl_rasterization_rules);
}

llvmpipe->dirty |= LP_NEW_RASTERIZER;

Loading…
Cancel
Save