i915g: prepare winsys/batchbuffer for execbuf2
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Sun, 21 Nov 2010 19:21:00 +0000 (20:21 +0100)
committerJakob Bornecrantz <wallbraker@gmail.com>
Thu, 2 Dec 2010 00:34:13 +0000 (01:34 +0100)
Wire up a fenced parameter, switch all relocations to _FENCED

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Jakob Bornecrantz <wallbraker@gmail.com>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
src/gallium/drivers/i915/i915_batch.h
src/gallium/drivers/i915/i915_batchbuffer.h
src/gallium/drivers/i915/i915_blit.c
src/gallium/drivers/i915/i915_state_emit.c
src/gallium/drivers/i915/i915_winsys.h
src/gallium/winsys/i915/drm/i915_drm_batchbuffer.c
src/gallium/winsys/i915/drm/i915_drm_winsys.c
src/gallium/winsys/i915/sw/i915_sw_batchbuffer.c

index c411b84ccd4756f72b5c8a0f9248d42c20f34f61..6e93da76209937aab21c556be8cdcf1eb4520149 100644 (file)
    i915_winsys_batchbuffer_dword(i915->batch, dword)
 
 #define OUT_RELOC(buf, usage, offset) \
-   i915_winsys_batchbuffer_reloc(i915->batch, buf, usage, offset)
+   i915_winsys_batchbuffer_reloc(i915->batch, buf, usage, offset, false)
+
+#define OUT_RELOC_FENCED(buf, usage, offset) \
+   i915_winsys_batchbuffer_reloc(i915->batch, buf, usage, offset, true)
 
 #define FLUSH_BATCH(fence) \
    i915_flush(i915, fence)
index c1cd314e7b8aca94664ebd2c9b7f0166cd3ce3c8..f210c53c72f7c825a9aa06b46519b59265e22031 100644 (file)
@@ -74,9 +74,9 @@ static INLINE int
 i915_winsys_batchbuffer_reloc(struct i915_winsys_batchbuffer *batch,
                               struct i915_winsys_buffer *buffer,
                               enum i915_winsys_buffer_usage usage,
-                              size_t offset)
+                              size_t offset, bool fenced)
 {
-   return batch->iws->batchbuffer_reloc(batch, buffer, usage, offset);
+   return batch->iws->batchbuffer_reloc(batch, buffer, usage, offset, fenced);
 }
 
 #endif
index cdf20c0055a73e124e34c746d55ea369d59350ff..97c256651563486ba8c541ec65af8486ff240efb 100644 (file)
@@ -74,7 +74,7 @@ i915_fill_blit(struct i915_context *i915,
    OUT_BATCH(BR13);
    OUT_BATCH((y << 16) | x);
    OUT_BATCH(((y + h) << 16) | (x + w));
-   OUT_RELOC(dst_buffer, I915_USAGE_2D_TARGET, dst_offset);
+   OUT_RELOC_FENCED(dst_buffer, I915_USAGE_2D_TARGET, dst_offset);
    OUT_BATCH(color);
 }
 
@@ -138,8 +138,8 @@ i915_copy_blit(struct i915_context *i915,
    OUT_BATCH(BR13);
    OUT_BATCH((dst_y << 16) | dst_x);
    OUT_BATCH((dst_y2 << 16) | dst_x2);
-   OUT_RELOC(dst_buffer, I915_USAGE_2D_TARGET, dst_offset);
+   OUT_RELOC_FENCED(dst_buffer, I915_USAGE_2D_TARGET, dst_offset);
    OUT_BATCH((src_y << 16) | src_x);
    OUT_BATCH(((int) src_pitch & 0xffff));
-   OUT_RELOC(src_buffer, I915_USAGE_2D_SOURCE, src_offset);
+   OUT_RELOC_FENCED(src_buffer, I915_USAGE_2D_SOURCE, src_offset);
 }
index 49dff1f775c040ea0c9e6ddf18159be16d879d79..51bbb2bb08eba93183462eac5c0be69fececbbf5 100644 (file)
@@ -230,7 +230,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
                    BUF_3D_PITCH(tex->stride) |  /* pitch in bytes */
                    ctile);
 
-         OUT_RELOC(tex->buffer,
+         OUT_RELOC_FENCED(tex->buffer,
                    I915_USAGE_RENDER,
                    cbuf_surface->offset);
       }
@@ -249,7 +249,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
                    BUF_3D_PITCH(tex->stride) |  /* pitch in bytes */
                    ztile);
 
-         OUT_RELOC(tex->buffer,
+         OUT_RELOC_FENCED(tex->buffer,
                    I915_USAGE_RENDER,
                    depth_surface->offset);
       }
@@ -298,7 +298,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
 
                   count++;
 
-                  OUT_RELOC(buf, I915_USAGE_SAMPLER, offset);
+                  OUT_RELOC_FENCED(buf, I915_USAGE_SAMPLER, offset);
                   OUT_BATCH(i915->current.texbuffer[unit][0]); /* MS3 */
                   OUT_BATCH(i915->current.texbuffer[unit][1]); /* MS4 */
                }
