[Lima] [PATCH 2/4] mesa: add STATE_VIEWPORT_SCALE/TRANSLATE

Qiang Yu yuq825 at gmail.com
Wed Mar 27 03:53:32 UTC 2019


Signed-off-by: Qiang Yu <yuq825 at gmail.com>
---
 src/mesa/program/prog_statevars.c | 35 +++++++++++++++++++++++++++++++
 src/mesa/program/prog_statevars.h |  2 ++
 2 files changed, 37 insertions(+)

diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c
index 3bbe451399f..ce74dbe317d 100644
--- a/src/mesa/program/prog_statevars.c
+++ b/src/mesa/program/prog_statevars.c
@@ -41,6 +41,7 @@
 #include "prog_parameter.h"
 #include "main/samplerobj.h"
 #include "main/framebuffer.h"
+#include "main/viewport.h"
 
 
 #define ONE_DIV_SQRT_LN2 (1.201122408786449815)
@@ -602,6 +603,30 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index16 state[],
                       ctx->Color.BlendEnabled, ctx->Color._AdvancedBlendMode);
          return;
 
+      case STATE_VIEWPORT_SCALE:
+         {
+            float scale[3];
+            _mesa_get_viewport_xform(ctx, 0, scale, NULL);
+            if (_mesa_is_winsys_fbo(ctx->DrawBuffer))
+               scale[1] = -scale[1];
+            value[0] = scale[0];
+            value[1] = scale[1];
+            value[2] = scale[2];
+            return;
+         }
+
+      case STATE_VIEWPORT_TRANSLATE:
+         {
+            float translate[3];
+            _mesa_get_viewport_xform(ctx, 0, NULL, translate);
+            if (_mesa_is_winsys_fbo(ctx->DrawBuffer))
+               translate[1] = (GLfloat)ctx->DrawBuffer->Height - translate[1];
+            value[0] = translate[0];
+            value[1] = translate[1];
+            value[2] = translate[2];
+            return;
+         }
+
       /* XXX: make sure new tokens added here are also handled in the 
        * _mesa_program_state_flags() switch, below.
        */
@@ -713,6 +738,10 @@ _mesa_program_state_flags(const gl_state_index16 state[STATE_LENGTH])
       case STATE_ADVANCED_BLENDING_MODE:
          return _NEW_COLOR;
 
+      case STATE_VIEWPORT_SCALE:
+      case STATE_VIEWPORT_TRANSLATE:
+         return _NEW_BUFFERS | _NEW_VIEWPORT | _NEW_TRANSFORM;
+
       default:
          /* unknown state indexes are silently ignored and
          *  no flag set, since it is handled by the driver.
@@ -919,6 +948,12 @@ append_token(char *dst, gl_state_index k)
    case STATE_ADVANCED_BLENDING_MODE:
       append(dst, "AdvancedBlendingMode");
       break;
+   case STATE_VIEWPORT_SCALE:
+      append(dst, "viewportScale");
+      break;
+   case STATE_VIEWPORT_TRANSLATE:
+      append(dst, "viewportTranslate");
+      break;
    default:
       /* probably STATE_INTERNAL_DRIVER+i (driver private state) */
       append(dst, "driverState");
diff --git a/src/mesa/program/prog_statevars.h b/src/mesa/program/prog_statevars.h
index f28d2bb4a37..0d7a255b8ee 100644
--- a/src/mesa/program/prog_statevars.h
+++ b/src/mesa/program/prog_statevars.h
@@ -129,6 +129,8 @@ typedef enum gl_state_index_ {
     * currently active advanced blending equation, or zero if disabled.
     */
    STATE_ADVANCED_BLENDING_MODE,
+   STATE_VIEWPORT_SCALE,
+   STATE_VIEWPORT_TRANSLATE,
    STATE_INTERNAL_DRIVER	/* first available state index for drivers (must be last) */
 } gl_state_index;
 
-- 
2.17.1



More information about the lima mailing list