From: Connor Abbott Date: Tue, 16 Jun 2020 12:02:24 +0000 (+0200) Subject: ir3: Pass reserved_user_consts to ir3_shader_from_nir() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6f2981176d96984288e1df57b84140096057eadb;p=mesa.git ir3: Pass reserved_user_consts to ir3_shader_from_nir() ir3_shader_from_nir() calls ir3_optimize_nir(), which currently sets up the const state. However, we need to know the number of user consts reserved by the driver before setting up the const state, which means that this information needs to be passed into ir3_shader_from_nir() somehow rather than being set in the shader. Part-of: --- diff --git a/src/freedreno/ir3/ir3_shader.c b/src/freedreno/ir3/ir3_shader.c index ddb2c997baf..c0f33263e88 100644 --- a/src/freedreno/ir3/ir3_shader.c +++ b/src/freedreno/ir3/ir3_shader.c @@ -335,7 +335,7 @@ ir3_setup_used_key(struct ir3_shader *shader) struct ir3_shader * ir3_shader_from_nir(struct ir3_compiler *compiler, nir_shader *nir, - struct ir3_stream_output_info *stream_output) + unsigned reserved_user_consts, struct ir3_stream_output_info *stream_output) { struct ir3_shader *shader = CALLOC_STRUCT(ir3_shader); @@ -345,6 +345,7 @@ ir3_shader_from_nir(struct ir3_compiler *compiler, nir_shader *nir, shader->type = nir->info.stage; if (stream_output) memcpy(&shader->stream_output, stream_output, sizeof(shader->stream_output)); + shader->const_state.num_reserved_user_consts = reserved_user_consts; if (nir->info.stage == MESA_SHADER_GEOMETRY) NIR_PASS_V(nir, ir3_nir_lower_gs); diff --git a/src/freedreno/ir3/ir3_shader.h b/src/freedreno/ir3/ir3_shader.h index 9fc175595ba..2fe79ea7a0f 100644 --- a/src/freedreno/ir3/ir3_shader.h +++ b/src/freedreno/ir3/ir3_shader.h @@ -646,7 +646,7 @@ void * ir3_shader_assemble(struct ir3_shader_variant *v, uint32_t gpu_id); struct ir3_shader_variant * ir3_shader_get_variant(struct ir3_shader *shader, struct ir3_shader_key *key, bool binning_pass, bool *created); struct ir3_shader * ir3_shader_from_nir(struct ir3_compiler *compiler, nir_shader *nir, - struct ir3_stream_output_info *stream_output); + unsigned reserved_user_consts, struct ir3_stream_output_info *stream_output); void ir3_shader_destroy(struct ir3_shader *shader); void ir3_shader_disasm(struct ir3_shader_variant *so, uint32_t *bin, FILE *out); uint64_t ir3_shader_outputs(const struct ir3_shader *so); diff --git a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c index 5544e0e50c7..cc986f3dc4e 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c @@ -168,7 +168,7 @@ ir3_shader_create(struct ir3_compiler *compiler, struct ir3_stream_output_info stream_output; copy_stream_out(&stream_output, &cso->stream_output); - struct ir3_shader *shader = ir3_shader_from_nir(compiler, nir, &stream_output); + struct ir3_shader *shader = ir3_shader_from_nir(compiler, nir, 0, &stream_output); /* Compile standard variants immediately to try to avoid draw-time stalls * to run the compiler. @@ -234,7 +234,7 @@ ir3_shader_create_compute(struct ir3_compiler *compiler, nir = tgsi_to_nir(cso->prog, screen, false); } - struct ir3_shader *shader = ir3_shader_from_nir(compiler, nir, NULL); + struct ir3_shader *shader = ir3_shader_from_nir(compiler, nir, 0, NULL); /* Immediately compile a standard variant. We have so few variants in our * shaders, that doing so almost eliminates draw-time recompiles. (This