index 2ca9e581f3163db288de6b7013326469e3e25788..ddf8a906348416a1121c5da521416503b4da509e 100644 (file)
@@ -106,7 +106,7 @@ struct i915_winsys {
    int (*batchbuffer_reloc)(struct i915_winsys_batchbuffer *batch,
                             struct i915_winsys_buffer *reloc,
                             enum i915_winsys_buffer_usage usage,
-                            unsigned offset);
+                            unsigned offset, bool fenced);
 
    /**
     * Flush a bufferbatch.
index c6daa52a379e0bad756aae8ab2d109f619778853..79aa74c21be25c65074aa3e879f2ac6f89700c9b 100644 (file)
@@ -94,7 +94,7 @@ static int
 i915_drm_batchbuffer_reloc(struct i915_winsys_batchbuffer *ibatch,
                             struct i915_winsys_buffer *buffer,
                             enum i915_winsys_buffer_usage usage,
-                            unsigned pre_add)
+                            unsigned pre_add, bool fenced)
 {
    struct i915_drm_batchbuffer *batch = i915_drm_batchbuffer(ibatch);
    unsigned write_domain = 0;
@@ -104,37 +104,44 @@ i915_drm_batchbuffer_reloc(struct i915_winsys_batchbuffer *ibatch,
 
    assert(batch->base.relocs < batch->base.max_relocs);
 
-   if (usage == I915_USAGE_SAMPLER) {
+   switch (usage) {
+   case I915_USAGE_SAMPLER:
       write_domain = 0;
       read_domain = I915_GEM_DOMAIN_SAMPLER;
-
-   } else if (usage == I915_USAGE_RENDER) {
+      break;
+   case I915_USAGE_RENDER:
       write_domain = I915_GEM_DOMAIN_RENDER;
       read_domain = I915_GEM_DOMAIN_RENDER;
-
-   } else if (usage == I915_USAGE_2D_TARGET) {
+      break;
+   case I915_USAGE_2D_TARGET:
       write_domain = I915_GEM_DOMAIN_RENDER;
       read_domain = I915_GEM_DOMAIN_RENDER;
-
-   } else if (usage == I915_USAGE_2D_SOURCE) {
+      break;
+   case I915_USAGE_2D_SOURCE:
       write_domain = 0;
       read_domain = I915_GEM_DOMAIN_RENDER;
-
-   } else if (usage == I915_USAGE_VERTEX) {
+      break;
+   case I915_USAGE_VERTEX:
       write_domain = 0;
       read_domain = I915_GEM_DOMAIN_VERTEX;
-
-   } else {
+      break;
+   default:
       assert(0);
       return -1;
    }
 
    offset = (unsigned)(batch->base.ptr - batch->base.map);
 
-   ret = drm_intel_bo_emit_reloc(batch->bo, offset,
-                                 intel_bo(buffer), pre_add,
-                                 read_domain,
-                                 write_domain);
+   if (fenced)
+      ret = drm_intel_bo_emit_reloc_fence(batch->bo, offset,
+                                   intel_bo(buffer), pre_add,
+                                   read_domain,
+                                   write_domain);
+   else
+      ret = drm_intel_bo_emit_reloc(batch->bo, offset,
+                                   intel_bo(buffer), pre_add,
+                                   read_domain,
+                                   write_domain);
 
    ((uint32_t*)batch->base.ptr)[0] = intel_bo(buffer)->offset + pre_add;
    batch->base.ptr += 4;
index cc0b6a99577220e49e9b0485f290dfc6c7caba50..2288b48b2bde84cf557e565129afead87ba69889 100644 (file)
@@ -69,6 +69,7 @@ i915_drm_winsys_create(int drmFD)
 
    idws->gem_manager = drm_intel_bufmgr_gem_init(idws->fd, idws->max_batch_size);
    drm_intel_bufmgr_gem_enable_reuse(idws->gem_manager);
+   drm_intel_bufmgr_gem_enable_fenced_relocs(idws->gem_manager);
 
    idws->dump_cmd = debug_get_bool_option("I915_DUMP_CMD", FALSE);
    idws->send_cmd = !debug_get_bool_option("I915_NO_HW", FALSE);
index a480cfed57bf4b7e585f4a0083a39af4203635c8..44773ae30e7492bd368683593267af9f73128286 100644 (file)
@@ -61,7 +61,7 @@ static int
 i915_sw_batchbuffer_reloc(struct i915_winsys_batchbuffer *ibatch,
                           struct i915_winsys_buffer *buffer,
                           enum i915_winsys_buffer_usage usage,
-                          unsigned pre_add)
+                          unsigned pre_add, bool fenced)
 {
    struct i915_sw_batchbuffer *batch = i915_sw_batchbuffer(ibatch);
    int ret = 0;