[Mesa-dev] [PATCH 2/6] nvc0: rework nvc0_compute_validate_program()

Ilia Mirkin imirkin at alum.mit.edu
Sun Feb 21 23:19:06 UTC 2016


Should you instead move nvc0_compute_validate into nvc0_shader_state?
Currently that's where all this stuff lives. I see
nvc0_program_validate as more of an "internal" module function that
shouldn't be exported across files.

On Sun, Feb 21, 2016 at 9:19 AM, Samuel Pitoiset
<samuel.pitoiset at gmail.com> wrote:
> Reduce the amount of duplicated code by re-using
> nvc0_program_validate(). While we are at it, change the prototype
> to return void.
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> ---
>  src/gallium/drivers/nouveau/nvc0/nvc0_compute.c    | 32 ++++++----------------
>  src/gallium/drivers/nouveau/nvc0/nvc0_compute.h    |  4 +--
>  src/gallium/drivers/nouveau/nvc0/nvc0_context.h    |  1 +
>  .../drivers/nouveau/nvc0/nvc0_shader_state.c       |  2 +-
>  src/gallium/drivers/nouveau/nvc0/nve4_compute.c    |  3 +-
>  5 files changed, 13 insertions(+), 29 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c b/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c
> index 0f1265f..491221e 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c
> @@ -120,32 +120,17 @@ nvc0_screen_compute_setup(struct nvc0_screen *screen,
>     return 0;
>  }
>
> -bool
> +void
>  nvc0_compute_validate_program(struct nvc0_context *nvc0)
>  {
> -   struct nvc0_program *prog = nvc0->compprog;
> -
> -   if (prog->mem)
> -      return true;
> +   struct nouveau_pushbuf *push = nvc0->base.pushbuf;
> +   struct nvc0_program *cp = nvc0->compprog;
>
> -   if (!prog->translated) {
> -      prog->translated = nvc0_program_translate(
> -         prog, nvc0->screen->base.device->chipset, &nvc0->base.debug);
> -      if (!prog->translated)
> -         return false;
> -   }
> -   if (unlikely(!prog->code_size))
> -      return false;
> +   if (cp && !nvc0_program_validate(nvc0, cp))
> +      return;
>
> -   if (likely(prog->code_size)) {
> -      if (nvc0_program_upload_code(nvc0, prog)) {
> -         struct nouveau_pushbuf *push = nvc0->base.pushbuf;
> -         BEGIN_NVC0(push, NVC0_CP(FLUSH), 1);
> -         PUSH_DATA (push, NVC0_COMPUTE_FLUSH_CODE);
> -         return true;
> -      }
> -   }
> -   return false;
> +   BEGIN_NVC0(push, NVC0_CP(FLUSH), 1);
> +   PUSH_DATA (push, NVC0_COMPUTE_FLUSH_CODE);
>  }
>
>  static void
> @@ -277,8 +262,7 @@ nvc0_compute_validate_buffers(struct nvc0_context *nvc0)
>  static bool
>  nvc0_compute_state_validate(struct nvc0_context *nvc0)
>  {
> -   if (!nvc0_compute_validate_program(nvc0))
> -      return false;
> +   nvc0_compute_validate_program(nvc0);
>     if (nvc0->dirty_cp & NVC0_NEW_CP_CONSTBUF)
>        nvc0_compute_validate_constbufs(nvc0);
>     if (nvc0->dirty_cp & NVC0_NEW_CP_DRIVERCONST)
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_compute.h b/src/gallium/drivers/nouveau/nvc0/nvc0_compute.h
> index a23f7f3..19cc15a 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_compute.h
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_compute.h
> @@ -3,7 +3,7 @@
>
>  #include "nvc0/nvc0_compute.xml.h"
>
> -bool
> -nvc0_compute_validate_program(struct nvc0_context *nvc0);
> +void
> +nvc0_compute_validate_program(struct nvc0_context *);
>
>  #endif /* NVC0_COMPUTE_H */
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
> index 0bbbff5..542d644 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
> @@ -249,6 +249,7 @@ uint32_t nvc0_program_symbol_offset(const struct nvc0_program *,
>  void nvc0_program_init_tcp_empty(struct nvc0_context *);
>
>  /* nvc0_shader_state.c */
> +bool nvc0_program_validate(struct nvc0_context *, struct nvc0_program *);
>  void nvc0_vertprog_validate(struct nvc0_context *);
>  void nvc0_tctlprog_validate(struct nvc0_context *);
>  void nvc0_tevlprog_validate(struct nvc0_context *);
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c b/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c
> index 2f46c43..4def04f 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c
> @@ -64,7 +64,7 @@ nvc0_program_update_context_state(struct nvc0_context *nvc0,
>     }
>  }
>
> -static inline bool
> +bool
>  nvc0_program_validate(struct nvc0_context *nvc0, struct nvc0_program *prog)
>  {
>     if (prog->mem)
> diff --git a/src/gallium/drivers/nouveau/nvc0/nve4_compute.c b/src/gallium/drivers/nouveau/nvc0/nve4_compute.c
> index 0ffcfb1..60a7118 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nve4_compute.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nve4_compute.c
> @@ -321,8 +321,7 @@ nvc0_compute_validate_globals(struct nvc0_context *nvc0)
>  static bool
>  nve4_compute_state_validate(struct nvc0_context *nvc0)
>  {
> -   if (!nvc0_compute_validate_program(nvc0))
> -      return false;
> +   nvc0_compute_validate_program(nvc0);
>     if (nvc0->dirty_cp & NVC0_NEW_CP_TEXTURES)
>        nve4_compute_validate_textures(nvc0);
>     if (nvc0->dirty_cp & NVC0_NEW_CP_SAMPLERS)
> --
> 2.6.4
>
> _______________________________________________
> 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