glsl: Add IsCentroid bitfield to gl_fragment_program.
[mesa.git] / src / mesa / main / shaderobj.c
index 33d91ad594d1ef87ee060aef62273677067f2ec1..16800ae5ec6509028b4a4b36cf65edd04ad3bf9f 100644 (file)
 #include "main/mfeatures.h"
 #include "main/mtypes.h"
 #include "main/shaderobj.h"
+#include "main/uniforms.h"
 #include "program/program.h"
 #include "program/prog_parameter.h"
-#include "program/prog_uniform.h"
+#include "program/hash_table.h"
 #include "ralloc.h"
 
 /**********************************************************************/
@@ -238,12 +239,18 @@ _mesa_init_shader_program(struct gl_context *ctx, struct gl_shader_program *prog
 {
    prog->Type = GL_SHADER_PROGRAM_MESA;
    prog->RefCount = 1;
-   prog->Attributes = _mesa_new_parameter_list();
+
+   prog->AttributeBindings = string_to_uint_map_ctor();
+   prog->FragDataBindings = string_to_uint_map_ctor();
+   prog->FragDataIndexBindings = string_to_uint_map_ctor();
+
 #if FEATURE_ARB_geometry_shader4
    prog->Geom.VerticesOut = 0;
    prog->Geom.InputType = GL_TRIANGLES;
    prog->Geom.OutputType = GL_TRIANGLE_STRIP;
 #endif
+
+   prog->InfoLog = ralloc_strdup(prog, "");
 }
 
 /**
@@ -270,19 +277,23 @@ void
 _mesa_clear_shader_program_data(struct gl_context *ctx,
                                 struct gl_shader_program *shProg)
 {
-   _mesa_reference_vertprog(ctx, &shProg->VertexProgram, NULL);
-   _mesa_reference_fragprog(ctx, &shProg->FragmentProgram, NULL);
-   _mesa_reference_geomprog(ctx, &shProg->GeometryProgram, NULL);
-
-   if (shProg->Uniforms) {
-      _mesa_free_uniform_list(shProg->Uniforms);
-      shProg->Uniforms = NULL;
+   if (shProg->UniformStorage) {
+      unsigned i;
+      for (i = 0; i < shProg->NumUserUniformStorage; ++i)
+         _mesa_uniform_detach_all_driver_storage(&shProg->UniformStorage[i]);
+      ralloc_free(shProg->UniformStorage);
+      shProg->NumUserUniformStorage = 0;
+      shProg->UniformStorage = NULL;
    }
 
-   if (shProg->Varying) {
-      _mesa_free_parameter_list(shProg->Varying);
-      shProg->Varying = NULL;
+   if (shProg->UniformHash) {
+      string_to_uint_map_dtor(shProg->UniformHash);
+      shProg->UniformHash = NULL;
    }
+
+   assert(shProg->InfoLog != NULL);
+   ralloc_free(shProg->InfoLog);
+   shProg->InfoLog = ralloc_strdup(shProg, "");
 }
 
 
@@ -301,9 +312,19 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
 
    _mesa_clear_shader_program_data(ctx, shProg);
 
-   if (shProg->Attributes) {
-      _mesa_free_parameter_list(shProg->Attributes);
-      shProg->Attributes = NULL;
+   if (shProg->AttributeBindings) {
+      string_to_uint_map_dtor(shProg->AttributeBindings);
+      shProg->AttributeBindings = NULL;
+   }
+
+   if (shProg->FragDataBindings) {
+      string_to_uint_map_dtor(shProg->FragDataBindings);
+      shProg->FragDataBindings = NULL;
+   }
+
+   if (shProg->FragDataIndexBindings) {
+      string_to_uint_map_dtor(shProg->FragDataIndexBindings);
+      shProg->FragDataIndexBindings = NULL;
    }
 
    /* detach shaders */
@@ -317,11 +338,6 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
       shProg->Shaders = NULL;
    }
 
-   if (shProg->InfoLog) {
-      ralloc_free(shProg->InfoLog);
-      shProg->InfoLog = NULL;
-   }
-
    /* Transform feedback varying vars */
    for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) {
       free(shProg->TransformFeedback.VaryingNames[i]);