#include "main/glheader.h"
#include "main/context.h"
-#include "main/dispatch.h"
#include "main/hash.h"
#include "main/shaderobj.h"
#include "program/program.h"
#include "program/prog_parameter.h"
#include "program/prog_uniform.h"
-
+#include "talloc.h"
/**********************************************************************/
/*** Shader object functions ***/
* Allocate a new gl_shader object, initialize it.
* Called via ctx->Driver.NewShader()
*/
-static struct gl_shader *
+struct gl_shader *
_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type)
{
struct gl_shader *shader;
- assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER);
- shader = CALLOC_STRUCT(gl_shader);
+ assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER ||
+ type == GL_GEOMETRY_SHADER_ARB);
+ shader = talloc_zero(NULL, struct gl_shader);
if (shader) {
shader->Type = type;
shader->Name = name;
{
if (sh->Source)
free((void *) sh->Source);
- if (sh->InfoLog)
- free(sh->InfoLog);
_mesa_reference_program(ctx, &sh->Program, NULL);
- free(sh);
+ talloc_free(sh);
}
_mesa_new_shader_program(GLcontext *ctx, GLuint name)
{
struct gl_shader_program *shProg;
- shProg = CALLOC_STRUCT(gl_shader_program);
+ shProg = talloc_zero(NULL, struct gl_shader_program);
if (shProg) {
shProg->Type = GL_SHADER_PROGRAM_MESA;
shProg->Name = name;
shProg->RefCount = 1;
shProg->Attributes = _mesa_new_parameter_list();
+#if FEATURE_ARB_geometry_shader4
+ shProg->Geom.VerticesOut = 0;
+ shProg->Geom.InputType = GL_TRIANGLES;
+ shProg->Geom.OutputType = GL_TRIANGLE_STRIP;
+#endif
}
return 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);
}
if (shProg->InfoLog) {
- free(shProg->InfoLog);
+ talloc_free(shProg->InfoLog);
shProg->InfoLog = NULL;
}
{
_mesa_free_shader_program_data(ctx, shProg);
- free(shProg);
+ talloc_free(shProg);
}