diff options
author | Rob Clark <[email protected]> | 2015-07-31 14:34:19 -0400 |
---|---|---|
committer | Rob Clark <[email protected]> | 2015-08-04 16:03:45 -0400 |
commit | b37a97c97d6477d5062a75a0313162ed324a36ed (patch) | |
tree | f7f191b75be72d4b9ec15a6f8422d9dd07af819e /src/gallium/drivers/freedreno/freedreno_util.h | |
parent | 5ca032a9a8ece0a8a43151f988215484da3c1811 (diff) |
freedreno: move the half-precision logic into core
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 <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno/freedreno_util.h')
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_util.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_util.h b/src/gallium/drivers/freedreno/freedreno_util.h index ed568173497..2880e890a1c 100644 --- a/src/gallium/drivers/freedreno/freedreno_util.h +++ b/src/gallium/drivers/freedreno/freedreno_util.h @@ -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); |