mesa: don't update draw buffer bounds in _mesa_update_state
authorMarek Olšák <marek.olsak@amd.com>
Fri, 9 Jun 2017 20:19:33 +0000 (22:19 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 21 Jun 2017 23:51:02 +0000 (01:51 +0200)
st/mesa doesn't need the draw bounds for draw calls. I've added the call
where it's necessary in core Mesa and drivers, but I suspect that most
drivers can just move the call to the right places.

The core Mesa places aren't hot paths, so the call overhead doesn't matter
there.

For now, only st/mesa is made such that this function is invoked very
rarely.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
13 files changed:
src/mesa/drivers/dri/i915/i915_context.c
src/mesa/drivers/dri/i915/intel_context.c
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/nouveau/nouveau_state.c
src/mesa/drivers/dri/r200/r200_state.c
src/mesa/drivers/dri/radeon/radeon_state.c
src/mesa/drivers/dri/swrast/swrast.c
src/mesa/drivers/osmesa/osmesa.c
src/mesa/drivers/x11/xm_dd.c
src/mesa/main/accum.c
src/mesa/main/state.c
src/mesa/state_tracker/st_cb_clear.c
src/mesa/state_tracker/st_cb_drawpixels.c

index 4d89af182d51e9a0c763c122cac873123f7c9c4e..4f6bdb74e7c4507c3132261b6e1ec1a2e5a343bb 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "i915_context.h"
 #include "main/api_exec.h"
+#include "main/framebuffer.h"
 #include "main/imports.h"
 #include "main/macros.h"
 #include "main/version.h"
@@ -62,6 +63,9 @@ i915InvalidateState(struct gl_context * ctx)
    _tnl_invalidate_vertex_state(ctx, new_state);
    intel_context(ctx)->NewGLState |= new_state;
 
+   if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
+      _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
+
    /* Todo: gather state values under which tracked parameters become
     * invalidated, add callbacks for things like
     * ProgramLocalParameters, etc.
index 7f3924573f926850ff55e147f4ea551712c0ac53..e0766a0e3f3a98a13db95e258bb626d1d490d2b4 100644 (file)
@@ -324,6 +324,9 @@ intelInvalidateState(struct gl_context * ctx)
 
    intel->NewGLState |= new_state;
 
+   if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
+      _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
+
    if (intel->vtbl.invalidate_state)
       intel->vtbl.invalidate_state( intel, new_state );
 }
index e9de5b7b238b7f47fb5e791897ed08de27499b09..e921a41c827305e123c90282e742fa57d546b245 100644 (file)
@@ -203,6 +203,9 @@ intel_update_state(struct gl_context * ctx)
 
    _mesa_unlock_context_textures(ctx);
 
+   if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
+      _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
+
    if (new_state & (_NEW_STENCIL | _NEW_BUFFERS)) {
       brw->stencil_enabled = _mesa_stencil_is_enabled(ctx);
       brw->stencil_two_sided = _mesa_stencil_is_two_sided(ctx);
index 6d998fca832d21c39779ac9bff7f0e8e9be58dfa..1aa26e955bf2c30bceab249fd01533e1df38a591 100644 (file)
@@ -32,6 +32,7 @@
 #include "swrast/swrast.h"
 #include "tnl/tnl.h"
 #include "util/bitscan.h"
+#include "main/framebuffer.h"
 
 static void
 nouveau_alpha_func(struct gl_context *ctx, GLenum func, GLfloat ref)
@@ -456,6 +457,9 @@ nouveau_update_state(struct gl_context *ctx)
        GLbitfield new_state = ctx->NewState;
        int i;
 
+       if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
+               _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
+
        if (new_state & (_NEW_PROJECTION | _NEW_MODELVIEW))
                context_dirty(ctx, PROJECTION);
 
index 30437e3201ad36b208419120f1e0c809ea4b39bf..b157572832c722b92fa6eadc652093caf6b6a8b9 100644 (file)
@@ -2282,6 +2282,9 @@ static void r200InvalidateState(struct gl_context *ctx)
 
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
 
+   if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
+      _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
+
    _swrast_InvalidateState( ctx, new_state );
    _swsetup_InvalidateState( ctx, new_state );
    _tnl_InvalidateState( ctx, new_state );
index 940f8de3b48c67791ee4084e036135f1a20c404b..d2ca812155f856a971186066cb3c73afd89aec29 100644 (file)
@@ -2048,6 +2048,9 @@ static void radeonInvalidateState(struct gl_context *ctx)
 {
    GLuint new_state = ctx->NewState;
 
+   if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
+      _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
+
    _swrast_InvalidateState( ctx, new_state );
    _swsetup_InvalidateState( ctx, new_state );
    _tnl_InvalidateState( ctx, new_state );
index 3b1de420f6d6db4964d1d9d681ec08941c5885b8..e66b2257de85e8eea7864175d3e7f79285546988 100644 (file)
@@ -701,6 +701,9 @@ update_state(struct gl_context *ctx)
 {
     GLuint new_state = ctx->NewState;
 
+    if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
+      _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
+
     /* not much to do here - pass it on */
     _swrast_InvalidateState( ctx, new_state );
     _swsetup_InvalidateState( ctx, new_state );
index c77dcc4d37212abebbf6f6f630c141b9a7db82ff..734a4e891cbbb1f5d25bc735b6c471fcc755aa0f 100644 (file)
@@ -119,6 +119,9 @@ get_string( struct gl_context *ctx, GLenum name )
 static void
 osmesa_update_state(struct gl_context *ctx, GLuint new_state)
 {
+   if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
+      _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
+
    /* easy - just propogate */
    _swrast_InvalidateState( ctx, new_state );
    _swsetup_InvalidateState( ctx, new_state );
index 61aa6c88aa36a1ea4036266022bf02a01bdf6755..27534da60c2775a1e18aa2bda3b4ff79c8d7aabb 100644 (file)
@@ -684,6 +684,9 @@ xmesa_update_state(struct gl_context *ctx)
    GLbitfield new_state = ctx->NewState;
    const XMesaContext xmesa = XMESA_CONTEXT(ctx);
 
+   if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
+      _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
+
    /* Propagate statechange information to swrast and swrast_setup
     * modules.  The X11 driver has no internal GL-dependent state.
     */
index c0a3e7ea72ae1e24e0c23ff0cb0ddb20b10c95e3..2b15b6ee0d3a6bea148036bd96054f44e3739f6d 100644 (file)
@@ -28,6 +28,7 @@
 #include "context.h"
 #include "format_unpack.h"
 #include "format_pack.h"
+#include "framebuffer.h"
 #include "imports.h"
 #include "macros.h"
 #include "state.h"
@@ -73,6 +74,8 @@ _mesa_clear_accum_buffer(struct gl_context *ctx)
    if (!accRb)
       return;   /* missing accum buffer, not an error */
 
+   _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
+
    /* bounds, with scissor */
    x = ctx->DrawBuffer->_Xmin;
    y = ctx->DrawBuffer->_Ymin;
@@ -398,6 +401,8 @@ accum(struct gl_context *ctx, GLenum op, GLfloat value)
    if (!_mesa_check_conditional_render(ctx))
       return;
 
+   _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
+
    xpos = ctx->DrawBuffer->_Xmin;
    ypos = ctx->DrawBuffer->_Ymin;
    width =  ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
index 79727983f1f4b39907423e11606f92a6fcb35b72..8df03f075fd4d846c4c7e2c0f79d64431ef92a5e 100644 (file)
@@ -336,9 +336,6 @@ _mesa_update_state_locked( struct gl_context *ctx )
    if (new_state & _NEW_BUFFERS)
       _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
 
-   if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
-      _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
-
    if (new_state & _NEW_LIGHT)
       _mesa_update_lighting( ctx );
 
index 175e2e8a32c60ced306263a513a462471f401df5..cda9c71729cfc594201c4c43f1f05ce4cfffd707 100644 (file)
@@ -36,6 +36,7 @@
 #include "main/glheader.h"
 #include "main/accum.h"
 #include "main/formats.h"
+#include "main/framebuffer.h"
 #include "main/macros.h"
 #include "main/glformats.h"
 #include "program/prog_instruction.h"
@@ -179,6 +180,9 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers)
    const struct gl_framebuffer *fb = ctx->DrawBuffer;
    const GLfloat fb_width = (GLfloat) fb->Width;
    const GLfloat fb_height = (GLfloat) fb->Height;
+
+   _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
+
    const GLfloat x0 = (GLfloat) ctx->DrawBuffer->_Xmin / fb_width * 2.0f - 1.0f;
    const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax / fb_width * 2.0f - 1.0f;
    const GLfloat y0 = (GLfloat) ctx->DrawBuffer->_Ymin / fb_height * 2.0f - 1.0f;
index 33d10f67e26fa990ba4652113a74092d30b5632c..092b418122510af1d9eaeb860d7a0435eab3c96a 100644 (file)
@@ -1072,6 +1072,8 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
    /* Mesa state should be up to date by now */
    assert(ctx->NewState == 0x0);
 
+   _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
+
    st_flush_bitmap_cache(st);
    st_invalidate_readpix_cache(st);
 
@@ -1437,6 +1439,8 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
    GLint readX, readY, readW, readH;
    struct gl_pixelstore_attrib pack = ctx->DefaultPacking;
 
+   _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
+
    st_flush_bitmap_cache(st);
    st_invalidate_readpix_cache(st);