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 <nicolai.haehnle@amd.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
Marek Olšák
2017-06-09 22:19:33 +02:00
parent ab784e0fee
commit 585c5cf8a5
13 changed files with 42 additions and 3 deletions

View File

@@ -27,6 +27,7 @@
#include "i915_context.h" #include "i915_context.h"
#include "main/api_exec.h" #include "main/api_exec.h"
#include "main/framebuffer.h"
#include "main/imports.h" #include "main/imports.h"
#include "main/macros.h" #include "main/macros.h"
#include "main/version.h" #include "main/version.h"
@@ -62,6 +63,9 @@ i915InvalidateState(struct gl_context * ctx)
_tnl_invalidate_vertex_state(ctx, new_state); _tnl_invalidate_vertex_state(ctx, new_state);
intel_context(ctx)->NewGLState |= 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 /* Todo: gather state values under which tracked parameters become
* invalidated, add callbacks for things like * invalidated, add callbacks for things like
* ProgramLocalParameters, etc. * ProgramLocalParameters, etc.

View File

@@ -324,6 +324,9 @@ intelInvalidateState(struct gl_context * ctx)
intel->NewGLState |= new_state; 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) if (intel->vtbl.invalidate_state)
intel->vtbl.invalidate_state( intel, new_state ); intel->vtbl.invalidate_state( intel, new_state );
} }

View File

@@ -203,6 +203,9 @@ intel_update_state(struct gl_context * ctx)
_mesa_unlock_context_textures(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)) { if (new_state & (_NEW_STENCIL | _NEW_BUFFERS)) {
brw->stencil_enabled = _mesa_stencil_is_enabled(ctx); brw->stencil_enabled = _mesa_stencil_is_enabled(ctx);
brw->stencil_two_sided = _mesa_stencil_is_two_sided(ctx); brw->stencil_two_sided = _mesa_stencil_is_two_sided(ctx);

View File

@@ -32,6 +32,7 @@
#include "swrast/swrast.h" #include "swrast/swrast.h"
#include "tnl/tnl.h" #include "tnl/tnl.h"
#include "util/bitscan.h" #include "util/bitscan.h"
#include "main/framebuffer.h"
static void static void
nouveau_alpha_func(struct gl_context *ctx, GLenum func, GLfloat ref) 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; GLbitfield new_state = ctx->NewState;
int i; 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)) if (new_state & (_NEW_PROJECTION | _NEW_MODELVIEW))
context_dirty(ctx, PROJECTION); context_dirty(ctx, PROJECTION);

View File

@@ -2282,6 +2282,9 @@ static void r200InvalidateState(struct gl_context *ctx)
r200ContextPtr rmesa = R200_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 ); _swrast_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state ); _swsetup_InvalidateState( ctx, new_state );
_tnl_InvalidateState( ctx, new_state ); _tnl_InvalidateState( ctx, new_state );

View File

@@ -2048,6 +2048,9 @@ static void radeonInvalidateState(struct gl_context *ctx)
{ {
GLuint new_state = ctx->NewState; 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 ); _swrast_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state ); _swsetup_InvalidateState( ctx, new_state );
_tnl_InvalidateState( ctx, new_state ); _tnl_InvalidateState( ctx, new_state );

View File

@@ -701,6 +701,9 @@ update_state(struct gl_context *ctx)
{ {
GLuint new_state = ctx->NewState; 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 */ /* not much to do here - pass it on */
_swrast_InvalidateState( ctx, new_state ); _swrast_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state ); _swsetup_InvalidateState( ctx, new_state );

View File

@@ -119,6 +119,9 @@ get_string( struct gl_context *ctx, GLenum name )
static void static void
osmesa_update_state(struct gl_context *ctx, GLuint new_state) 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 */ /* easy - just propogate */
_swrast_InvalidateState( ctx, new_state ); _swrast_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state ); _swsetup_InvalidateState( ctx, new_state );

