[Mesa-dev] [PATCH v2 4/7] intel/blorp_blit: Move RGB=>R conversion to follow blit splitting
Jordan Justen
jordan.l.justen at intel.com
Thu Dec 1 04:12:31 UTC 2016
In blorp_copy, when RGB surfaces are copied, we convert the
destination surface to a Red only surface, but 3 times as wide. This
introduces an implicit restriction of "mod 3" for the destination
width.
It is easier to handle the blorp split buffer offsetting with the
original RGB surface, and do the RGB=>R after this.
Suggested-by: Jason Ekstrand <jason at jlekstrand.net>
Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
Cc: Jason Ekstrand <jason at jlekstrand.net>
---
src/intel/blorp/blorp_blit.c | 113 +++++++++++++++++++++++++------------------
1 file changed, 66 insertions(+), 47 deletions(-)
diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c
index 5ca3190..782144a 100644
--- a/src/intel/blorp/blorp_blit.c
+++ b/src/intel/blorp/blorp_blit.c
@@ -1823,6 +1823,68 @@ shrink_surfaces(const struct isl_device *dev,
}
static void
+surf_fake_rgb_with_red(const struct isl_device *isl_dev,
+ struct brw_blorp_surface_info *info,
+ uint32_t *x, uint32_t *width)
+{
+ surf_convert_to_single_slice(isl_dev, info);
+
+ info->surf.logical_level0_px.width *= 3;
+ info->surf.phys_level0_sa.width *= 3;
+ *x *= 3;
+ *width *= 3;
+
+ enum isl_format red_format;
+ switch (info->view.format) {
+ case ISL_FORMAT_R8G8B8_UNORM:
+ red_format = ISL_FORMAT_R8_UNORM;
+ break;
+ case ISL_FORMAT_R8G8B8_UINT:
+ red_format = ISL_FORMAT_R8_UINT;
+ break;
+ case ISL_FORMAT_R16G16B16_UNORM:
+ red_format = ISL_FORMAT_R16_UNORM;
+ break;
+ case ISL_FORMAT_R16G16B16_UINT:
+ red_format = ISL_FORMAT_R16_UINT;
+ break;
+ case ISL_FORMAT_R32G32B32_UINT:
+ red_format = ISL_FORMAT_R32_UINT;
+ break;
+ default:
+ unreachable("Invalid RGB copy destination format");
+ }
+ assert(isl_format_get_layout(red_format)->channels.r.type ==
+ isl_format_get_layout(info->view.format)->channels.r.type);
+ assert(isl_format_get_layout(red_format)->channels.r.bits ==
+ isl_format_get_layout(info->view.format)->channels.r.bits);
+
+ info->surf.format = info->view.format = red_format;
+}
+
+static void
+fake_dest_rgb_with_red(const struct isl_device *dev,
+ struct blorp_params *params,
+ struct brw_blorp_blit_prog_key *wm_prog_key,
+ struct blt_coords *coords)
+{
+ /* Handle RGB destinations for blorp_copy */
+ const struct isl_format_layout *dst_fmtl =
+ isl_format_get_layout(params->dst.surf.format);
+
+ if (dst_fmtl->bpb % 3 == 0) {
+ uint32_t dst_x = coords->x.dst0;
+ uint32_t dst_width = coords->x.dst1 - dst_x;
+ surf_fake_rgb_with_red(dev, ¶ms->dst,
+ &dst_x, &dst_width);
+ coords->x.dst0 = dst_x;
+ coords->x.dst1 = dst_x + dst_width;
+ wm_prog_key->dst_rgb = true;
+ wm_prog_key->need_dst_offset = true;
+ }
+}
+
+static void
do_blorp_blit(struct blorp_batch *batch,
const struct blorp_params *orig_params,
struct brw_blorp_blit_prog_key *wm_prog_key,
@@ -1849,6 +1911,10 @@ do_blorp_blit(struct blorp_batch *batch,
shrink_surfaces(batch->blorp->isl_dev, ¶ms, wm_prog_key,
&blit_coords);
}
+
+ fake_dest_rgb_with_red(batch->blorp->isl_dev, ¶ms, wm_prog_key,
+ &blit_coords);
+
unsigned result =
try_blorp_blit(batch, ¶ms, wm_prog_key, &blit_coords);
@@ -2161,46 +2227,6 @@ surf_convert_to_uncompressed(const struct isl_device *isl_dev,
info->surf.format = get_copy_format_for_bpb(isl_dev, fmtl->bpb);
}
-static void
-surf_fake_rgb_with_red(const struct isl_device *isl_dev,
- struct brw_blorp_surface_info *info,
- uint32_t *x, uint32_t *width)
-{
- surf_convert_to_single_slice(isl_dev, info);
-
- info->surf.logical_level0_px.width *= 3;
- info->surf.phys_level0_sa.width *= 3;
- *x *= 3;
- *width *= 3;
-
- enum isl_format red_format;
- switch (info->view.format) {
- case ISL_FORMAT_R8G8B8_UNORM:
- red_format = ISL_FORMAT_R8_UNORM;
- break;
- case ISL_FORMAT_R8G8B8_UINT:
- red_format = ISL_FORMAT_R8_UINT;
- break;
- case ISL_FORMAT_R16G16B16_UNORM:
- red_format = ISL_FORMAT_R16_UNORM;
- break;
- case ISL_FORMAT_R16G16B16_UINT:
- red_format = ISL_FORMAT_R16_UINT;
- break;
- case ISL_FORMAT_R32G32B32_UINT:
- red_format = ISL_FORMAT_R32_UINT;
- break;
- default:
- unreachable("Invalid RGB copy destination format");
- }
- assert(isl_format_get_layout(red_format)->channels.r.type ==
- isl_format_get_layout(info->view.format)->channels.r.type);
- assert(isl_format_get_layout(red_format)->channels.r.bits ==
- isl_format_get_layout(info->view.format)->channels.r.bits);
-
- info->surf.format = info->view.format = red_format;
-}
-
void
blorp_copy(struct blorp_batch *batch,
const struct blorp_surf *src_surf,
@@ -2290,13 +2316,6 @@ blorp_copy(struct blorp_batch *batch,
uint32_t dst_width = src_width;
uint32_t dst_height = src_height;
- if (dst_fmtl->bpb % 3 == 0) {
- surf_fake_rgb_with_red(batch->blorp->isl_dev, ¶ms.dst,
- &dst_x, &dst_width);
- wm_prog_key.dst_rgb = true;
- wm_prog_key.need_dst_offset = true;
- }
-
struct blt_coords coords = {
.x = {
.src0 = src_x,
--
2.10.2
More information about the mesa-dev
mailing list