[Mesa-dev] [PATCH 6/8] mesa: inline vbo_exec_invalidate_state() and call from mesa core
Samuel Pitoiset
samuel.pitoiset at gmail.com
Wed Jun 7 08:16:14 UTC 2017
Nice cleanup!
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
On 06/07/2017 08:02 AM, Timothy Arceri wrote:
> Rather than calling it indirectly in each driver.
> ---
> src/mesa/drivers/dri/i915/i915_context.c | 1 -
> src/mesa/drivers/dri/i915/intel_context.c | 1 -
> src/mesa/drivers/dri/i965/brw_context.c | 1 -
> src/mesa/drivers/dri/nouveau/nouveau_state.c | 1 -
> src/mesa/drivers/dri/r200/r200_state.c | 1 -
> src/mesa/drivers/dri/radeon/radeon_state.c | 1 -
> src/mesa/drivers/dri/swrast/swrast.c | 1 -
> src/mesa/drivers/osmesa/osmesa.c | 1 -
> src/mesa/drivers/x11/xm_dd.c | 1 -
> src/mesa/main/state.c | 5 ++++-
> src/mesa/state_tracker/st_context.c | 5 -----
> src/mesa/vbo/vbo.h | 1 -
> src/mesa/vbo/vbo_context.c | 6 ------
> src/mesa/vbo/vbo_context.h | 18 ++++++++++++++++++
> src/mesa/vbo/vbo_exec.c | 22 ----------------------
> src/mesa/vbo/vbo_exec.h | 1 -
> 16 files changed, 22 insertions(+), 45 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c
> index 1406b65..4d89af1 100644
> --- a/src/mesa/drivers/dri/i915/i915_context.c
> +++ b/src/mesa/drivers/dri/i915/i915_context.c
> @@ -51,21 +51,20 @@
>
> /* Override intel default.
> */
> static void
> i915InvalidateState(struct gl_context * ctx)
> {
> GLuint new_state = ctx->NewState;
>
> _swrast_InvalidateState(ctx, new_state);
> _swsetup_InvalidateState(ctx, new_state);
> - _vbo_InvalidateState(ctx, new_state);
> _tnl_InvalidateState(ctx, new_state);
> _tnl_invalidate_vertex_state(ctx, new_state);
> intel_context(ctx)->NewGLState |= new_state;
>
> /* Todo: gather state values under which tracked parameters become
> * invalidated, add callbacks for things like
> * ProgramLocalParameters, etc.
> */
> {
> struct i915_fragment_program *p =
> diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c
> index 6c59b42..7f39245 100644
> --- a/src/mesa/drivers/dri/i915/intel_context.c
> +++ b/src/mesa/drivers/dri/i915/intel_context.c
> @@ -314,21 +314,20 @@ static const struct debug_control debug_control[] = {
>
>
> static void
> intelInvalidateState(struct gl_context * ctx)
> {
> GLuint new_state = ctx->NewState;
> struct intel_context *intel = intel_context(ctx);
>
> if (ctx->swrast_context)
> _swrast_InvalidateState(ctx, new_state);
> - _vbo_InvalidateState(ctx, new_state);
>
> intel->NewGLState |= new_state;
>
> if (intel->vtbl.invalidate_state)
> intel->vtbl.invalidate_state( intel, new_state );
> }
>
> void
> intel_flush_rendering_to_batch(struct gl_context *ctx)
> {
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
> index 8525d53..2cdd9ba 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -224,21 +224,20 @@ intel_texture_view_requires_resolve(struct brw_context *brw,
> static void
> intel_update_state(struct gl_context * ctx)
> {
> GLuint new_state = ctx->NewState;
> struct brw_context *brw = brw_context(ctx);
> struct intel_texture_object *tex_obj;
> struct intel_renderbuffer *depth_irb;
>
> if (ctx->swrast_context)
> _swrast_InvalidateState(ctx, new_state);
> - _vbo_InvalidateState(ctx, new_state);
>
> brw->NewGLState |= new_state;
>
> _mesa_unlock_context_textures(ctx);
>
> /* Resolve the depth buffer's HiZ buffer. */
> depth_irb = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_DEPTH);
> if (depth_irb)
> intel_renderbuffer_resolve_hiz(brw, depth_irb);
>
> diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c
> index 567f32f..6d998fc 100644
> --- a/src/mesa/drivers/dri/nouveau/nouveau_state.c
> +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c
> @@ -487,21 +487,20 @@ nouveau_update_state(struct gl_context *ctx)
>
> if (new_state & _NEW_TEXTURE) {
> for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
> if (ctx->Texture.Unit[i].Sampler)
> context_dirty_i(ctx, TEX_OBJ, i);
> }
> }
>
> _swrast_InvalidateState(ctx, new_state);
> _tnl_InvalidateState(ctx, new_state);
> - _vbo_InvalidateState(ctx, new_state);
>
> nouveau_state_emit(ctx);
> }
>
> void
> nouveau_state_init(struct gl_context *ctx)
> {
> struct nouveau_context *nctx = to_nouveau_context(ctx);
>
> ctx->Driver.AlphaFunc = nouveau_alpha_func;
> diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c
> index d5a6f09..30437e3 100644
> --- a/src/mesa/drivers/dri/r200/r200_state.c
> +++ b/src/mesa/drivers/dri/r200/r200_state.c
> @@ -2277,21 +2277,20 @@ GLboolean r200ValidateState( struct gl_context *ctx )
>
>
> static void r200InvalidateState(struct gl_context *ctx)
> {
> GLuint new_state = ctx->NewState;
>
> r200ContextPtr rmesa = R200_CONTEXT(ctx);
>
> _swrast_InvalidateState( ctx, new_state );
> _swsetup_InvalidateState( ctx, new_state );
> - _vbo_InvalidateState( ctx, new_state );
> _tnl_InvalidateState( ctx, new_state );
> R200_CONTEXT(ctx)->radeon.NewGLState |= new_state;
>
> if (new_state & _NEW_PROGRAM)
> rmesa->curr_vp_hw = NULL;
> }
>
> /* A hack. The r200 can actually cope just fine with materials
> * between begin/ends, so fix this.
> * Should map to inputs just like the generic vertex arrays for vertex progs.
> diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c
> index ff2a708..940f8de 100644
> --- a/src/mesa/drivers/dri/radeon/radeon_state.c
> +++ b/src/mesa/drivers/dri/radeon/radeon_state.c
> @@ -2043,21 +2043,20 @@ GLboolean radeonValidateState( struct gl_context *ctx )
> return GL_TRUE;
> }
>
>
> static void radeonInvalidateState(struct gl_context *ctx)
> {
> GLuint new_state = ctx->NewState;
>
> _swrast_InvalidateState( ctx, new_state );
> _swsetup_InvalidateState( ctx, new_state );
> - _vbo_InvalidateState( ctx, new_state );
> _tnl_InvalidateState( ctx, new_state );
> R100_CONTEXT(ctx)->radeon.NewGLState |= new_state;
> }
>
>
> /* A hack. Need a faster way to find this out.
> */
> static GLboolean check_material( struct gl_context *ctx )
> {
> TNLcontext *tnl = TNL_CONTEXT(ctx);
> diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c
> index a68f7a0..3b1de42 100644
> --- a/src/mesa/drivers/dri/swrast/swrast.c
> +++ b/src/mesa/drivers/dri/swrast/swrast.c
> @@ -697,21 +697,20 @@ get_string(struct gl_context *ctx, GLenum pname)
> }
>
> static void
> update_state(struct gl_context *ctx)
> {
> GLuint new_state = ctx->NewState;
>
> /* not much to do here - pass it on */
> _swrast_InvalidateState( ctx, new_state );
> _swsetup_InvalidateState( ctx, new_state );
> - _vbo_InvalidateState( ctx, new_state );
> _tnl_InvalidateState( ctx, new_state );
> }
>
> static void
> viewport(struct gl_context *ctx)
> {
> struct gl_framebuffer *draw = ctx->WinSysDrawBuffer;
> struct gl_framebuffer *read = ctx->WinSysReadBuffer;
>
> swrast_check_and_update_window_size(ctx, draw);
> diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
> index 759f6ae..16d731f 100644
> --- a/src/mesa/drivers/osmesa/osmesa.c
> +++ b/src/mesa/drivers/osmesa/osmesa.c
> @@ -118,21 +118,20 @@ get_string( struct gl_context *ctx, GLenum name )
>
> static void
> osmesa_update_state(struct gl_context *ctx)
> {
> GLuint new_state = ctx->NewState;
>
> /* easy - just propogate */
> _swrast_InvalidateState( ctx, new_state );
> _swsetup_InvalidateState( ctx, new_state );
> _tnl_InvalidateState( ctx, new_state );
> - _vbo_InvalidateState( ctx, new_state );
> }
>
>
>
> /**
> * Macros for optimized line/triangle rendering.
> * Only for 8-bit channel, RGBA, BGRA, ARGB formats.
> */
>
> #define PACK_RGBA(DST, R, G, B, A) \
> diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c
> index e06831c..61aa6c8 100644
> --- a/src/mesa/drivers/x11/xm_dd.c
> +++ b/src/mesa/drivers/x11/xm_dd.c
> @@ -682,21 +682,20 @@ static void
> xmesa_update_state(struct gl_context *ctx)
> {
> GLbitfield new_state = ctx->NewState;
> const XMesaContext xmesa = XMESA_CONTEXT(ctx);
>
> /* Propagate statechange information to swrast and swrast_setup
> * modules. The X11 driver has no internal GL-dependent state.
> */
> _swrast_InvalidateState( ctx, new_state );
> _tnl_InvalidateState( ctx, new_state );
> - _vbo_InvalidateState( ctx, new_state );
> _swsetup_InvalidateState( ctx, new_state );
>
> if (_mesa_is_user_fbo(ctx->DrawBuffer))
> return;
>
> /*
> * GL_DITHER, GL_READ/DRAW_BUFFER, buffer binding state, etc. effect
> * renderbuffer span/clear funcs.
> * Check _NEW_COLOR to detect dither enable/disable.
> */
> diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
> index 1de1d69..c8c96e3 100644
> --- a/src/mesa/main/state.c
> +++ b/src/mesa/main/state.c
> @@ -44,20 +44,21 @@
> #include "pixel.h"
> #include "program/program.h"
> #include "program/prog_parameter.h"
> #include "shaderobj.h"
> #include "state.h"
> #include "stencil.h"
> #include "texenvprogram.h"
> #include "texobj.h"
> #include "texstate.h"
> #include "varray.h"
> +#include "vbo/vbo_context.h"
> #include "viewport.h"
> #include "blend.h"
>
>
> /**
> * Update the following fields:
> * ctx->VertexProgram._Enabled
> * ctx->FragmentProgram._Enabled
> * ctx->ATIFragmentShader._Enabled
> * This needs to be done before texture state validation.
> @@ -403,27 +404,29 @@ _mesa_update_state_locked( struct gl_context *ctx )
> */
> new_prog_state |= update_program( ctx );
> }
>
> if (new_state & _NEW_ARRAY)
> _mesa_update_vao_client_arrays(ctx, ctx->Array.VAO);
>
> out:
> new_prog_state |= update_program_constants(ctx);
>
> + ctx->NewState |= new_prog_state;
> + vbo_exec_invalidate_state(ctx);
> +
> /*
> * Give the driver a chance to act upon the new_state flags.
> * The driver might plug in different span functions, for example.
> * Also, this is where the driver can invalidate the state of any
> * active modules (such as swrast_setup, swrast, tnl, etc).
> */
> - ctx->NewState |= new_prog_state;
> ctx->Driver.UpdateState(ctx);
> ctx->NewState = 0;
> ctx->Array.VAO->NewArrays = 0x0;
> }
>
>
> /* This is the usual entrypoint for state updates:
> */
> void
> _mesa_update_state( struct gl_context *ctx )
> diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
> index 058d9c3..cc6dcee 100644
> --- a/src/mesa/state_tracker/st_context.c
> +++ b/src/mesa/state_tracker/st_context.c
> @@ -256,25 +256,20 @@ st_invalidate_state(struct gl_context * ctx)
> ST_NEW_SAMPLERS |
> ST_NEW_IMAGE_UNITS);
> if (ctx->FragmentProgram._Current &&
> ctx->FragmentProgram._Current->ExternalSamplersUsed) {
> st->dirty |= ST_NEW_FS_STATE;
> }
> }
>
> if (new_state & _NEW_PROGRAM_CONSTANTS)
> st->dirty |= st->active_states & ST_NEW_CONSTANTS;
> -
> - /* This is the only core Mesa module we depend upon.
> - * No longer use swrast, swsetup, tnl.
> - */
> - _vbo_InvalidateState(ctx, new_state);
> }
>
>
> static void
> st_destroy_context_priv(struct st_context *st, bool destroy_pipe)
> {
> uint shader, i;
>
> st_destroy_atoms( st );
> st_destroy_draw( st );
> diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
> index 79f7538..eec484b 100644
> --- a/src/mesa/vbo/vbo.h
> +++ b/src/mesa/vbo/vbo.h
> @@ -71,21 +71,20 @@ struct _mesa_index_buffer {
> GLuint count;
> unsigned index_size;
> struct gl_buffer_object *obj;
> const void *ptr;
> };
>
>
>
> GLboolean _vbo_CreateContext( struct gl_context *ctx );
> void _vbo_DestroyContext( struct gl_context *ctx );
> -void _vbo_InvalidateState( struct gl_context *ctx, GLbitfield new_state );
>
>
> void
> vbo_initialize_exec_dispatch(const struct gl_context *ctx,
> struct _glapi_table *exec);
>
> void
> vbo_initialize_save_dispatch(const struct gl_context *ctx,
> struct _glapi_table *exec);
>
> diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
> index 384e405..a5f915d 100644
> --- a/src/mesa/vbo/vbo_context.c
> +++ b/src/mesa/vbo/vbo_context.c
> @@ -220,26 +220,20 @@ GLboolean _vbo_CreateContext( struct gl_context *ctx )
> vbo_exec_init( ctx );
> if (ctx->API == API_OPENGL_COMPAT)
> vbo_save_init( ctx );
>
> _math_init_eval();
>
> return GL_TRUE;
> }
>
>
> -void _vbo_InvalidateState( struct gl_context *ctx, GLbitfield new_state )
> -{
> - vbo_exec_invalidate_state(ctx, new_state);
> -}
> -
> -
> void _vbo_DestroyContext( struct gl_context *ctx )
> {
> struct vbo_context *vbo = vbo_context(ctx);
>
> if (ctx->aelt_context) {
> _ae_destroy_context( ctx );
> ctx->aelt_context = NULL;
> }
>
> if (vbo) {
> diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h
> index 5cf399f..0418643 100644
> --- a/src/mesa/vbo/vbo_context.h
> +++ b/src/mesa/vbo/vbo_context.h
> @@ -49,20 +49,21 @@
>
>
> #ifndef _VBO_CONTEXT_H
> #define _VBO_CONTEXT_H
>
> #include "vbo.h"
> #include "vbo_attrib.h"
> #include "vbo_exec.h"
> #include "vbo_save.h"
>
> +#include "main/api_arrayelt.h"
> #include "main/macros.h"
>
> #ifdef __cplusplus
> extern "C" {
> #endif
>
> struct vbo_context {
> struct gl_vertex_array currval[VBO_ATTRIB_MAX];
>
> /** Map VERT_ATTRIB_x to VBO_ATTRIB_y */
> @@ -84,20 +85,37 @@ struct vbo_context {
> vbo_indirect_draw_func draw_indirect_prims;
> };
>
>
> static inline struct vbo_context *vbo_context(struct gl_context *ctx)
> {
> return ctx->vbo_context;
> }
>
>
> +static inline void
> +vbo_exec_invalidate_state(struct gl_context *ctx)
> +{
> + struct vbo_context *vbo = vbo_context(ctx);
> + struct vbo_exec_context *exec = &vbo->exec;
> +
> + if (!exec->validating && ctx->NewState & (_NEW_PROGRAM | _NEW_ARRAY)) {
> + exec->array.recalculate_inputs = GL_TRUE;
> + }
> +
> + if (ctx->NewState & _NEW_EVAL)
> + exec->eval.recalculate_maps = GL_TRUE;
> +
> + _ae_invalidate_state(ctx, ctx->NewState);
> +}
> +
> +
> /**
> * Return VP_x token to indicate whether we're running fixed-function
> * vertex transformation, an NV vertex program or ARB vertex program/shader.
> */
> static inline enum vp_mode
> get_program_mode( struct gl_context *ctx )
> {
> if (!ctx->VertexProgram._Current)
> return VP_NONE;
> else if (ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram)
> diff --git a/src/mesa/vbo/vbo_exec.c b/src/mesa/vbo/vbo_exec.c
> index de8461f..dc26dfd 100644
> --- a/src/mesa/vbo/vbo_exec.c
> +++ b/src/mesa/vbo/vbo_exec.c
> @@ -19,21 +19,20 @@
> * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
> * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> * OTHER DEALINGS IN THE SOFTWARE.
> *
> * Authors:
> * Keith Whitwell <keithw at vmware.com>
> */
>
>
> -#include "main/api_arrayelt.h"
> #include "main/glheader.h"
> #include "main/mtypes.h"
> #include "main/vtxfmt.h"
> #include "vbo_context.h"
>
>
>
> void
> vbo_exec_init(struct gl_context *ctx)
> {
> @@ -64,41 +63,20 @@ void vbo_exec_destroy( struct gl_context *ctx )
> if (ctx->aelt_context) {
> _ae_destroy_context( ctx );
> ctx->aelt_context = NULL;
> }
>
> vbo_exec_vtx_destroy( exec );
> }
>
>
> /**
> - * Really want to install these callbacks to a central facility to be
> - * invoked according to the state flags. That will have to wait for a
> - * mesa rework:
> - */
> -void vbo_exec_invalidate_state( struct gl_context *ctx, GLbitfield new_state )
> -{
> - struct vbo_context *vbo = vbo_context(ctx);
> - struct vbo_exec_context *exec = &vbo->exec;
> -
> - if (!exec->validating && new_state & (_NEW_PROGRAM|_NEW_ARRAY)) {
> - exec->array.recalculate_inputs = GL_TRUE;
> - }
> -
> - if (new_state & _NEW_EVAL)
> - exec->eval.recalculate_maps = GL_TRUE;
> -
> - _ae_invalidate_state(ctx, new_state);
> -}
> -
> -
> -/**
> * Figure out the number of transform feedback primitives that will be output
> * considering the drawing mode, number of vertices, and instance count,
> * assuming that no geometry shading is done and primitive restart is not
> * used.
> *
> * This is used by driver back-ends in implementing the PRIMITIVES_GENERATED
> * and TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN queries. It is also used to
> * pre-validate draw calls in GLES3 (where draw calls only succeed if there is
> * enough room in the transform feedback buffer for the result).
> */
> diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h
> index 9358ca2..f1e3881 100644
> --- a/src/mesa/vbo/vbo_exec.h
> +++ b/src/mesa/vbo/vbo_exec.h
> @@ -140,21 +140,20 @@ struct vbo_exec_context
> GLint flush_call_depth;
> #endif
> };
>
>
>
> /* External API:
> */
> void vbo_exec_init( struct gl_context *ctx );
> void vbo_exec_destroy( struct gl_context *ctx );
> -void vbo_exec_invalidate_state( struct gl_context *ctx, GLbitfield new_state );
>
>
> /* Internal functions:
> */
> void vbo_exec_vtx_init( struct vbo_exec_context *exec );
> void vbo_exec_vtx_destroy( struct vbo_exec_context *exec );
>
>
> void vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap );
> void vbo_exec_vtx_map( struct vbo_exec_context *exec );
>
More information about the mesa-dev
mailing list