freedreno/a4xx: support lod_bias
authorIlia Mirkin <imirkin@alum.mit.edu>
Thu, 19 Nov 2015 04:54:25 +0000 (23:54 -0500)
committerIlia Mirkin <imirkin@alum.mit.edu>
Fri, 20 Nov 2015 00:00:17 +0000 (19:00 -0500)
The lower layers assume that we support this, and it's been core since
GL 1.4. This fixes a slew of piglit tests, especially around
tex-miplevel-selection.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: mesa-stable@lists.freedesktop.org
src/gallium/drivers/freedreno/a4xx/a4xx.xml.h
src/gallium/drivers/freedreno/a4xx/fd4_texture.c

index 76f525cb0c23bfe656d76cc89c3d35c038fd4efe..07d0db16cdeed9861225d8d43d751bdaa1094bc6 100644 (file)
@@ -2741,6 +2741,12 @@ static inline uint32_t A4XX_TEX_SAMP_0_ANISO(enum a4xx_tex_aniso val)
 {
        return ((val) << A4XX_TEX_SAMP_0_ANISO__SHIFT) & A4XX_TEX_SAMP_0_ANISO__MASK;
 }
+#define A4XX_TEX_SAMP_0_LOD_BIAS__MASK                         0xfff80000
+#define A4XX_TEX_SAMP_0_LOD_BIAS__SHIFT                                19
+static inline uint32_t A4XX_TEX_SAMP_0_LOD_BIAS(float val)
+{
+       return ((((int32_t)(val * 256.0))) << A4XX_TEX_SAMP_0_LOD_BIAS__SHIFT) & A4XX_TEX_SAMP_0_LOD_BIAS__MASK;
+}
 
 #define REG_A4XX_TEX_SAMP_1                                    0x00000001
 #define A4XX_TEX_SAMP_1_COMPARE_FUNC__MASK                     0x0000000e
index 297854f650502824b2cd6caceab09828a2cadc43..886b4547929c441c13d693e7137ff056e7940ba5 100644 (file)
@@ -127,6 +127,7 @@ fd4_sampler_state_create(struct pipe_context *pctx,
                COND(!cso->normalized_coords, A4XX_TEX_SAMP_1_UNNORM_COORDS);
 
        if (cso->min_mip_filter != PIPE_TEX_MIPFILTER_NONE) {
+               so->texsamp0 |= A4XX_TEX_SAMP_0_LOD_BIAS(cso->lod_bias);
                so->texsamp1 |=
                        A4XX_TEX_SAMP_1_MIN_LOD(cso->min_lod) |
                        A4XX_TEX_SAMP_1_MAX_LOD(cso->max_lod);