From: Rob Clark Date: Wed, 6 Feb 2019 15:23:50 +0000 (-0500) Subject: freedreno/a6xx: border-color offset helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2183d9cff7b068b9fcbc579480f787ebaee58a5f;p=mesa.git 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 --- 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: *