i965: Use brw_emit_reloc() instead of drm_bacon_bo_emit_reloc().
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 28 Mar 2017 21:41:39 +0000 (14:41 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 10 Apr 2017 21:31:52 +0000 (14:31 -0700)
I'm about to make brw_emit_reloc do actual work, so everybody needs
to start using it and not the raw drm_bacon function.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
src/mesa/drivers/dri/i965/brw_cc.c
src/mesa/drivers/dri/i965/brw_clip_state.c
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_gs_state.c
src/mesa/drivers/dri/i965/brw_sampler_state.c
src/mesa/drivers/dri/i965/brw_sf_state.c
src/mesa/drivers/dri/i965/brw_vs_state.c
src/mesa/drivers/dri/i965/brw_wm_state.c
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/drivers/dri/i965/genX_blorp_exec.c
src/mesa/drivers/dri/i965/intel_batchbuffer.h

index c47e7343d816c469bd84503c2dabeff963e48753..21b01f3bb18712a7eb10865b216076ec6b5c1bf5 100644 (file)
@@ -236,11 +236,11 @@ static void upload_cc_unit(struct brw_context *brw)
    brw->ctx.NewDriverState |= BRW_NEW_GEN4_UNIT_STATE;
 
    /* Emit CC viewport relocation */
-   drm_bacon_bo_emit_reloc(brw->batch.bo,
-                          (brw->cc.state_offset +
-                           offsetof(struct brw_cc_unit_state, cc4)),
-                          brw->batch.bo, brw->cc.vp_offset,
-                          I915_GEM_DOMAIN_INSTRUCTION, 0);
+   brw_emit_reloc(&brw->batch,
+                  (brw->cc.state_offset +
+                   offsetof(struct brw_cc_unit_state, cc4)),
+                  brw->batch.bo, brw->cc.vp_offset,
+                  I915_GEM_DOMAIN_INSTRUCTION, 0);
 }
 
 const struct brw_tracked_state brw_cc_unit = {
index 148b98f14d81caafcfa8b24780196b889c2f5c64..5e084a9961dcb43084967786a80b346bf8010219 100644 (file)
@@ -29,6 +29,7 @@
   *   Keith Whitwell <keithw@vmware.com>
   */
 
+#include "intel_batchbuffer.h"
 #include "brw_context.h"
 #include "brw_state.h"
 #include "brw_defines.h"
@@ -136,11 +137,11 @@ brw_upload_clip_unit(struct brw_context *brw)
          (brw->batch.bo->offset64 + brw->clip.vp_offset) >> 5;
 
       /* emit clip viewport relocation */
-      drm_bacon_bo_emit_reloc(brw->batch.bo,
-                              (brw->clip.state_offset +
-                               offsetof(struct brw_clip_unit_state, clip6)),
-                              brw->batch.bo, brw->clip.vp_offset,
-                              I915_GEM_DOMAIN_INSTRUCTION, 0);
+      brw_emit_reloc(&brw->batch,
+                     (brw->clip.state_offset +
+                      offsetof(struct brw_clip_unit_state, clip6)),
+                     brw->batch.bo, brw->clip.vp_offset,
+                     I915_GEM_DOMAIN_INSTRUCTION, 0);
    }
 
    /* _NEW_TRANSFORM */
index 8d94b41877719567fc295b6e2f1d743ebf3abc92..00e9224d7d7722d1afe4fdce3ca9069a1c1a6bf9 100644 (file)
@@ -1609,24 +1609,6 @@ brw_program_const(const struct gl_program *p)
    return (const struct brw_program *) p;
 }
 
