diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/freedreno/a3xx/fd3_emit.c | 33 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a3xx/fd3_texture.c | 10 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a3xx/fd3_texture.h | 1 |
3 files changed, 27 insertions, 17 deletions
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c index 4a5242aedb0..dc557faeec5 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c @@ -142,16 +142,8 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring, [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, BORDER_COLOR_UPLOAD_SIZE, - BORDER_COLOR_UPLOAD_SIZE, &off, - &fd3_ctx->border_color_buf, - &ptr); - - fd_setup_border_colors(tex, ptr, tex_off[sb]); + bool needs_border = false; + unsigned i, j; if (tex->num_samplers > 0) { /* output sampler state: */ @@ -170,6 +162,8 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring, OUT_RING(ring, sampler->texsamp0); OUT_RING(ring, sampler->texsamp1); + + needs_border |= sampler->needs_border; } } @@ -233,10 +227,23 @@ emit_textures(struct fd_context *ctx, 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); + if (needs_border) { + unsigned off; + void *ptr; + + u_upload_alloc(fd3_ctx->border_color_uploader, + 0, BORDER_COLOR_UPLOAD_SIZE, + BORDER_COLOR_UPLOAD_SIZE, &off, + &fd3_ctx->border_color_buf, + &ptr); - u_upload_unmap(fd3_ctx->border_color_uploader); + fd_setup_border_colors(tex, ptr, tex_off[sb]); + + 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 diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c index 9d54d41e1ad..81336bff97f 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c @@ -36,7 +36,7 @@ #include "fd3_format.h" static enum a3xx_tex_clamp -tex_clamp(unsigned wrap, bool clamp_to_edge) +tex_clamp(unsigned wrap, bool clamp_to_edge, bool *needs_border) { /* Hardware does not support _CLAMP, but we emulate it: */ if (wrap == PIPE_TEX_WRAP_CLAMP) { @@ -50,6 +50,7 @@ tex_clamp(unsigned wrap, bool clamp_to_edge) case PIPE_TEX_WRAP_CLAMP_TO_EDGE: return A3XX_TEX_CLAMP_TO_EDGE; case PIPE_TEX_WRAP_CLAMP_TO_BORDER: + *needs_border = true; return A3XX_TEX_CLAMP_TO_BORDER; case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE: /* only works for PoT.. need to emulate otherwise! */ @@ -113,6 +114,7 @@ fd3_sampler_state_create(struct pipe_context *pctx, so->saturate_r = (cso->wrap_r == PIPE_TEX_WRAP_CLAMP); } + so->needs_border = false; so->texsamp0 = COND(!cso->normalized_coords, A3XX_TEX_SAMP_0_UNNORM_COORDS) | COND(!cso->seamless_cube_map, A3XX_TEX_SAMP_0_CUBEMAPSEAMLESSFILTOFF) | @@ -120,9 +122,9 @@ fd3_sampler_state_create(struct pipe_context *pctx, A3XX_TEX_SAMP_0_XY_MAG(tex_filter(cso->mag_img_filter, aniso)) | A3XX_TEX_SAMP_0_XY_MIN(tex_filter(cso->min_img_filter, aniso)) | A3XX_TEX_SAMP_0_ANISO(aniso) | - A3XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s, clamp_to_edge)) | - A3XX_TEX_SAMP_0_WRAP_T(tex_clamp(cso->wrap_t, clamp_to_edge)) | - A3XX_TEX_SAMP_0_WRAP_R(tex_clamp(cso->wrap_r, clamp_to_edge)); + A3XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s, clamp_to_edge, &so->needs_border)) | + A3XX_TEX_SAMP_0_WRAP_T(tex_clamp(cso->wrap_t, clamp_to_edge, &so->needs_border)) | + A3XX_TEX_SAMP_0_WRAP_R(tex_clamp(cso->wrap_r, clamp_to_edge, &so->needs_border)); if (cso->compare_mode) so->texsamp0 |= A3XX_TEX_SAMP_0_COMPARE_FUNC(cso->compare_func); /* maps 1:1 */ diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_texture.h b/src/gallium/drivers/freedreno/a3xx/fd3_texture.h index d5afb03cd7a..22203feee02 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_texture.h +++ b/src/gallium/drivers/freedreno/a3xx/fd3_texture.h @@ -41,6 +41,7 @@ struct fd3_sampler_stateobj { struct pipe_sampler_state base; uint32_t texsamp0, texsamp1; bool saturate_s, saturate_t, saturate_r; + bool needs_border; }; static inline struct fd3_sampler_stateobj * |