vl: replace DIV-ADD with MAD using inverse size
authorGert Wollny <gert.wollny@collabora.com>
Wed, 12 Jun 2019 14:04:33 +0000 (16:04 +0200)
committerGert Wollny <gert.wollny@collabora.com>
Sun, 30 Jun 2019 16:41:26 +0000 (18:41 +0200)
Optimize the shader a bit by emitting MAD with the inverse size values
instead of DIV+ADD.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/auxiliary/vl/vl_bicubic_filter.c

index f3f8cbee778ebc166854d1d396b1bb5ec84149c6..077e2131bfd74f660097d9325cd7d35d8fe72f78 100644 (file)
@@ -201,10 +201,11 @@ create_frag_shader(struct vl_bicubic_filter *filter, unsigned video_width,
 
    ureg_FLR(shader, ureg_writemask(t_array[22], TGSI_WRITEMASK_XY),
             ureg_src(t_array[22]));
-   ureg_DIV(shader, ureg_writemask(t_array[22], TGSI_WRITEMASK_XY),
-            ureg_src(t_array[22]), ureg_imm2f(shader, video_width, video_height));
-   ureg_ADD(shader, ureg_writemask(t_array[22], TGSI_WRITEMASK_XY),
-            ureg_src(t_array[22]), half_pixel);
+
+   ureg_MAD(shader, ureg_writemask(t_array[22], TGSI_WRITEMASK_XY),
+            ureg_src(t_array[22]),
+            ureg_imm2f(shader, 1.0f / video_width, 1.0f / video_height),
+            half_pixel);
 
    /*
     * t_array[0..*] = vtex + offset[0..*]