[Mesa-dev] [PATCH 04/10] i965: Reorder workaround flags computation.

Mathias.Froehlich at gmx.net Mathias.Froehlich at gmx.net
Wed Dec 12 06:44:38 UTC 2018


From: Mathias Fröhlich <mathias.froehlich at web.de>

Vertex processing workaround flags can be split into
array and current vertex attributes. By that we
can use specific access functions for these different
vertex attribute kinds. This finally obsoletes
some access functions that I introduced last winter
for a smooth transition.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich at web.de>
---
 src/mesa/drivers/dri/i965/brw_draw.c | 76 ++++++++++++++++++----------
 1 file changed, 50 insertions(+), 26 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index 9826bc8761..fe96609e1f 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -297,6 +297,36 @@ brw_clear_buffers(struct brw_context *brw)
 }
 
 
+static uint8_t get_wa_flags(const struct gl_vertex_format *glformat)
+{
+   uint8_t wa_flags = 0;
+
+   switch (glformat->Type) {
+
+   case GL_FIXED:
+      wa_flags = glformat->Size;
+      break;
+
+   case GL_INT_2_10_10_10_REV:
+      wa_flags |= BRW_ATTRIB_WA_SIGN;
+      /* fallthough */
+
+   case GL_UNSIGNED_INT_2_10_10_10_REV:
+      if (glformat->Format == GL_BGRA)
+         wa_flags |= BRW_ATTRIB_WA_BGRA;
+
+      if (glformat->Normalized)
+         wa_flags |= BRW_ATTRIB_WA_NORMALIZE;
+      else if (!glformat->Integer)
+         wa_flags |= BRW_ATTRIB_WA_SCALE;
+
+      break;
+   }
+
+   return wa_flags;
+}
+
+
 static void
 brw_merge_inputs(struct brw_context *brw)
 {
@@ -311,38 +341,32 @@ brw_merge_inputs(struct brw_context *brw)
    }
 
    if (devinfo->gen < 8 && !devinfo->is_haswell) {
-      uint64_t mask = ctx->VertexProgram._Current->info.inputs_read;
       /* Prior to Haswell, the hardware can't natively support GL_FIXED or
        * 2_10_10_10_REV vertex formats.  Set appropriate workaround flags.
        */
-      while (mask) {
-         const struct gl_vertex_format *glformat;
-         uint8_t wa_flags = 0;
-
-         i = u_bit_scan64(&mask);
-         glformat = &brw->vb.inputs[i].glattrib->Format;
-
-         switch (glformat->Type) {
-
-         case GL_FIXED:
-            wa_flags = glformat->Size;
-            break;
-
-         case GL_INT_2_10_10_10_REV:
-            wa_flags |= BRW_ATTRIB_WA_SIGN;
-            /* fallthough */
-
-         case GL_UNSIGNED_INT_2_10_10_10_REV:
-            if (glformat->Format == GL_BGRA)
-               wa_flags |= BRW_ATTRIB_WA_BGRA;
+      const struct gl_vertex_array_object *vao = ctx->Array._DrawVAO;
+      const uint64_t vs_inputs = ctx->VertexProgram._Current->info.inputs_read;
+      assert((vs_inputs & ~((uint64_t)VERT_BIT_ALL)) == 0);
 
-            if (glformat->Normalized)
-               wa_flags |= BRW_ATTRIB_WA_NORMALIZE;
-            else if (!glformat->Integer)
-               wa_flags |= BRW_ATTRIB_WA_SCALE;
+      GLbitfield vaomask = vs_inputs & _mesa_draw_array_bits(ctx);
+      while (vaomask) {
+         const gl_vert_attrib i = u_bit_scan(&vaomask);
+         const struct gl_array_attributes *glattrib
+            = _mesa_draw_array_attrib(vao, i);
+         const uint8_t wa_flags = get_wa_flags(&glattrib->Format);
 
-            break;
+         if (brw->vb.attrib_wa_flags[i] != wa_flags) {
+            brw->vb.attrib_wa_flags[i] = wa_flags;
+            brw->ctx.NewDriverState |= BRW_NEW_VS_ATTRIB_WORKAROUNDS;
          }
+      }
+
+      GLbitfield currmask = vs_inputs & _mesa_draw_current_bits(ctx);
+      while (currmask) {
+         const gl_vert_attrib i = u_bit_scan(&currmask);
+         const struct gl_array_attributes *glattrib
+            = _mesa_draw_current_attrib(ctx, i);
+         const uint8_t wa_flags = get_wa_flags(&glattrib->Format);
 
          if (brw->vb.attrib_wa_flags[i] != wa_flags) {
             brw->vb.attrib_wa_flags[i] = wa_flags;
-- 
2.19.2



More information about the mesa-dev mailing list