intel/isl: Add a helper for getting the size of an interleaved pixel
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 29 Aug 2016 23:34:06 +0000 (16:34 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 13 Sep 2016 02:42:57 +0000 (19:42 -0700)
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/intel/isl/isl.c
src/intel/isl/isl.h

index 3dfdf201d9eaffdc7402afcc70067685447a1755..c19ef59edace1b1e53a9b85f9f324cd4ec2e0bad 100644 (file)
@@ -286,9 +286,8 @@ isl_choose_msaa_layout(const struct isl_device *dev,
    }
 }
 
-static void
-isl_msaa_interleaved_scale_px_to_sa(uint32_t samples,
-                                    uint32_t *width, uint32_t *height)
+struct isl_extent2d
+isl_get_interleaved_msaa_px_size_sa(uint32_t samples)
 {
    assert(isl_is_pow2(samples));
 
@@ -300,10 +299,23 @@ isl_msaa_interleaved_scale_px_to_sa(uint32_t samples,
     *    MSFMT_DEPTH_STENCIL, W_L and H_L must be adjusted as follows before
     *    proceeding: [...]
     */
+   return (struct isl_extent2d) {
+      .width = 1 << ((ffs(samples) - 0) / 2),
+      .height = 1 << ((ffs(samples) - 1) / 2),
+   };
+}
+
+static void
+isl_msaa_interleaved_scale_px_to_sa(uint32_t samples,
+                                    uint32_t *width, uint32_t *height)
+{
+   const struct isl_extent2d px_size_sa =
+      isl_get_interleaved_msaa_px_size_sa(samples);
+
    if (width)
-      *width = isl_align(*width, 2) << ((ffs(samples) - 0) / 2);
+      *width = isl_align(*width, 2) * px_size_sa.width;
    if (height)
-      *height = isl_align(*height, 2) << ((ffs(samples) - 1) / 2);
+      *height = isl_align(*height, 2) * px_size_sa.width;
 }
 
 static enum isl_array_pitch_span
index 219dd90f910d401e4b22e0c0f44ab2501332734f..3604fadb27e8714c63a9ad1e478b625fa3b12022 100644 (file)
@@ -1143,6 +1143,9 @@ isl_surf_choose_tiling(const struct isl_device *dev,
                        const struct isl_surf_init_info *restrict info,
                        enum isl_tiling *tiling);
 
+struct isl_extent2d ATTRIBUTE_CONST
+isl_get_interleaved_msaa_px_size_sa(uint32_t samples);
+
 static inline bool
 isl_surf_usage_is_display(isl_surf_usage_flags_t usage)
 {