glsl: lower mediump partial derivatives
[mesa.git] / src / mesa / main / light.c
index f52ed8ed25c189da8616d0a8f9b1c7f3ec8763b6..0883832dbd6a8197153175681a7b616155759453 100644 (file)
@@ -26,7 +26,6 @@
 
 #include "c99_math.h"
 #include "glheader.h"
-#include "imports.h"
 #include "context.h"
 #include "enums.h"
 #include "light.h"
@@ -613,7 +612,7 @@ _mesa_update_material( struct gl_context *ctx, GLuint bitmask )
 {
    GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
 
-   if (MESA_VERBOSE & VERBOSE_MATERIAL) 
+   if (MESA_VERBOSE & VERBOSE_MATERIAL)
       _mesa_debug(ctx, "_mesa_update_material, mask 0x%x\n", bitmask);
 
    if (!bitmask)
@@ -625,7 +624,7 @@ _mesa_update_material( struct gl_context *ctx, GLuint bitmask )
       while (mask) {
          const int i = u_bit_scan(&mask);
          struct gl_light *light = &ctx->Light.Light[i];
-         SCALE_3V( light->_MatAmbient[0], light->Ambient, 
+         SCALE_3V( light->_MatAmbient[0], light->Ambient,
                   mat[MAT_ATTRIB_FRONT_AMBIENT]);
       }
    }
@@ -635,7 +634,7 @@ _mesa_update_material( struct gl_context *ctx, GLuint bitmask )
       while (mask) {
          const int i = u_bit_scan(&mask);
          struct gl_light *light = &ctx->Light.Light[i];
-         SCALE_3V( light->_MatAmbient[1], light->Ambient, 
+         SCALE_3V( light->_MatAmbient[1], light->Ambient,
                   mat[MAT_ATTRIB_BACK_AMBIENT]);
       }
    }
@@ -659,7 +658,7 @@ _mesa_update_material( struct gl_context *ctx, GLuint bitmask )
       while (mask) {
          const int i = u_bit_scan(&mask);
          struct gl_light *light = &ctx->Light.Light[i];
-        SCALE_3V( light->_MatDiffuse[0], light->Diffuse, 
+        SCALE_3V( light->_MatDiffuse[0], light->Diffuse,
                   mat[MAT_ATTRIB_FRONT_DIFFUSE] );
       }
    }
@@ -669,7 +668,7 @@ _mesa_update_material( struct gl_context *ctx, GLuint bitmask )
       while (mask) {
          const int i = u_bit_scan(&mask);
          struct gl_light *light = &ctx->Light.Light[i];
-        SCALE_3V( light->_MatDiffuse[1], light->Diffuse, 
+        SCALE_3V( light->_MatDiffuse[1], light->Diffuse,
                   mat[MAT_ATTRIB_BACK_DIFFUSE] );
       }
    }
@@ -680,7 +679,7 @@ _mesa_update_material( struct gl_context *ctx, GLuint bitmask )
       while (mask) {
          const int i = u_bit_scan(&mask);
          struct gl_light *light = &ctx->Light.Light[i];
-        SCALE_3V( light->_MatSpecular[0], light->Specular, 
+        SCALE_3V( light->_MatSpecular[0], light->Specular,
                   mat[MAT_ATTRIB_FRONT_SPECULAR]);
       }
    }
@@ -857,12 +856,12 @@ _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
          params[3] = FLOAT_TO_INT( mat[MAT_ATTRIB_EMISSION(f)][3] );
         break;
       case GL_SHININESS:
-         *params = IROUND( mat[MAT_ATTRIB_SHININESS(f)][0] );
+         *params = lroundf( mat[MAT_ATTRIB_SHININESS(f)][0] );
         break;
       case GL_COLOR_INDEXES:
-        params[0] = IROUND( mat[MAT_ATTRIB_INDEXES(f)][0] );
-        params[1] = IROUND( mat[MAT_ATTRIB_INDEXES(f)][1] );
-        params[2] = IROUND( mat[MAT_ATTRIB_INDEXES(f)][2] );
+        params[0] = lroundf( mat[MAT_ATTRIB_INDEXES(f)][0] );
+        params[1] = lroundf( mat[MAT_ATTRIB_INDEXES(f)][1] );
+        params[2] = lroundf( mat[MAT_ATTRIB_INDEXES(f)][2] );
         break;
       default:
          _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" );
@@ -1032,6 +1031,7 @@ static void
 update_modelview_scale( struct gl_context *ctx )
 {
    ctx->_ModelViewInvScale = 1.0F;
+   ctx->_ModelViewInvScaleEyespace = 1.0F;
    if (!_math_matrix_is_length_preserving(ctx->ModelviewMatrixStack.Top)) {
       const GLfloat *m = ctx->ModelviewMatrixStack.Top->inv;
       GLfloat f = m[2] * m[2] + m[6] * m[6] + m[10] * m[10];
@@ -1040,6 +1040,7 @@ update_modelview_scale( struct gl_context *ctx )
         ctx->_ModelViewInvScale = 1.0f / sqrtf(f);
       else
         ctx->_ModelViewInvScale = sqrtf(f);
+      ctx->_ModelViewInvScaleEyespace = 1.0f / sqrtf(f);
    }
 }
 
@@ -1115,7 +1116,7 @@ _mesa_allow_light_in_model( struct gl_context *ctx, GLboolean flag )
  * Initialize the n-th light data structure.
  *
  * \param l pointer to the gl_light structure to be initialized.
- * \param n number of the light. 
+ * \param n number of the light.
  * \note The defaults for light 0 are different than the other lights.
  */
 static void
@@ -1159,7 +1160,7 @@ init_lightmodel( struct gl_lightmodel *lm )
 
 /**
  * Initialize the material data structure.
- * 
+ *
  * \param m pointer to the gl_material structure to be initialized.
  */
 static void
@@ -1171,7 +1172,7 @@ init_material( struct gl_material *m )
    ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_EMISSION], 0.0F, 0.0F, 0.0F, 1.0F );
    ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_SHININESS], 0.0F, 0.0F, 0.0F, 0.0F );
    ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_INDEXES], 0.0F, 1.0F, 1.0F, 0.0F );
+
    ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_AMBIENT],  0.2F, 0.2F, 0.2F, 1.0F );
    ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_DIFFUSE],  0.8F, 0.8F, 0.8F, 1.0F );
    ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_SPECULAR], 0.0F, 0.0F, 0.0F, 1.0F );
@@ -1216,4 +1217,5 @@ _mesa_init_lighting( struct gl_context *ctx )
    ctx->_NeedEyeCoords = GL_FALSE;
    ctx->_ForceEyeCoords = GL_FALSE;
    ctx->_ModelViewInvScale = 1.0;
+   ctx->_ModelViewInvScaleEyespace = 1.0;
 }