From 9ebc48005c92676c9b3adcb255204d8787286b65 Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Thu, 25 Nov 2021 14:30:46 +0100 Subject: [PATCH] ir3, freedreno: Add options struct for ir3_shader_from_nir() We'll expand this in a moment. Part-of: --- src/freedreno/ir3/ir3_shader.c | 4 ++-- src/freedreno/ir3/ir3_shader.h | 7 ++++++- src/freedreno/vulkan/tu_clear_blit.c | 6 ++++-- src/freedreno/vulkan/tu_shader.c | 6 +++--- src/gallium/drivers/freedreno/ir3/ir3_gallium.c | 7 +++++-- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/freedreno/ir3/ir3_shader.c b/src/freedreno/ir3/ir3_shader.c index 965d20d..be4d6b4 100644 --- a/src/freedreno/ir3/ir3_shader.c +++ b/src/freedreno/ir3/ir3_shader.c @@ -583,7 +583,7 @@ ir3_trim_constlen(struct ir3_shader_variant **variants, struct ir3_shader * ir3_shader_from_nir(struct ir3_compiler *compiler, nir_shader *nir, - unsigned reserved_user_consts, + const struct ir3_shader_options *options, struct ir3_stream_output_info *stream_output) { struct ir3_shader *shader = rzalloc_size(NULL, sizeof(*shader)); @@ -595,7 +595,7 @@ ir3_shader_from_nir(struct ir3_compiler *compiler, nir_shader *nir, if (stream_output) memcpy(&shader->stream_output, stream_output, sizeof(shader->stream_output)); - shader->num_reserved_user_consts = reserved_user_consts; + shader->num_reserved_user_consts = options->reserved_user_consts; shader->nir = nir; ir3_disk_cache_init_shader_key(compiler, shader); diff --git a/src/freedreno/ir3/ir3_shader.h b/src/freedreno/ir3/ir3_shader.h index 97f2632..4f35f00 100644 --- a/src/freedreno/ir3/ir3_shader.h +++ b/src/freedreno/ir3/ir3_shader.h @@ -819,9 +819,14 @@ struct ir3_shader_variant * ir3_shader_get_variant(struct ir3_shader *shader, const struct ir3_shader_key *key, bool binning_pass, bool keep_ir, bool *created); + +struct ir3_shader_options { + unsigned reserved_user_consts; +}; + struct ir3_shader * ir3_shader_from_nir(struct ir3_compiler *compiler, nir_shader *nir, - unsigned reserved_user_consts, + const struct ir3_shader_options *options, struct ir3_stream_output_info *stream_output); uint32_t ir3_trim_constlen(struct ir3_shader_variant **variants, const struct ir3_compiler *compiler); diff --git a/src/freedreno/vulkan/tu_clear_blit.c b/src/freedreno/vulkan/tu_clear_blit.c index 3524313..fece488 100644 --- a/src/freedreno/vulkan/tu_clear_blit.c +++ b/src/freedreno/vulkan/tu_clear_blit.c @@ -547,8 +547,10 @@ compile_shader(struct tu_device *dev, struct nir_shader *nir, ir3_finalize_nir(dev->compiler, nir); - struct ir3_shader *sh = ir3_shader_from_nir(dev->compiler, nir, - align(consts, 4), NULL); + struct ir3_shader *sh = + ir3_shader_from_nir(dev->compiler, nir, &(struct ir3_shader_options) { + .reserved_user_consts = align(consts, 4), + }, NULL); struct ir3_shader_key key = {}; bool created; diff --git a/src/freedreno/vulkan/tu_shader.c b/src/freedreno/vulkan/tu_shader.c index a6c2330..ef8d732 100644 --- a/src/freedreno/vulkan/tu_shader.c +++ b/src/freedreno/vulkan/tu_shader.c @@ -785,9 +785,9 @@ tu_shader_create(struct tu_device *dev, ir3_finalize_nir(dev->compiler, nir); shader->ir3_shader = - ir3_shader_from_nir(dev->compiler, nir, - align(shader->push_consts.count, 4), - &so_info); + ir3_shader_from_nir(dev->compiler, nir, &(struct ir3_shader_options) { + .reserved_user_consts = align(shader->push_consts.count, 4), + }, &so_info); return shader; } diff --git a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c index 92c6527..4ee1e05 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c @@ -307,7 +307,8 @@ ir3_shader_compute_state_create(struct pipe_context *pctx, nir = tgsi_to_nir(cso->prog, pctx->screen, false); } - struct ir3_shader *shader = ir3_shader_from_nir(compiler, nir, 0, NULL); + struct ir3_shader *shader = + ir3_shader_from_nir(compiler, nir, &(struct ir3_shader_options){}, NULL); shader->cs.req_input_mem = align(cso->req_input_mem, 4) / 4; /* byte->dword */ shader->cs.req_local_mem = cso->req_local_mem; @@ -367,7 +368,9 @@ ir3_shader_state_create(struct pipe_context *pctx, struct ir3_stream_output_info stream_output = {}; copy_stream_out(&stream_output, &cso->stream_output); - hwcso->shader = ir3_shader_from_nir(compiler, nir, 0, &stream_output); + hwcso->shader = + ir3_shader_from_nir(compiler, nir, &(struct ir3_shader_options){}, + &stream_output); /* * Create initial variants to avoid draw-time stalls. This is -- 2.7.4