Mesa (staging/21.1): gallium/util: add half texel offset param to util_compute_blit

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 9 07:32:38 UTC 2021


Module: Mesa
Branch: staging/21.1
Commit: fd7d769544a3763ec94874bfba372ecc63df3c34
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=fd7d769544a3763ec94874bfba372ecc63df3c34

Author: Thong Thai <thong.thai at amd.com>
Date:   Fri Aug  6 10:42:00 2021 -0400

gallium/util: add half texel offset param to util_compute_blit

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

Fixes: c5088b49729 ("gallium: Fix VAAPI postproc blit")
Signed-off-by: Thong Thai <thong.thai at amd.com>
Reviewed-by: Leo Liu <leo.liu at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12251>
(cherry picked from commit 5dace8e0fb9c1dc9a0de062d6747cf4c3e2e819f)

---

 .pick_status.json                      | 2 +-
 src/gallium/auxiliary/util/u_compute.c | 7 ++++---
 src/gallium/auxiliary/util/u_compute.h | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 9bc4e75feb1..af7ee93b6a8 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -121,7 +121,7 @@
         "description": "gallium/util: add half texel offset param to util_compute_blit",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "c5088b497290ba1207085899ec635ef851635267"
     },
diff --git a/src/gallium/auxiliary/util/u_compute.c b/src/gallium/auxiliary/util/u_compute.c
index 79755abaf1d..1eab36ab6b8 100644
--- a/src/gallium/auxiliary/util/u_compute.c
+++ b/src/gallium/auxiliary/util/u_compute.c
@@ -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),
diff --git a/src/gallium/auxiliary/util/u_compute.h b/src/gallium/auxiliary/util/u_compute.h
index 8c2866af8d4..4a6c66e0ef4 100644
--- a/src/gallium/auxiliary/util/u_compute.h
+++ b/src/gallium/auxiliary/util/u_compute.h
@@ -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
 }



More information about the mesa-commit mailing list