OSDN Git Service

intel: use more efficient loop over buffers
authorBrian Paul <brianp@vmware.com>
Thu, 27 Aug 2009 20:34:21 +0000 (14:34 -0600)
committerBrian Paul <brianp@vmware.com>
Sun, 30 Aug 2009 15:10:36 +0000 (09:10 -0600)
src/mesa/drivers/dri/intel/intel_clear.c

index cfddabd..630d2ad 100644 (file)
@@ -150,14 +150,18 @@ intelClear(GLcontext *ctx, GLbitfield mask)
    /* SW fallback clearing */
    swrast_mask = mask & ~tri_mask & ~blit_mask;
 
-   for (i = 0; i < BUFFER_COUNT; i++) {
-      GLuint bufBit = 1 << i;
-      if ((blit_mask | tri_mask) & bufBit) {
+   {
+      /* look for non-Intel renderbuffers (clear them with swrast) */
+      GLbitfield blit_or_tri = blit_mask | tri_mask;
+      while (blit_or_tri) {
+         GLuint i = _mesa_ffs(blit_or_tri) - 1;
+         GLbitfield bufBit = 1 << i;
          if (!fb->Attachment[i].Renderbuffer->ClassID) {
             blit_mask &= ~bufBit;
             tri_mask &= ~bufBit;
             swrast_mask |= bufBit;
          }
+         blit_or_tri ^= bufBit;
       }
    }