Mesa (staging/19.1): intel: Add and use helpers for level0 extent
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jun 28 08:18:43 UTC 2019
Module: Mesa
Branch: staging/19.1
Commit: eef57b818bd5332912941fed592f30e5631f7eab
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=eef57b818bd5332912941fed592f30e5631f7eab
Author: Nanley Chery <nanley.g.chery at intel.com>
Date: Thu May 23 13:44:52 2019 -0700
intel: Add and use helpers for level0 extent
Prepare for a bug fix by adding and using helpers which convert
isl_surf::logical_level0_px and isl_surf::phys_level0_sa to units of
surface elements.
v2:
- Update iris (Ken).
- Update anv.
Cc: <mesa-stable at lists.freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
(cherry picked from commit fb1350c76f1525e6bd320cef62d55aff19ec3f05)
---
src/gallium/drivers/iris/iris_state.c | 8 ++------
src/intel/blorp/blorp_blit.c | 11 ++---------
src/intel/isl/isl.h | 32 ++++++++++++++++++++++++++++++++
src/intel/vulkan/anv_image.c | 9 +++------
4 files changed, 39 insertions(+), 21 deletions(-)
diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c
index dd440003e0b..3d6460a86e7 100644
--- a/src/gallium/drivers/iris/iris_state.c
+++ b/src/gallium/drivers/iris/iris_state.c
@@ -2001,12 +2001,8 @@ iris_create_surface(struct pipe_context *ctx,
const struct isl_format_layout *fmtl =
isl_format_get_layout(res->surf.format);
isl_surf.format = fmt.fmt;
- isl_surf.logical_level0_px.width =
- DIV_ROUND_UP(isl_surf.logical_level0_px.width, fmtl->bw);
- isl_surf.logical_level0_px.height =
- DIV_ROUND_UP(isl_surf.logical_level0_px.height, fmtl->bh);
- isl_surf.phys_level0_sa.width /= fmtl->bw;
- isl_surf.phys_level0_sa.height /= fmtl->bh;
+ isl_surf.logical_level0_px = isl_surf_get_logical_level0_el(&isl_surf);
+ isl_surf.phys_level0_sa = isl_surf_get_phys_level0_el(&isl_surf);
tile_x_sa /= fmtl->bw;
tile_y_sa /= fmtl->bh;
diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c
index 9e964d02f36..222a7bcf4b2 100644
--- a/src/intel/blorp/blorp_blit.c
+++ b/src/intel/blorp/blorp_blit.c
@@ -2506,15 +2506,8 @@ blorp_surf_convert_to_uncompressed(const struct isl_device *isl_dev,
*y /= fmtl->bh;
}
- info->surf.logical_level0_px.width =
- DIV_ROUND_UP(info->surf.logical_level0_px.width, fmtl->bw);
- info->surf.logical_level0_px.height =
- DIV_ROUND_UP(info->surf.logical_level0_px.height, fmtl->bh);
-
- assert(info->surf.phys_level0_sa.width % fmtl->bw == 0);
- assert(info->surf.phys_level0_sa.height % fmtl->bh == 0);
- info->surf.phys_level0_sa.width /= fmtl->bw;
- info->surf.phys_level0_sa.height /= fmtl->bh;
+ info->surf.logical_level0_px = isl_surf_get_logical_level0_el(&info->surf);
+ info->surf.phys_level0_sa = isl_surf_get_phys_level0_el(&info->surf);
assert(info->tile_x_sa % fmtl->bw == 0);
assert(info->tile_y_sa % fmtl->bh == 0);
diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
index 6790ba002ad..3971c91b55a 100644
--- a/src/intel/isl/isl.h
+++ b/src/intel/isl/isl.h
@@ -1886,6 +1886,38 @@ isl_surf_get_image_alignment_sa(const struct isl_surf *surf)
}
/**
+ * Logical extent of level 0 in units of surface elements.
+ */
+static inline struct isl_extent4d
+isl_surf_get_logical_level0_el(const struct isl_surf *surf)
+{
+ const struct isl_format_layout *fmtl = isl_format_get_layout(surf->format);
+
+ return isl_extent4d(DIV_ROUND_UP(surf->logical_level0_px.w, fmtl->bw),
+ DIV_ROUND_UP(surf->logical_level0_px.h, fmtl->bh),
+ DIV_ROUND_UP(surf->logical_level0_px.d, fmtl->bd),
+ surf->logical_level0_px.a);
+}
+
+/**
+ * Physical extent of level 0 in units of surface elements.
+ */
+static inline struct isl_extent4d
+isl_surf_get_phys_level0_el(const struct isl_surf *surf)
+{
+ const struct isl_format_layout *fmtl = isl_format_get_layout(surf->format);
+
+ assert(surf->phys_level0_sa.w % fmtl->bw == 0);
+ assert(surf->phys_level0_sa.h % fmtl->bh == 0);
+ assert(surf->phys_level0_sa.d % fmtl->bd == 0);
+
+ return isl_extent4d(surf->phys_level0_sa.w / fmtl->bw,
+ surf->phys_level0_sa.h / fmtl->bh,
+ surf->phys_level0_sa.d / fmtl->bd,
+ surf->phys_level0_sa.a);
+}
+
+/**
* Pitch between vertically adjacent surface elements, in bytes.
*/
static inline uint32_t
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index a56a4ab3d90..0572bd5708f 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -1360,12 +1360,9 @@ anv_image_fill_surface_state(struct anv_device *device,
const struct isl_format_layout *fmtl =
isl_format_get_layout(surface->isl.format);
tmp_surf.format = view.format;
- tmp_surf.logical_level0_px.width =
- DIV_ROUND_UP(tmp_surf.logical_level0_px.width, fmtl->bw);
- tmp_surf.logical_level0_px.height =
- DIV_ROUND_UP(tmp_surf.logical_level0_px.height, fmtl->bh);
- tmp_surf.phys_level0_sa.width /= fmtl->bw;
- tmp_surf.phys_level0_sa.height /= fmtl->bh;
+ tmp_surf.logical_level0_px =
+ isl_surf_get_logical_level0_el(&tmp_surf);
+ tmp_surf.phys_level0_sa = isl_surf_get_phys_level0_el(&tmp_surf);
tile_x_sa /= fmtl->bw;
tile_y_sa /= fmtl->bh;
More information about the mesa-commit
mailing list