static void
update_scissor( struct st_context *st )
{
- struct pipe_scissor_state scissor;
+ struct pipe_scissor_state scissor[PIPE_MAX_VIEWPORTS];
const struct gl_context *ctx = st->ctx;
const struct gl_framebuffer *fb = ctx->DrawBuffer;
GLint miny, maxy;
+ int i;
+ bool changed = false;
+ for (i = 0 ; i < ctx->Const.MaxViewports; i++) {
+ scissor[i].minx = 0;
+ scissor[i].miny = 0;
+ scissor[i].maxx = fb->Width;
+ scissor[i].maxy = fb->Height;
- scissor.minx = 0;
- scissor.miny = 0;
- scissor.maxx = fb->Width;
- scissor.maxy = fb->Height;
+ if (ctx->Scissor.EnableFlags & (1 << i)) {
+ /* need to be careful here with xmax or ymax < 0 */
+ GLint xmax = MAX2(0, ctx->Scissor.ScissorArray[i].X + ctx->Scissor.ScissorArray[i].Width);
+ GLint ymax = MAX2(0, ctx->Scissor.ScissorArray[i].Y + ctx->Scissor.ScissorArray[i].Height);
- if (ctx->Scissor.EnableFlags & 1) {
- /* need to be careful here with xmax or ymax < 0 */
- GLint xmax = MAX2(0, ctx->Scissor.ScissorArray[0].X + ctx->Scissor.ScissorArray[0].Width);
- GLint ymax = MAX2(0, ctx->Scissor.ScissorArray[0].Y + ctx->Scissor.ScissorArray[0].Height);
+ if (ctx->Scissor.ScissorArray[i].X > (GLint)scissor[i].minx)
+ scissor[i].minx = ctx->Scissor.ScissorArray[i].X;
+ if (ctx->Scissor.ScissorArray[i].Y > (GLint)scissor[i].miny)
+ scissor[i].miny = ctx->Scissor.ScissorArray[i].Y;
- if (ctx->Scissor.ScissorArray[0].X > (GLint)scissor.minx)
- scissor.minx = ctx->Scissor.ScissorArray[0].X;
- if (ctx->Scissor.ScissorArray[0].Y > (GLint)scissor.miny)
- scissor.miny = ctx->Scissor.ScissorArray[0].Y;
+ if (xmax < (GLint) scissor[i].maxx)
+ scissor[i].maxx = xmax;
+ if (ymax < (GLint) scissor[i].maxy)
+ scissor[i].maxy = ymax;
+
+ /* check for null space */
+ if (scissor[i].minx >= scissor[i].maxx || scissor[i].miny >= scissor[i].maxy)
+ scissor[i].minx = scissor[i].miny = scissor[i].maxx = scissor[i].maxy = 0;
+ }
- if (xmax < (GLint) scissor.maxx)
- scissor.maxx = xmax;
- if (ymax < (GLint) scissor.maxy)
- scissor.maxy = ymax;
+ /* Now invert Y if needed.
+ * Gallium drivers use the convention Y=0=top for surfaces.
+ */
+ if (st_fb_orientation(fb) == Y_0_TOP) {
+ miny = fb->Height - scissor[i].maxy;
+ maxy = fb->Height - scissor[i].miny;
+ scissor[i].miny = miny;
+ scissor[i].maxy = maxy;
+ }
- /* check for null space */
- if (scissor.minx >= scissor.maxx || scissor.miny >= scissor.maxy)
- scissor.minx = scissor.miny = scissor.maxx = scissor.maxy = 0;
- }
-
- /* Now invert Y if needed.
- * Gallium drivers use the convention Y=0=top for surfaces.
- */
- if (st_fb_orientation(fb) == Y_0_TOP) {
- miny = fb->Height - scissor.maxy;
- maxy = fb->Height - scissor.miny;
- scissor.miny = miny;
- scissor.maxy = maxy;
- }
-
- if (memcmp(&scissor, &st->state.scissor, sizeof(scissor)) != 0) {
- /* state has changed */
- st->state.scissor = scissor; /* struct copy */
- st->pipe->set_scissor_states(st->pipe, 0, 1, &scissor); /* activate */
+ if (memcmp(&scissor[i], &st->state.scissor[i], sizeof(scissor)) != 0) {
+ /* state has changed */
+ st->state.scissor[i] = scissor[i]; /* struct copy */
+ changed = true;
+ }
}
+ if (changed)
+ st->pipe->set_scissor_states(st->pipe, 0, ctx->Const.MaxViewports, scissor); /* activate */
}
{
struct gl_context *ctx = st->ctx;
GLfloat yScale, yBias;
-
+ int i;
/* _NEW_BUFFERS
*/
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
/* _NEW_VIEWPORT
*/
+ for (i = 0; i < ctx->Const.MaxViewports; i++)
{
- GLfloat x = ctx->ViewportArray[0].X;
- GLfloat y = ctx->ViewportArray[0].Y;
- GLfloat z = ctx->ViewportArray[0].Near;
- GLfloat half_width = ctx->ViewportArray[0].Width * 0.5f;
- GLfloat half_height = ctx->ViewportArray[0].Height * 0.5f;
- GLfloat half_depth = (GLfloat)(ctx->ViewportArray[0].Far - ctx->ViewportArray[0].Near) * 0.5f;
+ GLfloat x = ctx->ViewportArray[i].X;
+ GLfloat y = ctx->ViewportArray[i].Y;
+ GLfloat z = ctx->ViewportArray[i].Near;
+ GLfloat half_width = ctx->ViewportArray[i].Width * 0.5f;
+ GLfloat half_height = ctx->ViewportArray[i].Height * 0.5f;
+ GLfloat half_depth = (GLfloat)(ctx->ViewportArray[i].Far - ctx->ViewportArray[i].Near) * 0.5f;
- st->state.viewport.scale[0] = half_width;
- st->state.viewport.scale[1] = half_height * yScale;
- st->state.viewport.scale[2] = half_depth;
- st->state.viewport.scale[3] = 1.0;
-
- st->state.viewport.translate[0] = half_width + x;
- st->state.viewport.translate[1] = (half_height + y) * yScale + yBias;
- st->state.viewport.translate[2] = half_depth + z;
- st->state.viewport.translate[3] = 0.0;
+ st->state.viewport[i].scale[0] = half_width;
+ st->state.viewport[i].scale[1] = half_height * yScale;
+ st->state.viewport[i].scale[2] = half_depth;
+ st->state.viewport[i].scale[3] = 1.0;
- cso_set_viewport(st->cso_context, &st->state.viewport);
+ st->state.viewport[i].translate[0] = half_width + x;
+ st->state.viewport[i].translate[1] = (half_height + y) * yScale + yBias;
+ st->state.viewport[i].translate[2] = half_depth + z;
+ st->state.viewport[i].translate[3] = 0.0;
}
+
+ cso_set_viewport(st->cso_context, &st->state.viewport[0]);
+ if (ctx->Const.MaxViewports > 1)
+ st->pipe->set_viewport_states(st->pipe, 1, ctx->Const.MaxViewports - 1, &st->state.viewport[1]);
}