- {
- const GLboolean invert = (st_fb_orientation(fb) == Y_0_TOP);
- struct pipe_viewport_state vp;
- vp.scale[0] = 0.5f * fb_width;
- vp.scale[1] = fb_height * (invert ? -0.5f : 0.5f);
- vp.scale[2] = 1.0f;
- vp.scale[3] = 1.0f;
- vp.translate[0] = 0.5f * fb_width;
- vp.translate[1] = 0.5f * fb_height;
- vp.translate[2] = 0.0f;
- vp.translate[3] = 0.0f;
- cso_set_viewport(st->cso_context, &vp);
+ cso_set_viewport_dims(st->cso_context, fb_width, fb_height,
+ st_fb_orientation(fb) == Y_0_TOP);
+
+ set_fragment_shader(st);
+ cso_set_tessctrl_shader_handle(cso, NULL);
+ cso_set_tesseval_shader_handle(cso, NULL);
+
+ if (num_layers > 1)
+ set_vertex_shader_layered(st);
+ else
+ set_vertex_shader(st);
+
+ /* draw quad matching scissor rect.
+ *
+ * Note: if we're only clearing depth/stencil we still setup vertices
+ * with color, but they'll be ignored.
+ *
+ * We can't translate the clear color to the colorbuffer format,
+ * because different colorbuffers may have different formats.
+ */
+ if (!st_draw_quad(st, x0, y0, x1, y1,
+ ctx->Depth.Clear * 2.0f - 1.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f,
+ (const float *) &ctx->Color.ClearColor.f,
+ num_layers)) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glClear");