nir: Embed the shader_info in the nir_shader again
[mesa.git] / src / mesa / drivers / dri / i965 / brw_program.c
index e1f989646c4a25ade8c3720dcbb6a82aeccbb8e6..d26dce07f9785399fccb819065978b0224e21635 100644 (file)
@@ -109,14 +109,12 @@ brw_create_nir(struct brw_context *brw,
 
    nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
 
-   /* nir_shader may have been cloned so make sure shader_info is in sync */
-   if (nir->info != &prog->info) {
-      const char *name = prog->info.name;
-      const char *label = prog->info.label;
-      prog->info = *nir->info;
-      prog->info.name = name;
-      prog->info.label = label;
-   }
+   /* Copy the info we just generated back into the gl_program */
+   const char *prog_name = prog->info.name;
+   const char *prog_label = prog->info.label;
+   prog->info = nir->info;
+   prog->info.name = prog_name;
+   prog->info.label = prog_label;
 
    if (shader_prog) {
       NIR_PASS_V(nir, nir_lower_samplers, shader_prog);
@@ -343,17 +341,17 @@ brw_blend_barrier(struct gl_context *ctx)
 
 void
 brw_get_scratch_bo(struct brw_context *brw,
-                  drm_intel_bo **scratch_bo, int size)
+                  struct brw_bo **scratch_bo, int size)
 {
-   drm_intel_bo *old_bo = *scratch_bo;
+   struct brw_bo *old_bo = *scratch_bo;
 
    if (old_bo && old_bo->size < size) {
-      drm_intel_bo_unreference(old_bo);
+      brw_bo_unreference(old_bo);
       old_bo = NULL;
    }
 
    if (!old_bo) {
-      *scratch_bo = drm_intel_bo_alloc(brw->bufmgr, "scratch bo", size, 4096);
+      *scratch_bo = brw_bo_alloc(brw->bufmgr, "scratch bo", size, 4096);
    }
 }
 
@@ -371,11 +369,11 @@ brw_alloc_stage_scratch(struct brw_context *brw,
       stage_state->per_thread_scratch = per_thread_size;
 
       if (stage_state->scratch_bo)
-         drm_intel_bo_unreference(stage_state->scratch_bo);
+         brw_bo_unreference(stage_state->scratch_bo);
 
       stage_state->scratch_bo =
-         drm_intel_bo_alloc(brw->bufmgr, "shader scratch space",
-                            per_thread_size * thread_count, 4096);
+         brw_bo_alloc(brw->bufmgr, "shader scratch space",
+                      per_thread_size * thread_count, 4096);
    }
 }
 
@@ -404,8 +402,8 @@ brw_init_shader_time(struct brw_context *brw)
 {
    const int max_entries = 2048;
    brw->shader_time.bo =
-      drm_intel_bo_alloc(brw->bufmgr, "shader time",
-                         max_entries * BRW_SHADER_TIME_STRIDE * 3, 4096);
+      brw_bo_alloc(brw->bufmgr, "shader time",
+                   max_entries * BRW_SHADER_TIME_STRIDE * 3, 4096);
    brw->shader_time.names = rzalloc_array(brw, const char *, max_entries);
    brw->shader_time.ids = rzalloc_array(brw, int, max_entries);
    brw->shader_time.types = rzalloc_array(brw, enum shader_time_shader_type,
@@ -580,7 +578,7 @@ brw_collect_shader_time(struct brw_context *brw)
     * delaying reading the reports, but it doesn't look like it's a big
     * overhead compared to the cost of tracking the time in the first place.
     */
-   drm_intel_bo_map(brw->shader_time.bo, true);
+   brw_bo_map(brw, brw->shader_time.bo, true);
    void *bo_map = brw->shader_time.bo->virtual;
 
    for (int i = 0; i < brw->shader_time.num_entries; i++) {
@@ -594,7 +592,7 @@ brw_collect_shader_time(struct brw_context *brw)
    /* Zero the BO out to clear it out for our next collection.
     */
    memset(bo_map, 0, brw->shader_time.bo->size);
-   drm_intel_bo_unmap(brw->shader_time.bo);
+   brw_bo_unmap(brw->shader_time.bo);
 }
 
 void
@@ -643,7 +641,7 @@ brw_get_shader_time_index(struct brw_context *brw, struct gl_program *prog,
 void
 brw_destroy_shader_time(struct brw_context *brw)
 {
-   drm_intel_bo_unreference(brw->shader_time.bo);
+   brw_bo_unreference(brw->shader_time.bo);
    brw->shader_time.bo = NULL;
 }
 
@@ -726,7 +724,7 @@ brw_assign_common_binding_table_offsets(const struct gen_device_info *devinfo,
       stage_prog_data->binding_table.shader_time_start = 0xd0d0d0d0;
    }
 
-   if (prog->nir->info->uses_texture_gather) {
+   if (prog->nir->info.uses_texture_gather) {
       if (devinfo->gen >= 8) {
          stage_prog_data->binding_table.gather_texture_start =
             stage_prog_data->binding_table.texture_start;