diff options
author | Jordan Justen <[email protected]> | 2016-11-30 15:53:48 -0800 |
---|---|---|
committer | Jordan Justen <[email protected]> | 2016-12-07 09:00:49 -0800 |
commit | efea8e724458f6a388fb70421db3e655719fffb0 (patch) | |
tree | 44c3d2ca72d285f5139e13bf39dd4b804a06bdc8 /src/intel/blorp | |
parent | edf3113aeddcf66cb24906e53a2d4f41616f8985 (diff) |
intel/blorp_blit: Move RGB=>R conversion to follow blit splitting
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 <[email protected]>
Signed-off-by: Jordan Justen <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/intel/blorp')
-rw-r--r-- | src/intel/blorp/blorp_blit.c | 113 |
1 files changed, 65 insertions, 48 deletions
diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c index b976eefef8e..d16bab2898d 100644 --- a/src/intel/blorp/blorp_blit.c +++ b/src/intel/blorp/blorp_blit.c @@ -1499,6 +1499,68 @@ struct blt_coords { struct blt_axis x, y; }; +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; + } +} + enum blit_shrink_status { BLIT_NO_SHRINK = 0, BLIT_WIDTH_SHRINK = 1, @@ -1513,10 +1575,12 @@ static enum blit_shrink_status try_blorp_blit(struct blorp_batch *batch, struct blorp_params *params, struct brw_blorp_blit_prog_key *wm_prog_key, - const struct blt_coords *coords) + struct blt_coords *coords) { const struct gen_device_info *devinfo = batch->blorp->isl_dev->info; + fake_dest_rgb_with_red(batch->blorp->isl_dev, params, wm_prog_key, coords); + if (isl_format_has_sint_channel(params->src.view.format)) { wm_prog_key->texture_data_type = nir_type_int; } else if (isl_format_has_uint_channel(params->src.view.format)) { @@ -2149,46 +2213,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, @@ -2273,13 +2297,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, |