isl: Add func isl_surf_get_image_offset_el()
authorChad Versace <chad.versace@intel.com>
Mon, 25 Jan 2016 20:15:07 +0000 (12:15 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 27 Jan 2016 23:12:42 +0000 (15:12 -0800)
This replaces function isl_surf_get_image_offset_sa()

src/isl/isl.c
src/isl/isl.h
src/isl/tests/isl_surf_get_image_offset_test.c

index ec66f97b779f9af0355d69d8c5d30373b4f34d75..65f624ce95e1ed1c26826ab2baf645ce58af4ab8 100644 (file)
@@ -1282,13 +1282,21 @@ get_image_offset_sa_gen9_1d(const struct isl_surf *surf,
    *y_offset_sa = layer * isl_surf_get_array_pitch_sa_rows(surf);
 }
 
-void
-isl_surf_get_image_offset_sa(const struct isl_surf *surf,
-                             uint32_t level,
-                             uint32_t logical_array_layer,
-                             uint32_t logical_z_offset_px,
-                             uint32_t *x_offset_sa,
-                             uint32_t *y_offset_sa)
+/**
+ * Calculate the offset, in units of surface samples, to a subimage in the
+ * surface.
+ *
+ * @invariant level < surface levels
+ * @invariant logical_array_layer < logical array length of surface
+ * @invariant logical_z_offset_px < logical depth of surface at level
+ */
+static void
+get_image_offset_sa(const struct isl_surf *surf,
+                    uint32_t level,
+                    uint32_t logical_array_layer,
+                    uint32_t logical_z_offset_px,
+                    uint32_t *x_offset_sa,
+                    uint32_t *y_offset_sa)
 {
    assert(level < surf->levels);
    assert(logical_array_layer < surf->logical_level0_px.array_len);
@@ -1310,3 +1318,29 @@ isl_surf_get_image_offset_sa(const struct isl_surf *surf,
       break;
    }
 }
+
+void
+isl_surf_get_image_offset_el(const struct isl_surf *surf,
+                             uint32_t level,
+                             uint32_t logical_array_layer,
+                             uint32_t logical_z_offset_px,
+                             uint32_t *x_offset_el,
+                             uint32_t *y_offset_el)
+{
+   const struct isl_format_layout *fmtl = isl_format_get_layout(surf->format);
+
+   assert(level < surf->levels);
+   assert(logical_array_layer < surf->logical_level0_px.array_len);
+   assert(logical_z_offset_px
+          < isl_minify(surf->logical_level0_px.depth, level));
+
+   uint32_t x_offset_sa, y_offset_sa;
+   get_image_offset_sa(surf, level,
+                       logical_array_layer,
+                       logical_z_offset_px,
+                       &x_offset_sa,
+                       &y_offset_sa);
+
+   *x_offset_el = x_offset_sa / fmtl->bw;
+   *y_offset_el = y_offset_sa / fmtl->bh;
+}
index 3eada623fbe7c6adad5069ac0ed21ef4b1452107..392aaf7e9c5772c91526ff4f360332d0c76b60bc 100644 (file)
@@ -975,20 +975,20 @@ isl_surf_get_array_pitch(const struct isl_surf *surf)
 }
 
 /**
- * Get the offset to an subimage within the surface, in units of surface
- * samples.
+ * Calculate the offset, in units of surface elements, to a subimage in the
+ * surface.
  *
  * @invariant level < surface levels
  * @invariant logical_array_layer < logical array length of surface
  * @invariant logical_z_offset_px < logical depth of surface at level
  */
 void
-isl_surf_get_image_offset_sa(const struct isl_surf *surf,
+isl_surf_get_image_offset_el(const struct isl_surf *surf,
                              uint32_t level,
                              uint32_t logical_array_layer,
                              uint32_t logical_z_offset_px,
-                             uint32_t *x_offset_sa,
-                             uint32_t *y_offset_sa);
+                             uint32_t *x_offset_el,
+                             uint32_t *y_offset_el);
 
 #ifdef __cplusplus
 }
index 525180ea204aa2a7a026fec98016fb3d80f8d556..b0b4635359cbc1acbd1607afb67fe89a1e507fcc 100644 (file)
@@ -82,15 +82,15 @@ t_assert_offset(const struct isl_surf *surf,
                 uint32_t level,
                 uint32_t logical_array_layer,
                 uint32_t logical_z_offset_px,
-                uint32_t expected_x_offset_sa,
-                uint32_t expected_y_offset_sa)
+                uint32_t expected_x_offset_el,
+                uint32_t expected_y_offset_el)
 {
    uint32_t x, y;
-   isl_surf_get_image_offset_sa(surf, level, logical_array_layer,
+   isl_surf_get_image_offset_el(surf, level, logical_array_layer,
                                 logical_z_offset_px, &x, &y);
 
-   t_assert(x == expected_x_offset_sa);
-   t_assert(y == expected_y_offset_sa);
+   t_assert(x == expected_x_offset_el);
+   t_assert(y == expected_y_offset_el);
 }
 
 static void