summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/shader/shaderobjects.c212
1 files changed, 114 insertions, 98 deletions
diff --git a/src/mesa/shader/shaderobjects.c b/src/mesa/shader/shaderobjects.c
index 998d4e455e1..a98c310bac4 100644
--- a/src/mesa/shader/shaderobjects.c
+++ b/src/mesa/shader/shaderobjects.c
@@ -200,13 +200,13 @@ _mesa_ShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **s
GET_SHADER(sha, shaderObj, "glShaderSourceARB");
if (sha == NULL)
- return;
-
- if (string == NULL)
- {
- RELEASE_SHADER(sha);
- _mesa_error (ctx, GL_INVALID_VALUE, "glShaderSourceARB");
- return;
+ return;
+
+ if (string == NULL)
+ {
+ RELEASE_SHADER(sha);
+ _mesa_error (ctx, GL_INVALID_VALUE, "glShaderSourceARB");
+ return;
}
/*
@@ -222,13 +222,13 @@ _mesa_ShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **s
}
for (i = 0; i < count; i++)
- {
- if (string[i] == NULL)
- {
- _mesa_free ((GLvoid *) offsets);
- RELEASE_SHADER(sha);
- _mesa_error (ctx, GL_INVALID_VALUE, "glShaderSourceARB");
- return;
+ {
+ if (string[i] == NULL)
+ {
+ _mesa_free ((GLvoid *) offsets);
+ RELEASE_SHADER(sha);
+ _mesa_error (ctx, GL_INVALID_VALUE, "glShaderSourceARB");
+ return;
}
if (length == NULL || length[i] < 0)
offsets[i] = _mesa_strlen (string[i]);
@@ -305,13 +305,13 @@ _mesa_LinkProgramARB (GLhandleARB programObj)
if (pro != NULL)
{
- (**pro).Link (pro);
- if (pro == ctx->ShaderObjects.CurrentProgram)
- {
- if ((**pro).GetLinkStatus (pro))
- _mesa_UseProgramObjectARB (programObj);
- else
- _mesa_UseProgramObjectARB (0);
+ (**pro).Link (pro);
+ if (pro == ctx->ShaderObjects.CurrentProgram)
+ {
+ if ((**pro).GetLinkStatus (pro))
+ _mesa_UseProgramObjectARB (programObj);
+ else
+ _mesa_UseProgramObjectARB (0);
}
RELEASE_PROGRAM(pro);
}
@@ -326,7 +326,7 @@ _mesa_UseProgramObjectARB (GLhandleARB programObj)
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (programObj != 0)
- {
+ {
GET_PROGRAM(pro, programObj, "glUseProgramObjectARB");
if (pro == NULL)
@@ -339,16 +339,16 @@ _mesa_UseProgramObjectARB (GLhandleARB programObj)
return;
}
- program = pro;
-
- ctx->ShaderObjects._VertexShaderPresent = (**pro).IsShaderPresent (pro, GL_VERTEX_SHADER_ARB);
- ctx->ShaderObjects._FragmentShaderPresent = (**pro).IsShaderPresent (pro,
+ program = pro;
+
+ ctx->ShaderObjects._VertexShaderPresent = (**pro).IsShaderPresent (pro, GL_VERTEX_SHADER_ARB);
+ ctx->ShaderObjects._FragmentShaderPresent = (**pro).IsShaderPresent (pro,
GL_FRAGMENT_SHADER_ARB);
- }
- else
- {
- ctx->ShaderObjects._VertexShaderPresent = GL_FALSE;
- ctx->ShaderObjects._FragmentShaderPresent = GL_FALSE;
+ }
+ else
+ {
+ ctx->ShaderObjects._VertexShaderPresent = GL_FALSE;
+ ctx->ShaderObjects._FragmentShaderPresent = GL_FALSE;
}
if (ctx->ShaderObjects.CurrentProgram != NULL)
@@ -373,8 +373,8 @@ GLvoid GLAPIENTRY
_mesa_Uniform1fARB (GLint location, GLfloat v0)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1fARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1fARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
@@ -388,13 +388,15 @@ GLvoid GLAPIENTRY
_mesa_Uniform2fARB (GLint location, GLfloat v0, GLfloat v1)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2fARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2fARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
{
- GLfloat v[2] = { v0, v1 };
+ GLfloat v[2];
+ v[0] = v0;
+ v[1] = v1;
if (!_slang_write_uniform (pro, location, 1, v, GL_FLOAT_VEC2))
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2fARB");
@@ -405,13 +407,16 @@ GLvoid GLAPIENTRY
_mesa_Uniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3fARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3fARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
{
- GLfloat v[3] = { v0, v1, v2 };
+ GLfloat v[3];
+ v[0] = v0;
+ v[1] = v1;
+ v[2] = v2;
if (!_slang_write_uniform (pro, location, 1, v, GL_FLOAT_VEC3))
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3fARB");
@@ -422,13 +427,17 @@ GLvoid GLAPIENTRY
_mesa_Uniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4fARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4fARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
{
- GLfloat v[4] = { v0, v1, v2, v3 };
+ GLfloat v[4];
+ v[0] = v0;
+ v[1] = v1;
+ v[2] = v2;
+ v[3] = v3;
if (!_slang_write_uniform (pro, location, 1, v, GL_FLOAT_VEC4))
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4fARB");
@@ -439,8 +448,8 @@ GLvoid GLAPIENTRY
_mesa_Uniform1iARB (GLint location, GLint v0)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1iARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1iARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
@@ -454,13 +463,15 @@ GLvoid GLAPIENTRY
_mesa_Uniform2iARB (GLint location, GLint v0, GLint v1)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2iARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2iARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
{
- GLint v[2] = { v0, v1 };
+ GLint v[2];
+ v[0] = v0;
+ v[1] = v1;
if (!_slang_write_uniform (pro, location, 1, v, GL_INT_VEC2))
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2iARB");
@@ -471,13 +482,16 @@ GLvoid GLAPIENTRY
_mesa_Uniform3iARB (GLint location, GLint v0, GLint v1, GLint v2)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3iARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3iARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
{
- GLint v[3] = { v0, v1, v2 };
+ GLint v[3];
+ v[0] = v0;
+ v[1] = v1;
+ v[2] = v2;
if (!_slang_write_uniform (pro, location, 1, v, GL_INT_VEC3))
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3iARB");
@@ -488,13 +502,17 @@ GLvoid GLAPIENTRY
_mesa_Uniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4iARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4iARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
{
- GLint v[4] = { v0, v1, v2, v3 };
+ GLint v[4];
+ v[0] = v0;
+ v[1] = v1;
+ v[2] = v2;
+ v[3] = v3;
if (!_slang_write_uniform (pro, location, 1, v, GL_INT_VEC4))
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4iARB");
@@ -505,8 +523,8 @@ GLvoid GLAPIENTRY
_mesa_Uniform1fvARB (GLint location, GLsizei count, const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1fvARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1fvARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
@@ -520,8 +538,8 @@ GLvoid GLAPIENTRY
_mesa_Uniform2fvARB (GLint location, GLsizei count, const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2fvARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2fvARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
@@ -535,8 +553,8 @@ GLvoid GLAPIENTRY
_mesa_Uniform3fvARB (GLint location, GLsizei count, const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3fvARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3fvARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
@@ -550,8 +568,8 @@ GLvoid GLAPIENTRY
_mesa_Uniform4fvARB (GLint location, GLsizei count, const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4fvARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4fvARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
@@ -565,8 +583,8 @@ GLvoid GLAPIENTRY
_mesa_Uniform1ivARB (GLint location, GLsizei count, const GLint *value)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1ivARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1ivARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
@@ -580,8 +598,8 @@ GLvoid GLAPIENTRY
_mesa_Uniform2ivARB (GLint location, GLsizei count, const GLint *value)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2ivARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2ivARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
@@ -595,8 +613,8 @@ GLvoid GLAPIENTRY
_mesa_Uniform3ivARB (GLint location, GLsizei count, const GLint *value)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3ivARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3ivARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
@@ -610,8 +628,8 @@ GLvoid GLAPIENTRY
_mesa_Uniform4ivARB (GLint location, GLsizei count, const GLint *value)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4ivARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4ivARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
@@ -625,8 +643,8 @@ GLvoid GLAPIENTRY
_mesa_UniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniformMatrix2fvARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniformMatrix2fvARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
@@ -665,8 +683,8 @@ GLvoid GLAPIENTRY
_mesa_UniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniformMatrix3fvARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniformMatrix3fvARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
@@ -710,8 +728,8 @@ GLvoid GLAPIENTRY
_mesa_UniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- GET_CURRENT_LINKED_PROGRAM(pro, "glUniformMatrix4fvARB");
-
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniformMatrix4fvARB");
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
@@ -897,31 +915,29 @@ _mesa_GetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params)
}
}
+
+/**
+ * Copy string from <src> to <dst>, up to maxLength characters, returning
+ * length of <dst> in <length>.
+ * \param src the strings source
+ * \param maxLength max chars to copy
+ * \param length returns numberof chars copied
+ * \param dst the string destination
+ */
static GLvoid
-_mesa_get_string (const GLcharARB *src, GLsizei maxLength, GLsizei *length, GLcharARB *str)
+copy_string(const GLcharARB *src, GLsizei maxLength, GLsizei *length,
+ GLcharARB *dst)
{
GLsizei len;
-
- if (maxLength == 0)
- {
- if (length != NULL)
- *length = 0;
- return;
- }
-
- if (src == NULL)
- src = "";
-
- len = _mesa_strlen (src);
- if (len >= maxLength)
- len = maxLength - 1;
-
- _mesa_memcpy (str, src, len * sizeof (GLcharARB));
- str[len] = '\0';
- if (length != NULL)
+ for (len = 0; len < maxLength - 1 && src && src[len]; len++)
+ dst[len] = src[len];
+ if (maxLength > 0)
+ dst[len] = 0;
+ if (length)
*length = len;
}
+
GLvoid GLAPIENTRY
_mesa_GetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog)
{
@@ -930,7 +946,7 @@ _mesa_GetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLchar
if (gen != NULL)
{
- _mesa_get_string ((**gen).GetInfoLog (gen), maxLength, length, infoLog);
+ copy_string((**gen).GetInfoLog (gen), maxLength, length, infoLog);
RELEASE_GENERIC(gen);
}
}
@@ -1028,7 +1044,7 @@ _mesa_GetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, G
if (sha != NULL)
{
- _mesa_get_string ((**sha).GetSource (sha), maxLength, length, source);
+ copy_string((**sha).GetSource (sha), maxLength, length, source);
RELEASE_SHADER(sha);
}
}
@@ -1086,8 +1102,8 @@ _mesa_GetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name)
GLvoid
_mesa_init_shaderobjects (GLcontext *ctx)
{
- ctx->ShaderObjects.CurrentProgram = NULL;
- ctx->ShaderObjects._FragmentShaderPresent = GL_FALSE;
+ ctx->ShaderObjects.CurrentProgram = NULL;
+ ctx->ShaderObjects._FragmentShaderPresent = GL_FALSE;
ctx->ShaderObjects._VertexShaderPresent = GL_FALSE;
_mesa_init_shaderobjects_3dlabs (ctx);