[Mesa-dev] [PATCH 1/6] r600g: inline r600_pipe_shader function

Jerome Glisse j.glisse at gmail.com
Mon Mar 4 07:23:39 PST 2013


On Sun, Mar 3, 2013 at 8:39 AM, Marek Olšák <maraeo at gmail.com> wrote:
> also change names of other functions, so that they make sense

For the serie:
Reviewed-by: Jerome Glisse <jglisse at redhat.com>

> ---
>  src/gallium/drivers/r600/evergreen_state.c   |    4 +-
>  src/gallium/drivers/r600/r600_pipe.h         |    8 +--
>  src/gallium/drivers/r600/r600_shader.c       |   89 ++++++++++++--------------
>  src/gallium/drivers/r600/r600_state.c        |    4 +-
>  src/gallium/drivers/r600/r600_state_common.c |    4 +-
>  5 files changed, 51 insertions(+), 58 deletions(-)
>
> diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
> index 97f91df..5c7cd40 100644
> --- a/src/gallium/drivers/r600/evergreen_state.c
> +++ b/src/gallium/drivers/r600/evergreen_state.c
> @@ -3311,7 +3311,7 @@ void evergreen_init_atom_start_cs(struct r600_context *rctx)
>         eg_store_loop_const(cb, R_03A200_SQ_LOOP_CONST_0 + (32 * 4), 0x01000FFF);
>  }
>
> -void evergreen_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shader)
> +void evergreen_update_ps_state(struct pipe_context *ctx, struct r600_pipe_shader *shader)
>  {
>         struct r600_context *rctx = (struct r600_context *)ctx;
>         struct r600_pipe_state *rstate = &shader->rstate;
> @@ -3460,7 +3460,7 @@ void evergreen_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader
>                 shader->flatshade = rctx->rasterizer->flatshade;
>  }
>
> -void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *shader)
> +void evergreen_update_vs_state(struct pipe_context *ctx, struct r600_pipe_shader *shader)
>  {
>         struct r600_context *rctx = (struct r600_context *)ctx;
>         struct r600_pipe_state *rstate = &shader->rstate;
> diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
> index 3eb2968..28c7de3 100644
> --- a/src/gallium/drivers/r600/r600_pipe.h
> +++ b/src/gallium/drivers/r600/r600_pipe.h
> @@ -626,8 +626,8 @@ void cayman_init_common_regs(struct r600_command_buffer *cb,
>
>  void evergreen_init_state_functions(struct r600_context *rctx);
>  void evergreen_init_atom_start_cs(struct r600_context *rctx);
> -void evergreen_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shader);
> -void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *shader);
> +void evergreen_update_ps_state(struct pipe_context *ctx, struct r600_pipe_shader *shader);
> +void evergreen_update_vs_state(struct pipe_context *ctx, struct r600_pipe_shader *shader);
>  void *evergreen_create_db_flush_dsa(struct r600_context *rctx);
>  void *evergreen_create_resolve_blend(struct r600_context *rctx);
>  void *evergreen_create_decompress_blend(struct r600_context *rctx);
> @@ -701,8 +701,8 @@ r600_create_sampler_view_custom(struct pipe_context *ctx,
>                                 unsigned width_first_level, unsigned height_first_level);
>  void r600_init_state_functions(struct r600_context *rctx);
>  void r600_init_atom_start_cs(struct r600_context *rctx);
> -void r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shader);
> -void r600_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *shader);
> +void r600_update_ps_state(struct pipe_context *ctx, struct r600_pipe_shader *shader);
> +void r600_update_vs_state(struct pipe_context *ctx, struct r600_pipe_shader *shader);
>  void *r600_create_db_flush_dsa(struct r600_context *rctx);
>  void *r600_create_resolve_blend(struct r600_context *rctx);
>  void *r700_create_resolve_blend(struct r600_context *rctx);
> diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
> index 949191a..7ecab7b 100644
> --- a/src/gallium/drivers/r600/r600_shader.c
> +++ b/src/gallium/drivers/r600/r600_shader.c
> @@ -58,52 +58,6 @@ issued in the w slot as well.
>  The compiler must issue the source argument to slots z, y, and x
>  */
>
> -static int r600_pipe_shader(struct pipe_context *ctx, struct r600_pipe_shader *shader)
> -{
> -       struct r600_context *rctx = (struct r600_context *)ctx;
> -       struct r600_shader *rshader = &shader->shader;
> -       uint32_t *ptr;
> -       int     i;
> -
> -       /* copy new shader */
> -       if (shader->bo == NULL) {
> -               shader->bo = (struct r600_resource*)
> -                       pipe_buffer_create(ctx->screen, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE, rshader->bc.ndw * 4);
> -               if (shader->bo == NULL) {
> -                       return -ENOMEM;
> -               }
> -               ptr = r600_buffer_mmap_sync_with_rings(rctx, shader->bo, PIPE_TRANSFER_WRITE);
> -               if (R600_BIG_ENDIAN) {
> -                       for (i = 0; i < rshader->bc.ndw; ++i) {
> -                               ptr[i] = bswap_32(rshader->bc.bytecode[i]);
> -                       }
> -               } else {
> -                       memcpy(ptr, rshader->bc.bytecode, rshader->bc.ndw * sizeof(*ptr));
> -               }
> -               rctx->ws->buffer_unmap(shader->bo->cs_buf);
> -       }
> -       /* build state */
> -       switch (rshader->processor_type) {
> -       case TGSI_PROCESSOR_VERTEX:
> -               if (rctx->chip_class >= EVERGREEN) {
> -                       evergreen_pipe_shader_vs(ctx, shader);
> -               } else {
> -                       r600_pipe_shader_vs(ctx, shader);
> -               }
> -               break;
> -       case TGSI_PROCESSOR_FRAGMENT:
> -               if (rctx->chip_class >= EVERGREEN) {
> -                       evergreen_pipe_shader_ps(ctx, shader);
> -               } else {
> -                       r600_pipe_shader_ps(ctx, shader);
> -               }
> -               break;
> -       default:
> -               return -EINVAL;
> -       }
> -       return 0;
> -}
> -
>  static int r600_shader_from_tgsi(struct r600_screen *rscreen,
>                                  struct r600_pipe_shader *pipeshader,
>                                  struct r600_shader_key key);
> @@ -161,7 +115,8 @@ int r600_pipe_shader_create(struct pipe_context *ctx,
>  {
>         struct r600_context *rctx = (struct r600_context *)ctx;
>         struct r600_pipe_shader_selector *sel = shader->selector;
> -       int r;
> +       int r, i;
> +       uint32_t *ptr;
>         bool dump = r600_can_dump_shader(rctx->screen, tgsi_get_processor_type(sel->tokens));
>
>         shader->shader.bc.isa = rctx->isa;
> @@ -190,7 +145,45 @@ int r600_pipe_shader_create(struct pipe_context *ctx,
>                 fprintf(stderr, "______________________________________________________________\n");
>         }
>
> -       return r600_pipe_shader(ctx, shader);
> +
> +       /* Store the shader in a buffer. */
> +       if (shader->bo == NULL) {
> +               shader->bo = (struct r600_resource*)
> +                       pipe_buffer_create(ctx->screen, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE, shader->shader.bc.ndw * 4);
> +               if (shader->bo == NULL) {
> +                       return -ENOMEM;
> +               }
> +               ptr = r600_buffer_mmap_sync_with_rings(rctx, shader->bo, PIPE_TRANSFER_WRITE);
> +               if (R600_BIG_ENDIAN) {
> +                       for (i = 0; i < shader->shader.bc.ndw; ++i) {
> +                               ptr[i] = bswap_32(shader->shader.bc.bytecode[i]);
> +                       }
> +               } else {
> +                       memcpy(ptr, shader->shader.bc.bytecode, shader->shader.bc.ndw * sizeof(*ptr));
> +               }
> +               rctx->ws->buffer_unmap(shader->bo->cs_buf);
> +       }
> +
> +       /* Build state. */
> +       switch (shader->shader.processor_type) {
> +       case TGSI_PROCESSOR_VERTEX:
> +               if (rctx->chip_class >= EVERGREEN) {
> +                       evergreen_update_vs_state(ctx, shader);
> +               } else {
> +                       r600_update_vs_state(ctx, shader);
> +               }
> +               break;
> +       case TGSI_PROCESSOR_FRAGMENT:
> +               if (rctx->chip_class >= EVERGREEN) {
> +                       evergreen_update_ps_state(ctx, shader);
> +               } else {
> +                       r600_update_ps_state(ctx, shader);
> +               }
> +               break;
> +       default:
> +               return -EINVAL;
> +       }
> +       return 0;
>  }
>
>  void r600_pipe_shader_destroy(struct pipe_context *ctx, struct r600_pipe_shader *shader)
> diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
> index 1e62afc..2ddd567 100644
> --- a/src/gallium/drivers/r600/r600_state.c
> +++ b/src/gallium/drivers/r600/r600_state.c
> @@ -2754,7 +2754,7 @@ void r600_init_atom_start_cs(struct r600_context *rctx)
>         r600_store_loop_const(cb, R_03E200_SQ_LOOP_CONST_0 + (32 * 4), 0x1000FFF);
>  }
>
> -void r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shader)
> +void r600_update_ps_state(struct pipe_context *ctx, struct r600_pipe_shader *shader)
>  {
>         struct r600_context *rctx = (struct r600_context *)ctx;
>         struct r600_pipe_state *rstate = &shader->rstate;
> @@ -2874,7 +2874,7 @@ void r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shad
>                 shader->flatshade = rctx->rasterizer->flatshade;
>  }
>
> -void r600_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *shader)
> +void r600_update_vs_state(struct pipe_context *ctx, struct r600_pipe_shader *shader)
>  {
>         struct r600_context *rctx = (struct r600_context *)ctx;
>         struct r600_pipe_state *rstate = &shader->rstate;
> diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
> index 22ac846..4566fc7 100644
> --- a/src/gallium/drivers/r600/r600_state_common.c
> +++ b/src/gallium/drivers/r600/r600_state_common.c
> @@ -1222,9 +1222,9 @@ static bool r600_update_derived_state(struct r600_context *rctx)
>              (rctx->rasterizer->flatshade != rctx->ps_shader->current->flatshade))) {
>
>                 if (rctx->chip_class >= EVERGREEN)
> -                       evergreen_pipe_shader_ps(ctx, rctx->ps_shader->current);
> +                       evergreen_update_ps_state(ctx, rctx->ps_shader->current);
>                 else
> -                       r600_pipe_shader_ps(ctx, rctx->ps_shader->current);
> +                       r600_update_ps_state(ctx, rctx->ps_shader->current);
>
>                 ps_dirty = 1;
>         }
> --
> 1.7.10.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list