ilo: add ilo_resource_get_bo() helper
authorChia-I Wu <olvaffe@gmail.com>
Mon, 28 Jul 2014 15:52:54 +0000 (23:52 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Mon, 28 Jul 2014 15:55:55 +0000 (23:55 +0800)
We will need it in the following commit.

src/gallium/drivers/ilo/ilo_resource.h
src/gallium/drivers/ilo/ilo_transfer.c

index 5af9cc1b440db389ea67e1a32ec78d14f480cc8d..b0eab5b9c0eed2ae3914cbda8bdee673f6591181 100644 (file)
@@ -160,6 +160,16 @@ ilo_buffer_rename_bo(struct ilo_buffer *buf);
 bool
 ilo_texture_rename_bo(struct ilo_texture *tex);
 
+/**
+ * Return the bo of the resource.
+ */
+static inline struct intel_bo *
+ilo_resource_get_bo(struct pipe_resource *res)
+{
+   return (res->target == PIPE_BUFFER) ?
+      ilo_buffer(res)->bo : ilo_texture(res)->bo;
+}
+
 static inline struct ilo_texture_slice *
 ilo_texture_get_slice(const struct ilo_texture *tex,
                       unsigned level, unsigned slice)
index 0170bb1ff91c39b6cc5016cd049f7910d0d01057..59e06b21a53003a97579d63466fac310baa6c5c2 100644 (file)
@@ -126,16 +126,6 @@ resource_get_transfer_method(struct pipe_resource *res, unsigned usage,
    return true;
 }
 
-/**
- * Return the bo of the resource.
- */
-static struct intel_bo *
-resource_get_bo(struct pipe_resource *res)
-{
-   return (res->target == PIPE_BUFFER) ?
-      ilo_buffer(res)->bo : ilo_texture(res)->bo;
-}
-
 /**
  * Rename the bo of the resource.
  */
@@ -285,19 +275,20 @@ xfer_map(struct ilo_transfer *xfer)
 
    switch (xfer->method) {
    case ILO_TRANSFER_MAP_CPU:
-      ptr = intel_bo_map(resource_get_bo(xfer->base.resource),
+      ptr = intel_bo_map(ilo_resource_get_bo(xfer->base.resource),
             xfer->base.usage & PIPE_TRANSFER_WRITE);
       break;
    case ILO_TRANSFER_MAP_GTT:
-      ptr = intel_bo_map_gtt(resource_get_bo(xfer->base.resource));
+      ptr = intel_bo_map_gtt(ilo_resource_get_bo(xfer->base.resource));
       break;
    case ILO_TRANSFER_MAP_GTT_UNSYNC:
-      ptr = intel_bo_map_unsynchronized(resource_get_bo(xfer->base.resource));
+      ptr = intel_bo_map_unsynchronized(
+            ilo_resource_get_bo(xfer->base.resource));
       break;
    case ILO_TRANSFER_MAP_STAGING:
       {
          const struct ilo_screen *is = ilo_screen(xfer->staging.res->screen);
-         struct intel_bo *bo = resource_get_bo(xfer->staging.res);
+         struct intel_bo *bo = ilo_resource_get_bo(xfer->staging.res);
 
          /*
           * We want a writable, optionally persistent and coherent, mapping
@@ -337,10 +328,10 @@ xfer_unmap(struct ilo_transfer *xfer)
    case ILO_TRANSFER_MAP_CPU:
    case ILO_TRANSFER_MAP_GTT:
    case ILO_TRANSFER_MAP_GTT_UNSYNC:
-      intel_bo_unmap(resource_get_bo(xfer->base.resource));
+      intel_bo_unmap(ilo_resource_get_bo(xfer->base.resource));
       break;
    case ILO_TRANSFER_MAP_STAGING:
-      intel_bo_unmap(resource_get_bo(xfer->staging.res));
+      intel_bo_unmap(ilo_resource_get_bo(xfer->staging.res));
       break;
    default:
       break;
@@ -1096,7 +1087,7 @@ choose_transfer_method(struct ilo_context *ilo, struct ilo_transfer *xfer)
       return false;
 
    /* see if we can avoid blocking */
-   if (is_bo_busy(ilo, resource_get_bo(res), &need_flush)) {
+   if (is_bo_busy(ilo, ilo_resource_get_bo(res), &need_flush)) {
       bool resource_renamed;
 
       if (!xfer_unblock(xfer, &resource_renamed)) {