summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2015-07-31 14:34:19 -0400
committerRob Clark <[email protected]>2015-08-04 16:03:45 -0400
commitb37a97c97d6477d5062a75a0313162ed324a36ed (patch)
treef7f191b75be72d4b9ec15a6f8422d9dd07af819e /src
parent5ca032a9a8ece0a8a43151f988215484da3c1811 (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')
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_draw.c5
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_format.h23
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_gmem.c5
-rw-r--r--src/gallium/drivers/freedreno/freedreno_util.h36
4 files changed, 38 insertions, 31 deletions
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_draw.c b/src/gallium/drivers/freedreno/a3xx/fd3_draw.c
index 43550ae6a22..a9498835011 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_draw.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_draw.c
@@ -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),
},
};
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_format.h b/src/gallium/drivers/freedreno/a3xx/fd3_format.h
index 678343aaa11..05c5ea3d247 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_format.h
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_format.h
@@ -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_ */
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c b/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c
index 4689085e516..302452657b6 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c
@@ -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;
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);