freedreno: move the half-precision logic into core
authorRob Clark <robclark@freedesktop.org>
Fri, 31 Jul 2015 18:34:19 +0000 (14:34 -0400)
committerRob Clark <robclark@freedesktop.org>
Tue, 4 Aug 2015 20:03:45 +0000 (16:03 -0400)
Both a3xx and a4xx need the same logic to decide if half-precision can
be used for blit shaders.  So move it to core and simplify things a bit
with a helper that considers all render targets.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/drivers/freedreno/a3xx/fd3_draw.c
src/gallium/drivers/freedreno/a3xx/fd3_format.h
src/gallium/drivers/freedreno/a3xx/fd3_gmem.c
src/gallium/drivers/freedreno/freedreno_util.h

index 43550ae6a220e8f02d36f4fcc6e0b20391a0b4b9..a9498835011d65d4fbfeed2d609adbf64deaab07 100644 (file)
@@ -243,10 +243,7 @@ fd3_clear(struct fd_context *ctx, unsigned buffers,
                .vtx  = &fd3_ctx->solid_vbuf_state,
                .prog = &ctx->solid_prog,
                .key = {
-                       .half_precision = (fd3_half_precision(pfb->cbufs[0]) &&
-                                                          fd3_half_precision(pfb->cbufs[1]) &&
-                                                          fd3_half_precision(pfb->cbufs[2]) &&
-                                                          fd3_half_precision(pfb->cbufs[3])),
+                       .half_precision = fd_half_precision(pfb),
                },
        };
 
index 678343aaa110f5a5ed545b4f08bdc4c0f09680ec..05c5ea3d247d9e35839abb8a6815621ac6c4432d 100644 (file)
@@ -41,27 +41,4 @@ enum a3xx_color_swap fd3_pipe2swap(enum pipe_format format);
 uint32_t fd3_tex_swiz(enum pipe_format format, unsigned swizzle_r,
                unsigned swizzle_g, unsigned swizzle_b, unsigned swizzle_a);
 
-static inline bool
-fd3_half_precision(const struct pipe_surface *surface)
-{
-       enum pipe_format format;
-       if (!surface)
-               return true;
-
-       format = surface->format;
-
-       /* colors are provided in consts, which go through cov.f32f16, which will
-        * break these values
-        */
-       if (util_format_is_pure_integer(format))
-               return false;
-
-       /* avoid losing precision on 32-bit float formats */
-       if (util_format_is_float(format) &&
-               util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) == 32)
-               return false;
-
-       return true;
-}
-
 #endif /* FD3_FORMAT_H_ */
index 4689085e51602a233a92a47469f1b05b2e819751..302452657b641a7480f6081f268feca5f0bf9c3c 100644 (file)
@@ -537,10 +537,7 @@ fd3_emit_tile_mem2gmem(struct fd_context *ctx, struct fd_tile *tile)
                        /* NOTE: They all use the same VP, this is for vtx bufs. */
                        .prog = &ctx->blit_prog[0],
                        .key = {
-                               .half_precision = (fd3_half_precision(pfb->cbufs[0]) &&
-                                                                  fd3_half_precision(pfb->cbufs[1]) &&
-                                                                  fd3_half_precision(pfb->cbufs[2]) &&
-                                                                  fd3_half_precision(pfb->cbufs[3]))
+                               .half_precision = fd_half_precision(pfb),
                        },
        };
        float x0, y0, x1, y1;
index ed56817349772747ab43eaa6e8e921af07e232b0..2880e890a1c350d8b2806bd3a30edaa5088a9863 100644 (file)
@@ -116,6 +116,42 @@ pipe_surface_format(struct pipe_surface *psurf)
        return psurf->format;
 }
 
+static inline bool
+fd_surface_half_precision(const struct pipe_surface *psurf)
+{
+       enum pipe_format format;
+
+       if (!psurf)
+               return true;
+
+       format = psurf->format;
+
+       /* colors are provided in consts, which go through cov.f32f16, which will
+        * break these values
+        */
+       if (util_format_is_pure_integer(format))
+               return false;
+
+       /* avoid losing precision on 32-bit float formats */
+       if (util_format_is_float(format) &&
+               util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) == 32)
+               return false;
+
+       return true;
+}
+
+static inline bool
+fd_half_precision(struct pipe_framebuffer_state *pfb)
+{
+       unsigned i;
+
+       for (i = 0; i < pfb->nr_cbufs; i++)
+               if (!fd_surface_half_precision(pfb->cbufs[i]))
+                       return false;
+
+       return true;
+}
+
 #define LOG_DWORDS 0
 
 static inline void emit_marker(struct fd_ringbuffer *ring, int scratch_idx);