Beispiel #1
0
static void make_state_key( GLcontext *ctx, struct state_key *key )
{
   const struct gl_fragment_program *fp;
   GLuint i;

   memset(key, 0, sizeof(struct state_key));
   fp = ctx->FragmentProgram._Current;

   /* This now relies on texenvprogram.c being active:
    */
   assert(fp);

   key->need_eye_coords = ctx->_NeedEyeCoords;

   key->fragprog_inputs_read = fp->Base.InputsRead;
   key->varying_vp_inputs = ctx->varying_vp_inputs;

   if (ctx->RenderMode == GL_FEEDBACK) {
      /* make sure the vertprog emits color and tex0 */
      key->fragprog_inputs_read |= (FRAG_BIT_COL0 | FRAG_BIT_TEX0);
   }

   key->separate_specular = (ctx->Light.Model.ColorControl ==
			     GL_SEPARATE_SPECULAR_COLOR);

   if (ctx->Light.Enabled) {
      key->light_global_enabled = 1;

      if (ctx->Light.Model.LocalViewer)
	 key->light_local_viewer = 1;

      if (ctx->Light.Model.TwoSide)
	 key->light_twoside = 1;

      if (ctx->Light.ColorMaterialEnabled) {
	 key->light_color_material_mask = ctx->Light.ColorMaterialBitmask;
      }

      for (i = 0; i < MAX_LIGHTS; i++) {
	 struct gl_light *light = &ctx->Light.Light[i];

	 if (light->Enabled) {
	    key->unit[i].light_enabled = 1;

	    if (light->EyePosition[3] == 0.0)
	       key->unit[i].light_eyepos3_is_zero = 1;

	    if (light->SpotCutoff == 180.0)
	       key->unit[i].light_spotcutoff_is_180 = 1;

	    if (light->ConstantAttenuation != 1.0 ||
		light->LinearAttenuation != 0.0 ||
		light->QuadraticAttenuation != 0.0)
	       key->unit[i].light_attenuated = 1;
	 }
      }

      if (check_active_shininess(ctx, key, 0)) {
         key->material_shininess_is_zero = 0;
      }
      else if (key->light_twoside &&
               check_active_shininess(ctx, key, 1)) {
         key->material_shininess_is_zero = 0;
      }
      else {
         key->material_shininess_is_zero = 1;
      }
   }

   if (ctx->Transform.Normalize)
      key->normalize = 1;

   if (ctx->Transform.RescaleNormals)
      key->rescale_normals = 1;

   if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT)
      key->fog_source_is_depth = 1;

   if (ctx->Point._Attenuated)
      key->point_attenuated = 1;

#if FEATURE_point_size_array
   if (ctx->Array.ArrayObj->PointSize.Enabled)
      key->point_array = 1;
#endif

   if (ctx->Texture._TexGenEnabled ||
       ctx->Texture._TexMatEnabled ||
       ctx->Texture._EnabledUnits)
      key->texture_enabled_global = 1;

   for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
      struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];

      if (texUnit->_ReallyEnabled)
	 key->unit[i].texunit_really_enabled = 1;

      if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i))
	 key->unit[i].texmat_enabled = 1;

      if (texUnit->TexGenEnabled) {
	 key->unit[i].texgen_enabled = 1;

	 key->unit[i].texgen_mode0 =
	    translate_texgen( texUnit->TexGenEnabled & (1<<0),
			      texUnit->GenS.Mode );
	 key->unit[i].texgen_mode1 =
	    translate_texgen( texUnit->TexGenEnabled & (1<<1),
			      texUnit->GenT.Mode );
	 key->unit[i].texgen_mode2 =
	    translate_texgen( texUnit->TexGenEnabled & (1<<2),
			      texUnit->GenR.Mode );
	 key->unit[i].texgen_mode3 =
	    translate_texgen( texUnit->TexGenEnabled & (1<<3),
			      texUnit->GenQ.Mode );
      }
   }
}
static struct state_key *make_state_key( GLcontext *ctx )
{
   TNLcontext *tnl = TNL_CONTEXT(ctx);
   struct vertex_buffer *VB = &tnl->vb;
   const struct gl_fragment_program *fp = ctx->FragmentProgram._Current;
   struct state_key *key = CALLOC_STRUCT(state_key);
   GLuint i;

