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 <robdclark@gmail.com>
This commit is contained in:
Rob Clark 2019-02-06 10:23:50 -05:00
parent c1a27ba9ba
commit 2183d9cff7
2 changed files with 31 additions and 13 deletions

View file

@ -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 =

View file

@ -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:
*