[Mesa-dev] [PATCH 23/36] isl: Use logical width/height for computing physical slice0 extent

Jason Ekstrand jason at jlekstrand.net
Thu Jun 30 00:37:42 UTC 2016


Previously, we tried to take advantage of the already computed physical
level0 extent in samples.  However, this was wrong because you can't minify
a value that's expressed in samples; only pixels.  Instead, we just pull
directly from the number of pixels provided by the user.  Fortunately,
calc_phys_slice0_extent_sa_gen4_2d already takes interleaved MSAA into
account it was just doing so twice.  Now it's only adjusting from pixels to
samples in the one place where it needs to do so.
---
 src/intel/isl/isl.c | 39 +++++++++++++++------------------------
 1 file changed, 15 insertions(+), 24 deletions(-)

diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c
index 404cfc1..0bbbd53 100644
--- a/src/intel/isl/isl.c
+++ b/src/intel/isl/isl.c
@@ -568,13 +568,10 @@ isl_calc_phys_slice0_extent_sa_gen4_2d(
       const struct isl_surf_init_info *restrict info,
       enum isl_msaa_layout msaa_layout,
       const struct isl_extent3d *image_align_sa,
-      const struct isl_extent4d *phys_level0_sa,
       struct isl_extent2d *phys_slice0_sa)
 {
    const struct isl_format_layout *fmtl = isl_format_get_layout(info->format);
 
-   assert(phys_level0_sa->depth == 1);
-
    if (info->levels == 1 && msaa_layout != ISL_MSAA_LAYOUT_INTERLEAVED) {
       /* Do not pad the surface to the image alignment. Instead, pad it only
        * to the pixel format's block alignment.
@@ -592,8 +589,8 @@ isl_calc_phys_slice0_extent_sa_gen4_2d(
        * VkBufferImageCopy::bufferRowLength.
        */
       *phys_slice0_sa = (struct isl_extent2d) {
-         .w = isl_align_npot(phys_level0_sa->w, fmtl->bw),
-         .h = isl_align_npot(phys_level0_sa->h, fmtl->bh),
+         .w = isl_align_npot(info->width, fmtl->bw),
+         .h = isl_align_npot(info->height, fmtl->bh),
       };
       return;
    }
@@ -603,8 +600,8 @@ isl_calc_phys_slice0_extent_sa_gen4_2d(
    uint32_t slice_left_h = 0;
    uint32_t slice_right_h = 0;
 
-   uint32_t W0 = phys_level0_sa->w;
-   uint32_t H0 = phys_level0_sa->h;
+   uint32_t W0 = info->width;
+   uint32_t H0 = info->height;
 
    for (uint32_t l = 0; l < info->levels; ++l) {
       uint32_t W = isl_minify(W0, l);
@@ -655,18 +652,17 @@ isl_calc_phys_slice0_extent_sa_gen4_3d(
       const struct isl_device *dev,
       const struct isl_surf_init_info *restrict info,
       const struct isl_extent3d *image_align_sa,
-      const struct isl_extent4d *phys_level0_sa,
       struct isl_extent2d *phys_slice0_sa)
 {
    assert(info->samples == 1);
-   assert(phys_level0_sa->array_len == 1);
+   assert(info->array_len == 1);
 
    uint32_t slice_w = 0;
    uint32_t slice_h = 0;
 
-   uint32_t W0 = phys_level0_sa->w;
-   uint32_t H0 = phys_level0_sa->h;
-   uint32_t D0 = phys_level0_sa->d;
+   uint32_t W0 = info->width;
+   uint32_t H0 = info->height;
+   uint32_t D0 = info->depth;
 
    for (uint32_t l = 0; l < info->levels; ++l) {
       uint32_t level_w = isl_align_npot(isl_minify(W0, l), image_align_sa->w);
@@ -695,18 +691,17 @@ isl_calc_phys_slice0_extent_sa_gen9_1d(
       const struct isl_device *dev,
       const struct isl_surf_init_info *restrict info,
       const struct isl_extent3d *image_align_sa,
-      const struct isl_extent4d *phys_level0_sa,
       struct isl_extent2d *phys_slice0_sa)
 {
    MAYBE_UNUSED const struct isl_format_layout *fmtl = isl_format_get_layout(info->format);
 
-   assert(phys_level0_sa->height == 1);
-   assert(phys_level0_sa->depth == 1);
+   assert(info->height == 1);
+   assert(info->depth == 1);
    assert(info->samples == 1);
    assert(image_align_sa->w >= fmtl->bw);
 
    uint32_t slice_w = 0;
-   const uint32_t W0 = phys_level0_sa->w;
+   const uint32_t W0 = info->width;
 
    for (uint32_t l = 0; l < info->levels; ++l) {
       uint32_t W = isl_minify(W0, l);
@@ -729,23 +724,20 @@ isl_calc_phys_slice0_extent_sa(const struct isl_device *dev,
                                enum isl_dim_layout dim_layout,
                                enum isl_msaa_layout msaa_layout,
                                const struct isl_extent3d *image_align_sa,
-                               const struct isl_extent4d *phys_level0_sa,
                                struct isl_extent2d *phys_slice0_sa)
 {
    switch (dim_layout) {
    case ISL_DIM_LAYOUT_GEN9_1D:
       isl_calc_phys_slice0_extent_sa_gen9_1d(dev, info,
-                                             image_align_sa, phys_level0_sa,
-                                             phys_slice0_sa);
+                                             image_align_sa, phys_slice0_sa);
       return;
    case ISL_DIM_LAYOUT_GEN4_2D:
       isl_calc_phys_slice0_extent_sa_gen4_2d(dev, info, msaa_layout,
-                                             image_align_sa, phys_level0_sa,
-                                             phys_slice0_sa);
+                                             image_align_sa, phys_slice0_sa);
       return;
    case ISL_DIM_LAYOUT_GEN4_3D:
       isl_calc_phys_slice0_extent_sa_gen4_3d(dev, info, image_align_sa,
-                                             phys_level0_sa, phys_slice0_sa);
+                                             phys_slice0_sa);
       return;
    }
 }
@@ -1105,8 +1097,7 @@ isl_surf_init_s(const struct isl_device *dev,
 
    struct isl_extent2d phys_slice0_sa;
    isl_calc_phys_slice0_extent_sa(dev, info, dim_layout, msaa_layout,
-                                  &image_align_sa, &phys_level0_sa,
-                                  &phys_slice0_sa);
+                                  &image_align_sa, &phys_slice0_sa);
    assert(phys_slice0_sa.w % fmtl->bw == 0);
    assert(phys_slice0_sa.h % fmtl->bh == 0);
 
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list