   /* This now relies on texenvprogram.c being active:
    */
   assert(fp);

   key->fragprog_inputs_read = fp->Base.InputsRead;

   key->separate_specular = (ctx->Light.Model.ColorControl ==
			     GL_SEPARATE_SPECULAR_COLOR);

   if (ctx->Light.Enabled) {
      key->light_global_enabled = 1;

      if (ctx->Light.Model.LocalViewer)
	 key->light_local_viewer = 1;

      if (ctx->Light.Model.TwoSide)
	 key->light_twoside = 1;

      if (ctx->Light.ColorMaterialEnabled) {
	 key->light_color_material = 1;
	 key->light_color_material_mask = ctx->Light.ColorMaterialBitmask;
      }

      for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) 
	 if (VB->AttribPtr[i]->stride) 
	    key->light_material_mask |= 1<<(i-_TNL_ATTRIB_MAT_FRONT_AMBIENT);

      for (i = 0; i < MAX_LIGHTS; i++) {
	 struct gl_light *light = &ctx->Light.Light[i];

	 if (light->Enabled) {
	    key->unit[i].light_enabled = 1;

	    if (light->EyePosition[3] == 0.0)
	       key->unit[i].light_eyepos3_is_zero = 1;
	    
	    if (light->SpotCutoff == 180.0)
	       key->unit[i].light_spotcutoff_is_180 = 1;

	    if (light->ConstantAttenuation != 1.0 ||
		light->LinearAttenuation != 0.0 ||
		light->QuadraticAttenuation != 0.0)
	       key->unit[i].light_attenuated = 1;
	 }
      }
   }

   if (ctx->Transform.Normalize)
      key->normalize = 1;

   if (ctx->Transform.RescaleNormals)
      key->rescale_normals = 1;

   key->fog_mode = translate_fog_mode(fp->FogOption);
   
   if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT)
      key->fog_source_is_depth = 1;
   
   if (tnl->_DoVertexFog)
      key->tnl_do_vertex_fog = 1;

   if (ctx->Point._Attenuated)
      key->point_attenuated = 1;

   if (ctx->Texture._TexGenEnabled ||
       ctx->Texture._TexMatEnabled ||
       ctx->Texture._EnabledUnits)
      key->texture_enabled_global = 1;
      
   for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
      struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];

      if (texUnit->_ReallyEnabled)
	 key->unit[i].texunit_really_enabled = 1;

      if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i))      
	 key->unit[i].texmat_enabled = 1;
      
      if (texUnit->TexGenEnabled) {
	 key->unit[i].texgen_enabled = 1;
      
	 key->unit[i].texgen_mode0 = 
	    translate_texgen( texUnit->TexGenEnabled & (1<<0),
			      texUnit->GenModeS );
	 key->unit[i].texgen_mode1 = 
	    translate_texgen( texUnit->TexGenEnabled & (1<<1),
			      texUnit->GenModeT );
	 key->unit[i].texgen_mode2 = 
	    translate_texgen( texUnit->TexGenEnabled & (1<<2),
			      texUnit->GenModeR );
	 key->unit[i].texgen_mode3 = 
	    translate_texgen( texUnit->TexGenEnabled & (1<<3),
			      texUnit->GenModeQ );
      }
   }
   
   return key;
}
Beispiel #3
0
static void make_state_key( GLcontext *ctx, struct state_key *key )
{
   struct brw_context *brw = brw_context(ctx);
   const struct gl_fragment_program *fp = brw->fragment_program;
   GLuint i;

   /* This now relies on texenvprogram.c being active:
    */
   assert(fp);

   memset(key, 0, sizeof(*key));

   /* BRW_NEW_FRAGMENT_PROGRAM */
   key->fragprog_inputs_read = fp->Base.InputsRead;

   /* _NEW_LIGHT */
   key->separate_specular = (brw->attribs.Light->Model.ColorControl ==
			     GL_SEPARATE_SPECULAR_COLOR);

   /* _NEW_LIGHT */
   if (brw->attribs.Light->Enabled) {
      key->light_global_enabled = 1;

      if (brw->attribs.Light->Model.LocalViewer)
	 key->light_local_viewer = 1;

      if (brw->attribs.Light->Model.TwoSide)
	 key->light_twoside = 1;

      if (brw->attribs.Light->ColorMaterialEnabled) {
	 key->light_color_material = 1;
	 key->light_color_material_mask = brw->attribs.Light->ColorMaterialBitmask;
      }

      /* BRW_NEW_INPUT_VARYING */

      /* For these programs, material values are stuffed into the
       * generic slots:
       */
      for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) 
	 if (brw->vb.info.varying & (1<<(VERT_ATTRIB_GENERIC0 + i))) 
	    key->light_material_mask |= 1<<i;

      for (i = 0; i < MAX_LIGHTS; i++) {
	 struct gl_light *light = &brw->attribs.Light->Light[i];

	 if (light->Enabled) {
	    key->unit[i].light_enabled = 1;

	    if (light->EyePosition[3] == 0.0)
	       key->unit[i].light_eyepos3_is_zero = 1;
	    
	    if (light->SpotCutoff == 180.0)
	       key->unit[i].light_spotcutoff_is_180 = 1;

	    if (light->ConstantAttenuation != 1.0 ||
		light->LinearAttenuation != 0.0 ||
		light->QuadraticAttenuation != 0.0)
	       key->unit[i].light_attenuated = 1;
	 }
      }
   }

   /* _NEW_TRANSFORM */
   if (brw->attribs.Transform->Normalize)
      key->normalize = 1;

   if (brw->attribs.Transform->RescaleNormals)
      key->rescale_normals = 1;

   /* BRW_NEW_FRAGMENT_PROGRAM */
   key->fog_option = translate_fog_mode(fp->FogOption);
   if (key->fog_option)
      key->fragprog_inputs_read |= FRAG_BIT_FOGC;
   
   /* _NEW_FOG */
   if (brw->attribs.Fog->FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT)
      key->fog_source_is_depth = 1;
   
   /* _NEW_HINT, ??? */
   if (1)
      key->tnl_do_vertex_fog = 1;

   /* _NEW_POINT */
   if (brw->attribs.Point->_Attenuated)
      key->point_attenuated = 1;

   /* _NEW_TEXTURE */
   if (brw->attribs.Texture->_TexGenEnabled ||
       brw->attribs.Texture->_TexMatEnabled ||
       brw->attribs.Texture->_EnabledUnits)
      key->texture_enabled_global = 1;
      
   for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
      struct gl_texture_unit *texUnit = &brw->attribs.Texture->Unit[i];

      if (texUnit->_ReallyEnabled)
 	 key->unit[i].texunit_really_enabled = 1;

      if (brw->attribs.Texture->_TexMatEnabled & ENABLE_TEXMAT(i))      
	 key->unit[i].texmat_enabled = 1;
      
      if (texUnit->TexGenEnabled) {
	 key->unit[i].texgen_enabled = 1;
      
	 key->unit[i].texgen_mode0 = 
	    translate_texgen( texUnit->TexGenEnabled & (1<<0),
			      texUnit->GenModeS );
	 key->unit[i].texgen_mode1 = 
	    translate_texgen( texUnit->TexGenEnabled & (1<<1),
			      texUnit->GenModeT );
	 key->unit[i].texgen_mode2 = 
	    translate_texgen( texUnit->TexGenEnabled & (1<<2),
			      texUnit->GenModeR );
	 key->unit[i].texgen_mode3 = 
	    translate_texgen( texUnit->TexGenEnabled & (1<<3),
			      texUnit->GenModeQ );
      }
   }
}
Beispiel #4
0
static void make_state_key( struct gl_context *ctx, struct state_key *key )
{
   const struct gl_program *fp = ctx->FragmentProgram._Current;
   GLbitfield mask;

   memset(key, 0, sizeof(struct state_key));

   /* This now relies on texenvprogram.c being active:
    */
   assert(fp);

   key->need_eye_coords = ctx->_NeedEyeCoords;

   key->fragprog_inputs_read = fp->info.inputs_read;
   key->varying_vp_inputs = ctx->varying_vp_inputs;

   if (ctx->RenderMode == GL_FEEDBACK) {
      /* make sure the vertprog emits color and tex0 */
      key->fragprog_inputs_read |= (VARYING_BIT_COL0 | VARYING_BIT_TEX0);
   }

   key->separate_specular = (ctx->Light.Model.ColorControl ==
			     GL_SEPARATE_SPECULAR_COLOR);

   if (ctx->Light.Enabled) {
      key->light_global_enabled = 1;

      if (ctx->Light.Model.LocalViewer)
	 key->light_local_viewer = 1;

      if (ctx->Light.Model.TwoSide)
	 key->light_twoside = 1;

      if (ctx->Light.ColorMaterialEnabled) {
	 key->light_color_material_mask = ctx->Light._ColorMaterialBitmask;
      }

      mask = ctx->Light._EnabledLights;
      while (mask) {
         const int i = u_bit_scan(&mask);
         struct gl_light *light = &ctx->Light.Light[i];

         key->unit[i].light_enabled = 1;

         if (light->EyePosition[3] == 0.0F)
            key->unit[i].light_eyepos3_is_zero = 1;

         if (light->SpotCutoff == 180.0F)
            key->unit[i].light_spotcutoff_is_180 = 1;

         if (light->ConstantAttenuation != 1.0F ||
             light->LinearAttenuation != 0.0F ||
             light->QuadraticAttenuation != 0.0F)
            key->unit[i].light_attenuated = 1;
      }

      if (check_active_shininess(ctx, key, 0)) {
         key->material_shininess_is_zero = 0;
      }
      else if (key->light_twoside &&
               check_active_shininess(ctx, key, 1)) {
         key->material_shininess_is_zero = 0;
      }
      else {
         key->material_shininess_is_zero = 1;
      }
   }

   if (ctx->Transform.Normalize)
      key->normalize = 1;

   if (ctx->Transform.RescaleNormals)
      key->rescale_normals = 1;

   if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) {
      key->fog_source_is_depth = 1;
      key->fog_distance_mode = translate_fog_distance_mode(ctx->Fog.FogDistanceMode);
   }

   if (ctx->Point._Attenuated)
      key->point_attenuated = 1;

   if (ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled)
      key->point_array = 1;

   if (ctx->Texture._TexGenEnabled ||
       ctx->Texture._TexMatEnabled ||
       ctx->Texture._MaxEnabledTexImageUnit != -1)
      key->texture_enabled_global = 1;

   mask = ctx->Texture._EnabledCoordUnits | ctx->Texture._TexGenEnabled
      | ctx->Texture._TexMatEnabled | ctx->Point.CoordReplace;
   while (mask) {
      const int i = u_bit_scan(&mask);
      struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];

      if (texUnit->_Current)
	 key->unit[i].texunit_really_enabled = 1;

      if (ctx->Point.PointSprite)
	 if (ctx->Point.CoordReplace & (1u << i))
	    key->unit[i].coord_replace = 1;

      if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i))
	 key->unit[i].texmat_enabled = 1;

      if (texUnit->TexGenEnabled) {
	 key->unit[i].texgen_enabled = 1;

	 key->unit[i].texgen_mode0 =
	    translate_texgen( texUnit->TexGenEnabled & (1<<0),
			      texUnit->GenS.Mode );
	 key->unit[i].texgen_mode1 =
	    translate_texgen( texUnit->TexGenEnabled & (1<<1),
			      texUnit->GenT.Mode );
	 key->unit[i].texgen_mode2 =
	    translate_texgen( texUnit->TexGenEnabled & (1<<2),
			      texUnit->GenR.Mode );
	 key->unit[i].texgen_mode3 =
	    translate_texgen( texUnit->TexGenEnabled & (1<<3),
			      texUnit->GenQ.Mode );
      }
   }
}