summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker/st_cb_clear.c
diff options
context:
space:
mode:
authorMichal Krol <michal@vmware.com>2010-02-22 21:36:22 +0100
committerMichal Krol <michal@vmware.com>2010-02-22 21:36:22 +0100
commit63cb6f59eac91ba34cf80ff3736568e40b094fe1 (patch)
treea5172db4e43c41654ed038079b745ca67474ddd8 /src/mesa/state_tracker/st_cb_clear.c
parent2467354842d7118efff73165ddaaf4c519b41e46 (diff)
gallium: Remove bypass_vs_clip_and_viewport from rasteriser state.
Needs testing.
Diffstat (limited to 'src/mesa/state_tracker/st_cb_clear.c')
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 898c32293d..5edab55cca 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -65,9 +65,6 @@ st_init_clear(struct st_context *st)
memset(&st->clear.raster, 0, sizeof(st->clear.raster));
st->clear.raster.gl_rasterization_rules = 1;
- /* rasterizer state: bypass vertex shader, clipping and viewport */
- st->clear.raster.bypass_vs_clip_and_viewport = 1;
-
/* fragment shader state: color pass-through program */
st->clear.fs =
util_make_fragment_passthrough_shader(pipe);
@@ -104,9 +101,7 @@ st_destroy_clear(struct st_context *st)
/**
* Draw a screen-aligned quadrilateral.
- * Coords are window coords with y=0=bottom. These will be passed
- * through unmodified to the rasterizer as we have set
- * rasterizer->bypass_vs_clip_and_viewport.
+ * Coords are clip coords with y=0=bottom.
*/
static void
draw_quad(GLcontext *ctx,
@@ -192,18 +187,13 @@ clear_with_quad(GLcontext *ctx,
GLboolean color, GLboolean depth, GLboolean stencil)
{
struct st_context *st = ctx->st;
- const GLfloat x0 = (GLfloat) ctx->DrawBuffer->_Xmin;
- const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax;
- GLfloat y0, y1;
-
- if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
- y0 = (GLfloat) (ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymax);
- y1 = (GLfloat) (ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymin);
- }
- else {
- y0 = (GLfloat) ctx->DrawBuffer->_Ymin;
- y1 = (GLfloat) ctx->DrawBuffer->_Ymax;
- }
+ const struct gl_framebuffer *fb = ctx->DrawBuffer;
+ const GLfloat fb_width = (GLfloat) fb->Width;
+ const GLfloat fb_height = (GLfloat) fb->Height;
+ const GLfloat x0 = (GLfloat) ctx->DrawBuffer->_Xmin / fb_width * 2.0f - 1.0f;
+ const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax / fb_width * 2.0f - 1.0f;
+ const GLfloat y0 = (GLfloat) ctx->DrawBuffer->_Ymin / fb_height * 2.0f - 1.0f;
+ const GLfloat y1 = (GLfloat) ctx->DrawBuffer->_Ymax / fb_height * 2.0f - 1.0f;
/*
printf("%s %s%s%s %f,%f %f,%f\n", __FUNCTION__,
@@ -218,6 +208,7 @@ clear_with_quad(GLcontext *ctx,
cso_save_stencil_ref(st->cso_context);
cso_save_depth_stencil_alpha(st->cso_context);
cso_save_rasterizer(st->cso_context);
+ cso_save_viewport(st->cso_context);
cso_save_fragment_shader(st->cso_context);
cso_save_vertex_shader(st->cso_context);
@@ -273,6 +264,21 @@ clear_with_quad(GLcontext *ctx,
cso_set_rasterizer(st->cso_context, &st->clear.raster);
+ /* viewport state: viewport matching window dims */
+ {
+ 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_fragment_shader_handle(st->cso_context, st->clear.fs);
cso_set_vertex_shader_handle(st->cso_context, st->clear.vs);
@@ -284,9 +290,9 @@ clear_with_quad(GLcontext *ctx,
cso_restore_stencil_ref(st->cso_context);
cso_restore_depth_stencil_alpha(st->cso_context);
cso_restore_rasterizer(st->cso_context);
+ cso_restore_viewport(st->cso_context);
cso_restore_fragment_shader(st->cso_context);
cso_restore_vertex_shader(st->cso_context);
-
}