-/*
- * Mesa 3-D graphics library
- * Version: 6.1
- *
- * Copyright (C) 2004 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"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 6.3\r
+ *\r
+ * Copyright (C) 2004-2005 Brian Paul All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included\r
+ * in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
+/**\r
+ * \file shaderobjects.c\r
+ * ARB_shader_objects state management functions\r
+ * \author Michal Krol\r
+ */\r
+\r
#include "glheader.h"
-#include "shaderobjects.h"
-#include "mtypes.h"
+#include "shaderobjects.h"\r
+#include "shaderobjects_3dlabs.h"
#include "context.h"
-#include "macros.h"
-
+#include "macros.h"\r
+#include "hash.h"\r
+\r
+\r
void GLAPIENTRY
-_mesa_DeleteObjectARB(GLhandleARB obj)
-{
+_mesa_DeleteObjectARB (GLhandleARB obj)
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_unknown_intf **unk;\r
+ struct gl2_generic_intf **gen;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, obj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unk == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glDeleteObjectARB");\r
+ return;\r
+ }\r
+\r
+ gen = (struct gl2_generic_intf **) (**unk).QueryInterface (unk, UIID_GENERIC);\r
+ if (gen == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glDeleteObjectARB");\r
+ return;\r
+ }\r
+\r
+ (**gen).Delete (gen);\r
+ (**gen)._unknown.Release ((struct gl2_unknown_intf **) gen);
}
GLhandleARB GLAPIENTRY
-_mesa_GetHandleARB(GLenum pname)
-{
- return 0;
+_mesa_GetHandleARB (GLenum pname)
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ switch (pname)\r
+ {\r
+ case GL_PROGRAM_OBJECT_ARB:\r
+ if (ctx->ShaderObjects.current_program != NULL)\r
+ return (**ctx->ShaderObjects.current_program)._container._generic.GetName (\r
+ (struct gl2_generic_intf **) ctx->ShaderObjects.current_program);\r
+ break;\r
+ }\r
+
+ return 0;
}
void GLAPIENTRY
_mesa_DetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_unknown_intf **unkc, **unka;\r
+ struct gl2_container_intf **con;\r
+ struct gl2_generic_intf **att;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unkc = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, containerObj);\r
+ unka = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, attachedObj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unkc == NULL || unka == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glDetachObjectARB");\r
+ return;\r
+ }\r
+\r
+ con = (struct gl2_container_intf **) (**unkc).QueryInterface (unkc, UIID_CONTAINER);\r
+ if (con == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glDetachObjectARB");\r
+ return;\r
+ }\r
+\r
+ att = (struct gl2_generic_intf **) (**unka).QueryInterface (unka, UIID_GENERIC);\r
+ if (att == NULL)\r
+ {\r
+ (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glDetachObjectARB");\r
+ return;\r
+ }\r
+\r
+ if ((**con).Detach (con, att) == GL_FALSE)\r
+ {\r
+ (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);\r
+ (**att)._unknown.Release ((struct gl2_unknown_intf **) att);\r
+ return;\r
+ }\r
+\r
+ (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);\r
+ (**att)._unknown.Release ((struct gl2_unknown_intf **) att);
}
GLhandleARB GLAPIENTRY
_mesa_CreateShaderObjectARB (GLenum shaderType)
-{
- return 0;
+{\r
+ return _mesa_3dlabs_create_shader_object (shaderType);
}
void GLAPIENTRY
-_mesa_ShaderSourceARB (GLhandleARB shaderObj, GLsizei count,
- const GLcharARB **string, const GLint *length)
-{
+_mesa_ShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string,\r
+ const GLint *length)
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_unknown_intf **unk;\r
+ struct gl2_shader_intf **sha;\r
+ GLint *offsets;\r
+ GLsizei i;\r
+ GLcharARB *source;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, shaderObj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unk == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glShaderSourceARB");\r
+ return;\r
+ }\r
+\r
+ sha = (struct gl2_shader_intf **) (**unk).QueryInterface (unk, UIID_SHADER);\r
+ if (sha == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glShaderSourceARB");\r
+ return;\r
+ }\r
+\r
+ /* this array holds offsets of where the appropriate string ends, thus the last\r
+ element will be set to the total length of the source code */\r
+ offsets = (GLint *) _mesa_malloc (count * sizeof (GLint));\r
+ if (offsets == NULL)\r
+ {\r
+ (**sha)._generic._unknown.Release ((struct gl2_unknown_intf **) sha);\r
+ _mesa_error (ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB");\r
+ return;\r
+ }\r
+\r
+ for (i = 0; i < count; i++)\r
+ {\r
+ if (length == NULL || length[i] < 0)\r
+ offsets[i] = _mesa_strlen (string[i]);\r
+ else\r
+ offsets[i] = length[i];\r
+ /* accumulate string lengths */\r
+ if (i > 0)\r
+ offsets[i] += offsets[i - 1];\r
+ }\r
+\r
+ source = (GLcharARB *) _mesa_malloc ((offsets[count - 1] + 1) * sizeof (GLcharARB));\r
+ if (source == NULL)\r
+ {\r
+ _mesa_free ((void *) offsets);\r
+ (**sha)._generic._unknown.Release ((struct gl2_unknown_intf **) sha);\r
+ _mesa_error (ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB");\r
+ return;\r
+ }\r
+\r
+ for (i = 0; i < count; i++)\r
+ {\r
+ GLint start = (i > 0) ? offsets[i - 1] : 0;\r
+ _mesa_memcpy (source + start, string[i], (offsets[i] - start) * sizeof (GLcharARB));\r
+ }\r
+ source[offsets[count - 1]] = '\0';\r
+\r
+ (**sha).SetSource (sha, source, offsets, count);\r
+ (**sha)._generic._unknown.Release ((struct gl2_unknown_intf **) sha);
}
void GLAPIENTRY
_mesa_CompileShaderARB (GLhandleARB shaderObj)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_unknown_intf **unk;\r
+ struct gl2_shader_intf **sha;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, shaderObj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unk == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glCompileShaderARB");\r
+ return;\r
+ }\r
+\r
+ sha = (struct gl2_shader_intf **) (**unk).QueryInterface (unk, UIID_SHADER);\r
+ if (sha == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glCompileShaderARB");\r
+ return;\r
+ }\r
+\r
+ (**sha).Compile (sha);\r
+ (**sha)._generic._unknown.Release ((struct gl2_unknown_intf **) sha);
}
GLhandleARB GLAPIENTRY
_mesa_CreateProgramObjectARB (void)
{
- return 0;
+ return _mesa_3dlabs_create_program_object ();
}
void GLAPIENTRY
_mesa_AttachObjectARB (GLhandleARB containerObj, GLhandleARB obj)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_unknown_intf **unkc, **unka;\r
+ struct gl2_container_intf **con;\r
+ struct gl2_generic_intf **att;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unkc = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, containerObj);\r
+ unka = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, obj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unkc == NULL || unka == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glAttachObjectARB");\r
+ return;\r
+ }\r
+\r
+ con = (struct gl2_container_intf **) (**unkc).QueryInterface (unkc, UIID_CONTAINER);\r
+ if (con == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glAttachObjectARB");\r
+ return;\r
+ }\r
+\r
+ att = (struct gl2_generic_intf **) (**unka).QueryInterface (unka, UIID_GENERIC);\r
+ if (att == NULL)\r
+ {\r
+ (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glAttachObjectARB");\r
+ return;\r
+ }\r
+\r
+ if (!(**con).Attach (con, att))\r
+ {\r
+ (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);\r
+ (**att)._unknown.Release ((struct gl2_unknown_intf **) att);\r
+ return;\r
+ }\r
+\r
+ (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);\r
+ (**att)._unknown.Release ((struct gl2_unknown_intf **) att);
}
void GLAPIENTRY
_mesa_LinkProgramARB (GLhandleARB programObj)
-{
-}
-
-#if 0
-GLboolean
-_mesa_use_program_object( GLcontext *ctx, struct gl_program_object *pobj )
-{
- return GL_FALSE;
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_unknown_intf **unk;\r
+ struct gl2_program_intf **pro;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unk == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glLinkProgramARB");\r
+ return;\r
+ }\r
+\r
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);\r
+ if (pro == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glLinkProgramARB");\r
+ return;\r
+ }\r
+\r
+ if (pro == ctx->ShaderObjects.current_program)\r
+ {\r
+ /* TODO re-install executable program */\r
+ }\r
+\r
+ (**pro).Link (pro);\r
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
}
-#endif
void GLAPIENTRY
_mesa_UseProgramObjectARB (GLhandleARB programObj)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_program_intf **pro;\r
+\r
+ if (programObj == 0)\r
+ {\r
+ pro = NULL;\r
+ }\r
+ else\r
+ {\r
+ struct gl2_unknown_intf **unk;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unk == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glUseProgramObjectARB");\r
+ return;\r
+ }\r
+\r
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);\r
+ if (pro == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUseProgramObjectARB");\r
+ return;\r
+ }\r
+\r
+ if ((**pro).GetLinkStatus (pro) == GL_FALSE)\r
+ {\r
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUseProgramObjectARB");\r
+ return;\r
+ }\r
+ }\r
+\r
+ if (ctx->ShaderObjects.current_program != NULL)\r
+ {\r
+ (**ctx->ShaderObjects.current_program)._container._generic._unknown.Release (\r
+ (struct gl2_unknown_intf **) ctx->ShaderObjects.current_program);\r
+ }\r
+\r
+ ctx->ShaderObjects.current_program = pro;
}
void GLAPIENTRY
_mesa_ValidateProgramARB (GLhandleARB programObj)
-{
-}
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_unknown_intf **unk;\r
+ struct gl2_program_intf **pro;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unk == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glValidateProgramARB");\r
+ return;\r
+ }\r
+\r
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);\r
+ if (pro == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glValidateProgramARB");\r
+ return;\r
+ }\r
+\r
+ (**pro).Validate (pro);\r
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+}\r
+\r
+/*\r
+Errors TODO\r
+\r
+ The error INVALID_OPERATION is generated by the Uniform*ARB if the\r
+ number of values loaded results in exceeding the declared extent of a\r
+ uniform.\r
+\r
+ The error INVALID_OPERATION is generated by the Uniform*ARB commands if\r
+ the size does not match the size of the uniform declared in the shader.\r
+\r
+ The error INVALID_OPERATION is generated by the Uniform*ARB commands if\r
+ the type does not match the type of the uniform declared in the shader,\r
+ if the uniform is not of type Boolean.\r
+\r
+ The error INVALID_OPERATION is generated by the Uniform*ARB commands if\r
+ <location> does not exist for the program object currently in use.\r
+\r
+ The error INVALID_OPERATION is generated if a uniform command other than\r
+ Uniform1i{v}ARB is used to load a sampler value.\r
+\r
+\r
+*/
void GLAPIENTRY
_mesa_Uniform1fARB (GLint location, GLfloat v0)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1fARB");\r
+ return;\r
+ }
}
void GLAPIENTRY
_mesa_Uniform2fARB (GLint location, GLfloat v0, GLfloat v1)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2fARB");\r
+ return;\r
+ }
}
void GLAPIENTRY
_mesa_Uniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3fARB");\r
+ return;\r
+ }
}
void GLAPIENTRY
_mesa_Uniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4fARB");\r
+ return;\r
+ }
}
void GLAPIENTRY
_mesa_Uniform1iARB (GLint location, GLint v0)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1iARB");\r
+ return;\r
+ }
}
void GLAPIENTRY
_mesa_Uniform2iARB (GLint location, GLint v0, GLint v1)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2iARB");\r
+ return;\r
+ }
}
void GLAPIENTRY
_mesa_Uniform3iARB (GLint location, GLint v0, GLint v1, GLint v2)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3iARB");\r
+ return;\r
+ }
}
void GLAPIENTRY
_mesa_Uniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4iARB");\r
+ return;\r
+ }
}
void GLAPIENTRY
_mesa_Uniform1fvARB (GLint location, GLsizei count, const GLfloat *value)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1fvARB");\r
+ return;\r
+ }
}
void GLAPIENTRY
_mesa_Uniform2fvARB (GLint location, GLsizei count, const GLfloat *value)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2fvARB");\r
+ return;\r
+ }
}
void GLAPIENTRY
_mesa_Uniform3fvARB (GLint location, GLsizei count, const GLfloat *value)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3fvARB");\r
+ return;\r
+ }
}
void GLAPIENTRY
_mesa_Uniform4fvARB (GLint location, GLsizei count, const GLfloat *value)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4fvARB");\r
+ return;\r
+ }
}
void GLAPIENTRY
_mesa_Uniform1ivARB (GLint location, GLsizei count, const GLint *value)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1ivARB");\r
+ return;\r
+ }
}
void GLAPIENTRY
_mesa_Uniform2ivARB (GLint location, GLsizei count, const GLint *value)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2ivARB");\r
+ return;\r
+ }
}
void GLAPIENTRY
_mesa_Uniform3ivARB (GLint location, GLsizei count, const GLint *value)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3ivARB");\r
+ return;\r
+ }
}
void GLAPIENTRY
_mesa_Uniform4ivARB (GLint location, GLsizei count, const GLint *value)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4ivARB");\r
+ return;\r
+ }
}
void GLAPIENTRY
_mesa_UniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix2fvARB");\r
+ return;\r
+ }
}
void GLAPIENTRY
_mesa_UniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix3fvARB");\r
+ return;\r
+ }
}
void GLAPIENTRY
_mesa_UniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
-}
-
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+\r
+ if (ctx->ShaderObjects.current_program == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix4fvARB");\r
+ return;\r
+ }
+}\r
+\r
void GLAPIENTRY
_mesa_GetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params)
-{
+{\r
+ GLint iparams;\r
+\r
+ /* NOTE we are assuming here that all parameters are one-element wide */\r
+\r
+ _mesa_GetObjectParameterivARB (obj, pname, &iparams);\r
+ *params = (GLfloat) iparams;
}
void GLAPIENTRY
_mesa_GetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_unknown_intf **unk;\r
+ struct gl2_generic_intf **gen;\r
+ struct gl2_shader_intf **sha;\r
+ struct gl2_program_intf **pro;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, obj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unk == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetObjectParameterivARB");\r
+ return;\r
+ }\r
+\r
+ gen = (struct gl2_generic_intf **) (**unk).QueryInterface (unk, UIID_GENERIC);\r
+ if (gen == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");\r
+ return;\r
+ }\r
+\r
+ sha = (struct gl2_shader_intf **) (**unk).QueryInterface (unk, UIID_SHADER);\r
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);\r
+\r
+ /* NOTE this function is called by GetObjectParameterfv so watch out with types and sizes */\r
+\r
+ switch (pname)\r
+ {\r
+ case GL_OBJECT_TYPE_ARB:\r
+ *params = (**gen).GetType (gen);\r
+ break;\r
+ case GL_OBJECT_SUBTYPE_ARB:\r
+ if (sha != NULL)\r
+ *params = (**sha).GetSubType (sha);\r
+ else\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");\r
+ break;\r
+ case GL_OBJECT_DELETE_STATUS_ARB:\r
+ *params = (**gen).GetDeleteStatus (gen);\r
+ break;\r
+ case GL_OBJECT_COMPILE_STATUS_ARB:\r
+ if (sha != NULL)\r
+ *params = (**sha).GetCompileStatus (sha);\r
+ else\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");\r
+ break;\r
+ case GL_OBJECT_LINK_STATUS_ARB:\r
+ if (pro != NULL)\r
+ *params = (**pro).GetLinkStatus (pro);\r
+ else\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");\r
+ break;\r
+ case GL_OBJECT_VALIDATE_STATUS_ARB:\r
+ if (pro != NULL)\r
+ *params = (**pro).GetValidateStatus (pro);\r
+ else\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");\r
+ break;\r
+ case GL_OBJECT_INFO_LOG_LENGTH_ARB:\r
+ {\r
+ const GLcharARB *info = (**gen).GetInfoLog (gen);\r
+ if (info == NULL)\r
+ *params = 0;\r
+ else\r
+ *params = _mesa_strlen (info) + 1;\r
+ }\r
+ break;\r
+ case GL_OBJECT_ATTACHED_OBJECTS_ARB:\r
+ if (pro != NULL)\r
+ *params = (**pro)._container.GetAttachedCount ((struct gl2_container_intf **) pro);\r
+ else\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");\r
+ break;\r
+ case GL_OBJECT_ACTIVE_UNIFORMS_ARB:\r
+ *params = 0; /* TODO */\r
+ break;\r
+ case GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB:\r
+ *params = 0; /* TODO */\r
+ break;\r
+ case GL_OBJECT_SHADER_SOURCE_LENGTH_ARB:\r
+ if (sha != NULL)\r
+ {\r
+ const GLcharARB *src = (**sha).GetSource (sha);\r
+ if (src == NULL)\r
+ *params = 0;\r
+ else\r
+ *params = _mesa_strlen (src) + 1;\r
+ }\r
+ else\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");\r
+ break;\r
+ }\r
+\r
+ (**gen)._unknown.Release ((struct gl2_unknown_intf **) gen);\r
+ if (sha != NULL)\r
+ (**sha)._generic._unknown.Release ((struct gl2_unknown_intf **) sha);\r
+ if (pro != NULL)\r
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
}
void GLAPIENTRY
_mesa_GetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_unknown_intf **unk;\r
+ struct gl2_generic_intf **gen;\r
+ const GLcharARB *info;\r
+ GLsizei len;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, obj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unk == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetInfoLogARB");\r
+ return;\r
+ }\r
+\r
+ gen = (struct gl2_generic_intf **) (**unk).QueryInterface (unk, UIID_GENERIC);\r
+ if (gen == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetInfoLogARB");\r
+ return;\r
+ }\r
+\r
+ info = (**gen).GetInfoLog (gen);\r
+ if (info == NULL)\r
+ info = "";\r
+ (**gen)._unknown.Release ((struct gl2_unknown_intf **) gen);\r
+\r
+ len = _mesa_strlen (info);\r
+ if (len > maxLength)\r
+ {\r
+ len = maxLength;\r
+ /* allocate space for null termination */\r
+ if (len > 0)\r
+ len--;\r
+ }\r
+\r
+ _mesa_memcpy (infoLog, info, len * sizeof (GLcharARB));\r
+ if (maxLength > 0)\r
+ infoLog[len] = '\0';\r
+\r
+ if (length != NULL)\r
+ *length = len;
}
void GLAPIENTRY
_mesa_GetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_unknown_intf **unk;\r
+ struct gl2_container_intf **con;\r
+ GLsizei cnt, i;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, containerObj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unk == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetAttachedObjectsARB");\r
+ return;\r
+ }\r
+\r
+ con = (struct gl2_container_intf **) (**unk).QueryInterface (unk, UIID_CONTAINER);\r
+ if (con == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetAttachedObjectsARB");\r
+ return;\r
+ }\r
+\r
+ cnt = (**con).GetAttachedCount (con);\r
+ if (cnt > maxCount)\r
+ cnt = maxCount;\r
+\r
+ for (i = 0; i < cnt; i++)\r
+ {\r
+ struct gl2_generic_intf **x = (**con).GetAttached (con, i);\r
+ obj[i] = (**x).GetName (x);\r
+ (**x)._unknown.Release ((struct gl2_unknown_intf **) x);\r
+ }\r
+\r
+ (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);\r
+\r
+ if (count != NULL)\r
+ *count = cnt;
}
GLint GLAPIENTRY
_mesa_GetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name)
-{
- return -1;
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_unknown_intf **unk;\r
+ struct gl2_program_intf **pro;\r
+ GLint loc = -1;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unk == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetUniformLocationARB");\r
+ return -1;\r
+ }\r
+\r
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);\r
+ if (pro == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetUniformLocationARB");\r
+ return -1;\r
+ }\r
+\r
+ if ((**pro).GetLinkStatus (pro) == GL_FALSE)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetUniformLocationARB");\r
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);\r
+ return -1;\r
+ }\r
+\r
+ /* TODO */\r
+\r
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+ return loc;
}
void GLAPIENTRY
_mesa_GetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_unknown_intf **unk;\r
+ struct gl2_program_intf **pro;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unk == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetActiveUniformARB");\r
+ return;\r
+ }\r
+\r
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);\r
+ if (pro == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetActiveUniformARB");\r
+ return;\r
+ }\r
+\r
+/* if (index >= val (OBJECT_ACTIVE_ATTRIBUTES_ARB))\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetActiveUniformARB");\r
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);\r
+ return;\r
+ }*/\r
+\r
+ /* TODO */\r
+\r
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
}
void GLAPIENTRY
_mesa_GetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_unknown_intf **unk;\r
+ struct gl2_program_intf **pro;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unk == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetUniformfvARB");\r
+ return;\r
+ }\r
+\r
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);\r
+ if (pro == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetUniformfvARB");\r
+ return;\r
+ }\r
+\r
+ /* TODO */\r
+\r
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
}
void GLAPIENTRY
_mesa_GetUniformivARB (GLhandleARB programObj, GLint location, GLint *params)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_unknown_intf **unk;\r
+ struct gl2_program_intf **pro;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unk == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetUniformivARB");\r
+ return;\r
+ }\r
+\r
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);\r
+ if (pro == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetUniformivARB");\r
+ return;\r
+ }\r
+\r
+ /* TODO */\r
+\r
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
}
void GLAPIENTRY
_mesa_GetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_unknown_intf **unk;\r
+ struct gl2_shader_intf **sha;\r
+ const GLcharARB *src;\r
+ GLsizei len;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, obj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unk == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetShaderSourceARB");\r
+ return;\r
+ }\r
+\r
+ sha = (struct gl2_shader_intf **) (**unk).QueryInterface (unk, UIID_SHADER);\r
+ if (sha == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetShaderSourceARB");\r
+ return;\r
+ }\r
+\r
+ src = (**sha).GetSource (sha);\r
+ if (src == NULL)\r
+ src = "";\r
+ (**sha)._generic._unknown.Release ((struct gl2_unknown_intf **) sha);\r
+\r
+ len = _mesa_strlen (src);\r
+ if (len > maxLength)\r
+ {\r
+ len = maxLength;\r
+ /* allocate space for null termination */\r
+ if (len > 0)\r
+ len--;\r
+ }\r
+\r
+ _mesa_memcpy (source, src, len * sizeof (GLcharARB));\r
+ if (maxLength > 0)\r
+ source[len] = '\0';\r
+\r
+ if (length != NULL)\r
+ *length = len;
}
/* GL_ARB_vertex_shader */
void GLAPIENTRY
_mesa_BindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_unknown_intf **unk;\r
+ struct gl2_program_intf **pro;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unk == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glBindAttribLocationARB");\r
+ return;\r
+ }\r
+\r
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);\r
+ if (pro == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glBindAttribLocationARB");\r
+ return;\r
+ }\r
+\r
+ /* TODO */\r
+\r
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
}
void GLAPIENTRY
_mesa_GetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name)
-{
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_unknown_intf **unk;\r
+ struct gl2_program_intf **pro;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unk == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetActiveAttribARB");\r
+ return;\r
+ }\r
+\r
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);\r
+ if (pro == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetActiveAttribARB");\r
+ return;\r
+ }\r
+\r
+ /* TODO */\r
+\r
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
}
GLint GLAPIENTRY
_mesa_GetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name)
-{
- return 0;
+{\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ struct gl2_unknown_intf **unk;\r
+ struct gl2_program_intf **pro;\r
+ GLint loc = 0;\r
+\r
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\r
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);\r
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\r
+\r
+ if (unk == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetAttribLocationARB");\r
+ return 0;\r
+ }\r
+\r
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);\r
+ if (pro == NULL)\r
+ {\r
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetAttribLocationARB");\r
+ return 0;\r
+ }\r
+\r
+ /* TODO */\r
+\r
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+ return loc;
}
-void _mesa_init_shaderobjects( GLcontext * ctx )
-{
+void\r
+_mesa_init_shaderobjects (GLcontext *ctx)
+{\r
+ ctx->ShaderObjects.current_program = NULL;
}
+\r