isl: Let isl_surf_init's caller set the exact row pitch (v2)
authorChad Versace <chadversary@chromium.org>
Sat, 25 Feb 2017 00:30:13 +0000 (16:30 -0800)
committerChad Versace <chadversary@chromium.org>
Tue, 28 Mar 2017 16:44:44 +0000 (09:44 -0700)
The caller does so by setting the new field
isl_surf_init_info::row_pitch.

v2: Validate the requested row_pitch.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> (v2)
src/intel/isl/isl.c
src/intel/isl/isl.h

index 749fcdf46b08a001f4c11f6130ceecbb30727101..98a1152c282ddffecee8295db22703486329e961 100644 (file)
@@ -1118,10 +1118,22 @@ isl_calc_row_pitch(const struct isl_device *dev,
    const uint32_t alignment =
       isl_calc_row_pitch_alignment(surf_info, tile_info);
 
-   const uint32_t row_pitch =
+   const uint32_t min_row_pitch =
       isl_calc_min_row_pitch(dev, surf_info, tile_info, phys_slice0_sa,
                              alignment);
 
+   uint32_t row_pitch = min_row_pitch;
+
+   if (surf_info->row_pitch != 0) {
+      row_pitch = surf_info->row_pitch;
+
+      if (row_pitch < min_row_pitch)
+         return false;
+
+      if (row_pitch % alignment != 0)
+         return false;
+   }
+
    const uint32_t row_pitch_tiles = row_pitch / tile_info->phys_extent_B.width;
 
    if (row_pitch == 0)
index 9d92906ca71a197ce02b83663d72660663911a3c..012be7b98e7a442c5b02a469fb845fbb4dd22709 100644 (file)
@@ -813,6 +813,12 @@ struct isl_surf_init_info {
    /** Lower bound for isl_surf::pitch, in bytes. */
    uint32_t min_pitch;
 
+   /**
+    * Exact value for isl_surf::row_pitch. Ignored if zero.  isl_surf_init()
+    * will fail if this is misaligned or out of bounds.
+    */
+   uint32_t row_pitch;
+
    isl_surf_usage_flags_t usage;
 
    /** Flags that alter how ISL selects isl_surf::tiling.  */