From 378c14331b8b9bd48045b6fc6453146ab97e8150 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Sat, 6 Feb 2021 11:20:27 -0800 Subject: [PATCH] freedreno/ir3+a5xx+a6xx: De-duplicate create_compute_state() These were identical between a5xx and a6xx, so move into shared helper that can be directly plugged into pctx, similar to the various 3d shader state creation. Signed-off-by: Rob Clark Part-of: --- .../drivers/freedreno/a5xx/fd5_compute.c | 23 +------------------ .../drivers/freedreno/a6xx/fd6_compute.c | 23 +------------------ .../drivers/freedreno/ir3/ir3_gallium.c | 23 ++++++++++++++++++- .../drivers/freedreno/ir3/ir3_gallium.h | 7 ++---- 4 files changed, 26 insertions(+), 50 deletions(-) diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_compute.c b/src/gallium/drivers/freedreno/a5xx/fd5_compute.c index 4402819946b..3cf0efbf3e1 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_compute.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_compute.c @@ -33,27 +33,6 @@ #include "fd5_emit.h" -static void * -fd5_create_compute_state(struct pipe_context *pctx, - const struct pipe_compute_state *cso) -{ - struct fd_context *ctx = fd_context(pctx); - - /* req_input_mem will only be non-zero for cl kernels (ie. clover). - * This isn't a perfect test because I guess it is possible (but - * uncommon) for none for the kernel parameters to be a global, - * but ctx->set_global_bindings() can't fail, so this is the next - * best place to fail if we need a newer version of kernel driver: - */ - if ((cso->req_input_mem > 0) && - fd_device_version(ctx->dev) < FD_VERSION_BO_IOVA) { - return NULL; - } - - struct ir3_compiler *compiler = ctx->screen->compiler; - return ir3_shader_create_compute(compiler, cso, &ctx->debug, pctx->screen); -} - /* maybe move to fd5_program? */ static void cs_program_emit(struct fd_ringbuffer *ring, struct ir3_shader_variant *v, @@ -216,6 +195,6 @@ fd5_compute_init(struct pipe_context *pctx) { struct fd_context *ctx = fd_context(pctx); ctx->launch_grid = fd5_launch_grid; - pctx->create_compute_state = fd5_create_compute_state; + pctx->create_compute_state = ir3_shader_compute_state_create; pctx->delete_compute_state = ir3_shader_state_delete; } diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_compute.c b/src/gallium/drivers/freedreno/a6xx/fd6_compute.c index 814febbff6c..94f4245849e 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_compute.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_compute.c @@ -38,27 +38,6 @@ #include "fd6_pack.h" -static void * -fd6_create_compute_state(struct pipe_context *pctx, - const struct pipe_compute_state *cso) -{ - struct fd_context *ctx = fd_context(pctx); - - /* req_input_mem will only be non-zero for cl kernels (ie. clover). - * This isn't a perfect test because I guess it is possible (but - * uncommon) for none for the kernel parameters to be a global, - * but ctx->set_global_bindings() can't fail, so this is the next - * best place to fail if we need a newer version of kernel driver: - */ - if ((cso->req_input_mem > 0) && - fd_device_version(ctx->dev) < FD_VERSION_BO_IOVA) { - return NULL; - } - - struct ir3_compiler *compiler = ctx->screen->compiler; - return ir3_shader_create_compute(compiler, cso, &ctx->debug, pctx->screen); -} - /* maybe move to fd6_program? */ static void cs_program_emit(struct fd_context *ctx, struct fd_ringbuffer *ring, @@ -210,6 +189,6 @@ fd6_compute_init(struct pipe_context *pctx) { struct fd_context *ctx = fd_context(pctx); ctx->launch_grid = fd6_launch_grid; - pctx->create_compute_state = fd6_create_compute_state; + pctx->create_compute_state = ir3_shader_compute_state_create; pctx->delete_compute_state = ir3_shader_state_delete; } diff --git a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c index f6689608efc..34e1a8ce22a 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c @@ -246,7 +246,7 @@ ir3_shader_create(struct ir3_compiler *compiler, /* a bit annoying that compute-shader and normal shader state objects * aren't a bit more aligned. */ -struct ir3_shader * +static struct ir3_shader * ir3_shader_create_compute(struct ir3_compiler *compiler, const struct pipe_compute_state *cso, struct pipe_debug_callback *debug, @@ -278,6 +278,27 @@ ir3_shader_create_compute(struct ir3_compiler *compiler, return shader; } +void * +ir3_shader_compute_state_create(struct pipe_context *pctx, + const struct pipe_compute_state *cso) +{ + struct fd_context *ctx = fd_context(pctx); + + /* req_input_mem will only be non-zero for cl kernels (ie. clover). + * This isn't a perfect test because I guess it is possible (but + * uncommon) for none for the kernel parameters to be a global, + * but ctx->set_global_bindings() can't fail, so this is the next + * best place to fail if we need a newer version of kernel driver: + */ + if ((cso->req_input_mem > 0) && + fd_device_version(ctx->dev) < FD_VERSION_BO_IOVA) { + return NULL; + } + + struct ir3_compiler *compiler = ctx->screen->compiler; + return ir3_shader_create_compute(compiler, cso, &ctx->debug, pctx->screen); +} + void * ir3_shader_state_create(struct pipe_context *pctx, const struct pipe_shader_state *cso) { diff --git a/src/gallium/drivers/freedreno/ir3/ir3_gallium.h b/src/gallium/drivers/freedreno/ir3/ir3_gallium.h index 10445069916..bc11bb43386 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_gallium.h +++ b/src/gallium/drivers/freedreno/ir3/ir3_gallium.h @@ -35,15 +35,12 @@ struct ir3_shader * ir3_shader_create(struct ir3_compiler *compiler, const struct pipe_shader_state *cso, struct pipe_debug_callback *debug, struct pipe_screen *screen); -struct ir3_shader * -ir3_shader_create_compute(struct ir3_compiler *compiler, - const struct pipe_compute_state *cso, - struct pipe_debug_callback *debug, - struct pipe_screen *screen); struct ir3_shader_variant * ir3_shader_variant(struct ir3_shader *shader, struct ir3_shader_key key, bool binning_pass, struct pipe_debug_callback *debug); +void * ir3_shader_compute_state_create(struct pipe_context *pctx, + const struct pipe_compute_state *cso); void * ir3_shader_state_create(struct pipe_context *pctx, const struct pipe_shader_state *cso); void ir3_shader_state_delete(struct pipe_context *pctx, void *hwcso);