summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/freedreno
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/freedreno')
-rw-r--r--src/gallium/drivers/freedreno/a2xx/fd2_draw.c9
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_context.c3
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_context.h20
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_emit.c37
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_texture.c2
-rw-r--r--src/gallium/drivers/freedreno/freedreno_util.h9
6 files changed, 65 insertions, 15 deletions
diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_draw.c b/src/gallium/drivers/freedreno/a2xx/fd2_draw.c
index 77fbf1af224..bc7960a28a5 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_draw.c
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_draw.c
@@ -30,7 +30,6 @@
#include "util/u_string.h"
#include "util/u_memory.h"
#include "util/u_prim.h"
-#include "util/u_pack_color.h"
#include "freedreno_state.h"
#include "freedreno_resource.h"
@@ -118,14 +117,6 @@ fd2_draw(struct fd_context *ctx, const struct pipe_draw_info *info)
}
-static uint32_t
-pack_rgba(enum pipe_format format, const float *rgba)
-{
- union util_color uc;
- util_pack_color(rgba, format, &uc);
- return uc.ui[0];
-}
-
static void
fd2_clear(struct fd_context *ctx, unsigned buffers,
const union pipe_color_union *color, double depth, unsigned stencil)
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_context.c b/src/gallium/drivers/freedreno/a3xx/fd3_context.c
index 847414ac082..f8f412e1a1b 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_context.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_context.c
@@ -137,5 +137,8 @@ fd3_context_create(struct pipe_screen *pscreen, void *priv)
fd3_query_context_init(pctx);
+ fd3_ctx->border_color_uploader = u_upload_create(pctx, 4096,
+ 2 * PIPE_MAX_SAMPLERS * BORDERCOLOR_SIZE, 0);
+
return pctx;
}
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_context.h b/src/gallium/drivers/freedreno/a3xx/fd3_context.h
index 26c8cc762b9..7d7663a28bc 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_context.h
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_context.h
@@ -29,6 +29,8 @@
#ifndef FD3_CONTEXT_H_
#define FD3_CONTEXT_H_
+#include "util/u_upload_mgr.h"
+
#include "freedreno_drmif.h"
#include "freedreno_context.h"
@@ -56,6 +58,24 @@ struct fd3_context {
/* vertex buf used for mem->gmem tex coords:
*/
struct pipe_resource *blit_texcoord_vbuf;
+
+ /*
+ * Border color layout *appears* to be as arrays of 0x40 byte
+ * elements, with frag shader elements starting at (16 x 0x40).
+ * But at some point I should probably experiment more with
+ * samplers in vertex shaders to be sure. Unclear about why
+ * there is this offset when there are separate VS and FS base
+ * addr regs.
+ *
+ * The first 8 bytes of each entry are the requested border
+ * color in fp16. Unclear about the rest.. could be used for
+ * other formats, or could simply be for aligning the pitch
+ * to 32 pixels.
+ */
+#define BORDERCOLOR_SIZE 0x40
+
+ struct u_upload_mgr *border_color_uploader;
+ struct pipe_resource *border_color_buf;
};
static INLINE struct fd3_context *
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
index 62e02bc6b2d..73a28dda5e6 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
@@ -152,9 +152,8 @@ emit_constants(struct fd_ringbuffer *ring,
#define BASETABLE_SZ A3XX_MAX_MIP_LEVELS
static void
-emit_textures(struct fd_ringbuffer *ring,
- enum adreno_state_block sb,
- struct fd_texture_stateobj *tex)
+emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring,
+ enum adreno_state_block sb, struct fd_texture_stateobj *tex)
{
static const unsigned tex_off[] = {
[SB_VERT_TEX] = VERT_TEX_OFF,
@@ -164,7 +163,18 @@ emit_textures(struct fd_ringbuffer *ring,
[SB_VERT_TEX] = SB_VERT_MIPADDR,
[SB_FRAG_TEX] = SB_FRAG_MIPADDR,
};
- unsigned i, j;
+ static const uint32_t bcolor_reg[] = {
+ [SB_VERT_TEX] = REG_A3XX_TPL1_TP_VS_BORDER_COLOR_BASE_ADDR,
+ [SB_FRAG_TEX] = REG_A3XX_TPL1_TP_FS_BORDER_COLOR_BASE_ADDR,
+ };
+ struct fd3_context *fd3_ctx = fd3_context(ctx);
+ unsigned i, j, off;
+ void *ptr;
+
+ u_upload_alloc(fd3_ctx->border_color_uploader,
+ 0, 2 * PIPE_MAX_SAMPLERS * BORDERCOLOR_SIZE, &off,
+ &fd3_ctx->border_color_buf,
+ &ptr);
if (tex->num_samplers > 0) {
/* output sampler state: */
@@ -180,6 +190,16 @@ emit_textures(struct fd_ringbuffer *ring,
const struct fd3_sampler_stateobj *sampler = tex->samplers[i] ?
fd3_sampler_stateobj(tex->samplers[i]) :
&dummy_sampler;
+ uint16_t *bcolor = (uint16_t *)((uint8_t *)ptr +
+ (BORDERCOLOR_SIZE * tex_off[sb]) +
+ (BORDERCOLOR_SIZE * i));
+
+ /* TODO not quite sure if bcolor is pre or post swizzle: */
+ for (j = 0; j < 4; j++) {
+ bcolor[j] =
+ util_float_to_half(sampler->base.border_color.f[j]);
+ }
+
OUT_RING(ring, sampler->texsamp0);
OUT_RING(ring, sampler->texsamp1);
}
@@ -237,6 +257,11 @@ emit_textures(struct fd_ringbuffer *ring,
}
}
}
+
+ OUT_PKT0(ring, bcolor_reg[sb], 1);
+ OUT_RELOC(ring, fd_resource(fd3_ctx->border_color_buf)->bo, off, 0, 0);
+
+ u_upload_unmap(fd3_ctx->border_color_uploader);
}
/* emit texture state for mem->gmem restore operation.. eventually it would
@@ -553,14 +578,14 @@ fd3_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
if (dirty & FD_DIRTY_VERTTEX) {
if (vp->has_samp)
- emit_textures(ring, SB_VERT_TEX, &ctx->verttex);
+ emit_textures(ctx, ring, SB_VERT_TEX, &ctx->verttex);
else
dirty &= ~FD_DIRTY_VERTTEX;
}
if (dirty & FD_DIRTY_FRAGTEX) {
if (fp->has_samp)
- emit_textures(ring, SB_FRAG_TEX, &ctx->fragtex);
+ emit_textures(ctx, ring, SB_FRAG_TEX, &ctx->fragtex);
else
dirty &= ~FD_DIRTY_FRAGTEX;
}
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c
index 36a877dcd92..8308674178d 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c
@@ -54,7 +54,9 @@ tex_clamp(unsigned wrap)
return A3XX_TEX_CLAMP_TO_BORDER;
case PIPE_TEX_WRAP_MIRROR_CLAMP:
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
+ /* these two we should emulate! */
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
+ /* only works for PoT.. need to emulate otherwise! */
return A3XX_TEX_MIRROR_CLAMP;
case PIPE_TEX_WRAP_MIRROR_REPEAT:
return A3XX_TEX_MIRROR_REPEAT;
diff --git a/src/gallium/drivers/freedreno/freedreno_util.h b/src/gallium/drivers/freedreno/freedreno_util.h
index d676f80d71b..a762c8f0575 100644
--- a/src/gallium/drivers/freedreno/freedreno_util.h
+++ b/src/gallium/drivers/freedreno/freedreno_util.h
@@ -38,6 +38,7 @@
#include "util/u_math.h"
#include "util/u_half.h"
#include "util/u_dynarray.h"
+#include "util/u_pack_color.h"
#include "adreno_common.xml.h"
#include "adreno_pm4.xml.h"
@@ -250,4 +251,12 @@ static inline uint32_t env2u(const char *envvar)
return 0;
}
+static inline uint32_t
+pack_rgba(enum pipe_format format, const float *rgba)
+{
+ union util_color uc;
+ util_pack_color(rgba, format, &uc);
+ return uc.ui[0];
+}
+
#endif /* FREEDRENO_UTIL_H_ */