mesa: don't flag _NEW_VIEWPORT for st/mesa if possible
authorMarek Olšák <marek.olsak@amd.com>
Sat, 10 Jun 2017 00:39:06 +0000 (02:39 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 21 Jun 2017 23:51:02 +0000 (01:51 +0200)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/main/mtypes.h
src/mesa/main/viewport.c
src/mesa/state_tracker/st_context.c

index c4e67353e9f4431450d954395fdbe756b526c6a4..59292f0c8a45866442af5d64bdf29e6962def05e 100644 (file)
@@ -4507,6 +4507,12 @@ struct gl_driver_flags
 
    /** gl_context::Stencil */
    uint64_t NewStencil;
+
+   /** gl_context::Transform::Clip* */
+   uint64_t NewClipControl;
+
+   /** gl_context::ViewportArray */
+   uint64_t NewViewport;
 };
 
 struct gl_uniform_buffer_binding
index 6d3e57654ccf0a72c60fc1c962d0e478a6de1808..51ae6692f7b6a88bc1e4af7b42eedabe70858aad 100644 (file)
@@ -40,7 +40,8 @@ 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);
@@ -241,7 +242,9 @@ set_depth_range_no_notify(struct gl_context *ctx, unsigned idx,
        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);
@@ -449,7 +452,9 @@ _mesa_ClipControl(GLenum origin, GLenum 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;
index 23e3768373fb33dfb3036a02e38b48d51698a93c..c5f46aedb456253f6519f5e46c9f2b080caa8a35 100644 (file)
@@ -202,9 +202,6 @@ st_invalidate_state(struct gl_context * ctx)
       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;
@@ -524,6 +521,9 @@ static void st_init_driver_flags(struct st_context *st)
    } 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,