[965] Simplify scissor handling by using DrawBuffer values.
This commit is contained in:
parent
8336f3ffb7
commit
447facfcd6
|
@ -43,61 +43,40 @@ static void upload_sf_vp(struct brw_context *brw)
|
||||||
struct brw_sf_viewport sfv;
|
struct brw_sf_viewport sfv;
|
||||||
|
|
||||||
memset(&sfv, 0, sizeof(sfv));
|
memset(&sfv, 0, sizeof(sfv));
|
||||||
|
|
||||||
if (brw->intel.driDrawable)
|
|
||||||
{
|
|
||||||
/* _NEW_VIEWPORT, BRW_NEW_METAOPS */
|
|
||||||
|
|
||||||
if (!brw->metaops.active) {
|
/* _NEW_VIEWPORT, BRW_NEW_METAOPS */
|
||||||
const GLfloat *v = ctx->Viewport._WindowMap.m;
|
|
||||||
|
if (!brw->metaops.active) {
|
||||||
sfv.viewport.m00 = v[MAT_SX];
|
const GLfloat *v = ctx->Viewport._WindowMap.m;
|
||||||
sfv.viewport.m11 = - v[MAT_SY];
|
|
||||||
sfv.viewport.m22 = v[MAT_SZ] * depth_scale;
|
sfv.viewport.m00 = v[MAT_SX];
|
||||||
sfv.viewport.m30 = v[MAT_TX];
|
sfv.viewport.m11 = - v[MAT_SY];
|
||||||
sfv.viewport.m31 = - v[MAT_TY] + brw->intel.driDrawable->h;
|
sfv.viewport.m22 = v[MAT_SZ] * depth_scale;
|
||||||
sfv.viewport.m32 = v[MAT_TZ] * depth_scale;
|
sfv.viewport.m30 = v[MAT_TX];
|
||||||
}
|
sfv.viewport.m31 = - v[MAT_TY] + ctx->DrawBuffer->Height;
|
||||||
else {
|
sfv.viewport.m32 = v[MAT_TZ] * depth_scale;
|
||||||
sfv.viewport.m00 = 1;
|
} else {
|
||||||
sfv.viewport.m11 = - 1;
|
sfv.viewport.m00 = 1;
|
||||||
sfv.viewport.m22 = 1;
|
sfv.viewport.m11 = - 1;
|
||||||
sfv.viewport.m30 = 0;
|
sfv.viewport.m22 = 1;
|
||||||
sfv.viewport.m31 = brw->intel.driDrawable->h;
|
sfv.viewport.m30 = 0;
|
||||||
sfv.viewport.m32 = 0;
|
sfv.viewport.m31 = ctx->DrawBuffer->Height;
|
||||||
}
|
sfv.viewport.m32 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX: what state for this? */
|
/* _NEW_SCISSOR */
|
||||||
if (brw->intel.driDrawable)
|
|
||||||
{
|
|
||||||
intelScreenPrivate *screen = brw->intel.intelScreen;
|
|
||||||
/* _NEW_SCISSOR */
|
|
||||||
GLint x = brw->attribs.Scissor->X;
|
|
||||||
GLint y = brw->attribs.Scissor->Y;
|
|
||||||
GLuint w = brw->attribs.Scissor->Width;
|
|
||||||
GLuint h = brw->attribs.Scissor->Height;
|
|
||||||
|
|
||||||
GLint x1 = x;
|
/* The scissor only needs to handle the intersection of drawable and
|
||||||
GLint y1 = brw->intel.driDrawable->h - (y + h);
|
* scissor rect. Clipping to the boundaries of static shared buffers
|
||||||
GLint x2 = x + w - 1;
|
* for front/back/depth is covered by looping over cliprects in brw_draw.c.
|
||||||
GLint y2 = y1 + h - 1;
|
*
|
||||||
|
* Note that the hardware's coordinates are inclusive, while Mesa's min is
|
||||||
if (x1 < 0) x1 = 0;
|
* inclusive but max is exclusive.
|
||||||
if (y1 < 0) y1 = 0;
|
*/
|
||||||
if (x2 < 0) x2 = 0;
|
sfv.scissor.xmin = ctx->DrawBuffer->_Xmin;
|
||||||
if (y2 < 0) y2 = 0;
|
sfv.scissor.xmax = ctx->DrawBuffer->_Xmax - 1;
|
||||||
|
sfv.scissor.ymin = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymax;
|
||||||
if (x2 >= screen->width) x2 = screen->width-1;
|
sfv.scissor.ymax = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymin - 1;
|
||||||
if (y2 >= screen->height) y2 = screen->height-1;
|
|
||||||
if (x1 >= screen->width) x1 = screen->width-1;
|
|
||||||
if (y1 >= screen->height) y1 = screen->height-1;
|
|
||||||
|
|
||||||
sfv.scissor.xmin = x1;
|
|
||||||
sfv.scissor.xmax = x2;
|
|
||||||
sfv.scissor.ymin = y1;
|
|
||||||
sfv.scissor.ymax = y2;
|
|
||||||
}
|
|
||||||
|
|
||||||
dri_bo_unreference(brw->sf.vp_bo);
|
dri_bo_unreference(brw->sf.vp_bo);
|
||||||
brw->sf.vp_bo = brw_cache_data( &brw->cache, BRW_SF_VP, &sfv, NULL, 0 );
|
brw->sf.vp_bo = brw_cache_data( &brw->cache, BRW_SF_VP, &sfv, NULL, 0 );
|
||||||
|
|
|
@ -924,6 +924,7 @@ struct brw_sf_viewport
|
||||||
GLfloat m32;
|
GLfloat m32;
|
||||||
} viewport;
|
} viewport;
|
||||||
|
|
||||||
|
/* scissor coordinates are inclusive */
|
||||||
struct {
|
struct {
|
||||||
GLshort xmin;
|
GLshort xmin;
|
||||||
GLshort ymin;
|
GLshort ymin;
|
||||||
|
|
Loading…
Reference in New Issue