-static inline uint32_t
-brw_program_reloc(struct brw_context *brw, uint32_t state_offset,
-                 uint32_t prog_offset)
-{
-   if (brw->gen >= 5) {
-      /* Using state base address. */
-      return prog_offset;
-   }
-
-   drm_bacon_bo_emit_reloc(brw->batch.bo,
-                          state_offset,
-                          brw->cache.bo,
-                          prog_offset,
-                          I915_GEM_DOMAIN_INSTRUCTION, 0);
-
-   return brw->cache.bo->offset64 + prog_offset;
-}
-
 static inline bool
 brw_depth_writes_enabled(const struct brw_context *brw)
 {
index acd0f5f877dadde5283c64e3370b5acaaa460e85..ed9ae44bcdb28b2ad6c01df8d4e13954f91bdd3d 100644 (file)
@@ -34,6 +34,7 @@
 #include "brw_context.h"
 #include "brw_state.h"
 #include "brw_defines.h"
+#include "intel_batchbuffer.h"
 
 static void
 brw_upload_gs_unit(struct brw_context *brw)
index ff338809aa62e3fabf6438a6aa891204d4657dff..5d57a35f20f311849b21c6ccba1fe55b7089cad7 100644 (file)
@@ -104,10 +104,9 @@ brw_emit_sampler_state(struct brw_context *brw,
    ss[2] = border_color_offset;
    if (brw->gen < 6) {
       ss[2] += brw->batch.bo->offset64; /* reloc */
-      drm_bacon_bo_emit_reloc(brw->batch.bo,
-                              batch_offset_for_sampler_state + 8,
-                              brw->batch.bo, border_color_offset,
-                              I915_GEM_DOMAIN_SAMPLER, 0);
+      brw_emit_reloc(&brw->batch, batch_offset_for_sampler_state + 8,
+                     brw->batch.bo, border_color_offset,
+                     I915_GEM_DOMAIN_SAMPLER, 0);
    }
 
    ss[3] = SET_FIELD(max_anisotropy, BRW_SAMPLER_MAX_ANISOTROPY) |
index 7bcf59d6d7db4326f1bfd2547143d439b617c0b0..e919f5d14b40dbed0e0374b56b06b7eb221fc9c9 100644 (file)
@@ -35,6 +35,7 @@
 #include "main/macros.h"
 #include "main/fbobject.h"
 #include "main/viewport.h"
+#include "intel_batchbuffer.h"
 #include "brw_context.h"
 #include "brw_state.h"
 #include "brw_defines.h"
@@ -133,7 +134,6 @@ static void upload_sf_unit( struct brw_context *brw )
 {
    struct gl_context *ctx = &brw->ctx;
    struct brw_sf_unit_state *sf;
-   drm_bacon_bo *bo = brw->batch.bo;
    int chipset_max_threads;
    bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer);
 
@@ -291,12 +291,13 @@ static void upload_sf_unit( struct brw_context *brw )
     */
 
    /* Emit SF viewport relocation */
-   drm_bacon_bo_emit_reloc(bo, (brw->sf.state_offset +
-                               offsetof(struct brw_sf_unit_state, sf5)),
-                          brw->batch.bo, (brw->sf.vp_offset |
-                                            sf->sf5.front_winding |
-                                            (sf->sf5.viewport_transform << 1)),
-                          I915_GEM_DOMAIN_INSTRUCTION, 0);
+   brw_emit_reloc(&brw->batch,
+                  brw->sf.state_offset +
+                 offsetof(struct brw_sf_unit_state, sf5),
+                  brw->batch.bo,
+                  brw->sf.vp_offset | sf->sf5.front_winding |
+                  (sf->sf5.viewport_transform << 1),
+                  I915_GEM_DOMAIN_INSTRUCTION, 0);
 
    brw->ctx.NewDriverState |= BRW_NEW_GEN4_UNIT_STATE;
 }
index 9aa49ebeb1fbdc700f66c05c920e54bf37bf7c24..8a94eb2869c92aef8b18598dacb008af09c5ef4b 100644 (file)
@@ -31,6 +31,7 @@
 
 
 
+#include "intel_batchbuffer.h"
 #include "brw_context.h"
 #include "brw_state.h"
 #include "brw_defines.h"
@@ -159,23 +160,22 @@ brw_upload_vs_unit(struct brw_context *brw)
       /* BRW_NEW_SAMPLER_STATE_TABLE - reloc */
       vs->vs5.sampler_state_pointer =
          (brw->batch.bo->offset64 + stage_state->sampler_offset) >> 5;
-      drm_bacon_bo_emit_reloc(brw->batch.bo,
-                              stage_state->state_offset +
-                              offsetof(struct brw_vs_unit_state, vs5),
-                              brw->batch.bo,
-                              (stage_state->sampler_offset |
-                               vs->vs5.sampler_count),
-                              I915_GEM_DOMAIN_INSTRUCTION, 0);
+      brw_emit_reloc(&brw->batch,
+                     stage_state->state_offset +
+                     offsetof(struct brw_vs_unit_state, vs5),
+                     brw->batch.bo,
+                     (stage_state->sampler_offset | vs->vs5.sampler_count),
+                     I915_GEM_DOMAIN_INSTRUCTION, 0);
    }
 
    /* Emit scratch space relocation */
    if (prog_data->total_scratch != 0) {
-      drm_bacon_bo_emit_reloc(brw->batch.bo,
-                             stage_state->state_offset +
-                             offsetof(struct brw_vs_unit_state, thread2),
-                             stage_state->scratch_bo,
-                             vs->thread2.per_thread_scratch_space,
-                             I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
+      brw_emit_reloc(&brw->batch,
+                     stage_state->state_offset +
+                     offsetof(struct brw_vs_unit_state, thread2),
+                     stage_state->scratch_bo,
+                     vs->thread2.per_thread_scratch_space,
+                     I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
    }
 
    brw->ctx.NewDriverState |= BRW_NEW_GEN4_UNIT_STATE;
index 723cdc27e15ffec43b180f1c71866f73dfce1dda..5da7d6dd391705043053826776cd717626a53c86 100644 (file)
@@ -222,23 +222,23 @@ brw_upload_wm_unit(struct brw_context *brw)
 
    /* Emit scratch space relocation */
    if (prog_data->base.total_scratch != 0) {
-      drm_bacon_bo_emit_reloc(brw->batch.bo,
-                             brw->wm.base.state_offset +
-                             offsetof(struct brw_wm_unit_state, thread2),
-                             brw->wm.base.scratch_bo,
-                             wm->thread2.per_thread_scratch_space,
-                             I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
+      brw_emit_reloc(&brw->batch,
+                     brw->wm.base.state_offset +
+                     offsetof(struct brw_wm_unit_state, thread2),
+                     brw->wm.base.scratch_bo,
+                     wm->thread2.per_thread_scratch_space,
+                     I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
    }
 
    /* Emit sampler state relocation */
    if (brw->wm.base.sampler_count != 0) {
-      drm_bacon_bo_emit_reloc(brw->batch.bo,
-                             brw->wm.base.state_offset +
-                             offsetof(struct brw_wm_unit_state, wm4),
-                             brw->batch.bo, (brw->wm.base.sampler_offset |
-                                              wm->wm4.stats_enable |
-                                              (wm->wm4.sampler_count << 2)),
-                             I915_GEM_DOMAIN_INSTRUCTION, 0);
+      brw_emit_reloc(&brw->batch,
+                     brw->wm.base.state_offset +
+                     offsetof(struct brw_wm_unit_state, wm4),
+                     brw->batch.bo,
+                     brw->wm.base.sampler_offset | wm->wm4.stats_enable |
+                     (wm->wm4.sampler_count << 2),
+                     I915_GEM_DOMAIN_INSTRUCTION, 0);
    }
 
    brw->ctx.NewDriverState |= BRW_NEW_GEN4_UNIT_STATE;
index 9b59092aa7af5670408c23bdde5843010d04e815..c5824844bdc58e89a63c4379a12f9866ea8f33a5 100644 (file)
@@ -168,10 +168,8 @@ brw_emit_surface_state(struct brw_context *brw,
                        .mocs = mocs, .clear_color = clear_color,
                        .x_offset_sa = tile_x, .y_offset_sa = tile_y);
 
-   drm_bacon_bo_emit_reloc(brw->batch.bo,
-                           *surf_offset + brw->isl_dev.ss.addr_offset,
-                           mt->bo, offset,
-                           read_domains, write_domains);
+   brw_emit_reloc(&brw->batch, *surf_offset + brw->isl_dev.ss.addr_offset,
+                  mt->bo, offset, read_domains, write_domains);
 
    if (aux_surf) {
       /* On gen7 and prior, the upper 20 bits of surface state DWORD 6 are the
@@ -182,10 +180,10 @@ brw_emit_surface_state(struct brw_context *brw,
        */
       assert((aux_offset & 0xfff) == 0);
       uint32_t *aux_addr = state + brw->isl_dev.ss.aux_addr_offset;
-      drm_bacon_bo_emit_reloc(brw->batch.bo,
-                              *surf_offset + brw->isl_dev.ss.aux_addr_offset,
-                              aux_bo, *aux_addr - aux_bo->offset64,
-                              read_domains, write_domains);
+      brw_emit_reloc(&brw->batch,
+                     *surf_offset + brw->isl_dev.ss.aux_addr_offset,
+                     aux_bo, *aux_addr - aux_bo->offset64,
+                     read_domains, write_domains);
    }
 }
 
@@ -667,11 +665,10 @@ brw_emit_buffer_surface_state(struct brw_context *brw,
                          .mocs = tex_mocs[brw->gen]);
 
    if (bo) {
-      drm_bacon_bo_emit_reloc(brw->batch.bo,
-                              *out_offset + brw->isl_dev.ss.addr_offset,
-                              bo, buffer_offset,
-                              I915_GEM_DOMAIN_SAMPLER,
-                              (rw ? I915_GEM_DOMAIN_SAMPLER : 0));
+      brw_emit_reloc(&brw->batch, *out_offset + brw->isl_dev.ss.addr_offset,
+                     bo, buffer_offset,
+                     I915_GEM_DOMAIN_SAMPLER,
+                     (rw ? I915_GEM_DOMAIN_SAMPLER : 0));
    }
 }
 
@@ -842,10 +839,8 @@ brw_update_sol_surface(struct brw_context *brw,
    surf[5] = 0;
 
    /* Emit relocation to surface contents. */
-   drm_bacon_bo_emit_reloc(brw->batch.bo,
-                          *out_offset + 4,
-                          bo, offset_bytes,
-                          I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
+   brw_emit_reloc(&brw->batch, *out_offset + 4, bo, offset_bytes,
+                  I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
 }
 
 /* Creates a new WM constant buffer reflecting the current fragment program's
@@ -968,10 +963,8 @@ brw_emit_null_surface_state(struct brw_context *brw,
    surf[5] = 0;
 
    if (bo) {
-      drm_bacon_bo_emit_reloc(brw->batch.bo,
-                              *out_offset + 4,
-                              bo, 0,
-                              I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
+      brw_emit_reloc(&brw->batch, *out_offset + 4, bo, 0,
+                     I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
    }
 }
 
@@ -1071,12 +1064,8 @@ gen4_update_renderbuffer_surface(struct brw_context *brw,
       }
    }
 
-   drm_bacon_bo_emit_reloc(brw->batch.bo,
-                           offset + 4,
-                           mt->bo,
-                           surf[1] - mt->bo->offset64,
-                           I915_GEM_DOMAIN_RENDER,
-                           I915_GEM_DOMAIN_RENDER);
+   brw_emit_reloc(&brw->batch, offset + 4, mt->bo, surf[1] - mt->bo->offset64,
+                  I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
 
    return offset;
 }
index bdbce589a638bbebec0611f88a0c0236de4f1a6b..145adf84f6db62218cc6897f2f5d4fd19c22b68e 100644 (file)
@@ -69,9 +69,8 @@ blorp_surface_reloc(struct blorp_batch *batch, uint32_t ss_offset,
    struct brw_context *brw = batch->driver_batch;
    drm_bacon_bo *bo = address.buffer;
 
-   drm_bacon_bo_emit_reloc(brw->batch.bo, ss_offset,
-                           bo, address.offset + delta,
-                           address.read_domains, address.write_domain);
+   brw_emit_reloc(&brw->batch, ss_offset, bo, address.offset + delta,
+                  address.read_domains, address.write_domain);
 
    uint64_t reloc_val = bo->offset64 + address.offset + delta;
    void *reloc_ptr = (void *)brw->batch.map + ss_offset;
index d5f0fc025b76c38a96ef105210022e279db9916a..332334f130cd00a1707095b606c7efe2455d3ed5 100644 (file)
@@ -69,6 +69,21 @@ uint64_t brw_emit_reloc(struct intel_batchbuffer *batch, uint32_t batch_offset,
                         drm_bacon_bo *target, uint32_t target_offset,
                         uint32_t read_domains, uint32_t write_domain);
 
+static inline uint32_t
+brw_program_reloc(struct brw_context *brw, uint32_t state_offset,
+                 uint32_t prog_offset)
+{
+   if (brw->gen >= 5) {
+      /* Using state base address. */
+      return prog_offset;
+   }
+
+   brw_emit_reloc(&brw->batch, state_offset, brw->cache.bo, prog_offset,
+                  I915_GEM_DOMAIN_INSTRUCTION, 0);
+
+   return brw->cache.bo->offset64 + prog_offset;
+}
+
 #define USED_BATCH(batch) ((uintptr_t)((batch).map_next - (batch).map))
 
 static inline uint32_t float_as_int(float f)