ilo: replace domains by reloc flags
authorChia-I Wu <olvaffe@gmail.com>
Tue, 26 Aug 2014 04:36:33 +0000 (12:36 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Tue, 26 Aug 2014 06:10:50 +0000 (14:10 +0800)
It is simpler and is supported by the kernel.  It cannot be used with
libdrm_intel yet though.

src/gallium/drivers/ilo/ilo_3d.c
src/gallium/drivers/ilo/ilo_3d_pipeline.c
src/gallium/drivers/ilo/ilo_blitter_blt.c
src/gallium/drivers/ilo/ilo_cp.c
src/gallium/drivers/ilo/ilo_cp.h
src/gallium/drivers/ilo/ilo_gpe_gen6.h
src/gallium/drivers/ilo/ilo_gpe_gen7.h
src/gallium/drivers/ilo/ilo_query.c
src/gallium/drivers/ilo/ilo_resource.c
src/gallium/winsys/intel/drm/intel_drm_winsys.c
src/gallium/winsys/intel/intel_winsys.h

index 90063761d16e4e631f51932fe5f2966ed2aaf34d..48984ba006a58de701aa07fc46cac62d0256c329 100644 (file)
@@ -746,7 +746,7 @@ upload_shaders(struct ilo_3d *hw3d, struct ilo_shader_cache *shc)
          intel_bo_unreference(hw3d->kernel.bo);
 
       hw3d->kernel.bo = intel_winsys_alloc_buffer(hw3d->cp->winsys,
-            "kernel bo", new_size, INTEL_DOMAIN_CPU);
+            "kernel bo", new_size, true);
       if (!hw3d->kernel.bo) {
          ilo_err("failed to allocate kernel bo\n");
          return false;
index 1f18bbbedfe247213ffc1cb0c0602718586fdd92..1152a7ffc3e5f48fb9c8d49fb5940353353bf4ee 100644 (file)
@@ -95,7 +95,7 @@ ilo_3d_pipeline_create(struct ilo_cp *cp, const struct ilo_dev_info *dev)
    p->invalidate_flags = ILO_3D_PIPELINE_INVALIDATE_ALL;
 
    p->workaround_bo = intel_winsys_alloc_buffer(p->cp->winsys,
-         "PIPE_CONTROL workaround", 4096, INTEL_DOMAIN_INSTRUCTION);
+         "PIPE_CONTROL workaround", 4096, false);
    if (!p->workaround_bo) {
       ilo_warn("failed to allocate PIPE_CONTROL workaround bo\n");
       FREE(p);
index 1dd00af6c9c909c097e4405f916c5c8d1fc4915b..5c2d2d498212ca932e8172e07791183c20f6846f 100644 (file)
@@ -153,8 +153,7 @@ gen6_emit_COLOR_BLT(struct ilo_dev_info *dev,
    ilo_cp_write(cp, dw0);
    ilo_cp_write(cp, dw1);
    ilo_cp_write(cp, height << 16 | width);
-   ilo_cp_write_bo(cp, dst_offset, dst_bo, INTEL_DOMAIN_RENDER,
-                                           INTEL_DOMAIN_RENDER);
+   ilo_cp_write_bo(cp, dst_offset, dst_bo, INTEL_RELOC_WRITE);
    ilo_cp_write(cp, pattern);
    ilo_cp_end(cp);
 }
@@ -204,8 +203,7 @@ gen6_emit_XY_COLOR_BLT(struct ilo_dev_info *dev,
    ilo_cp_write(cp, dw1);
    ilo_cp_write(cp, y1 << 16 | x1);
    ilo_cp_write(cp, y2 << 16 | x2);
-   ilo_cp_write_bo(cp, dst_offset, dst_bo,
-                   INTEL_DOMAIN_RENDER, INTEL_DOMAIN_RENDER);
+   ilo_cp_write_bo(cp, dst_offset, dst_bo, INTEL_RELOC_WRITE);
    ilo_cp_write(cp, pattern);
    ilo_cp_end(cp);
 }
@@ -247,10 +245,9 @@ gen6_emit_SRC_COPY_BLT(struct ilo_dev_info *dev,
    ilo_cp_write(cp, dw0);
    ilo_cp_write(cp, dw1);
    ilo_cp_write(cp, height << 16 | width);
-   ilo_cp_write_bo(cp, dst_offset, dst_bo, INTEL_DOMAIN_RENDER,
-                                           INTEL_DOMAIN_RENDER);
+   ilo_cp_write_bo(cp, dst_offset, dst_bo, INTEL_RELOC_WRITE);
    ilo_cp_write(cp, src_pitch);
-   ilo_cp_write_bo(cp, src_offset, src_bo, INTEL_DOMAIN_RENDER, 0);
+   ilo_cp_write_bo(cp, src_offset, src_bo, 0);
    ilo_cp_end(cp);
 }
 
@@ -316,11 +313,10 @@ gen6_emit_XY_SRC_COPY_BLT(struct ilo_dev_info *dev,
    ilo_cp_write(cp, dw1);
    ilo_cp_write(cp, y1 << 16 | x1);
    ilo_cp_write(cp, y2 << 16 | x2);
-   ilo_cp_write_bo(cp, dst_offset, dst_bo, INTEL_DOMAIN_RENDER,
-                                           INTEL_DOMAIN_RENDER);
+   ilo_cp_write_bo(cp, dst_offset, dst_bo, INTEL_RELOC_WRITE);
    ilo_cp_write(cp, src_y << 16 | src_x);
    ilo_cp_write(cp, src_pitch >> src_pitch_shift);
-   ilo_cp_write_bo(cp, src_offset, src_bo, INTEL_DOMAIN_RENDER, 0);
+   ilo_cp_write_bo(cp, src_offset, src_bo, 0);
    ilo_cp_end(cp);
 }
 
index ec99e0fb02eccf9240e447a74ef5c37e0d01470c..0b2bbfacf4c2b4b3474beaf87c94a95b0780bba4 100644 (file)
@@ -163,7 +163,7 @@ ilo_cp_realloc_bo(struct ilo_cp *cp)
     * won't point at the same address, which is needed for jmpbuf
     */
    bo = intel_winsys_alloc_buffer(cp->winsys,
-         "batch buffer", cp->bo_size * 4, INTEL_DOMAIN_CPU);
+         "batch buffer", cp->bo_size * 4, true);
    if (unlikely(!bo)) {
       /* reuse the old one */
       bo = cp->bo;
index 15b66040f6eedc2e6726feb0bf24ab48ca8c011d..b4963022b009bfc7a665fde0fb9eb3753f359b70 100644 (file)
@@ -320,14 +320,14 @@ ilo_cp_write_multi(struct ilo_cp *cp, const void *vals, int num_vals)
  * bo to the buffer, it also emits a relocation.
  */
 static inline void
-ilo_cp_write_bo(struct ilo_cp *cp, uint32_t val, struct intel_bo *bo,
-                uint32_t read_domains, uint32_t write_domain)
+ilo_cp_write_bo(struct ilo_cp *cp, uint32_t val,
+                struct intel_bo *bo, uint32_t flags)
 {
    uint64_t presumed_offset;
 
    if (bo) {
-      intel_bo_add_reloc(cp->bo, cp->cmd_cur * 4, bo, val,
-            read_domains, write_domain, &presumed_offset);
+      intel_bo_add_reloc(cp->bo, cp->cmd_cur * 4, bo, val, flags,
+            &presumed_offset);
    }
    else {
       presumed_offset = 0;
index 8e394ded95fec3bb7cd8623e1c17b1ed9f9bc461..efd928d2ed95fe3e6f10a51633f9dce7c7842bd7 100644 (file)
@@ -253,8 +253,6 @@ gen6_emit_MI_STORE_DATA_IMM(const struct ilo_dev_info *dev,
    const uint8_t cmd_len = (store_qword) ? 5 : 4;
    /* must use GGTT on GEN6 as in PIPE_CONTROL */
    const uint32_t cmd_flags = (dev->gen == ILO_GEN(6)) ? (1 << 22) : 0;
-   const uint32_t read_domains = INTEL_DOMAIN_INSTRUCTION;
-   const uint32_t write_domain = INTEL_DOMAIN_INSTRUCTION;
 
    ILO_GPE_VALID_GEN(dev, 6, 7.5);
 
@@ -263,7 +261,7 @@ gen6_emit_MI_STORE_DATA_IMM(const struct ilo_dev_info *dev,
    ilo_cp_begin(cp, cmd_len);
    ilo_cp_write(cp, cmd | cmd_flags | (cmd_len - 2));
    ilo_cp_write(cp, 0);
-   ilo_cp_write_bo(cp, bo_offset, bo, read_domains, write_domain);
+   ilo_cp_write_bo(cp, bo_offset, bo, INTEL_RELOC_WRITE | INTEL_RELOC_GGTT);
    ilo_cp_write(cp, (uint32_t) val);
 
    if (store_qword)
@@ -302,8 +300,6 @@ gen6_emit_MI_STORE_REGISTER_MEM(const struct ilo_dev_info *dev,
    const uint8_t cmd_len = 3;
    /* must use GGTT on GEN6 as in PIPE_CONTROL */
    const uint32_t cmd_flags = (dev->gen == ILO_GEN(6)) ? (1 << 22) : 0;
-   const uint32_t read_domains = INTEL_DOMAIN_INSTRUCTION;
-   const uint32_t write_domain = INTEL_DOMAIN_INSTRUCTION;
 
    ILO_GPE_VALID_GEN(dev, 6, 7.5);
 
@@ -312,7 +308,7 @@ gen6_emit_MI_STORE_REGISTER_MEM(const struct ilo_dev_info *dev,
    ilo_cp_begin(cp, cmd_len);
    ilo_cp_write(cp, cmd | cmd_flags | (cmd_len - 2));
    ilo_cp_write(cp, reg);
-   ilo_cp_write_bo(cp, bo_offset, bo, read_domains, write_domain);
+   ilo_cp_write_bo(cp, bo_offset, bo, INTEL_RELOC_WRITE | INTEL_RELOC_GGTT);
    ilo_cp_end(cp);
 }
 
@@ -323,8 +319,6 @@ gen6_emit_MI_REPORT_PERF_COUNT(const struct ilo_dev_info *dev,
 {
    const uint32_t cmd = ILO_GPE_MI(0x28);
    const uint8_t cmd_len = 3;
-   const uint32_t read_domains = INTEL_DOMAIN_INSTRUCTION;
-   const uint32_t write_domain = INTEL_DOMAIN_INSTRUCTION;
 
    ILO_GPE_VALID_GEN(dev, 6, 7.5);
 
@@ -336,7 +330,7 @@ gen6_emit_MI_REPORT_PERF_COUNT(const struct ilo_dev_info *dev,
 
    ilo_cp_begin(cp, cmd_len);
    ilo_cp_write(cp, cmd | (cmd_len - 2));
-   ilo_cp_write_bo(cp, bo_offset, bo, read_domains, write_domain);
+   ilo_cp_write_bo(cp, bo_offset, bo, INTEL_RELOC_WRITE | INTEL_RELOC_GGTT);
    ilo_cp_write(cp, report_id);
    ilo_cp_end(cp);
 }
@@ -366,26 +360,14 @@ gen6_emit_STATE_BASE_ADDRESS(const struct ilo_dev_info *dev,
    ilo_cp_begin(cp, cmd_len);
    ilo_cp_write(cp, cmd | (cmd_len - 2));
 
-   ilo_cp_write_bo(cp, 1, general_state_bo,
-                       INTEL_DOMAIN_RENDER,
-                       0);
-   ilo_cp_write_bo(cp, 1, surface_state_bo,
-                       INTEL_DOMAIN_SAMPLER,
-                       0);
-   ilo_cp_write_bo(cp, 1, dynamic_state_bo,
-                       INTEL_DOMAIN_RENDER | INTEL_DOMAIN_INSTRUCTION,
-                       0);
-   ilo_cp_write_bo(cp, 1, indirect_object_bo,
-                       0,
-                       0);
-   ilo_cp_write_bo(cp, 1, instruction_bo,
-                       INTEL_DOMAIN_INSTRUCTION,
-                       0);
+   ilo_cp_write_bo(cp, 1, general_state_bo, 0);
+   ilo_cp_write_bo(cp, 1, surface_state_bo, 0);
+   ilo_cp_write_bo(cp, 1, dynamic_state_bo, 0);
+   ilo_cp_write_bo(cp, 1, indirect_object_bo, 0);
+   ilo_cp_write_bo(cp, 1, instruction_bo, 0);
 
    if (general_state_size) {
-      ilo_cp_write_bo(cp, general_state_size | 1, general_state_bo,
-                          INTEL_DOMAIN_RENDER,
-                          0);
+      ilo_cp_write_bo(cp, general_state_size | 1, general_state_bo, 0);
    }
    else {
       /* skip range check */
@@ -393,9 +375,7 @@ gen6_emit_STATE_BASE_ADDRESS(const struct ilo_dev_info *dev,
    }
 
    if (dynamic_state_size) {
-      ilo_cp_write_bo(cp, dynamic_state_size | 1, dynamic_state_bo,
-                          INTEL_DOMAIN_RENDER | INTEL_DOMAIN_INSTRUCTION,
-                          0);
+      ilo_cp_write_bo(cp, dynamic_state_size | 1, dynamic_state_bo, 0);
    }
    else {
       /* skip range check */
@@ -403,9 +383,7 @@ gen6_emit_STATE_BASE_ADDRESS(const struct ilo_dev_info *dev,
    }
 
    if (indirect_object_size) {
-      ilo_cp_write_bo(cp, indirect_object_size | 1, indirect_object_bo,
-                          0,
-                          0);
+      ilo_cp_write_bo(cp, indirect_object_size | 1, indirect_object_bo, 0);
    }
    else {
       /* skip range check */
@@ -413,9 +391,7 @@ gen6_emit_STATE_BASE_ADDRESS(const struct ilo_dev_info *dev,
    }
 
    if (instruction_size) {
-      ilo_cp_write_bo(cp, instruction_size | 1, instruction_bo,
-                          INTEL_DOMAIN_INSTRUCTION,
-                          0);
+      ilo_cp_write_bo(cp, instruction_size | 1, instruction_bo, 0);
    }
    else {
       /* skip range check */
@@ -741,8 +717,8 @@ gen6_emit_3DSTATE_VERTEX_BUFFERS(const struct ilo_dev_info *dev,
          dw |= cso->stride << GEN6_VB_STATE_DW0_PITCH__SHIFT;
 
          ilo_cp_write(cp, dw);
-         ilo_cp_write_bo(cp, start_offset, buf->bo, INTEL_DOMAIN_VERTEX, 0);
-         ilo_cp_write_bo(cp, end_offset, buf->bo, INTEL_DOMAIN_VERTEX, 0);
+         ilo_cp_write_bo(cp, start_offset, buf->bo, 0);
+         ilo_cp_write_bo(cp, end_offset, buf->bo, 0);
          ilo_cp_write(cp, instance_divisor);
       }
       else {
@@ -951,8 +927,8 @@ gen6_emit_3DSTATE_INDEX_BUFFER(const struct ilo_dev_info *dev,
    ilo_cp_write(cp, cmd | (cmd_len - 2) |
                     ((enable_cut_index) ? GEN6_IB_DW0_CUT_INDEX_ENABLE : 0) |
                     format);
-   ilo_cp_write_bo(cp, start_offset, buf->bo, INTEL_DOMAIN_VERTEX, 0);
-   ilo_cp_write_bo(cp, end_offset, buf->bo, INTEL_DOMAIN_VERTEX, 0);
+   ilo_cp_write_bo(cp, start_offset, buf->bo, 0);
+   ilo_cp_write_bo(cp, end_offset, buf->bo, 0);
    ilo_cp_end(cp);
 }
 
@@ -1527,8 +1503,7 @@ gen6_emit_3DSTATE_DEPTH_BUFFER(const struct ilo_dev_info *dev,
    ilo_cp_begin(cp, cmd_len);
    ilo_cp_write(cp, cmd | (cmd_len - 2));
    ilo_cp_write(cp, zs->payload[0]);
-   ilo_cp_write_bo(cp, zs->payload[1], zs->bo,
-         INTEL_DOMAIN_RENDER, INTEL_DOMAIN_RENDER);
+   ilo_cp_write_bo(cp, zs->payload[1], zs->bo, INTEL_RELOC_WRITE);
    ilo_cp_write(cp, zs->payload[2]);
    ilo_cp_write(cp, zs->payload[3]);
    ilo_cp_write(cp, zs->payload[4]);
@@ -1713,8 +1688,7 @@ gen6_emit_3DSTATE_STENCIL_BUFFER(const struct ilo_dev_info *dev,
    ilo_cp_write(cp, cmd | (cmd_len - 2));
    /* see ilo_gpe_init_zs_surface() */
    ilo_cp_write(cp, zs->payload[6]);
-   ilo_cp_write_bo(cp, zs->payload[7], zs->separate_s8_bo,
-         INTEL_DOMAIN_RENDER, INTEL_DOMAIN_RENDER);
+   ilo_cp_write_bo(cp, zs->payload[7], zs->separate_s8_bo, INTEL_RELOC_WRITE);
    ilo_cp_end(cp);
 }
 
@@ -1734,8 +1708,7 @@ gen6_emit_3DSTATE_HIER_DEPTH_BUFFER(const struct ilo_dev_info *dev,
    ilo_cp_write(cp, cmd | (cmd_len - 2));
    /* see ilo_gpe_init_zs_surface() */
    ilo_cp_write(cp, zs->payload[8]);
-   ilo_cp_write_bo(cp, zs->payload[9], zs->hiz_bo,
-         INTEL_DOMAIN_RENDER, INTEL_DOMAIN_RENDER);
+   ilo_cp_write_bo(cp, zs->payload[9], zs->hiz_bo, INTEL_RELOC_WRITE);
    ilo_cp_end(cp);
 }
 
@@ -1765,8 +1738,6 @@ gen6_emit_PIPE_CONTROL(const struct ilo_dev_info *dev,
 {
    const uint32_t cmd = ILO_GPE_CMD(0x3, 0x2, 0x00);
    const uint8_t cmd_len = (write_qword) ? 5 : 4;
-   const uint32_t read_domains = INTEL_DOMAIN_INSTRUCTION;
-   const uint32_t write_domain = INTEL_DOMAIN_INSTRUCTION;
 
    ILO_GPE_VALID_GEN(dev, 6, 7.5);
 
@@ -1839,7 +1810,7 @@ gen6_emit_PIPE_CONTROL(const struct ilo_dev_info *dev,
    ilo_cp_begin(cp, cmd_len);
    ilo_cp_write(cp, cmd | (cmd_len - 2));
    ilo_cp_write(cp, dw1);
-   ilo_cp_write_bo(cp, bo_offset, bo, read_domains, write_domain);
+   ilo_cp_write_bo(cp, bo_offset, bo, INTEL_RELOC_WRITE | INTEL_RELOC_GGTT);
    ilo_cp_write(cp, 0);
    if (write_qword)
       ilo_cp_write(cp, 0);
@@ -2286,26 +2257,16 @@ gen6_emit_SURFACE_STATE(const struct ilo_dev_info *dev,
    const int state_align = 32 / 4;
    const int state_len = (dev->gen >= ILO_GEN(7)) ? 8 : 6;
    uint32_t state_offset;
-   uint32_t read_domains, write_domain;
 
    ILO_GPE_VALID_GEN(dev, 6, 7.5);
 
-   if (for_render) {
-      read_domains = INTEL_DOMAIN_RENDER;
-      write_domain = INTEL_DOMAIN_RENDER;
-   }
-   else {
-      read_domains = INTEL_DOMAIN_SAMPLER;
-      write_domain = 0;
-   }
-
    ilo_cp_steal(cp, "SURFACE_STATE", state_len, state_align, &state_offset);
 
    STATIC_ASSERT(Elements(surf->payload) >= 8);
 
    ilo_cp_write(cp, surf->payload[0]);
-   ilo_cp_write_bo(cp, surf->payload[1],
-         surf->bo, read_domains, write_domain);
+   ilo_cp_write_bo(cp, surf->payload[1], surf->bo,
+         (for_render) ? INTEL_RELOC_WRITE : 0);
    ilo_cp_write(cp, surf->payload[2]);
    ilo_cp_write(cp, surf->payload[3]);
    ilo_cp_write(cp, surf->payload[4]);
index 0816fd674775586cb0ec6deec5b0f04ee1905d62..bbba9cd6b01d810d417798692ab2b5b77ad729e6 100644 (file)
@@ -1036,8 +1036,8 @@ gen7_emit_3DSTATE_SO_BUFFER(const struct ilo_dev_info *dev,
    ilo_cp_write(cp, cmd | (cmd_len - 2));
    ilo_cp_write(cp, index << GEN7_SO_BUF_DW1_INDEX__SHIFT |
                     stride);
-   ilo_cp_write_bo(cp, base, buf->bo, INTEL_DOMAIN_RENDER, INTEL_DOMAIN_RENDER);
-   ilo_cp_write_bo(cp, end, buf->bo, INTEL_DOMAIN_RENDER, INTEL_DOMAIN_RENDER);
+   ilo_cp_write_bo(cp, base, buf->bo, INTEL_RELOC_WRITE);
+   ilo_cp_write_bo(cp, end, buf->bo, INTEL_RELOC_WRITE);
    ilo_cp_end(cp);
 }
 
index 46e6bf766e16334ae6acb2984499dd87d6b6dfe2..72fc1c70a70c1eaf5e1647eab1c3934072ff2021 100644 (file)
@@ -229,7 +229,7 @@ ilo_query_alloc_bo(struct ilo_query *q, int reg_count, int repeat_count,
          intel_bo_unreference(q->bo);
 
       q->bo = intel_winsys_alloc_buffer(winsys,
-            name, size, INTEL_DOMAIN_INSTRUCTION);
+            name, size, false);
       q->reg_total = (q->bo) ? reg_total : 0;
    }
 
index 54d6c368ae9bec95f70d663074a2987893f5b452..d312a4dffddfb59fa56d65dc8359b88acb7b2b9a 100644 (file)
@@ -76,13 +76,12 @@ resource_get_bo_name(const struct pipe_resource *templ)
    return name;
 }
 
-static enum intel_domain_flag
-resource_get_bo_initial_domain(const struct pipe_resource *templ)
+static bool
+resource_get_cpu_init(const struct pipe_resource *templ)
 {
    return (templ->bind & (PIPE_BIND_DEPTH_STENCIL |
                           PIPE_BIND_RENDER_TARGET |
-                          PIPE_BIND_STREAM_OUTPUT)) ?
-      INTEL_DOMAIN_RENDER : 0;
+                          PIPE_BIND_STREAM_OUTPUT)) ? false : true;
 }
 
 static void
@@ -152,11 +151,10 @@ tex_create_bo(struct ilo_texture *tex)
 {
    struct ilo_screen *is = ilo_screen(tex->base.screen);
    const char *name = resource_get_bo_name(&tex->base);
-   const enum intel_domain_flag initial_domain =
-      resource_get_bo_initial_domain(&tex->base);
+   const bool cpu_init = resource_get_cpu_init(&tex->base);
 
    tex->bo = intel_winsys_alloc_bo(is->winsys, name, tex->layout.tiling,
-         tex->layout.bo_stride, tex->layout.bo_height, initial_domain);
+         tex->layout.bo_stride, tex->layout.bo_height, cpu_init);
 
    return (tex->bo != NULL);
 }
@@ -194,7 +192,7 @@ tex_create_hiz(struct ilo_texture *tex)
 
    tex->aux_bo = intel_winsys_alloc_bo(is->winsys, "hiz texture",
          INTEL_TILING_Y, tex->layout.aux_stride, tex->layout.aux_height,
-         INTEL_DOMAIN_RENDER);
+         false);
    if (!tex->aux_bo)
       return false;
 
@@ -224,7 +222,7 @@ tex_create_mcs(struct ilo_texture *tex)
 
    tex->aux_bo = intel_winsys_alloc_bo(is->winsys, "mcs texture",
          INTEL_TILING_Y, tex->layout.aux_stride, tex->layout.aux_height,
-         INTEL_DOMAIN_RENDER);
+         false);
    if (!tex->aux_bo)
       return false;
 
@@ -357,11 +355,10 @@ buf_create_bo(struct ilo_buffer *buf)
 {
    struct ilo_screen *is = ilo_screen(buf->base.screen);
    const char *name = resource_get_bo_name(&buf->base);
-   const enum intel_domain_flag initial_domain =
-      resource_get_bo_initial_domain(&buf->base);
+   const bool cpu_init = resource_get_cpu_init(&buf->base);
 
    buf->bo = intel_winsys_alloc_buffer(is->winsys, name,
-         buf->bo_size, initial_domain);
+         buf->bo_size, cpu_init);
 
    return (buf->bo != NULL);
 }
index f94a1cb9f338cd8e72424b14ee8f0a1d729f01ea..c8ae6c16a8c297426ea24786f8702fbd30f8c803 100644 (file)
@@ -195,12 +195,7 @@ intel_winsys_create_for_fd(int fd)
 
    /*
     * No need to implicitly set up a fence register for each non-linear reloc
-    * entry.  When a fence register is needed for a reloc entry,
-    * drm_intel_bo_emit_reloc_fence() will be called explicitly.
-    *
-    * intel_bo_add_reloc() currently lacks "bool fenced" for this to work.
-    * But we never need a fence register on GEN4+ so we do not need to worry
-    * about it yet.
+    * entry.  INTEL_RELOC_FENCE will be set on reloc entries that need them.
     */
    drm_intel_bufmgr_gem_enable_fenced_relocs(winsys->bufmgr);
 
@@ -266,10 +261,8 @@ intel_winsys_alloc_bo(struct intel_winsys *winsys,
                       enum intel_tiling_mode tiling,
                       unsigned long pitch,
                       unsigned long height,
-                      uint32_t initial_domain)
+                      bool cpu_init)
 {
-   const bool for_render =
-      (initial_domain & (INTEL_DOMAIN_RENDER | INTEL_DOMAIN_INSTRUCTION));
    const unsigned int alignment = 4096; /* always page-aligned */
    unsigned long size;
    drm_intel_bo *bo;
@@ -292,12 +285,12 @@ intel_winsys_alloc_bo(struct intel_winsys *winsys,
 
    size = pitch * height;
 
-   if (for_render) {
-      bo = drm_intel_bo_alloc_for_render(winsys->bufmgr,
-            name, size, alignment);
+   if (cpu_init) {
+      bo = drm_intel_bo_alloc(winsys->bufmgr, name, size, alignment);
    }
    else {
-      bo = drm_intel_bo_alloc(winsys->bufmgr, name, size, alignment);
+      bo = drm_intel_bo_alloc_for_render(winsys->bufmgr,
+            name, size, alignment);
    }
 
    if (bo && tiling != INTEL_TILING_NONE) {
@@ -558,14 +551,37 @@ intel_bo_pread(struct intel_bo *bo, unsigned long offset,
 int
 intel_bo_add_reloc(struct intel_bo *bo, uint32_t offset,
                    struct intel_bo *target_bo, uint32_t target_offset,
-                   uint32_t read_domains, uint32_t write_domain,
-                   uint64_t *presumed_offset)
+                   uint32_t flags, uint64_t *presumed_offset)
 {
+   uint32_t read_domains, write_domain;
    int err;
 
-   err = drm_intel_bo_emit_reloc(gem_bo(bo), offset,
-         gem_bo(target_bo), target_offset,
-         read_domains, write_domain);
+   if (flags & INTEL_RELOC_WRITE) {
+      /*
+       * Because of the translation to domains, INTEL_RELOC_GGTT should only
+       * be set on GEN6 when the bo is written by MI_* or PIPE_CONTROL.  The
+       * kernel will translate it back to INTEL_RELOC_GGTT.
+       */
+      write_domain = (flags & INTEL_RELOC_GGTT) ?
+         I915_GEM_DOMAIN_INSTRUCTION : I915_GEM_DOMAIN_RENDER;
+      read_domains = write_domain;
+   } else {
+      write_domain = 0;
+      read_domains = I915_GEM_DOMAIN_RENDER |
+                     I915_GEM_DOMAIN_SAMPLER |
+                     I915_GEM_DOMAIN_INSTRUCTION |
+                     I915_GEM_DOMAIN_VERTEX;
+   }
+
+   if (flags & INTEL_RELOC_FENCE) {
+      err = drm_intel_bo_emit_reloc_fence(gem_bo(bo), offset,
+            gem_bo(target_bo), target_offset,
+            read_domains, write_domain);
+   } else {
+      err = drm_intel_bo_emit_reloc(gem_bo(bo), offset,
+            gem_bo(target_bo), target_offset,
+            read_domains, write_domain);
+   }
 
    *presumed_offset = gem_bo(target_bo)->offset64 + target_offset;
 
index 679f24817b875df1b13b94a70148f0901845cabb..bc18bb69be5ac2290f4a4850b9beae7ba1f62fb1 100644 (file)
@@ -44,14 +44,10 @@ enum intel_exec_flag {
 };
 
 /* this is compatible with i915_drm.h's definitions */
-enum intel_domain_flag {
-   INTEL_DOMAIN_CPU           = 0x00000001,
-   INTEL_DOMAIN_RENDER        = 0x00000002,
-   INTEL_DOMAIN_SAMPLER       = 0x00000004,
-   INTEL_DOMAIN_COMMAND              = 0x00000008,
-   INTEL_DOMAIN_INSTRUCTION   = 0x00000010,
-   INTEL_DOMAIN_VERTEX        = 0x00000020,
-   INTEL_DOMAIN_GTT           = 0x00000040,
+enum intel_reloc_flag {
+   INTEL_RELOC_FENCE          = 1 << 0,
+   INTEL_RELOC_GGTT           = 1 << 1,
+   INTEL_RELOC_WRITE          = 1 << 2,
 };
 
 /* this is compatible with i915_drm.h's definitions */
@@ -126,7 +122,7 @@ intel_winsys_read_reg(struct intel_winsys *winsys,
  * \param tiling           Tiling mode.
  * \param pitch            Pitch of the bo.
  * \param height           Height of the bo.
- * \param initial_domain   Initial (write) domain.
+ * \param cpu_init         Will be initialized by CPU.
  */
 struct intel_bo *
 intel_winsys_alloc_bo(struct intel_winsys *winsys,
@@ -134,7 +130,7 @@ intel_winsys_alloc_bo(struct intel_winsys *winsys,
                       enum intel_tiling_mode tiling,
                       unsigned long pitch,
                       unsigned long height,
-                      uint32_t initial_domain);
+                      bool cpu_init);
 
 /**
  * Allocate a linear buffer object.
@@ -143,10 +139,10 @@ static inline struct intel_bo *
 intel_winsys_alloc_buffer(struct intel_winsys *winsys,
                           const char *name,
                           unsigned long size,
-                          uint32_t initial_domain)
+                          bool cpu_init)
 {
    return intel_winsys_alloc_bo(winsys, name,
-         INTEL_TILING_NONE, size, 1, initial_domain);
+         INTEL_TILING_NONE, size, 1, cpu_init);
 }
 
 /**
@@ -275,8 +271,7 @@ intel_bo_pread(struct intel_bo *bo, unsigned long offset,
 int
 intel_bo_add_reloc(struct intel_bo *bo, uint32_t offset,
                    struct intel_bo *target_bo, uint32_t target_offset,
-                   uint32_t read_domains, uint32_t write_domain,
-                   uint64_t *presumed_offset);
+                   uint32_t flags, uint64_t *presumed_offset);
 
 /**
  * Return the current number of relocations.