summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian <[email protected]>2006-12-19 18:02:41 -0700
committerBrian <[email protected]>2006-12-19 18:02:41 -0700
commit0bf5dbe002a64e198f55724cc1542602c012490f (patch)
tree06ef50fd181c0985562797197db244fadea893c5 /src/mesa
parent5b01c5e9d2c0283cc31981b6c85dc6392144b3db (diff)
Overhaul of GLSL API functions, dispatching, etc.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/common/driverfuncs.c46
-rw-r--r--src/mesa/drivers/common/driverfuncs.h8
-rw-r--r--src/mesa/main/context.c17
-rw-r--r--src/mesa/main/dd.h52
-rw-r--r--src/mesa/main/mtypes.h22
-rw-r--r--src/mesa/main/state.c4
-rw-r--r--src/mesa/main/texstate.c2
-rw-r--r--src/mesa/sources5
-rw-r--r--src/mesa/swrast/s_context.c2
-rw-r--r--src/mesa/swrast/s_span.c2
10 files changed, 130 insertions, 30 deletions
diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c
index 1e44904b930..bc637a879e3 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 6.5.3
*
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -43,6 +43,7 @@
#include "fbobject.h"
#include "texrender.h"
#endif
+#include "shader_api.h"
#include "arrayobj.h"
#include "driverfuncs.h"
@@ -248,4 +249,45 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
driver->EndList = NULL;
driver->BeginCallList = NULL;
driver->EndCallList = NULL;
+
+
+ /* XXX temporary here */
+ _mesa_init_glsl_driver_functions(driver);
+}
+
+
+/**
+ * Plug in Mesa's GLSL functions.
+ */
+void
+_mesa_init_glsl_driver_functions(struct dd_function_table *driver)
+{
+ driver->AttachShader = _mesa_attach_shader;
+ driver->BindAttribLocation = _mesa_bind_attrib_location;
+ driver->CompileShader = _mesa_compile_shader;
+ driver->CreateProgram = _mesa_create_program;
+ driver->CreateShader = _mesa_create_shader;
+ driver->DeleteProgram2 = _mesa_delete_program2;
+ driver->DeleteShader = _mesa_delete_shader;
+ driver->DetachShader = _mesa_detach_shader;
+ driver->GetActiveAttrib = _mesa_get_active_attrib;
+ driver->GetActiveUniform = _mesa_get_active_uniform;
+ driver->GetAttachedShaders = _mesa_get_attached_shaders;
+ driver->GetAttribLocation = _mesa_get_attrib_location;
+ driver->GetHandle = _mesa_get_handle;
+ driver->GetProgramiv = _mesa_get_programiv;
+ driver->GetProgramInfoLog = _mesa_get_program_info_log;
+ driver->GetShaderiv = _mesa_get_shaderiv;
+ driver->GetShaderInfoLog = _mesa_get_shader_info_log;
+ driver->GetShaderSource = _mesa_get_shader_source;
+ driver->GetUniformfv = _mesa_get_uniformfv;
+ driver->GetUniformLocation = _mesa_get_uniform_location;
+ driver->IsProgram = _mesa_is_program;
+ driver->IsShader = _mesa_is_shader;
+ driver->LinkProgram = _mesa_link_program;
+ driver->ShaderSource = _mesa_shader_source;
+ driver->Uniform = _mesa_uniform;
+ driver->UniformMatrix = _mesa_uniform_matrix;
+ driver->UseProgram = _mesa_use_program;
+ driver->ValidateProgram = _mesa_validate_program;
}
diff --git a/src/mesa/drivers/common/driverfuncs.h b/src/mesa/drivers/common/driverfuncs.h
index 64f56d91f95..50f2b4271dc 100644
--- a/src/mesa/drivers/common/driverfuncs.h
+++ b/src/mesa/drivers/common/driverfuncs.h
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 6.5.3
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -29,4 +29,8 @@
extern void
_mesa_init_driver_functions(struct dd_function_table *driver);
+
+extern void
+_mesa_init_glsl_driver_functions(struct dd_function_table *driver);
+
#endif
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 4986b29ef0c..c5220b5b2eb 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -131,7 +131,7 @@
#include "math/m_xform.h"
#include "math/mathmod.h"
#endif
-#include "shaderobjects.h"
+#include "shaders.h"
#ifdef USE_SPARC_ASM
#include "sparc/sparc.h"
@@ -705,7 +705,6 @@ alloc_shared_state( GLcontext *ctx )
ss->ArrayObjects = _mesa_NewHashTable();
#if FEATURE_ARB_shader_objects
- ss->GL2Objects = _mesa_NewHashTable ();
ss->ShaderObjects = _mesa_NewHashTable();
ss->ProgramObjects = _mesa_NewHashTable();
#endif
@@ -784,11 +783,10 @@ alloc_shared_state( GLcontext *ctx )
_mesa_DeleteHashTable (ss->ArrayObjects);
#if FEATURE_ARB_shader_objects
- if (ss->GL2Objects) {
- _mesa_DeleteHashTable (ss->GL2Objects);
+ if (ss->ShaderObjects)
_mesa_DeleteHashTable (ss->ShaderObjects);
+ if (ss->ProgramObjects)
_mesa_DeleteHashTable (ss->ProgramObjects);
- }
#endif
#if FEATURE_EXT_framebuffer_object
@@ -953,8 +951,11 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss )
_mesa_DeleteHashTable(ss->ArrayObjects);
#if FEATURE_ARB_shader_objects
- _mesa_HashDeleteAll(ss->GL2Objects, delete_shaderobj_cb, ctx);
- _mesa_DeleteHashTable(ss->GL2Objects);
+ /* XXX SLANG TO-DO */
+ /*
+ struct _mesa_HashTable *ShaderObjects;
+ struct _mesa_HashTable *ProgramObjects;
+ */
#endif
#if FEATURE_EXT_framebuffer_object
@@ -1202,7 +1203,7 @@ init_attrib_groups( GLcontext *ctx )
_mesa_init_query( ctx );
_mesa_init_rastpos( ctx );
_mesa_init_scissor( ctx );
- _mesa_init_shaderobjects (ctx);
+ _mesa_init_shader_state( ctx );
_mesa_init_stencil( ctx );
_mesa_init_transform( ctx );
_mesa_init_varray( ctx );
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 1de2542bee2..90c1f69c3d1 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -821,6 +821,58 @@ struct dd_function_table {
void (*BindArrayObject)(GLcontext *ctx, struct gl_array_object *obj);
/*@}*/
+ /**
+ * \name GLSL-related functions (ARB extensions and OpenGL 2.x)
+ */
+ /*@{*/
+ void (*AttachShader)(GLcontext *ctx, GLuint program, GLuint shader);
+ void (*BindAttribLocation)(GLcontext *ctx, GLuint program, GLuint index,
+ const GLcharARB *name);
+ void (*CompileShader)(GLcontext *ctx, GLuint shader);
+ GLuint (*CreateShader)(GLcontext *ctx, GLenum type);
+ GLuint (*CreateProgram)(GLcontext *ctx);
+ void (*DeleteProgram2)(GLcontext *ctx, GLuint program);
+ void (*DeleteShader)(GLcontext *ctx, GLuint shader);
+ void (*DetachShader)(GLcontext *ctx, GLuint program, GLuint shader);
+ void (*GetActiveAttrib)(GLcontext *ctx, GLuint program, GLuint index,
+ GLsizei maxLength, GLsizei * length, GLint * size,
+ GLenum * type, GLcharARB * name);
+ void (*GetActiveUniform)(GLcontext *ctx, GLuint program, GLuint index,
+ GLsizei maxLength, GLsizei *length, GLint *size,
+ GLenum *type, GLcharARB *name);
+ void (*GetAttachedShaders)(GLcontext *ctx, GLuint program, GLsizei maxCount,
+ GLsizei *count, GLuint *obj);
+ GLint (*GetAttribLocation)(GLcontext *ctx, GLuint program,
+ const GLcharARB *name);
+ GLuint (*GetHandle)(GLcontext *ctx, GLenum pname);
+ void (*GetProgramiv)(GLcontext *ctx, GLuint program,
+ GLenum pname, GLint *params);
+ void (*GetProgramInfoLog)(GLcontext *ctx, GLuint program, GLsizei bufSize,
+ GLsizei *length, GLchar *infoLog);
+ void (*GetShaderiv)(GLcontext *ctx, GLuint shader,
+ GLenum pname, GLint *params);
+ void (*GetShaderInfoLog)(GLcontext *ctx, GLuint shader, GLsizei bufSize,
+ GLsizei *length, GLchar *infoLog);
+ void (*GetShaderSource)(GLcontext *ctx, GLuint shader, GLsizei maxLength,
+ GLsizei *length, GLcharARB *sourceOut);
+ void (*GetUniformfv)(GLcontext *ctx, GLuint program, GLint location,
+ GLfloat *params);
+ GLint (*GetUniformLocation)(GLcontext *ctx, GLuint program,
+ const GLcharARB *name);
+ GLboolean (*IsProgram)(GLcontext *ctx, GLuint name);
+ GLboolean (*IsShader)(GLcontext *ctx, GLuint name);
+ void (*LinkProgram)(GLcontext *ctx, GLuint program);
+ void (*ShaderSource)(GLcontext *ctx, GLuint shader, const GLchar *source);
+ void (*Uniform)(GLcontext *ctx, GLint location, GLsizei count,
+ const GLvoid *values, GLenum type);
+ void (*UniformMatrix)(GLcontext *ctx, GLint cols, GLint rows,
+ GLenum matrixType, GLint location, GLsizei count,
+ GLboolean transpose, const GLfloat *values);
+ void (*UseProgram)(GLcontext *ctx, GLuint program);
+ void (*ValidateProgram)(GLcontext *ctx, GLuint program);
+ /* XXX many more to come */
+ /*@}*/
+
/**
* \name Support for multiple T&L engines
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 5ed95ccf656..4a8f7d22e30 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -7,9 +7,9 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 6.5.3
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -2052,8 +2052,10 @@ struct gl_shader
GLuint Name; /**< AKA the handle */
GLchar *Source; /**< Source code string */
GLboolean CompileStatus;
+ GLboolean DeletePending;
GLuint NumPrograms; /**< size of Programs[] array */
struct gl_program **Programs; /**< Post-compile assembly code */
+ GLchar *InfoLog;
};
@@ -2070,21 +2072,24 @@ struct gl_linked_program
struct gl_program **Shaders; /**< List of the shaders */
struct gl_vertex_program *VertexProgram; /**< Linked vertex program */
struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */
- GLboolean LinkStatus; /**< GL_LINK_STATUS */
struct gl_program_parameter_list *Uniforms; /**< Plus constants, etc */
struct gl_program_parameter_list *Varying;
+ struct gl_program_parameter_list *Attributes; /**< Vertex attributes */
+ GLboolean LinkStatus; /**< GL_LINK_STATUS */
+ GLboolean Validated;
+ GLboolean DeletePending;
+ GLchar *InfoLog;
};
/**
- * Context state for vertex/fragment shaders.
+ * Context state for GLSL vertex/fragment shaders.
*/
-struct gl_shader_objects_state
+struct gl_shader_state
{
- struct gl2_program_intf **CurrentProgram;
GLboolean _VertexShaderPresent;
GLboolean _FragmentShaderPresent;
- struct gl_linked_program *Linked; /* XXX temporary here */
+ struct gl_linked_program *CurrentProgram;
};
@@ -2145,7 +2150,6 @@ struct gl_shared_state
#endif
#if FEATURE_ARB_shader_objects
- struct _mesa_HashTable *GL2Objects;
struct _mesa_HashTable *ShaderObjects;
struct _mesa_HashTable *ProgramObjects;
#endif
@@ -2966,7 +2970,7 @@ struct __GLcontextRec
struct gl_query_state Query; /**< GL_ARB_occlusion_query */
- struct gl_shader_objects_state ShaderObjects; /* GL_ARB_shader_objects */
+ struct gl_shader_state Shader; /**< GLSL shader object state */
/*@}*/
#if FEATURE_EXT_framebuffer_object
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index e121f59258c..1d8666888ef 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -93,7 +93,7 @@
#include "texenvprogram.h"
#endif
#if FEATURE_ARB_shader_objects
-#include "shaderobjects.h"
+#include "shaders.h"
#endif
#include "debug.h"
#include "dispatch.h"
@@ -949,7 +949,7 @@ update_arrays( GLcontext *ctx )
static void
update_program(GLcontext *ctx)
{
- const struct gl_linked_program *linked = ctx->ShaderObjects.Linked;
+ const struct gl_linked_program *linked = ctx->Shader.CurrentProgram;
/* These _Enabled flags indicate if the program is enabled AND valid. */
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index e379933a66e..e089de93104 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -41,7 +41,7 @@
#include "texenvprogram.h"
#include "mtypes.h"
#include "math/m_xform.h"
-#include "shaderobjects.h"
+/*#include "shaderobjects.h"*/
diff --git a/src/mesa/sources b/src/mesa/sources
index eed6fb0a0e6..19f43384ea1 100644
--- a/src/mesa/sources
+++ b/src/mesa/sources
@@ -48,6 +48,7 @@ MAIN_SOURCES = \
main/rastpos.c \
main/rbadaptors.c \
main/renderbuffer.c \
+ main/shaders.c \
main/state.c \
main/stencil.c \
main/texcompress.c \
@@ -164,10 +165,6 @@ SHADER_SOURCES = \
shader/programopt.c \
shader/shader_api.c \
-
-## shader/shaderobjects.c \
-## shader/shaderobjects_3dlabs.c
-
SLANG_SOURCES = \
shader/slang/slang_analyse.c \
shader/slang/slang_assemble.c \
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index 46f99ef6e09..749e278ffad 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -102,7 +102,7 @@ _swrast_update_rasterflags( GLcontext *ctx )
rasterMask |= FRAGPROG_BIT;
}
- if (ctx->ShaderObjects._FragmentShaderPresent) {
+ if (ctx->Shader._FragmentShaderPresent) {
rasterMask |= FRAGPROG_BIT;
}
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 7bfb23f0f74..536ac300337 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1365,7 +1365,7 @@ shade_texture_span(GLcontext *ctx, SWspan *span)
if (span->interpMask & SPAN_Z)
_swrast_span_interpolate_z (ctx, span);
- if (ctx->ShaderObjects.Linked && span->interpMask & SPAN_VARYING)
+ if (ctx->Shader.CurrentProgram && span->interpMask & SPAN_VARYING)
interpolate_varying(ctx, span);
/* Run fragment program/shader now */