aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_atom_scissor.c
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2014-01-21 15:26:29 +1000
committerDave Airlie <[email protected]>2014-02-11 14:14:50 +1000
commit0705fa35cdaf15ec969c28dc85e88b8be1149a3b (patch)
tree73b98d63456cd60823101bc864baf2dfd150609e /src/mesa/state_tracker/st_atom_scissor.c
parentc116ee604260faca75aaf2b0d8bbbd78b9c71154 (diff)
st/mesa: add support for GL_ARB_viewport_array (v0.2)
this just ties the mesa code to the pre-existing gallium interface, I'm not sure what to do with the CSO stuff yet. 0.2: fix min/max bounds Acked-by: Ilia Mirkin <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_atom_scissor.c')
-rw-r--r--src/mesa/state_tracker/st_atom_scissor.c77
1 files changed, 41 insertions, 36 deletions
diff --git a/src/mesa/state_tracker/st_atom_scissor.c b/src/mesa/state_tracker/st_atom_scissor.c
index a1f72da47e0..a19ade1fafe 100644
--- a/src/mesa/state_tracker/st_atom_scissor.c
+++ b/src/mesa/state_tracker/st_atom_scissor.c
@@ -43,51 +43,56 @@
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 */
}