[Mesa-dev] [PATCH v2 2/5] r600: remove custom and incomplete OpenCL code paths

Marek Olšák maraeo at gmail.com
Mon May 29 15:33:10 UTC 2017


The "ac" functions could also be forked and put into r600 if people
want to preserve the OpenCL support. That would remove the dependency
on "ac".

Marek

On Mon, May 29, 2017 at 3:46 PM, Emil Velikov <emil.l.velikov at gmail.com> wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
>
> The code hasn't bee en touched in a very long time, and was never
> completed.
>
> It is conditionally built only when OpenCL is selected at built time,
> and pulls the libamd_common static library, which in itself depends on
> amdgpu.
>
> With later commit(s) we'll address the amdgpu dependency, but for now
> drop this partial code. If anyone is interested in reviving and beating
> it into shape they are welcome to git revert.
>
> v2: remove unused radeon_shader_binary_clean() call and struct
> r600_pipe_compute::binary. Add ac_binary.h include in r600_pipe_common.h
>
> Cc: Nicolai Hähnle <nicolai.haehnle at amd.com>
> Cc: Marek Olšák <marek.olsak at amd.com>
> Cc: Dave Airlie <airlied at gmail.com>
> Cc: Aaron Watry <awatry at gmail.com>
> Cc: Jan Vesely <jan.vesely at rutgers.edu>
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
> ---
>
> Gents,
>
> Yes, this patch removes OpenCL for r600 and yes, ideally we'll get
> people to finish it.
>
> At the same time the (r300/r600 only) build was broken for over a week
> so I've opted for the simple solution as mentioned in [1].
>
> Feel free to address properly, but until then lets merge something so
> that people can actualy build the driver(s).
>
> [1] https://lists.freedesktop.org/archives/mesa-dev/2017-May/156429.html
>
>  src/gallium/drivers/r600/Makefile.am               |  5 --
>  src/gallium/drivers/r600/evergreen_compute.c       | 91 ----------------------
>  .../drivers/r600/evergreen_compute_internal.h      |  8 --
>  3 files changed, 104 deletions(-)
>
> diff --git a/src/gallium/drivers/r600/Makefile.am b/src/gallium/drivers/r600/Makefile.am
> index 21762d838d0..127e7424b74 100644
> --- a/src/gallium/drivers/r600/Makefile.am
> +++ b/src/gallium/drivers/r600/Makefile.am
> @@ -25,11 +25,6 @@ AM_CFLAGS += \
>
>  endif
>
> -if HAVE_GALLIUM_COMPUTE
> -AM_CFLAGS += \
> -       -DHAVE_OPENCL
> -endif
> -
>  EXTRA_DIST = \
>         sb/notes.markdown \
>         sb/sb_bc_fmt_def.inc
> diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c
> index 37ef1058d3f..fec49f439dd 100644
> --- a/src/gallium/drivers/r600/evergreen_compute.c
> +++ b/src/gallium/drivers/r600/evergreen_compute.c
> @@ -26,7 +26,6 @@
>
>  #include <stdio.h>
>  #include <errno.h>
> -#include "ac_binary.h"
>  #include "pipe/p_defines.h"
>  #include "pipe/p_state.h"
>  #include "pipe/p_context.h"
> @@ -172,65 +171,6 @@ static void evergreen_cs_set_constant_buffer(struct r600_context *rctx,
>         rctx->b.b.set_constant_buffer(&rctx->b.b, PIPE_SHADER_COMPUTE, cb_index, &cb);
>  }
>
> -/* We need to define these R600 registers here, because we can't include
> - * evergreend.h and r600d.h.
> - */
> -#define R_028868_SQ_PGM_RESOURCES_VS                 0x028868
> -#define R_028850_SQ_PGM_RESOURCES_PS                 0x028850
> -
> -#ifdef HAVE_OPENCL
> -
> -static void r600_shader_binary_read_config(const struct ac_shader_binary *binary,
> -                                          struct r600_bytecode *bc,
> -                                          uint64_t symbol_offset,
> -                                          boolean *use_kill)
> -{
> -       unsigned i;
> -       const unsigned char *config =
> -               ac_shader_binary_config_start(binary, symbol_offset);
> -
> -       for (i = 0; i < binary->config_size_per_symbol; i+= 8) {
> -               unsigned reg =
> -                       util_le32_to_cpu(*(uint32_t*)(config + i));
> -               unsigned value =
> -                       util_le32_to_cpu(*(uint32_t*)(config + i + 4));
> -               switch (reg) {
> -               /* R600 / R700 */
> -               case R_028850_SQ_PGM_RESOURCES_PS:
> -               case R_028868_SQ_PGM_RESOURCES_VS:
> -               /* Evergreen / Northern Islands */
> -               case R_028844_SQ_PGM_RESOURCES_PS:
> -               case R_028860_SQ_PGM_RESOURCES_VS:
> -               case R_0288D4_SQ_PGM_RESOURCES_LS:
> -                       bc->ngpr = MAX2(bc->ngpr, G_028844_NUM_GPRS(value));
> -                       bc->nstack = MAX2(bc->nstack, G_028844_STACK_SIZE(value));
> -                       break;
> -               case R_02880C_DB_SHADER_CONTROL:
> -                       *use_kill = G_02880C_KILL_ENABLE(value);
> -                       break;
> -               case R_0288E8_SQ_LDS_ALLOC:
> -                       bc->nlds_dw = value;
> -                       break;
> -               }
> -       }
> -}
> -
> -static unsigned r600_create_shader(struct r600_bytecode *bc,
> -                                  const struct ac_shader_binary *binary,
> -                                  boolean *use_kill)
> -
> -{
> -       assert(binary->code_size % 4 == 0);
> -       bc->bytecode = CALLOC(1, binary->code_size);
> -       memcpy(bc->bytecode, binary->code, binary->code_size);
> -       bc->ndw = binary->code_size / 4;
> -
> -       r600_shader_binary_read_config(binary, bc, 0, use_kill);
> -       return 0;
> -}
> -
> -#endif
> -
>  static void r600_destroy_shader(struct r600_bytecode *bc)
>  {
>         FREE(bc->bytecode);
> @@ -241,27 +181,6 @@ static void *evergreen_create_compute_state(struct pipe_context *ctx,
>  {
>         struct r600_context *rctx = (struct r600_context *)ctx;
>         struct r600_pipe_compute *shader = CALLOC_STRUCT(r600_pipe_compute);
> -#ifdef HAVE_OPENCL
> -       const struct pipe_llvm_program_header *header;
> -       const char *code;
> -       void *p;
> -       boolean use_kill;
> -
> -       COMPUTE_DBG(rctx->screen, "*** evergreen_create_compute_state\n");
> -       header = cso->prog;
> -       code = cso->prog + sizeof(struct pipe_llvm_program_header);
> -       radeon_shader_binary_init(&shader->binary);
> -       ac_elf_read(code, header->num_bytes, &shader->binary);
> -       r600_create_shader(&shader->bc, &shader->binary, &use_kill);
> -
> -       /* Upload code + ROdata */
> -       shader->code_bo = r600_compute_buffer_alloc_vram(rctx->screen,
> -                                                       shader->bc.ndw * 4);
> -       p = r600_buffer_map_sync_with_rings(&rctx->b, shader->code_bo, PIPE_TRANSFER_WRITE);
> -       //TODO: use util_memcpy_cpu_to_le32 ?
> -       memcpy(p, shader->bc.bytecode, shader->bc.ndw * 4);
> -       rctx->b.ws->buffer_unmap(shader->code_bo->buf);
> -#endif
>
>         shader->ctx = rctx;
>         shader->local_size = cso->req_local_mem;
> @@ -281,7 +200,6 @@ static void evergreen_delete_compute_state(struct pipe_context *ctx, void *state
>         if (!shader)
>                 return;
>
> -       radeon_shader_binary_clean(&shader->binary);
>         r600_destroy_shader(&shader->bc);
>
>         /* TODO destroy shader->code_bo, shader->const_bo
> @@ -589,15 +507,6 @@ static void evergreen_launch_grid(struct pipe_context *ctx,
>                                   const struct pipe_grid_info *info)
>  {
>         struct r600_context *rctx = (struct r600_context *)ctx;
> -#ifdef HAVE_OPENCL
> -       struct r600_pipe_compute *shader = rctx->cs_shader_state.shader;
> -       boolean use_kill;
> -
> -       rctx->cs_shader_state.pc = info->pc;
> -       /* Get the config information for this kernel. */
> -       r600_shader_binary_read_config(&shader->binary, &shader->bc,
> -                                  info->pc, &use_kill);
> -#endif
>
>         COMPUTE_DBG(rctx->screen, "*** evergreen_launch_grid: pc = %u\n", info->pc);
>
> diff --git a/src/gallium/drivers/r600/evergreen_compute_internal.h b/src/gallium/drivers/r600/evergreen_compute_internal.h
> index 6f4be3ea57f..c9945de4f3a 100644
> --- a/src/gallium/drivers/r600/evergreen_compute_internal.h
> +++ b/src/gallium/drivers/r600/evergreen_compute_internal.h
> @@ -26,14 +26,10 @@
>  #define EVERGREEN_COMPUTE_INTERNAL_H
>
>  #include "r600_asm.h"
> -#ifdef HAVE_OPENCL
> -#include <llvm-c/Core.h>
> -#endif
>
>  struct r600_pipe_compute {
>         struct r600_context *ctx;
>
> -       struct ac_shader_binary binary;
>         struct r600_resource *code_bo;
>         struct r600_bytecode bc;
>
> @@ -41,10 +37,6 @@ struct r600_pipe_compute {
>         unsigned private_size;
>         unsigned input_size;
>         struct r600_resource *kernel_param;
> -
> -#ifdef HAVE_OPENCL
> -       LLVMContextRef llvm_ctx;
> -#endif
>  };
>
>  struct r600_resource* r600_compute_buffer_alloc_vram(struct r600_screen *screen, unsigned size);
> --
> 2.12.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