View File

@@ -684,6 +684,9 @@ xmesa_update_state(struct gl_context *ctx)
GLbitfield new_state = ctx->NewState; GLbitfield new_state = ctx->NewState;
const XMesaContext xmesa = XMESA_CONTEXT(ctx); 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 /* Propagate statechange information to swrast and swrast_setup
* modules. The X11 driver has no internal GL-dependent state. * modules. The X11 driver has no internal GL-dependent state.
*/ */

View File

@@ -28,6 +28,7 @@
#include "context.h" #include "context.h"
#include "format_unpack.h" #include "format_unpack.h"
#include "format_pack.h" #include "format_pack.h"
#include "framebuffer.h"
#include "imports.h" #include "imports.h"
#include "macros.h" #include "macros.h"
#include "state.h" #include "state.h"
@@ -73,6 +74,8 @@ _mesa_clear_accum_buffer(struct gl_context *ctx)
if (!accRb) if (!accRb)
return; /* missing accum buffer, not an error */ return; /* missing accum buffer, not an error */
_mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
/* bounds, with scissor */ /* bounds, with scissor */
x = ctx->DrawBuffer->_Xmin; x = ctx->DrawBuffer->_Xmin;
y = ctx->DrawBuffer->_Ymin; y = ctx->DrawBuffer->_Ymin;
@@ -398,6 +401,8 @@ accum(struct gl_context *ctx, GLenum op, GLfloat value)
if (!_mesa_check_conditional_render(ctx)) if (!_mesa_check_conditional_render(ctx))
return; return;
_mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
xpos = ctx->DrawBuffer->_Xmin; xpos = ctx->DrawBuffer->_Xmin;
ypos = ctx->DrawBuffer->_Ymin; ypos = ctx->DrawBuffer->_Ymin;
width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;

View File

@@ -336,9 +336,6 @@ _mesa_update_state_locked( struct gl_context *ctx )
if (new_state & _NEW_BUFFERS) if (new_state & _NEW_BUFFERS)
_mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer); _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) if (new_state & _NEW_LIGHT)
_mesa_update_lighting( ctx ); _mesa_update_lighting( ctx );

View File

@@ -36,6 +36,7 @@
#include "main/glheader.h" #include "main/glheader.h"
#include "main/accum.h" #include "main/accum.h"
#include "main/formats.h" #include "main/formats.h"
#include "main/framebuffer.h"
#include "main/macros.h" #include "main/macros.h"
#include "main/glformats.h" #include "main/glformats.h"
#include "program/prog_instruction.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 struct gl_framebuffer *fb = ctx->DrawBuffer;
const GLfloat fb_width = (GLfloat) fb->Width; const GLfloat fb_width = (GLfloat) fb->Width;
const GLfloat fb_height = (GLfloat) fb->Height; 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 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 x1 = (GLfloat) ctx->DrawBuffer->_Xmax / fb_width * 2.0f - 1.0f;
const GLfloat y0 = (GLfloat) ctx->DrawBuffer->_Ymin / fb_height * 2.0f - 1.0f; const GLfloat y0 = (GLfloat) ctx->DrawBuffer->_Ymin / fb_height * 2.0f - 1.0f;

View File

@@ -1072,6 +1072,8 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
/* Mesa state should be up to date by now */ /* Mesa state should be up to date by now */
assert(ctx->NewState == 0x0); assert(ctx->NewState == 0x0);
_mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
st_flush_bitmap_cache(st); st_flush_bitmap_cache(st);
st_invalidate_readpix_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; GLint readX, readY, readW, readH;
struct gl_pixelstore_attrib pack = ctx->DefaultPacking; struct gl_pixelstore_attrib pack = ctx->DefaultPacking;
_mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
st_flush_bitmap_cache(st); st_flush_bitmap_cache(st);
st_invalidate_readpix_cache(st); st_invalidate_readpix_cache(st);