iris: Clone the NIR
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 9 Nov 2018 05:48:37 +0000 (21:48 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:09 +0000 (10:26 -0800)
The backend compiler used to do this for us, but after a rebase, it's
now the driver's responsibility.  This lets us alter it for say, clip
vertex lowering, at the global level rather than the per-variant level.

src/gallium/drivers/iris/iris_program.c

index 626098c..fdb29df 100644 (file)
@@ -471,7 +471,7 @@ iris_compile_vs(struct iris_context *ice,
    struct brw_vue_prog_data *vue_prog_data = &vs_prog_data->base;
    struct brw_stage_prog_data *prog_data = &vue_prog_data->base;
 
-   nir_shader *nir = ish->nir;
+   nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir);
 
    // XXX: alt mode
    assign_common_binding_table_offsets(devinfo, nir, prog_data, 0);
@@ -607,7 +607,7 @@ iris_compile_tcs(struct iris_context *ice,
    nir_shader *nir;
 
    if (ish) {
-      nir = ish->nir;
+      nir = nir_shader_clone(mem_ctx, ish->nir);
 
       assign_common_binding_table_offsets(devinfo, nir, prog_data, 0);
       iris_setup_uniforms(compiler, mem_ctx, nir, prog_data);
@@ -684,7 +684,7 @@ iris_compile_tes(struct iris_context *ice,
    struct brw_vue_prog_data *vue_prog_data = &tes_prog_data->base;
    struct brw_stage_prog_data *prog_data = &vue_prog_data->base;
 
-   nir_shader *nir = ish->nir;
+   nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir);
 
    assign_common_binding_table_offsets(devinfo, nir, prog_data, 0);
 
@@ -755,7 +755,7 @@ iris_compile_gs(struct iris_context *ice,
    struct brw_vue_prog_data *vue_prog_data = &gs_prog_data->base;
    struct brw_stage_prog_data *prog_data = &vue_prog_data->base;
 
-   nir_shader *nir = ish->nir;
+   nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir);
 
    assign_common_binding_table_offsets(devinfo, nir, prog_data, 0);
 
@@ -830,7 +830,7 @@ iris_compile_fs(struct iris_context *ice,
       rzalloc(mem_ctx, struct brw_wm_prog_data);
    struct brw_stage_prog_data *prog_data = &fs_prog_data->base;
 
-   nir_shader *nir = ish->nir;
+   nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir);
 
    // XXX: alt mode
    assign_common_binding_table_offsets(devinfo, nir, prog_data,
@@ -1020,7 +1020,7 @@ iris_compile_cs(struct iris_context *ice,
       rzalloc(mem_ctx, struct brw_cs_prog_data);
    struct brw_stage_prog_data *prog_data = &cs_prog_data->base;
 
-   nir_shader *nir = ish->nir;
+   nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir);
 
    cs_prog_data->binding_table.work_groups_start = 0;
    assign_common_binding_table_offsets(devinfo, nir, prog_data, 1);