summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_state.c10
-rw-r--r--src/mesa/drivers/dri/nouveau/nv10_state_tnl.c27
-rw-r--r--src/mesa/drivers/dri/nouveau/nv20_state_tnl.c27
3 files changed, 38 insertions, 26 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c
index 3aad10ed62e..6189997397f 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_state.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c
@@ -31,6 +31,7 @@
#include "swrast/swrast.h"
#include "tnl/tnl.h"
+#include "util/bitscan.h"
static void
nouveau_alpha_func(struct gl_context *ctx, GLenum func, GLfloat ref)
@@ -122,7 +123,7 @@ nouveau_draw_buffers(struct gl_context *ctx, GLsizei n, const GLenum *buffers)
static void
nouveau_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
{
- int i;
+ GLbitfield mask;
switch (cap) {
case GL_ALPHA_TEST:
@@ -187,9 +188,10 @@ nouveau_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
context_dirty(ctx, LIGHT_MODEL);
context_dirty(ctx, LIGHT_ENABLE);
- for (i = 0; i < MAX_LIGHTS; i++) {
- if (ctx->Light.Light[i].Enabled)
- context_dirty_i(ctx, LIGHT_SOURCE, i);
+ mask = ctx->Light._EnabledLights;
+ while (mask) {
+ const int i = u_bit_scan(&mask);
+ context_dirty_i(ctx, LIGHT_SOURCE, i);
}
context_dirty(ctx, MATERIAL_FRONT_AMBIENT);
diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c b/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c
index 1398385b262..9f80e413577 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c
@@ -30,8 +30,7 @@
#include "nouveau_util.h"
#include "nv10_3d.xml.h"
#include "nv10_driver.h"
-
-#include "util/simple_list.h"
+#include "util/bitscan.h"
void
nv10_emit_clip_plane(struct gl_context *ctx, int emit)
@@ -323,7 +322,7 @@ nv10_emit_material_ambient(struct gl_context *ctx, int emit)
struct nouveau_pushbuf *push = context_push(ctx);
float (*mat)[4] = ctx->Light.Material.Attrib;
float c_scene[3], c_factor[3];
- struct gl_light *l;
+ GLbitfield mask;
if (USE_COLOR_MATERIAL(AMBIENT)) {
COPY_3V(c_scene, ctx->Light.Model.Ambient);
@@ -347,8 +346,10 @@ nv10_emit_material_ambient(struct gl_context *ctx, int emit)
PUSH_DATAp(push, c_factor, 3);
}
- foreach(l, &ctx->Light.EnabledList) {
- const int i = l - ctx->Light.Light;
+ mask = ctx->Light._EnabledLights;
+ while (mask) {
+ const int i = u_bit_scan(&mask);
+ struct gl_light *l = &ctx->Light.Light[i];
float *c_light = (USE_COLOR_MATERIAL(AMBIENT) ?
l->Ambient :
l->_MatAmbient[0]);
@@ -363,13 +364,15 @@ nv10_emit_material_diffuse(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
- struct gl_light *l;
+ GLbitfield mask;
BEGIN_NV04(push, NV10_3D(MATERIAL_FACTOR_A), 1);
PUSH_DATAf(push, mat[MAT_ATTRIB_FRONT_DIFFUSE][3]);
- foreach(l, &ctx->Light.EnabledList) {
- const int i = l - ctx->Light.Light;
+ mask = ctx->Light._EnabledLights;
+ while (mask) {
+ const int i = u_bit_scan(&mask);
+ struct gl_light *l = &ctx->Light.Light[i];
float *c_light = (USE_COLOR_MATERIAL(DIFFUSE) ?
l->Diffuse :
l->_MatDiffuse[0]);
@@ -383,10 +386,12 @@ void
nv10_emit_material_specular(struct gl_context *ctx, int emit)
{
struct nouveau_pushbuf *push = context_push(ctx);
- struct gl_light *l;
+ GLbitfield mask;
- foreach(l, &ctx->Light.EnabledList) {
- const int i = l - ctx->Light.Light;
+ mask = ctx->Light._EnabledLights;
+ while (mask) {
+ const int i = u_bit_scan(&mask);
+ struct gl_light *l = &ctx->Light.Light[i];
float *c_light = (USE_COLOR_MATERIAL(SPECULAR) ?
l->Specular :
l->_MatSpecular[0]);
diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c b/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c
index 41395516ea4..607a5c0314a 100644
--- a/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c
+++ b/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c
@@ -31,8 +31,7 @@
#include "nv20_3d.xml.h"
#include "nv10_driver.h"
#include "nv20_driver.h"
-
-#include "util/simple_list.h"
+#include "util/bitscan.h"
#define LIGHT_MODEL_AMBIENT_R(side) \
((side) ? NV20_3D_LIGHT_MODEL_BACK_AMBIENT_R : \
@@ -240,7 +239,7 @@ nv20_emit_material_ambient(struct gl_context *ctx, int emit)
struct nouveau_pushbuf *push = context_push(ctx);
float (*mat)[4] = ctx->Light.Material.Attrib;
float c_scene[3], c_factor[3];
- struct gl_light *l;
+ GLbitfield mask;
if (USE_COLOR_MATERIAL(AMBIENT, side)) {
COPY_3V(c_scene, mat[MAT_ATTRIB_EMISSION(side)]);
@@ -264,8 +263,10 @@ nv20_emit_material_ambient(struct gl_context *ctx, int emit)
PUSH_DATAp(push, c_factor, 3);
}
- foreach(l, &ctx->Light.EnabledList) {
- const int i = l - ctx->Light.Light;
+ mask = ctx->Light._EnabledLights;
+ while (mask) {
+ const int i = u_bit_scan(&mask);
+ struct gl_light *l = &ctx->Light.Light[i];
float *c_light = (USE_COLOR_MATERIAL(AMBIENT, side) ?
l->Ambient :
l->_MatAmbient[side]);
@@ -281,13 +282,15 @@ nv20_emit_material_diffuse(struct gl_context *ctx, int emit)
const int side = emit - NOUVEAU_STATE_MATERIAL_FRONT_DIFFUSE;
struct nouveau_pushbuf *push = context_push(ctx);
GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
- struct gl_light *l;
+ GLbitfield mask;
BEGIN_NV04(push, SUBC_3D(MATERIAL_FACTOR_A(side)), 1);
PUSH_DATAf(push, mat[MAT_ATTRIB_DIFFUSE(side)][3]);
- foreach(l, &ctx->Light.EnabledList) {
- const int i = l - ctx->Light.Light;
+ mask = ctx->Light._EnabledLights;
+ while (mask) {
+ const int i = u_bit_scan(&mask);
+ struct gl_light *l = &ctx->Light.Light[i];
float *c_light = (USE_COLOR_MATERIAL(DIFFUSE, side) ?
l->Diffuse :
l->_MatDiffuse[side]);
@@ -302,10 +305,12 @@ nv20_emit_material_specular(struct gl_context *ctx, int emit)
{
const int side = emit - NOUVEAU_STATE_MATERIAL_FRONT_SPECULAR;
struct nouveau_pushbuf *push = context_push(ctx);
- struct gl_light *l;
+ GLbitfield mask;
- foreach(l, &ctx->Light.EnabledList) {
- const int i = l - ctx->Light.Light;
+ mask = ctx->Light._EnabledLights;
+ while (mask) {
+ const int i = u_bit_scan(&mask);
+ struct gl_light *l = &ctx->Light.Light[i];
float *c_light = (USE_COLOR_MATERIAL(SPECULAR, side) ?
l->Specular :
l->_MatSpecular[side]);