It would be great if you could put a comment on the new function explaining what it's doing. Many readers would not know why invalidating framebuffer state requires invalidating all that other state.

Thanks.

-Brian


On 06/07/2017 12:02 AM, Timothy Arceri wrote:
---
  src/mesa/state_tracker/st_cb_fbo.c  |  5 +++--
  src/mesa/state_tracker/st_context.c | 15 +++------------
  src/mesa/state_tracker/st_context.h | 16 +++++++++++++++-
  src/mesa/state_tracker/st_manager.c |  2 +-
  4 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_fbo.c 
b/src/mesa/state_tracker/st_cb_fbo.c
index f908225..d23cec8 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -500,45 +500,46 @@ st_render_texture(struct gl_context *ctx,
     strb->rtt_layered = att->Layered;
     pipe_resource_reference(&strb->texture, pt);

     st_update_renderbuffer_surface(st, strb);

     /* Invalidate buffer state so that the pipe's framebuffer state
      * gets updated.
      * That's where the new renderbuffer (which we just created) gets
      * passed to the pipe as a (color/depth) render target.
      */
-   st_invalidate_state(ctx, _NEW_BUFFERS);
+   st_invalidate_buffers(st);


     /* Need to trigger a call to update_framebuffer() since we just
      * attached a new renderbuffer.
      */
     ctx->NewState |= _NEW_BUFFERS;
  }


  /**
   * Called via ctx->Driver.FinishRenderTexture.
   */
  static void
  st_finish_render_texture(struct gl_context *ctx, struct gl_renderbuffer *rb)
  {
+   struct st_context *st = st_context(ctx);
     struct st_renderbuffer *strb = st_renderbuffer(rb);

     if (!strb)
        return;

     strb->is_rtt = FALSE;

     /* restore previous framebuffer state */
-   st_invalidate_state(ctx, _NEW_BUFFERS);
+   st_invalidate_buffers(st);
  }


  /** Debug helper */
  static void
  st_fbo_invalid(const char *reason)
  {
     if (MESA_DEBUG_FLAGS & DEBUG_INCOMPLETE_FBO) {
        _mesa_debug(NULL, "Invalid FBO: %s\n", reason);
     }
diff --git a/src/mesa/state_tracker/st_context.c 
b/src/mesa/state_tracker/st_context.c
index c901764..3207e95 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -157,36 +157,27 @@ st_get_active_states(struct gl_context *ctx)
        active_shader_states |= cp->affected_states;

     /* Mark non-shader-resource shader states as "always active". */
     return active_shader_states | ~ST_ALL_SHADER_RESOURCES;
  }


  /**
   * Called via ctx->Driver.UpdateState()
   */
-void st_invalidate_state(struct gl_context * ctx, GLbitfield new_state)
+static void
+st_invalidate_state(struct gl_context * ctx, GLbitfield new_state)
  {
     struct st_context *st = st_context(ctx);

     if (new_state & _NEW_BUFFERS) {
-      st->dirty |= ST_NEW_BLEND |
-                   ST_NEW_DSA |
-                   ST_NEW_FB_STATE |
-                   ST_NEW_SAMPLE_MASK |
-                   ST_NEW_SAMPLE_SHADING |
-                   ST_NEW_FS_STATE |
-                   ST_NEW_POLY_STIPPLE |
-                   ST_NEW_VIEWPORT |
-                   ST_NEW_RASTERIZER |
-                   ST_NEW_SCISSOR |
-                   ST_NEW_WINDOW_RECTANGLES;
+      st_invalidate_buffers(st);
     } else {
        /* These set a subset of flags set by _NEW_BUFFERS, so we only have to
         * check them when _NEW_BUFFERS isn't set.
         */
        if (new_state & (_NEW_DEPTH |
                         _NEW_STENCIL))
           st->dirty |= ST_NEW_DSA;

        if (new_state & _NEW_PROGRAM)
           st->dirty |= ST_NEW_RASTERIZER;
diff --git a/src/mesa/state_tracker/st_context.h 
b/src/mesa/state_tracker/st_context.h
index 520cd8d..dd38a7f 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -295,21 +295,35 @@ struct st_framebuffer
     enum st_attachment_type statts[ST_ATTACHMENT_COUNT];
     unsigned num_statts;
     int32_t stamp;
     int32_t iface_stamp;
  };


  extern void st_init_driver_functions(struct pipe_screen *screen,
                                       struct dd_function_table *functions);

-void st_invalidate_state(struct gl_context * ctx, GLbitfield new_state);
+static inline void
+st_invalidate_buffers(struct st_context *st)
+{
+   st->dirty |= ST_NEW_BLEND |
+                ST_NEW_DSA |
+                ST_NEW_FB_STATE |
+                ST_NEW_SAMPLE_MASK |
+                ST_NEW_SAMPLE_SHADING |
+                ST_NEW_FS_STATE |
+                ST_NEW_POLY_STIPPLE |
+                ST_NEW_VIEWPORT |
+                ST_NEW_RASTERIZER |
+                ST_NEW_SCISSOR |
+                ST_NEW_WINDOW_RECTANGLES;
+}

  /* Invalidate the readpixels cache to ensure we don't read stale data.
   */
  static inline void
  st_invalidate_readpix_cache(struct st_context *st)
  {
     if (unlikely(st->readpix_cache.src)) {
        pipe_resource_reference(&st->readpix_cache.src, NULL);
        pipe_resource_reference(&st->readpix_cache.cache, NULL);
     }
diff --git a/src/mesa/state_tracker/st_manager.c 
b/src/mesa/state_tracker/st_manager.c
index cc781f4..b8abd76 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -899,21 +899,21 @@ st_manager_add_color_renderbuffer(struct st_context *st,
     st_framebuffer_update_attachments(stfb);

     /*
      * Force a call to the state tracker manager to validate the
      * new renderbuffer. It might be that there is a window system
      * renderbuffer available.
      */
     if (stfb->iface)
        stfb->iface_stamp = p_atomic_read(&stfb->iface->stamp) - 1;

-   st_invalidate_state(st->ctx, _NEW_BUFFERS);
+   st_invalidate_buffers(st);

     return TRUE;
  }

  static unsigned
  get_version(struct pipe_screen *screen,
              struct st_config_options *options, gl_api api)
  {
     struct gl_constants consts = {0};
     struct gl_extensions extensions = {0};


_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to