diff options
author | Rob Clark <[email protected]> | 2016-06-11 12:59:00 -0400 |
---|---|---|
committer | Rob Clark <[email protected]> | 2016-06-14 11:00:59 -0400 |
commit | 243417810bce6b4e0c466a8b1dbe3873b4f5562b (patch) | |
tree | 3514d27523738dffbd1c4b6c27e84b0523f8fec4 /src/gallium/drivers/freedreno | |
parent | b8eb1493a9f4c6d5f1484269dc9553fb78066435 (diff) |
freedreno: support start param for sampler views/states
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno')
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_context.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_texture.c | 53 |
2 files changed, 23 insertions, 33 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h index 5861fbe8b06..7ce29203fa9 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.h +++ b/src/gallium/drivers/freedreno/freedreno_context.h @@ -47,9 +47,10 @@ struct fd_vertex_stateobj; struct fd_texture_stateobj { struct pipe_sampler_view *textures[PIPE_MAX_SAMPLERS]; unsigned num_textures; + unsigned valid_textures; struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS]; unsigned num_samplers; - unsigned dirty_samplers; + unsigned valid_samplers; }; struct fd_program_stateobj { diff --git a/src/gallium/drivers/freedreno/freedreno_texture.c b/src/gallium/drivers/freedreno/freedreno_texture.c index a301811995d..b506595192d 100644 --- a/src/gallium/drivers/freedreno/freedreno_texture.c +++ b/src/gallium/drivers/freedreno/freedreno_texture.c @@ -50,45 +50,38 @@ fd_sampler_view_destroy(struct pipe_context *pctx, } static void bind_sampler_states(struct fd_texture_stateobj *tex, - unsigned nr, void **hwcso) + unsigned start, unsigned nr, void **hwcso) { unsigned i; - unsigned new_nr = 0; for (i = 0; i < nr; i++) { - if (hwcso[i]) - new_nr = i + 1; - tex->samplers[i] = hwcso[i]; - tex->dirty_samplers |= (1 << i); - } - - for (; i < tex->num_samplers; i++) { - tex->samplers[i] = NULL; - tex->dirty_samplers |= (1 << i); + unsigned p = i + start; + tex->samplers[p] = hwcso[i]; + if (tex->samplers[p]) + tex->valid_samplers |= (1 << p); + else + tex->valid_samplers &= ~(1 << p); } - tex->num_samplers = new_nr; + tex->num_samplers = util_last_bit(tex->valid_samplers); } static void set_sampler_views(struct fd_texture_stateobj *tex, - unsigned nr, struct pipe_sampler_view **views) + unsigned start, unsigned nr, struct pipe_sampler_view **views) { unsigned i; - unsigned new_nr = 0; for (i = 0; i < nr; i++) { - if (views[i]) - new_nr = i + 1; - pipe_sampler_view_reference(&tex->textures[i], views[i]); - tex->dirty_samplers |= (1 << i); + struct pipe_sampler_view *view = views ? views[i] : NULL; + unsigned p = i + start; + pipe_sampler_view_reference(&tex->textures[p], view); + if (tex->textures[p]) + tex->valid_textures |= (1 << p); + else + tex->valid_textures &= ~(1 << p); } - for (; i < tex->num_textures; i++) { - pipe_sampler_view_reference(&tex->textures[i], NULL); - tex->dirty_samplers |= (1 << i); - } - - tex->num_textures = new_nr; + tex->num_textures = util_last_bit(tex->valid_textures); } void @@ -98,14 +91,12 @@ fd_sampler_states_bind(struct pipe_context *pctx, { struct fd_context *ctx = fd_context(pctx); - assert(start == 0); - if (shader == PIPE_SHADER_FRAGMENT) { - bind_sampler_states(&ctx->fragtex, nr, hwcso); + bind_sampler_states(&ctx->fragtex, start, nr, hwcso); ctx->dirty |= FD_DIRTY_FRAGTEX; } else if (shader == PIPE_SHADER_VERTEX) { - bind_sampler_states(&ctx->verttex, nr, hwcso); + bind_sampler_states(&ctx->verttex, start, nr, hwcso); ctx->dirty |= FD_DIRTY_VERTTEX; } } @@ -117,8 +108,6 @@ fd_set_sampler_views(struct pipe_context *pctx, unsigned shader, { struct fd_context *ctx = fd_context(pctx); - assert(start == 0); - switch (shader) { case PIPE_SHADER_FRAGMENT: /* on a2xx, since there is a flat address space for textures/samplers, @@ -130,11 +119,11 @@ fd_set_sampler_views(struct pipe_context *pctx, unsigned shader, if (nr != ctx->fragtex.num_textures) ctx->dirty |= FD_DIRTY_TEXSTATE; - set_sampler_views(&ctx->fragtex, nr, views); + set_sampler_views(&ctx->fragtex, start, nr, views); ctx->dirty |= FD_DIRTY_FRAGTEX; break; case PIPE_SHADER_VERTEX: - set_sampler_views(&ctx->verttex, nr, views); + set_sampler_views(&ctx->verttex, start, nr, views); ctx->dirty |= FD_DIRTY_VERTTEX; break; default: |