[Lima] [PATCH 1/4] mesa: seperate scale and translate in viewport calculation

Qiang Yu yuq825 at gmail.com
Wed Mar 27 03:41:11 UTC 2019


This is needed in _mesa_fetch_state where scale and translate
are get one by one.

Signed-off-by: Qiang Yu <yuq825 at gmail.com>
---
 src/mesa/main/viewport.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c
index 97d328541b2..c9b1c27f120 100644
--- a/src/mesa/main/viewport.c
+++ b/src/mesa/main/viewport.c
@@ -585,21 +585,19 @@ _mesa_get_viewport_xform(struct gl_context *ctx, unsigned i,
    double n = ctx->ViewportArray[i].Near;
    double f = ctx->ViewportArray[i].Far;
 
-   scale[0] = half_width;
-   translate[0] = half_width + x;
-   if (ctx->Transform.ClipOrigin == GL_UPPER_LEFT) {
-      scale[1] = -half_height;
-   } else {
-      scale[1] = half_height;
+   if (scale) {
+      scale[0] = half_width;
+      scale[1] = ctx->Transform.ClipOrigin == GL_UPPER_LEFT ?
+         -half_height : half_height;
+      scale[2] = ctx->Transform.ClipDepthMode == GL_NEGATIVE_ONE_TO_ONE ?
+         0.5 * (f - n) : f - n;
    }
-   translate[1] = half_height + y;
-
-   if (ctx->Transform.ClipDepthMode == GL_NEGATIVE_ONE_TO_ONE) {
-      scale[2] = 0.5 * (f - n);
-      translate[2] = 0.5 * (n + f);
-   } else {
-      scale[2] = f - n;
-      translate[2] = n;
+
+   if (translate) {
+      translate[0] = half_width + x;
+      translate[1] = half_height + y;
+      translate[2] = ctx->Transform.ClipDepthMode == GL_NEGATIVE_ONE_TO_ONE ?
+         0.5 * (n + f) : n;
    }
 }
 
-- 
2.17.1



More information about the lima mailing list