ir3, freedreno: Add options struct for ir3_shader_from_nir()

We'll expand this in a moment.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13960>
This commit is contained in:
Connor Abbott 2021-11-25 14:30:46 +01:00 committed by Marge Bot
parent fe9c9ec83f
commit 9ebc48005c
5 changed files with 20 additions and 10 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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;
}

View file

@ -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