[Mesa-dev] [PATCH 1/2] nvc0: rework the validation path for 3D

Samuel Pitoiset samuel.pitoiset at gmail.com
Tue Mar 8 20:14:45 UTC 2016



On 03/08/2016 09:11 PM, Ilia Mirkin wrote:
> On Tue, Mar 8, 2016 at 3:08 PM, Samuel Pitoiset
> <samuel.pitoiset at gmail.com> wrote:
>> This exposes an interface for state validation that will be also used
>> to rework the compute validation path.
>>
>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at 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     | 37 +++++++++++++++-------
>>   .../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, 50 insertions(+), 18 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 65f08c7..f3df05b 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 0f1ebb0..d0914b6 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);
>
> I'd just keep sticking stuff in here... no point in making 50
> different tiny header files IMHO. [This is also the style used for the
> most part.]

I can do that.

>
>> -
>>   /* 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 fbf45ce..9f53b5a 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,9 @@ 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, struct nouveau_bufctx *bufctx)
>>   {
>>      uint32_t state_mask;
>>      int ret;
>> @@ -723,26 +724,38 @@ 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);
>>
>> +   return !ret;
>> +}
>> +
>> +bool
>> +nvc0_state_validate_3d(struct nvc0_context *nvc0, uint32_t mask)
>> +{
>> +   bool ret;
>> +
>> +   ret = nvc0_state_validate(nvc0, mask, validate_list_3d,
>> +                             ARRAY_SIZE(validate_list_3d), &nvc0->dirty_3d,
>> +                             nvc0->bufctx_3d);
>> +
>>      if (unlikely(nvc0->state.flushed)) {
>>         nvc0->state.flushed = false;
>>         nvc0_bufctx_fence(nvc0, nvc0->bufctx_3d, true);
>>      }
>> -   return !ret;
>> +   return ret;
>>   }
>> 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..1230e7b
>> --- /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 *,
>> +                    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..4613c2d 100644
>> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c
>> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c
>> @@ -33,6 +33,7 @@
>>
>>   #include "nvc0/nvc0_context.h"
>>   #include "nvc0/nvc0_resource.h"
>> +#include "nvc0/nvc0_state_validate.h"
>>
>>   #include "nv50/g80_defs.xml.h"
>>   #include "nv50/g80_texture.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..09d9309 100644
>> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c
>> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c
>> @@ -31,6 +31,7 @@
>>   #include "nvc0/nvc0_context.h"
>>   #include "nvc0/nvc0_query_hw.h"
>>   #include "nvc0/nvc0_resource.h"
>> +#include "nvc0/nvc0_state_validate.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.7.1
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list