This controls whether the window origin is considered to be the lower-left or upper-left corner. This effects computation of gl_FragCoord and the application of polygon stipple.tags/mesa_20090313
@@ -94,6 +94,7 @@ struct pipe_rasterizer_state | |||
unsigned line_stipple_factor:8; /**< [1..256] actually */ | |||
unsigned line_stipple_pattern:16; | |||
unsigned bypass_clipping:1; | |||
unsigned origin_lower_left:1; /**< Is (0,0) the lower-left corner? */ | |||
float line_width; | |||
float point_size; /**< used when no per-vertex size */ |
@@ -480,15 +480,23 @@ static void tri_persp_coeff( struct setup_stage *setup, | |||
static void | |||
setup_fragcoord_coeff(struct setup_stage *setup) | |||
{ | |||
const int winHeight = setup->softpipe->framebuffer.cbufs[0]->height; | |||
/*X*/ | |||
setup->coef[0].a0[0] = 0; | |||
setup->coef[0].dadx[0] = 1.0; | |||
setup->coef[0].dady[0] = 0.0; | |||
/*Y*/ | |||
setup->coef[0].a0[1] = winHeight - 1; | |||
if (setup->softpipe->rasterizer->origin_lower_left) { | |||
/* y=0=bottom */ | |||
const int winHeight = setup->softpipe->framebuffer.cbufs[0]->height; | |||
setup->coef[0].a0[1] = winHeight - 1; | |||
setup->coef[0].dady[1] = -1.0; | |||
} | |||
else { | |||
/* y=0=top */ | |||
setup->coef[0].a0[1] = 0.0; | |||
setup->coef[0].dady[1] = 1.0; | |||
} | |||
setup->coef[0].dadx[1] = 0.0; | |||
setup->coef[0].dady[1] = -1.0; | |||
/*Z*/ | |||
setup->coef[0].a0[2] = setup->posCoef.a0[2]; | |||
setup->coef[0].dadx[2] = setup->posCoef.dadx[2]; |
@@ -22,10 +22,18 @@ stipple_quad(struct quad_stage *qs, struct quad_header *quad) | |||
if (quad->prim == PRIM_TRI) { | |||
struct softpipe_context *softpipe = qs->softpipe; | |||
/* need to invert Y to index into OpenGL's stipple pattern */ | |||
const int y0 = softpipe->framebuffer.cbufs[0]->height - 1 - quad->y0; | |||
const int y1 = y0 - 1; | |||
const unsigned stipple0 = softpipe->poly_stipple.stipple[y0 % 32]; | |||
const unsigned stipple1 = softpipe->poly_stipple.stipple[y1 % 32]; | |||
int y0, y1; | |||
uint stipple0, stipple1; | |||
if (softpipe->rasterizer->origin_lower_left) { | |||
y0 = softpipe->framebuffer.cbufs[0]->height - 1 - quad->y0; | |||
y1 = y0 - 1; | |||
} | |||
else { | |||
y0 = quad->y0; | |||
y1 = y0 + 1; | |||
} | |||
stipple0 = softpipe->poly_stipple.stipple[y0 % 32]; | |||
stipple1 = softpipe->poly_stipple.stipple[y1 % 32]; | |||
#if 1 | |||
const int col0 = quad->x0 % 32; |
@@ -77,6 +77,8 @@ static void update_raster_state( struct st_context *st ) | |||
uint i; | |||
memset(&raster, 0, sizeof(raster)); | |||
raster.origin_lower_left = 1; /* Always true for OpenGL */ | |||
/* _NEW_POLYGON, _NEW_BUFFERS | |||
*/ |