diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-12-12 12:03:40 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-12-12 11:59:01 +0000 |
commit | 9001263b32efde1361555432914d9ac3ee780511 (patch) | |
tree | 7868054dbfd37db2ee9593015f1dc96c2555b9d6 | |
parent | 2dbe7d91a7f15a3a9ddad696c5088ca98898fca2 (diff) |
sna/gen3+: Use nearest for unscaled videos
If the output is unscaled, then we do not require pixel interpolation
(and planar formats are exactly subsampled).
References: https://bugs.freedesktop.org/show_bug.cgi?id=58185
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/gen3_render.c | 10 | ||||
-rw-r--r-- | src/sna/gen4_render.c | 5 | ||||
-rw-r--r-- | src/sna/gen5_render.c | 5 | ||||
-rw-r--r-- | src/sna/gen6_render.c | 14 | ||||
-rw-r--r-- | src/sna/gen7_render.c | 14 |
5 files changed, 33 insertions, 15 deletions
diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index b092976f..f203e7ec 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -3528,7 +3528,8 @@ gen3_emit_video_state(struct sna *sna, struct sna_video_frame *frame, PixmapPtr pixmap, struct kgem_bo *dst_bo, - int width, int height) + int width, int height, + bool bilinear) { struct gen3_render_state *state = &sna->render_state.gen3; uint32_t id, ms3, rewind; @@ -3887,6 +3888,7 @@ gen3_render_video(struct sna *sna, float src_scale_x, src_scale_y; int pix_xoff, pix_yoff; struct kgem_bo *dst_bo; + bool bilinear; int copy = 0; DBG(("%s: %dx%d -> %dx%d\n", __FUNCTION__, src_w, src_h, drw_w, drw_h)); @@ -3927,6 +3929,8 @@ gen3_render_video(struct sna *sna, #endif } + bilinear = src_w != drw_w || src_h != drw_h; + src_scale_x = ((float)src_w / frame->width) / drw_w; src_scale_y = ((float)src_h / frame->height) / drw_h; @@ -3936,13 +3940,13 @@ gen3_render_video(struct sna *sna, gen3_video_get_batch(sna, dst_bo); gen3_emit_video_state(sna, video, frame, pixmap, - dst_bo, width, height); + dst_bo, width, height, bilinear); do { int nbox_this_time = gen3_get_inline_rectangles(sna, nbox, 4); if (nbox_this_time == 0) { gen3_video_get_batch(sna, dst_bo); gen3_emit_video_state(sna, video, frame, pixmap, - dst_bo, width, height); + dst_bo, width, height, bilinear); nbox_this_time = gen3_get_inline_rectangles(sna, nbox, 4); } nbox -= nbox_this_time; diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c index 75b07a3c..f80fa835 100644 --- a/src/sna/gen4_render.c +++ b/src/sna/gen4_render.c @@ -1690,7 +1690,10 @@ gen4_render_video(struct sna *sna, tmp.dst.format = sna_format_for_depth(pixmap->drawable.depth); tmp.dst.bo = priv->gpu_bo; - tmp.src.filter = SAMPLER_FILTER_BILINEAR; + if (src_w == drw_w && src_h == drw_h) + tmp.src.filter = SAMPLER_FILTER_NEAREST; + else + tmp.src.filter = SAMPLER_FILTER_BILINEAR; tmp.src.repeat = SAMPLER_EXTEND_PAD; tmp.src.bo = frame->bo; tmp.mask.bo = NULL; diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c index bff5066b..6e6389a1 100644 --- a/src/sna/gen5_render.c +++ b/src/sna/gen5_render.c @@ -1688,7 +1688,10 @@ gen5_render_video(struct sna *sna, tmp.dst.format = sna_format_for_depth(pixmap->drawable.depth); tmp.dst.bo = priv->gpu_bo; - tmp.src.filter = SAMPLER_FILTER_BILINEAR; + if (src_w == drw_w && src_h == drw_h) + tmp.src.filter = SAMPLER_FILTER_NEAREST; + else + tmp.src.filter = SAMPLER_FILTER_BILINEAR; tmp.src.repeat = SAMPLER_EXTEND_PAD; tmp.src.bo = frame->bo; tmp.mask.bo = NULL; diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index 64830925..801236f0 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -186,10 +186,6 @@ static const struct blendinfo { #define FILL_FLAGS(op, format) GEN6_SET_FLAGS(FILL_SAMPLER, gen6_get_blend((op), false, (format)), GEN6_WM_KERNEL_NOMASK, FILL_VERTEX) #define FILL_FLAGS_NOBLEND GEN6_SET_FLAGS(FILL_SAMPLER, NO_BLEND, GEN6_WM_KERNEL_NOMASK, FILL_VERTEX) -#define VIDEO_SAMPLER \ - SAMPLER_OFFSET(SAMPLER_FILTER_BILINEAR, SAMPLER_EXTEND_PAD, \ - SAMPLER_FILTER_NEAREST, SAMPLER_EXTEND_NONE) - #define GEN6_SAMPLER(f) (((f) >> 16) & 0xfff0) #define GEN6_BLEND(f) (((f) >> 0) & 0xfff0) #define GEN6_KERNEL(f) (((f) >> 16) & 0xf) @@ -1986,6 +1982,7 @@ gen6_render_video(struct sna *sna, int nbox, dxo, dyo, pix_xoff, pix_yoff; float src_scale_x, src_scale_y; struct sna_pixmap *priv; + unsigned filter; BoxPtr box; DBG(("%s: src=(%d, %d), dst=(%d, %d), %dx[(%d, %d), (%d, %d)...]\n", @@ -2014,8 +2011,15 @@ gen6_render_video(struct sna *sna, tmp.floats_per_vertex = 3; tmp.floats_per_rect = 9; + if (src_w == drw_w && src_h == drw_h) + filter = SAMPLER_FILTER_NEAREST; + else + filter = SAMPLER_FILTER_BILINEAR; + tmp.u.gen6.flags = - GEN6_SET_FLAGS(VIDEO_SAMPLER, NO_BLEND, + GEN6_SET_FLAGS(SAMPLER_OFFSET(filter, SAMPLER_EXTEND_PAD, + SAMPLER_FILTER_NEAREST, SAMPLER_EXTEND_NONE), + NO_BLEND, is_planar_fourcc(frame->id) ? GEN6_WM_KERNEL_VIDEO_PLANAR : GEN6_WM_KERNEL_VIDEO_PACKED, diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index fea5a101..270488cb 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -209,10 +209,6 @@ static const struct blendinfo { #define FILL_FLAGS(op, format) GEN7_SET_FLAGS(FILL_SAMPLER, gen7_get_blend((op), false, (format)), GEN7_WM_KERNEL_NOMASK, FILL_VERTEX) #define FILL_FLAGS_NOBLEND GEN7_SET_FLAGS(FILL_SAMPLER, NO_BLEND, GEN7_WM_KERNEL_NOMASK, FILL_VERTEX) -#define VIDEO_SAMPLER \ - SAMPLER_OFFSET(SAMPLER_FILTER_BILINEAR, SAMPLER_EXTEND_PAD, \ - SAMPLER_FILTER_NEAREST, SAMPLER_EXTEND_NONE) - #define GEN7_SAMPLER(f) (((f) >> 16) & 0xfff0) #define GEN7_BLEND(f) (((f) >> 0) & 0x7ff0) #define GEN7_READS_DST(f) (((f) >> 15) & 1) @@ -2098,6 +2094,7 @@ gen7_render_video(struct sna *sna, int nbox, dxo, dyo, pix_xoff, pix_yoff; float src_scale_x, src_scale_y; struct sna_pixmap *priv; + unsigned filter; BoxPtr box; DBG(("%s: src=(%d, %d), dst=(%d, %d), %dx[(%d, %d), (%d, %d)...]\n", @@ -2126,8 +2123,15 @@ gen7_render_video(struct sna *sna, tmp.floats_per_vertex = 3; tmp.floats_per_rect = 9; + if (src_w == drw_w && src_h == drw_h) + filter = SAMPLER_FILTER_NEAREST; + else + filter = SAMPLER_FILTER_BILINEAR; + tmp.u.gen7.flags = - GEN7_SET_FLAGS(VIDEO_SAMPLER, NO_BLEND, + GEN7_SET_FLAGS(SAMPLER_OFFSET(filter, SAMPLER_EXTEND_PAD, + SAMPLER_FILTER_NEAREST, SAMPLER_EXTEND_NONE), + NO_BLEND, is_planar_fourcc(frame->id) ? GEN7_WM_KERNEL_VIDEO_PLANAR : GEN7_WM_KERNEL_VIDEO_PACKED, |