i965: Do NIR shader cloning in the caller.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 9 Nov 2018 06:10:03 +0000 (22:10 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 20 Nov 2018 23:53:46 +0000 (15:53 -0800)
This moves nir_shader_clone() to the driver-specific compile function,
rather than the shared src/intel/compiler code.  This allows i965 to do
key-specific passes before calling brw_compile_*.  Vulkan should not
need this cloning as it doesn't compile multiple variants.

We do need to continue cloning in the compute shader code because we
lower various things in NIR based on the SIMD width.

Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
12 files changed:
src/intel/compiler/brw_compiler.h
src/intel/compiler/brw_fs.cpp
src/intel/compiler/brw_shader.cpp
src/intel/compiler/brw_vec4.cpp
src/intel/compiler/brw_vec4_gs_visitor.cpp
src/intel/compiler/brw_vec4_tcs.cpp
src/mesa/drivers/dri/i965/brw_cs.c
src/mesa/drivers/dri/i965/brw_gs.c
src/mesa/drivers/dri/i965/brw_tcs.c
src/mesa/drivers/dri/i965/brw_tes.c
src/mesa/drivers/dri/i965/brw_vs.c
src/mesa/drivers/dri/i965/brw_wm.c

index 8adc1ff8115d6cc47b5e0dd295424dc569945457..e4f4d83c8e887c68f22c79dea9a35dee77645086 100644 (file)
@@ -1239,7 +1239,7 @@ brw_compile_vs(const struct brw_compiler *compiler, void *log_data,
                void *mem_ctx,
                const struct brw_vs_prog_key *key,
                struct brw_vs_prog_data *prog_data,
-               const struct nir_shader *shader,
+               struct nir_shader *shader,
                int shader_time_index,
                char **error_str);
 
@@ -1254,7 +1254,7 @@ brw_compile_tcs(const struct brw_compiler *compiler,
                 void *mem_ctx,
                 const struct brw_tcs_prog_key *key,
                 struct brw_tcs_prog_data *prog_data,
-                const struct nir_shader *nir,
+                struct nir_shader *nir,
                 int shader_time_index,
                 char **error_str);
 
@@ -1269,7 +1269,7 @@ brw_compile_tes(const struct brw_compiler *compiler, void *log_data,
                 const struct brw_tes_prog_key *key,
                 const struct brw_vue_map *input_vue_map,
                 struct brw_tes_prog_data *prog_data,
-                const struct nir_shader *shader,
+                struct nir_shader *shader,
                 struct gl_program *prog,
                 int shader_time_index,
                 char **error_str);
@@ -1284,7 +1284,7 @@ brw_compile_gs(const struct brw_compiler *compiler, void *log_data,
                void *mem_ctx,
                const struct brw_gs_prog_key *key,
                struct brw_gs_prog_data *prog_data,
-               const struct nir_shader *shader,
+               struct nir_shader *shader,
                struct gl_program *prog,
                int shader_time_index,
                char **error_str);
@@ -1331,7 +1331,7 @@ brw_compile_fs(const struct brw_compiler *compiler, void *log_data,
                void *mem_ctx,
                const struct brw_wm_prog_key *key,
                struct brw_wm_prog_data *prog_data,
-               const struct nir_shader *shader,
+               struct nir_shader *shader,
                struct gl_program *prog,
                int shader_time_index8,
                int shader_time_index16,
index 3e08372347132ef22d9c8815f1d34758fc6a1a9d..aa29c8a4deb027d9a06f4f025b296297caf6d76b 100644 (file)
@@ -7119,7 +7119,7 @@ brw_compile_fs(const struct brw_compiler *compiler, void *log_data,
                void *mem_ctx,
                const struct brw_wm_prog_key *key,
                struct brw_wm_prog_data *prog_data,
-               const nir_shader *src_shader,
+               nir_shader *shader,
                struct gl_program *prog,
                int shader_time_index8, int shader_time_index16,
                int shader_time_index32, bool allow_spilling,
@@ -7128,7 +7128,6 @@ brw_compile_fs(const struct brw_compiler *compiler, void *log_data,
 {
    const struct gen_device_info *devinfo = compiler->devinfo;
 
-   nir_shader *shader = nir_shader_clone(mem_ctx, src_shader);
    shader = brw_nir_apply_sampler_key(shader, compiler, &key->tex, true);
    brw_nir_lower_fs_inputs(shader, devinfo, key);
    brw_nir_lower_fs_outputs(shader);
index 798c799a8286862ecc007813ca98cd767e949c0a..b77bd798d17ea0975c17905057048d8a3d7a176e 100644 (file)
@@ -1189,7 +1189,7 @@ brw_compile_tes(const struct brw_compiler *compiler,
                 const struct brw_tes_prog_key *key,
                 const struct brw_vue_map *input_vue_map,
                 struct brw_tes_prog_data *prog_data,
-                const nir_shader *src_shader,
+                nir_shader *nir,
                 struct gl_program *prog,
                 int shader_time_index,
                 char **error_str)
@@ -1198,7 +1198,6 @@ brw_compile_tes(const struct brw_compiler *compiler,
    const bool is_scalar = compiler->scalar_stage[MESA_SHADER_TESS_EVAL];
    const unsigned *assembly;
 
-   nir_shader *nir = nir_shader_clone(mem_ctx, src_shader);
    nir->info.inputs_read = key->inputs_read;
    nir->info.patch_inputs_read = key->patch_inputs_read;
 
index 74a4d09fc79ea4358671e6c2f8a4afd7b99ad936..6ed07b72f314710a1c8f7c348f4d3f6aef38820c 100644 (file)
@@ -2828,12 +2828,11 @@ brw_compile_vs(const struct brw_compiler *compiler, void *log_data,
                void *mem_ctx,
                const struct brw_vs_prog_key *key,
                struct brw_vs_prog_data *prog_data,
-               const nir_shader *src_shader,
+               nir_shader *shader,
                int shader_time_index,
                char **error_str)
 {
    const bool is_scalar = compiler->scalar_stage[MESA_SHADER_VERTEX];
-   nir_shader *shader = nir_shader_clone(mem_ctx, src_shader);
    shader = brw_nir_apply_sampler_key(shader, compiler, &key->tex, is_scalar);
 
    const unsigned *assembly = NULL;
index c4c876a0d0396e2c9500454f02b04a59a7a03c7c..63ff27e5e08d6734233e06bcc6dd6eb9d0c38d30 100644 (file)
@@ -615,7 +615,7 @@ brw_compile_gs(const struct brw_compiler *compiler, void *log_data,
                void *mem_ctx,
                const struct brw_gs_prog_key *key,
                struct brw_gs_prog_data *prog_data,
-               const nir_shader *src_shader,
+               nir_shader *shader,
                struct gl_program *prog,
                int shader_time_index,
                char **error_str)
@@ -625,7 +625,6 @@ brw_compile_gs(const struct brw_compiler *compiler, void *log_data,
    c.key = *key;
 
    const bool is_scalar = compiler->scalar_stage[MESA_SHADER_GEOMETRY];
-   nir_shader *shader = nir_shader_clone(mem_ctx, src_shader);
 
    /* The GLSL linker will have already matched up GS inputs and the outputs
     * of prior stages.  The driver does extend VS outputs in some cases, but
index 18c6dae8c10dbe81536d8470e2d798ddbf0954f3..be0969dda124be86c77a836bc74e69585f6c9c93 100644 (file)
@@ -378,7 +378,7 @@ brw_compile_tcs(const struct brw_compiler *compiler,
                 void *mem_ctx,
                 const struct brw_tcs_prog_key *key,
                 struct brw_tcs_prog_data *prog_data,
-                const nir_shader *src_shader,
+                nir_shader *nir,
                 int shader_time_index,
                 char **error_str)
 {
@@ -387,7 +387,6 @@ brw_compile_tcs(const struct brw_compiler *compiler,
    const bool is_scalar = compiler->scalar_stage[MESA_SHADER_TESS_CTRL];
    const unsigned *assembly;
 
-   nir_shader *nir = nir_shader_clone(mem_ctx, src_shader);
    nir->info.outputs_written = key->outputs_written;
    nir->info.patch_outputs_written = key->patch_outputs_written;
 
index 3ae54830f78d90f1faa6b77fae351c8ca6de12da..4d968c26656432c70453a966c870669a4ec061ff 100644 (file)
@@ -58,7 +58,7 @@ brw_codegen_cs_prog(struct brw_context *brw,
    struct brw_cs_prog_data prog_data;
    bool start_busy = false;
    double start_time = 0;
-   nir_shader *nir = cp->program.nir;
+   nir_shader *nir = nir_shader_clone(mem_ctx, cp->program.nir);
 
    memset(&prog_data, 0, sizeof(prog_data));
 
index 55c2923bdedeab2b3c699a29620c19c15d0086c1..a35ce97db3ea7f7bb8c2598713c27d3b8ac56d5a 100644 (file)
@@ -89,7 +89,7 @@ brw_codegen_gs_prog(struct brw_context *brw,
 
    void *mem_ctx = ralloc_context(NULL);
 
-   nir_shader *nir = gp->program.nir;
+   nir_shader *nir = nir_shader_clone(mem_ctx, gp->program.nir);
 
    assign_gs_binding_table_offsets(devinfo, &gp->program, &prog_data);
 
index 6e60a44fc10daadc23ba6bce9d3424bef1f9d2c6..86c09b921681be0c0ccaad50efb0d296aa6abe33 100644 (file)
@@ -84,7 +84,7 @@ brw_codegen_tcs_prog(struct brw_context *brw, struct brw_program *tcp,
 
    void *mem_ctx = ralloc_context(NULL);
    if (tcp) {
-      nir = tcp->program.nir;
+      nir = nir_shader_clone(mem_ctx, tcp->program.nir);
    } else {
       const nir_shader_compiler_options *options =
          ctx->Const.ShaderCompilerOptions[MESA_SHADER_TESS_CTRL].NirOptions;
index 8f8f68530b72ed5992c714bad1b555f927716ca4..567fed6f808de26654ebf8755aeda41604a3727c 100644 (file)
@@ -70,7 +70,6 @@ brw_codegen_tes_prog(struct brw_context *brw,
    const struct brw_compiler *compiler = brw->screen->compiler;
    const struct gen_device_info *devinfo = &brw->screen->devinfo;
    struct brw_stage_state *stage_state = &brw->tes.base;
-   nir_shader *nir = tep->program.nir;
    struct brw_tes_prog_data prog_data;
    bool start_busy = false;
    double start_time = 0;
@@ -79,6 +78,8 @@ brw_codegen_tes_prog(struct brw_context *brw,
 
    void *mem_ctx = ralloc_context(NULL);
 
+   nir_shader *nir = nir_shader_clone(mem_ctx, tep->program.nir);
+
    brw_assign_common_binding_table_offsets(devinfo, &tep->program,
                                            &prog_data.base.base, 0);
 
index d557e82f9fc3be0d958b88d10ffe2e71f1d8e90b..01ddf9a4851c6714d9a2ff8c655359b1317af80b 100644 (file)
@@ -174,7 +174,7 @@ brw_codegen_vs_prog(struct brw_context *brw,
 
    mem_ctx = ralloc_context(NULL);
 
-   nir_shader *nir = vp->program.nir;
+   nir_shader *nir = nir_shader_clone(mem_ctx, vp->program.nir);
 
    brw_assign_common_binding_table_offsets(devinfo, &vp->program,
                                            &prog_data.base.base, 0);
index 8ca6b9a84e98f8d4be67f0d9f854a54d8414642a..536e47638e690962faf66eeb34f55c3bc57fe4d8 100644 (file)
@@ -139,7 +139,7 @@ brw_codegen_wm_prog(struct brw_context *brw,
    bool start_busy = false;
    double start_time = 0;
 
-   nir_shader *nir = fp->program.nir;
+   nir_shader *nir = nir_shader_clone(mem_ctx, fp->program.nir);
 
    memset(&prog_data, 0, sizeof(prog_data));