st/mesa: don't update unrelated states in non-draw calls such as Clear
authorMarek Olšák <marek.olsak@amd.com>
Wed, 22 Feb 2017 18:59:27 +0000 (19:59 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 24 Feb 2017 23:03:09 +0000 (00:03 +0100)
If a VAO isn't bound and u_vbuf isn't enabled because of the Core profile,
we'll get user vertex buffers in drivers if we update vertex buffers
in glClear. So don't do that.

This fixes a regression since disabling u_vbuf for Core profiles.

Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/state_tracker/st_atom.c
src/mesa/state_tracker/st_atom.h
src/mesa/state_tracker/st_cb_clear.c
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_cb_msaa.c
src/mesa/state_tracker/st_cb_readpixels.c

index 65ac5170fdf53643a2ac6f5b827dafc9d6395731..4bef3423b07870b49373f20b9bcb8bad81e6dd19 100644 (file)
@@ -176,6 +176,16 @@ void st_validate_state( struct st_context *st, enum st_pipeline pipeline )
       pipeline_mask = ST_PIPELINE_RENDER_STATE_MASK;
       break;
 
+   case ST_PIPELINE_CLEAR:
+      st_manager_validate_framebuffers(st);
+      pipeline_mask = ST_PIPELINE_CLEAR_STATE_MASK;
+      break;
+
+   case ST_PIPELINE_UPDATE_FRAMEBUFFER:
+      st_manager_validate_framebuffers(st);
+      pipeline_mask = ST_PIPELINE_UPDATE_FB_STATE_MASK;
+      break;
+
    case ST_PIPELINE_COMPUTE: {
       struct st_compute_program *old_cp = st->cp;
       struct gl_program *new_cp = ctx->ComputeProgram._Current;
index 37e382c445679ce8d5075b40aad49337bfce5d45..45c3e4876471684c7b6df9714779d4b1f0173032 100644 (file)
@@ -43,6 +43,8 @@ struct st_context;
  */
 enum st_pipeline {
    ST_PIPELINE_RENDER,
+   ST_PIPELINE_CLEAR,
+   ST_PIPELINE_UPDATE_FRAMEBUFFER,
    ST_PIPELINE_COMPUTE,
 };
 
@@ -145,6 +147,11 @@ enum {
 /* All state flags within each group: */
 #define ST_PIPELINE_RENDER_STATE_MASK  (ST_NEW_CS_STATE - 1)
 #define ST_PIPELINE_COMPUTE_STATE_MASK (0xffllu << ST_NEW_CS_STATE_INDEX)
+#define ST_PIPELINE_CLEAR_STATE_MASK (ST_NEW_FB_STATE | \
+                                      ST_NEW_SCISSOR | \
+                                      ST_NEW_WINDOW_RECTANGLES)
+/* For ReadPixels, ReadBuffer, GetSamplePosition: */
+#define ST_PIPELINE_UPDATE_FB_STATE_MASK (ST_NEW_FB_STATE)
 
 #define ST_ALL_STATES_MASK (ST_PIPELINE_RENDER_STATE_MASK | \
                             ST_PIPELINE_COMPUTE_STATE_MASK)
index 158efc186c050a0112e18f566ea4172feac89062..f507775da20efe6b20591b46259705c122fe3391 100644 (file)
@@ -406,7 +406,7 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
    st_invalidate_readpix_cache(st);
 
    /* This makes sure the pipe has the latest scissor, etc values */
-   st_validate_state( st, ST_PIPELINE_RENDER );
+   st_validate_state(st, ST_PIPELINE_CLEAR);
 
    if (mask & BUFFER_BITS_COLOR) {
       for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
index d762ca660a42f507e563f7af4d375cf753803735..78433bff046626548c55d959cadbb90c19c3cde8 100644 (file)
@@ -734,7 +734,7 @@ st_ReadBuffer(struct gl_context *ctx, GLenum buffer)
       /* add the buffer */
       st_manager_add_color_renderbuffer(st, fb, fb->_ColorReadBufferIndex);
       _mesa_update_state(ctx);
-      st_validate_state(st, ST_PIPELINE_RENDER);
+      st_validate_state(st, ST_PIPELINE_UPDATE_FRAMEBUFFER);
    }
 }
 
index 22001e499736e7345ac5abd774c27ebf4a685fbf..7f1b4fde91d433cf86f123a5e838ff3fa3866a92 100644 (file)
@@ -45,7 +45,7 @@ st_GetSamplePosition(struct gl_context *ctx,
 {
    struct st_context *st = st_context(ctx);
 
-   st_validate_state(st, ST_PIPELINE_RENDER);
+   st_validate_state(st, ST_PIPELINE_UPDATE_FRAMEBUFFER);
 
    if (st->pipe->get_sample_position)
       st->pipe->get_sample_position(st->pipe,
index 78ea0c7bf8ccaf2c438b638eea2b8701945a02cc..795519d0a7e2a2a6f30acaebeaba879b25327670 100644 (file)
@@ -422,7 +422,7 @@ st_ReadPixels(struct gl_context *ctx, GLint x, GLint y,
 
    /* Validate state (to be sure we have up-to-date framebuffer surfaces)
     * and flush the bitmap cache prior to reading. */
-   st_validate_state(st, ST_PIPELINE_RENDER);
+   st_validate_state(st, ST_PIPELINE_UPDATE_FRAMEBUFFER);
    st_flush_bitmap_cache(st);
 
    if (!st->prefer_blit_based_texture_transfer) {