isl: Add func isl_get_intratile_image_offset_el()
authorChad Versace <chad.versace@intel.com>
Mon, 25 Jan 2016 20:43:56 +0000 (12:43 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 27 Jan 2016 23:12:42 +0000 (15:12 -0800)
src/isl/isl.c
src/isl/isl.h

index 65f624ce95e1ed1c26826ab2baf645ce58af4ab8..716ce29fe8ea684910413ff309472831f3136fe3 100644 (file)
@@ -1344,3 +1344,40 @@ isl_surf_get_image_offset_el(const struct isl_surf *surf,
    *x_offset_el = x_offset_sa / fmtl->bw;
    *y_offset_el = y_offset_sa / fmtl->bh;
 }
+
+void
+isl_surf_get_image_intratile_offset_el(const struct isl_device *dev,
+                                       const struct isl_surf *surf,
+                                       uint32_t level,
+                                       uint32_t logical_array_layer,
+                                       uint32_t logical_z_offset,
+                                       uint32_t *base_address_offset,
+                                       uint32_t *x_offset_el,
+                                       uint32_t *y_offset_el)
+{
+   const struct isl_format_layout *fmtl = isl_format_get_layout(surf->format);
+
+   struct isl_tile_info tile_info;
+   isl_surf_get_tile_info(dev, surf, &tile_info);
+
+   uint32_t total_x_offset_el;
+   uint32_t total_y_offset_el;
+   isl_surf_get_image_offset_el(surf, level,
+                                logical_array_layer,
+                                logical_z_offset,
+                                &total_x_offset_el,
+                                &total_y_offset_el);
+
+   uint32_t small_y_offset_el = total_y_offset_el % tile_info.height;
+   uint32_t big_y_offset_el = total_y_offset_el - small_y_offset_el;
+   uint32_t big_y_offset_B = big_y_offset_el * surf->row_pitch;
+
+   uint32_t total_x_offset_B = total_x_offset_el * fmtl->bs;
+   uint32_t small_x_offset_B = total_x_offset_B % tile_info.width;
+   uint32_t small_x_offset_el = small_x_offset_B / fmtl->bs;
+   uint32_t big_x_offset_B = total_x_offset_B - small_x_offset_B;
+
+   *base_address_offset = big_y_offset_B + big_x_offset_B;
+   *x_offset_el = small_x_offset_el;
+   *y_offset_el = small_y_offset_el;
+}
index 392aaf7e9c5772c91526ff4f360332d0c76b60bc..bc7a315e8aec9b0063ffb35676a3ce2a7c56efde 100644 (file)
@@ -990,6 +990,26 @@ isl_surf_get_image_offset_el(const struct isl_surf *surf,
                              uint32_t *x_offset_el,
                              uint32_t *y_offset_el);
 
+/**
+ * @brief Calculate the intratile offsets to a subimage in the surface.
+ *
+ * In @a base_address_offset return the offset from the base of the surface to
+ * the base address of the first tile of the subimage. In @a x_offset_el and
+ * @a y_offset_el, return the offset, in units of surface elements, from the
+ * tile's base to the subimage's first surface element. The x and y offsets
+ * are intratile offsets; that is, they do not exceed the boundary of the
+ * surface's tiling format.
+ */
+void
+isl_surf_get_image_intratile_offset_el(const struct isl_device *dev,
+                                       const struct isl_surf *surf,
+                                       uint32_t level,
+                                       uint32_t logical_array_layer,
+                                       uint32_t logical_z_offset,
+                                       uint32_t *base_address_offset,
+                                       uint32_t *x_offset_el,
+                                       uint32_t *y_offset_el);
+
 #ifdef __cplusplus
 }
 #endif