gallium/util: add half texel offset param to util_compute_blit

Fixes an issue where the video image is blurry after blitting.

Fixes: c5088b4972 ("gallium: Fix VAAPI postproc blit")
Signed-off-by: Thong Thai <thong.thai@amd.com>
Reviewed-by: Leo Liu <leo.liu@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12251>
This commit is contained in:
Thong Thai
2021-08-06 10:42:00 -04:00
committed by Marge Bot
parent 675508dd81
commit 5dace8e0fb
2 changed files with 5 additions and 4 deletions

View File

@@ -76,7 +76,7 @@ static void *blit_compute_shader(struct pipe_context *ctx)
}
void util_compute_blit(struct pipe_context *ctx, struct pipe_blit_info *blit_info,
void **compute_state)
void **compute_state, bool half_texel_offset)
{
if (blit_info->src.box.width == 0 || blit_info->src.box.height == 0 ||
blit_info->dst.box.width == 0 || blit_info->dst.box.height == 0)
@@ -91,9 +91,10 @@ void util_compute_blit(struct pipe_context *ctx, struct pipe_blit_info *blit_inf
float x_scale = blit_info->src.box.width / (float)blit_info->dst.box.width;
float y_scale = blit_info->src.box.height / (float)blit_info->dst.box.height;
float z_scale = blit_info->src.box.depth / (float)blit_info->dst.box.depth;
float offset = half_texel_offset ? 0.5 : 0.0;
unsigned data[] = {u_bitcast_f2u(blit_info->src.box.x / (float)src->width0),
u_bitcast_f2u(blit_info->src.box.y / (float)src->height0),
unsigned data[] = {u_bitcast_f2u((blit_info->src.box.x + offset) / (float)src->width0),
u_bitcast_f2u((blit_info->src.box.y + offset) / (float)src->height0),
u_bitcast_f2u(blit_info->src.box.z),
u_bitcast_f2u(0),
u_bitcast_f2u(x_scale / src->width0),

View File

@@ -36,7 +36,7 @@ extern "C" {
#endif
void util_compute_blit(struct pipe_context *ctx, struct pipe_blit_info *blit_info,
void **compute_state);
void **compute_state, bool half_texel_offset);
#ifdef __cplusplus
}