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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5500>
This commit is contained in:
Connor Abbott
2020-06-16 14:02:24 +02:00
committed by Marge Bot
parent 89c8393a16
commit 6f2981176d
3 changed files with 5 additions and 4 deletions

View File

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

View File

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

View File

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