diff options
author | Rob Clark <[email protected]> | 2019-02-06 10:23:50 -0500 |
---|---|---|
committer | Rob Clark <[email protected]> | 2019-02-16 16:28:00 -0500 |
commit | 2183d9cff7b068b9fcbc579480f787ebaee58a5f (patch) | |
tree | 318b5a577362013052fcd113316ab5b47ff2450c | |
parent | c1a27ba9baf7c1d6ce15a3c9b2d9cb1eafa72918 (diff) |
freedreno/a6xx: border-color offset helper
Soon we'll need this logic to deal w/ image/SSBO case, so split out a
helper rather than duplicate the logic.
Signed-off-by: Rob Clark <[email protected]>
-rw-r--r-- | src/gallium/drivers/freedreno/a6xx/fd6_texture.c | 14 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a6xx/fd6_texture.h | 30 |
2 files changed, 31 insertions, 13 deletions
diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c index cc86525ec63..f4bad031e6b 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c @@ -432,19 +432,7 @@ fd6_texture_state(struct fd_context *ctx, enum a6xx_state_block sb, needs_border |= sampler->needs_border; } - /* This will need update for HS/DS/GS: */ - if (unlikely(needs_border && (sb == SB6_FS_TEX))) { - /* TODO we could probably use fixed offsets for each shader - * stage and avoid the need for # of VS samplers to be part - * of the FS tex state.. but I don't think our handling of - * BCOLOR_OFFSET is actually correct, and trying to use a - * hard coded offset of 16 breaks things. - * - * Note that when this changes, then a corresponding change - * in emit_border_color() is also needed. - */ - key.bcolor_offset = ctx->tex[PIPE_SHADER_VERTEX].num_samplers; - } + key.bcolor_offset = fd6_border_color_offset(ctx, sb, tex); uint32_t hash = key_hash(&key); struct hash_entry *entry = diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.h b/src/gallium/drivers/freedreno/a6xx/fd6_texture.h index 576afaafdb4..417aa72b9ae 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.h +++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.h @@ -90,6 +90,36 @@ fd6_tex_type(unsigned target) } } +static inline unsigned +fd6_border_color_offset(struct fd_context *ctx, enum a6xx_state_block sb, + struct fd_texture_stateobj *tex) +{ + /* Currently we put the FS border-color state after VS. Possibly + * we could swap the order. + * + * This will need update for HS/DS/GS + */ + if (sb != SB6_FS_TEX) + return 0; + + unsigned needs_border = false; + + for (unsigned i = 0; i < tex->num_samplers; i++) { + if (!tex->samplers[i]) + continue; + + struct fd6_sampler_stateobj *sampler = + fd6_sampler_stateobj(tex->samplers[i]); + + needs_border |= sampler->needs_border; + } + + if (!needs_border) + return 0; + + return ctx->tex[PIPE_SHADER_VERTEX].num_samplers; +} + /* * Texture stateobj: * |