#include "teximage.h"
#include "texstate.h"
#include "mtypes.h"
+#include "util/bitscan.h"
#include "util/bitset.h"
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
- GLuint texIndex;
+ GLbitfield mask;
bool complete;
if (texUnit->Enabled == 0x0)
* undefined."
*/
complete = false;
- for (texIndex = 0; texIndex < NUM_TEXTURE_TARGETS; texIndex++) {
- if (texUnit->Enabled & (1 << texIndex)) {
- struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex];
- struct gl_sampler_object *sampler = texUnit->Sampler ?
- texUnit->Sampler : &texObj->Sampler;
-
- if (!_mesa_is_texture_complete(texObj, sampler)) {
- _mesa_test_texobj_completeness(ctx, texObj);
- }
- if (_mesa_is_texture_complete(texObj, sampler)) {
- _mesa_reference_texobj(&texUnit->_Current, texObj);
- complete = true;
- break;
- }
+ mask = texUnit->Enabled;
+ while (mask) {
+ const int texIndex = u_bit_scan(&mask);
+ struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex];
+ struct gl_sampler_object *sampler = texUnit->Sampler ?
+ texUnit->Sampler : &texObj->Sampler;
+
+ if (!_mesa_is_texture_complete(texObj, sampler)) {
+ _mesa_test_texobj_completeness(ctx, texObj);
+ }
+ if (_mesa_is_texture_complete(texObj, sampler)) {
+ _mesa_reference_texobj(&texUnit->_Current, texObj);
+ complete = true;
+ break;
}
}