st/mesa: remove some floating point divides in viewport calculation
authorKeith Whitwell <keithw@vmware.com>
Mon, 11 Jan 2010 16:15:37 +0000 (16:15 +0000)
committerKeith Whitwell <keithw@vmware.com>
Wed, 3 Feb 2010 10:36:55 +0000 (10:36 +0000)
Compiler can't usually turn x/2.0f into x * 0.5f, though we're happy
with either.

src/mesa/state_tracker/st_atom_viewport.c

index 27ec2eb0331587ecfe0865ad2015e8af27bda30e..b82bbfe410fe36e622415edbb4d53dcdc81d0157 100644 (file)
@@ -62,9 +62,9 @@ update_viewport( struct st_context *st )
       GLfloat x = (GLfloat)ctx->Viewport.X;
       GLfloat y = (GLfloat)ctx->Viewport.Y;
       GLfloat z = ctx->Viewport.Near;
-      GLfloat half_width = (GLfloat)ctx->Viewport.Width / 2.0f;
-      GLfloat half_height = (GLfloat)ctx->Viewport.Height / 2.0f;
-      GLfloat half_depth = (GLfloat)(ctx->Viewport.Far - ctx->Viewport.Near) / 2.0f;
+      GLfloat half_width = (GLfloat)ctx->Viewport.Width * 0.5f;
+      GLfloat half_height = (GLfloat)ctx->Viewport.Height * 0.5f;
+      GLfloat half_depth = (GLfloat)(ctx->Viewport.Far - ctx->Viewport.Near) * 0.5f;
       
       st->state.viewport.scale[0] = half_width;
       st->state.viewport.scale[1] = half_height * yScale;