freedreno: Switch to exposing only half-integer pixel centers.
authorEric Anholt <eric@anholt.net>
Tue, 17 Mar 2020 23:03:11 +0000 (16:03 -0700)
committerMarge Bot <eric+marge@anholt.net>
Thu, 19 Mar 2020 21:35:49 +0000 (21:35 +0000)
This is what the HW provides us.  If we need integer pixel centers, we
want the state tracker to do the lowering pass so that it gets to optimize
on the subtract.  This is also the shader instructions that the blob is
doing on GLES, and is what Vulkan wants too, as was noted in MR !4172.

shader-db on a630:
total instructions in shared programs: 186689 -> 186168 (-0.28%)
total nops in shared programs: 66253 -> 66139 (-0.17%)
total non-nops in shared programs: 120436 -> 120029 (-0.34%)
total dwords in shared programs: 292192 -> 291168 (-0.35%)
total last-baryf in shared programs: 4810 -> 4734 (-1.58%)
total full in shared programs: 10176 -> 10195 (0.19%)
total constlen in shared programs: 54589 -> 54575 (-0.03%)
total sstall in shared programs: 24582 -> 24802 (0.89%)
total (ss) in shared programs: 3921 -> 3925 (0.10%)
total (sy) in shared programs: 1934 -> 1923 (-0.57%)

Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4223>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4223>

src/freedreno/ir3/ir3_compiler_nir.c
src/gallium/drivers/freedreno/freedreno_screen.c

index 01f0985da62adbcd0a6b226ecb40bdcf62c81b90..75f949522f58dab0bd109c954cd6f435c6ebf3db 100644 (file)
@@ -1319,11 +1319,8 @@ get_frag_coord(struct ir3_context *ctx)
                 *
                 */
                for (int i = 0; i < 2; i++) {
-                       xyzw[i] = ir3_SUB_S(b, xyzw[i], 0,
-                                       create_immed(b, 8), 0);
-                       xyzw[i] = ir3_SHR_B(b, xyzw[i], 0,
-                                       create_immed(b, 4), 0);
                        xyzw[i] = ir3_COV(b, xyzw[i], TYPE_U32, TYPE_F32);
+                       xyzw[i] = ir3_MUL_F(b, xyzw[i], 0, create_immed(b, fui(1.0 / 16.0)), 0);
                }
 
                ctx->frag_coord = ir3_create_collect(ctx, xyzw, 4);
index bb8711f34d214f5e7df5618696176d228b5720c5..e6bfa49c4a8651b44110b6ead234870d7cc1bc6c 100644 (file)
@@ -187,7 +187,6 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_TEXTURE_SWIZZLE:
        case PIPE_CAP_MIXED_COLORBUFFER_FORMATS:
        case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
-       case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
        case PIPE_CAP_SEAMLESS_CUBE_MAP:
        case PIPE_CAP_VERTEX_COLOR_UNCLAMPED:
        case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION:
@@ -202,6 +201,11 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND:
                return 1;
 
+       case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
+               return is_a2xx(screen);
+       case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
+               return !is_a2xx(screen);
+
        case PIPE_CAP_PACKED_UNIFORMS:
                return !is_a2xx(screen);