i965: Remove artificial dependency between math instructions.
[mesa.git] / src / mesa / state_tracker / st_atom_viewport.c
index 8c6d679a0415d589dc6824db5b1eb8a394cc6d27..7584f9b3d55837e018e36b59c250fc0faffa3b96 100644 (file)
@@ -43,7 +43,7 @@ update_viewport( struct st_context *st )
 {
    struct gl_context *ctx = st->ctx;
    GLfloat yScale, yBias;
-
+   int i;
    /* _NEW_BUFFERS
     */
    if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
@@ -61,26 +61,29 @@ update_viewport( struct st_context *st )
 
    /* _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]);
 }