diff options
author | Marek Olšák <[email protected]> | 2017-06-09 22:19:33 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-06-22 01:51:02 +0200 |
commit | 585c5cf8a514783d9ed31dba3aa432797dd5f0e8 (patch) | |
tree | 498d2a9bf82c35ab7caf86fe09ab9b8a97fc0ecf /src | |
parent | ab784e0feeaa6af46afc5ee6ce3527324de29dea (diff) |
mesa: don't update draw buffer bounds in _mesa_update_state
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 <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/i915/i915_context.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915/intel_context.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nouveau_state.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_state.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_state.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/swrast/swrast.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/osmesa/osmesa.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_dd.c | 3 | ||||
-rw-r--r-- | src/mesa/main/accum.c | 5 | ||||
-rw-r--r-- | src/mesa/main/state.c | 3 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_clear.c | 4 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_drawpixels.c | 4 |
13 files changed, 42 insertions, 3 deletions
diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c index 4d89af182d5..4f6bdb74e7c 100644 --- a/src/mesa/drivers/dri/i915/i915_context.c +++ b/src/mesa/drivers/dri/i915/i915_context.c @@ -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. diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c index 7f3924573f9..e0766a0e3f3 100644 --- a/src/mesa/drivers/dri/i915/intel_context.c +++ b/src/mesa/drivers/dri/i915/intel_context.c @@ -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 ); } diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index e9de5b7b238..e921a41c827 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -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); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c index 6d998fca832..1aa26e955bf 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c @@ -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); diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c index 30437e3201a..b157572832c 100644 --- a/src/mesa/drivers/dri/r200/r200_state.c +++ b/src/mesa/drivers/dri/r200/r200_state.c @@ -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 ); diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c index 940f8de3b48..d2ca812155f 100644 --- a/src/mesa/drivers/dri/radeon/radeon_state.c +++ b/src/mesa/drivers/dri/radeon/radeon_state.c @@ -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 ); diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index 3b1de420f6d..e66b2257de8 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -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 ); diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index c77dcc4d372..734a4e891cb 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -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 ); diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index 61aa6c88aa3..27534da60c2 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -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. */ diff --git a/src/mesa/main/accum.c b/src/mesa/main/accum.c index c0a3e7ea72a..2b15b6ee0d3 100644 --- a/src/mesa/main/accum.c +++ b/src/mesa/main/accum.c @@ -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; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 79727983f1f..8df03f075fd 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -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 ); diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 175e2e8a32c..cda9c71729c 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -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; diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 33d10f67e26..092b4181225 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -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); |