diff options
author | Brian Paul <[email protected]> | 2009-11-02 13:20:19 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-11-03 09:52:25 -0700 |
commit | b28c637382cd3c3fcd54cd77062dab3df78230a9 (patch) | |
tree | ef48987868ec372c352230d0ccf9443a60112228 /src/mesa/main/buffers.c | |
parent | 2d11c48223adb78353ca32f0cc07941957310389 (diff) |
mesa: use ffs() to shorten loop in _mesa_drawbuffers()
Diffstat (limited to 'src/mesa/main/buffers.c')
-rw-r--r-- | src/mesa/main/buffers.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index b5acda8823c..cdd16a8ad1d 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -375,15 +375,19 @@ _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, destMask = mask; } + /* + * If n==1, destMask[0] may have up to four bits set. + * Otherwise, destMask[x] can only have one bit set. + */ if (n == 1) { - GLuint buf, count = 0; + GLuint count = 0, destMask0 = destMask[0]; /* init to -1 to help catch errors */ fb->_ColorDrawBufferIndexes[0] = -1; - for (buf = 0; buf < BUFFER_COUNT; buf++) { - if (destMask[0] & (1 << buf)) { - fb->_ColorDrawBufferIndexes[count] = buf; - count++; - } + while (destMask0) { + GLint bufIndex = _mesa_ffs(destMask0) - 1; + fb->_ColorDrawBufferIndexes[count] = bufIndex; + count++; + destMask0 &= ~(1 << bufIndex); } fb->ColorDrawBuffer[0] = buffers[0]; fb->_NumColorDrawBuffers = count; |