ir3: Pass reserved_user_consts to ir3_shader_from_nir()
authorConnor Abbott <cwabbott0@gmail.com>
Tue, 16 Jun 2020 12:02:24 +0000 (14:02 +0200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 17 Jun 2020 13:13:05 +0000 (13:13 +0000)
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>

src/freedreno/ir3/ir3_shader.c
src/freedreno/ir3/ir3_shader.h
src/gallium/drivers/freedreno/ir3/ir3_gallium.c

index ddb2c997baf6071d8498476f5505c9f5ef6c4b53..c0f33263e883a6e86485902497f25412df783921 100644 (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);
index 9fc175595ba031fc0ea5447c44da085f218b2155..2fe79ea7a0f3911b0e99af094916f5f0d4a5e1a0 100644 (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);
index 5544e0e50c71e5f1ac8510d2b303aea542381736..cc986f3dc4e673be0fa2f3334a12a2bde45495a0 100644 (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