diff options
author | Rob Clark <[email protected]> | 2014-09-23 17:24:27 -0400 |
---|---|---|
committer | Rob Clark <[email protected]> | 2014-09-24 18:52:58 -0400 |
commit | a87e44da3a801028783979cfd3548d0ebc9fdd88 (patch) | |
tree | b7272890c5f2be5567d602c3a6ba27b993cf78a8 /src/gallium/drivers/freedreno/a3xx | |
parent | 9f47220450d3083b7625db1818232cf5c68ae7cd (diff) |
freedreno/a3xx: initial texture border-color
Still some open questions.. and at any rate, no additional piglit passes
due to various wrap modes that we need to emulate in at least some
cases :-(
But it does fix some mystery page-faults.. So add some comments in the
code where there are things that we need to emulate or do more r/e, and
push as-is.
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno/a3xx')
-rw-r--r-- | src/gallium/drivers/freedreno/a3xx/fd3_context.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a3xx/fd3_context.h | 20 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a3xx/fd3_emit.c | 37 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a3xx/fd3_texture.c | 2 |
4 files changed, 56 insertions, 6 deletions
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; |