Mesa (master): st/mesa: remove some floating point divides in viewport calculation

Keith Whitwell keithw at kemper.freedesktop.org
Wed Feb 3 10:41:15 UTC 2010


Module: Mesa
Branch: master
Commit: aac76dcea95dc80663c78a5c20ec3723a010fd8b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=aac76dcea95dc80663c78a5c20ec3723a010fd8b

Author: Keith Whitwell <keithw at vmware.com>
Date:   Mon Jan 11 16:15:37 2010 +0000

st/mesa: remove some floating point divides in viewport calculation

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 |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_viewport.c b/src/mesa/state_tracker/st_atom_viewport.c
index 27ec2eb..b82bbfe 100644
--- a/src/mesa/state_tracker/st_atom_viewport.c
+++ b/src/mesa/state_tracker/st_atom_viewport.c
@@ -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;




More information about the mesa-commit mailing list