mesa: Track enabled lights in a bitmask
authorMathias Fröhlich <mathias.froehlich@web.de>
Sun, 22 May 2016 12:10:19 +0000 (14:10 +0200)
committerMathias Fröhlich <mathias.froehlich@web.de>
Thu, 16 Jun 2016 03:50:53 +0000 (05:50 +0200)
This enables some optimizations afterwards.

Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
src/mesa/main/enable.c
src/mesa/main/light.c
src/mesa/main/mtypes.h

index 1d674bf39f6e136a365c96249dd7057862ebc08f..bc59280f0905707233d2ffc5871932248144d5e5 100644 (file)
@@ -402,10 +402,12 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
          FLUSH_VERTICES(ctx, _NEW_LIGHT);
          ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
          if (state) {
+            ctx->Light._EnabledLights |= 1u << (cap - GL_LIGHT0);
             insert_at_tail(&ctx->Light.EnabledList,
                            &ctx->Light.Light[cap-GL_LIGHT0]);
          }
          else {
+            ctx->Light._EnabledLights &= ~(1u << (cap - GL_LIGHT0));
             remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]);
          }
          break;
index 4a8dee3f649ffaa3a37a195c65b7e374fcafe6fa..a52efdbdf87b8e741ff5257565593e40978fc3dc 100644 (file)
@@ -1171,6 +1171,7 @@ _mesa_init_lighting( struct gl_context *ctx )
    GLuint i;
 
    /* Lighting group */
+   ctx->Light._EnabledLights = 0;
    for (i = 0; i < MAX_LIGHTS; i++) {
       init_light( &ctx->Light.Light[i], i );
    }
index b86a0eead0f2046446f96f7df60059c2b70a4431..bea589fabbb5d98ca99e1f5c44bd37e121f74ea9 100644 (file)
@@ -630,6 +630,8 @@ struct gl_light_attrib
     * Derived state for optimizations: 
     */
    /*@{*/
+   GLbitfield _EnabledLights;  /**< bitmask containing enabled lights */
+
    GLboolean _NeedEyeCoords;           
    GLboolean _NeedVertices;            /**< Use fast shader? */
    struct gl_light EnabledList;         /**< List sentinel */