This will be used to rework the validation path for compute. Signed-off-by: Samuel Pitoiset <samuel.pitoi...@gmail.com> --- src/gallium/drivers/nouveau/Makefile.sources | 1 + src/gallium/drivers/nouveau/nvc0/nvc0_context.h | 3 -- .../drivers/nouveau/nvc0/nvc0_state_validate.c | 38 ++++++++++++++-------- .../drivers/nouveau/nvc0/nvc0_state_validate.h | 19 +++++++++++ src/gallium/drivers/nouveau/nvc0/nvc0_surface.c | 5 +-- src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c | 3 +- 6 files changed, 49 insertions(+), 20 deletions(-) create mode 100644 src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.h
diff --git a/src/gallium/drivers/nouveau/Makefile.sources b/src/gallium/drivers/nouveau/Makefile.sources index 31a9365..dc7dc0b 100644 --- a/src/gallium/drivers/nouveau/Makefile.sources +++ b/src/gallium/drivers/nouveau/Makefile.sources @@ -177,6 +177,7 @@ NVC0_C_SOURCES := \ nvc0/nvc0_state.c \ nvc0/nvc0_stateobj.h \ nvc0/nvc0_state_validate.c \ + nvc0/nvc0_state_validate.h \ nvc0/nvc0_surface.c \ nvc0/nvc0_tex.c \ nvc0/nvc0_transfer.c \ diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h index 542d644..e88cece 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h @@ -261,9 +261,6 @@ void nvc0_tfb_validate(struct nvc0_context *); /* nvc0_state.c */ extern void nvc0_init_state_functions(struct nvc0_context *); -/* nvc0_state_validate.c */ -bool nvc0_state_validate(struct nvc0_context *, uint32_t state_mask); - /* nvc0_surface.c */ extern void nvc0_clear(struct pipe_context *, unsigned buffers, const union pipe_color_union *color, diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c index e9a4f7c..2c4327e 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c @@ -3,6 +3,7 @@ #include "util/u_math.h" #include "nvc0/nvc0_context.h" +#include "nvc0/nvc0_state_validate.h" #if 0 static void @@ -672,10 +673,8 @@ nvc0_switch_pipe_context(struct nvc0_context *ctx_to) ctx_to->screen->cur_ctx = ctx_to; } -static struct state_validate { - void (*func)(struct nvc0_context *); - uint32_t states; -} validate_list[] = { +static struct nvc0_state_validate +validate_list_3d[] = { { nvc0_validate_fb, NVC0_NEW_3D_FRAMEBUFFER }, { nvc0_validate_blend, NVC0_NEW_3D_BLEND }, { nvc0_validate_zsa, NVC0_NEW_3D_ZSA }, @@ -714,7 +713,10 @@ static struct state_validate { }; bool -nvc0_state_validate(struct nvc0_context *nvc0, uint32_t mask) +nvc0_state_validate(struct nvc0_context *nvc0, uint32_t mask, + struct nvc0_state_validate *validate_list, int size, + uint32_t *dirty, bool *flushed, + struct nouveau_bufctx *bufctx) { uint32_t state_mask; int ret; @@ -723,26 +725,34 @@ nvc0_state_validate(struct nvc0_context *nvc0, uint32_t mask) if (nvc0->screen->cur_ctx != nvc0) nvc0_switch_pipe_context(nvc0); - state_mask = nvc0->dirty_3d & mask; + state_mask = *dirty & mask; if (state_mask) { - for (i = 0; i < ARRAY_SIZE(validate_list); ++i) { - struct state_validate *validate = &validate_list[i]; + for (i = 0; i < size; ++i) { + struct nvc0_state_validate *validate = &validate_list[i]; if (state_mask & validate->states) validate->func(nvc0); } - nvc0->dirty_3d &= ~state_mask; + *dirty &= ~state_mask; - nvc0_bufctx_fence(nvc0, nvc0->bufctx_3d, false); + nvc0_bufctx_fence(nvc0, bufctx, false); } - nouveau_pushbuf_bufctx(nvc0->base.pushbuf, nvc0->bufctx_3d); + nouveau_pushbuf_bufctx(nvc0->base.pushbuf, bufctx); ret = nouveau_pushbuf_validate(nvc0->base.pushbuf); - if (unlikely(nvc0->state.flushed_3d)) { - nvc0->state.flushed_3d = false; - nvc0_bufctx_fence(nvc0, nvc0->bufctx_3d, true); + if (unlikely(*flushed)) { + *flushed = false; + nvc0_bufctx_fence(nvc0, bufctx, true); } return !ret; } + +bool +nvc0_state_validate_3d(struct nvc0_context *nvc0, uint32_t mask) +{ + return nvc0_state_validate(nvc0, mask, validate_list_3d, + ARRAY_SIZE(validate_list_3d), &nvc0->dirty_3d, + &nvc0->state.flushed_3d, nvc0->bufctx_3d); +} diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.h b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.h new file mode 100644 index 0000000..d40d81d --- /dev/null +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.h @@ -0,0 +1,19 @@ +#ifndef __NVC0_STATE_VALIDATE_H__ +#define __NVC0_STATE_VALIDATE_H__ + +#include "nvc0/nvc0_context.h" + +struct nvc0_state_validate { + void (*func)(struct nvc0_context *); + uint32_t states; +}; + +bool +nvc0_state_validate(struct nvc0_context *, uint32_t, + struct nvc0_state_validate *, int, uint32_t *, bool *, + struct nouveau_bufctx *); + +bool +nvc0_state_validate_3d(struct nvc0_context *, uint32_t); + +#endif diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c index 4957796..b3cd9b8 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c @@ -32,6 +32,7 @@ #include "os/os_thread.h" #include "nvc0/nvc0_context.h" +#include "nvc0/nvc0_state_validate.h" #include "nvc0/nvc0_resource.h" #include "nv50/g80_defs.xml.h" @@ -693,7 +694,7 @@ nvc0_clear(struct pipe_context *pipe, unsigned buffers, uint32_t mode = 0; /* don't need NEW_BLEND, COLOR_MASK doesn't affect CLEAR_BUFFERS */ - if (!nvc0_state_validate(nvc0, NVC0_NEW_3D_FRAMEBUFFER)) + if (!nvc0_state_validate_3d(nvc0, NVC0_NEW_3D_FRAMEBUFFER)) return; if (buffers & PIPE_CLEAR_COLOR && fb->nr_cbufs) { @@ -1195,7 +1196,7 @@ nvc0_blit_3d(struct nvc0_context *nvc0, const struct pipe_blit_info *info) nvc0_blitctx_prepare_state(blit); - nvc0_state_validate(nvc0, ~0); + nvc0_state_validate_3d(nvc0, ~0); x_range = (float)info->src.box.width / (float)info->dst.box.width; y_range = (float)info->src.box.height / (float)info->dst.box.height; diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c index 647aa10..21cace7 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c @@ -30,6 +30,7 @@ #include "nvc0/nvc0_context.h" #include "nvc0/nvc0_query_hw.h" +#include "nvc0/nvc0_state_validate.h" #include "nvc0/nvc0_resource.h" #include "nvc0/nvc0_3d.xml.h" @@ -969,7 +970,7 @@ nvc0_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) IMMED_NVC0(push, NVC0_3D(PATCH_VERTICES), nvc0->state.patch_vertices); } - nvc0_state_validate(nvc0, ~0); + nvc0_state_validate_3d(nvc0, ~0); if (nvc0->vertprog->vp.need_draw_parameters) { PUSH_SPACE(push, 9); -- 2.6.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev