freedreno/a6xx: border-color offset helper
authorRob Clark <robdclark@gmail.com>
Wed, 6 Feb 2019 15:23:50 +0000 (10:23 -0500)
committerRob Clark <robdclark@gmail.com>
Sat, 16 Feb 2019 21:28:00 +0000 (16:28 -0500)
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>
src/gallium/drivers/freedreno/a6xx/fd6_texture.c
src/gallium/drivers/freedreno/a6xx/fd6_texture.h

index cc86525ec639c22113164ab7455d09d1a4db3f29..f4bad031e6b53864edab6d4b84b76198a852b5e9 100644 (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 =
index 576afaafdb49f6a22c34e2c66e41213ae06e39bc..417aa72b9aef458bdc9c55f2a57019ef880e5b66 100644 (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:
  *