[Mesa-dev] [PATCH 19/31] mesa: don't flag _NEW_VIEWPORT for st/mesa if possible

Marek Olšák maraeo at gmail.com
Mon Jun 12 16:55:44 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

---
 src/mesa/main/mtypes.h              | 6 ++++++
 src/mesa/main/viewport.c            | 9 +++++++--
 src/mesa/state_tracker/st_context.c | 6 +++---
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 6fdd0fd..55682e2 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4428,20 +4428,26 @@ struct gl_driver_flags
    uint64_t NewSampleAlphaToXEnable;
 
    /** gl_context::Multisample::SampleCoverage/SampleMaskValue */
    uint64_t NewSampleMask;
 
    /** gl_context::Multisample::(Min)SampleShading */
    uint64_t NewSampleShading;
 
    /** gl_context::Stencil */
    uint64_t NewStencil;
+
+   /** gl_context::Transform::Clip* */
+   uint64_t NewClipControl;
+
+   /** gl_context::ViewportArray */
+   uint64_t NewViewport;
 };
 
 struct gl_uniform_buffer_binding
 {
    struct gl_buffer_object *BufferObject;
    /** Start of uniform block data in the buffer */
    GLintptr Offset;
    /** Size of data allowed to be referenced from the buffer (in bytes) */
    GLsizeiptr Size;
    /**
diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c
index 6d3e576..51ae669 100644
--- a/src/mesa/main/viewport.c
+++ b/src/mesa/main/viewport.c
@@ -33,21 +33,22 @@
 #include "enums.h"
 #include "macros.h"
 #include "mtypes.h"
 #include "viewport.h"
 
 static void
 set_viewport_no_notify(struct gl_context *ctx, unsigned idx,
                        GLfloat x, GLfloat y,
                        GLfloat width, GLfloat height)
 {
-   FLUSH_VERTICES(ctx, _NEW_VIEWPORT);
+   FLUSH_VERTICES(ctx, ctx->DriverFlags.NewViewport ? 0 : _NEW_VIEWPORT);
+   ctx->NewDriverState |= ctx->DriverFlags.NewViewport;
 
    /* clamp width and height to the implementation dependent range */
    width  = MIN2(width, (GLfloat) ctx->Const.MaxViewportWidth);
    height = MIN2(height, (GLfloat) ctx->Const.MaxViewportHeight);
 
    /* The GL_ARB_viewport_array spec says:
     *
     *     "The location of the viewport's bottom-left corner, given by (x,y),
     *     are clamped to be within the implementation-dependent viewport
     *     bounds range.  The viewport bounds range [min, max] tuple may be
@@ -234,21 +235,23 @@ _mesa_ViewportIndexedfv(GLuint index, const GLfloat *v)
 }
 
 static void
 set_depth_range_no_notify(struct gl_context *ctx, unsigned idx,
                           GLclampd nearval, GLclampd farval)
 {
    if (ctx->ViewportArray[idx].Near == nearval &&
        ctx->ViewportArray[idx].Far == farval)
       return;
 
+   /* The depth range is needed by program state constants. */
    FLUSH_VERTICES(ctx, _NEW_VIEWPORT);
+   ctx->NewDriverState |= ctx->DriverFlags.NewViewport;
 
    ctx->ViewportArray[idx].Near = CLAMP(nearval, 0.0, 1.0);
    ctx->ViewportArray[idx].Far = CLAMP(farval, 0.0, 1.0);
 }
 
 void
 _mesa_set_depth_range(struct gl_context *ctx, unsigned idx,
                       GLclampd nearval, GLclampd farval)
 {
    set_depth_range_no_notify(ctx, idx, nearval, farval);
@@ -442,21 +445,23 @@ _mesa_ClipControl(GLenum origin, GLenum depth)
    if (depth != GL_NEGATIVE_ONE_TO_ONE && depth != GL_ZERO_TO_ONE) {
       _mesa_error(ctx, GL_INVALID_ENUM, "glClipControl");
       return;
    }
 
    if (ctx->Transform.ClipOrigin == origin &&
        ctx->Transform.ClipDepthMode == depth)
       return;
 
    /* Affects transform state and the viewport transform */
-   FLUSH_VERTICES(ctx, _NEW_TRANSFORM | _NEW_VIEWPORT);
+   FLUSH_VERTICES(ctx, ctx->DriverFlags.NewClipControl ? 0 :
+                                          _NEW_TRANSFORM | _NEW_VIEWPORT);
+   ctx->NewDriverState |= ctx->DriverFlags.NewClipControl;
 
    if (ctx->Transform.ClipOrigin != origin) {
       ctx->Transform.ClipOrigin = origin;
 
       /* Affects the winding order of the front face. */
       ctx->NewState |= _NEW_POLYGON;
 
       if (ctx->Driver.FrontFace)
          ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace);
    }
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index bb06853..357b838 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -195,23 +195,20 @@ st_invalidate_state(struct gl_context * ctx)
        */
       if (new_state & _NEW_PROGRAM)
          st->dirty |= ST_NEW_RASTERIZER;
 
       if (new_state & _NEW_FOG)
          st->dirty |= ST_NEW_FS_STATE;
 
       if (new_state & _NEW_POLYGONSTIPPLE)
          st->dirty |= ST_NEW_POLY_STIPPLE;
 
-      if (new_state & _NEW_VIEWPORT)
-         st->dirty |= ST_NEW_VIEWPORT;
-
       if (new_state & _NEW_FRAG_CLAMP) {
          if (st->clamp_frag_color_in_shader)
             st->dirty |= ST_NEW_FS_STATE;
          else
             st->dirty |= ST_NEW_RASTERIZER;
       }
    }
 
    if (new_state & (_NEW_LIGHT |
                     _NEW_LINE |
@@ -515,20 +512,23 @@ static void st_init_driver_flags(struct st_context *st)
    f->NewSampleMask = ST_NEW_SAMPLE_MASK;
    f->NewSampleShading = ST_NEW_SAMPLE_SHADING;
 
    /* This depends on what the gallium driver wants. */
    if (st->force_persample_in_shader) {
       f->NewMultisampleEnable |= ST_NEW_FS_STATE;
       f->NewSampleShading |= ST_NEW_FS_STATE;
    } else {
       f->NewSampleShading |= ST_NEW_RASTERIZER;
    }
+
+   f->NewClipControl = ST_NEW_VIEWPORT | ST_NEW_RASTERIZER;
+   f->NewViewport = ST_NEW_VIEWPORT;
 }
 
 struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
                                      const struct gl_config *visual,
                                      struct st_context *share,
                                      const struct st_config_options *options)
 {
    struct gl_context *ctx;
    struct gl_context *shareCtx = share ? share->ctx : NULL;
    struct dd_function_table funcs;
-- 
2.7.4



More information about the mesa-dev mailing list