[Mesa-dev] [PATCH 02/31] mesa: Make use of _mesa_bit_scan{,64}.

Mathias.Froehlich at gmx.net Mathias.Froehlich at gmx.net
Tue Jun 7 05:29:37 UTC 2016


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

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich at web.de>
---
 src/mesa/main/arrayobj.c | 5 ++---
 src/mesa/main/buffers.c  | 3 +--
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 897dac6..fb3c752 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -342,13 +342,12 @@ _mesa_update_vao_client_arrays(struct gl_context *ctx,
    GLbitfield64 arrays = vao->NewArrays;
 
    while (arrays) {
+      const int attrib = _mesa_bit_scan64(&arrays);
+
       struct gl_client_array *client_array;
       struct gl_vertex_attrib_array *attrib_array;
       struct gl_vertex_buffer_binding *buffer_binding;
 
-      GLint attrib = ffsll(arrays) - 1;
-      arrays ^= BITFIELD64_BIT(attrib);
-
       attrib_array = &vao->VertexAttrib[attrib];
       buffer_binding = &vao->VertexBinding[attrib_array->VertexBinding];
       client_array = &vao->_VertexAttrib[attrib];
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index a28c583..c93be3b 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -595,13 +595,12 @@ _mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
    if (n > 0 && _mesa_bitcount(destMask[0]) > 1) {
       GLuint count = 0, destMask0 = destMask[0];
       while (destMask0) {
-         GLint bufIndex = ffs(destMask0) - 1;
+         const int bufIndex = _mesa_bit_scan(&destMask0);
          if (fb->_ColorDrawBufferIndexes[count] != bufIndex) {
             updated_drawbuffers(ctx, fb);
             fb->_ColorDrawBufferIndexes[count] = bufIndex;
          }
          count++;
-         destMask0 &= ~(1 << bufIndex);
       }
       fb->ColorDrawBuffer[0] = buffers[0];
       fb->_NumColorDrawBuffers = count;
-- 
2.5.5



More information about the mesa-dev mailing list