diff options
author | Brian Paul <[email protected]> | 2003-04-11 01:20:06 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2003-04-11 01:20:06 +0000 |
commit | d0492cf1377897c8113a109aa936ee7a7084b9c8 (patch) | |
tree | 93fbb24cd921ec0e04365190d44d3d079e02aef3 /src | |
parent | 6cfaff16334981a247694b2ca30fffc398a330d0 (diff) |
Some groundwork for GL_ARB_vertex/fragment_program.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/arbprogram.c | 601 | ||||
-rw-r--r-- | src/mesa/main/arbprogram.h | 258 | ||||
-rw-r--r-- | src/mesa/main/config.h | 5 | ||||
-rw-r--r-- | src/mesa/main/context.c | 11 | ||||
-rw-r--r-- | src/mesa/main/extensions.c | 8 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 16 | ||||
-rw-r--r-- | src/mesa/main/nvfragparse.c | 1 | ||||
-rw-r--r-- | src/mesa/main/nvprogram.c | 51 | ||||
-rw-r--r-- | src/mesa/main/nvvertparse.c | 3 | ||||
-rw-r--r-- | src/mesa/swrast/s_nvfragprog.c | 4 |
10 files changed, 927 insertions, 31 deletions
diff --git a/src/mesa/main/arbprogram.c b/src/mesa/main/arbprogram.c new file mode 100644 index 00000000000..54df8183b5c --- /dev/null +++ b/src/mesa/main/arbprogram.c @@ -0,0 +1,601 @@ +/* + * Mesa 3-D graphics library + * Version: 5.1 + * + * Copyright (C) 1999-2003 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. + */ + +/** + * \file arbprogram.c + * \brief ARB_vertex/fragment_program state management functions. + * \author Brian Paul + */ + + +#include "glheader.h" +#include "context.h" +#include "hash.h" +#include "imports.h" +#include "macros.h" +#include "mtypes.h" +#include "arbprogram.h" + + + +void +_mesa_VertexAttrib1sARB(GLuint index, GLshort x) +{ +} + +void +_mesa_VertexAttrib1fARB(GLuint index, GLfloat x) +{ +} + +void +_mesa_VertexAttrib1dARB(GLuint index, GLdouble x) +{ +} + +void +_mesa_VertexAttrib2sARB(GLuint index, GLshort x, GLshort y) +{ +} + +void +_mesa_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y) +{ +} + +void +_mesa_VertexAttrib2dARB(GLuint index, GLdouble x, GLdouble y) +{ +} + +void +_mesa_VertexAttrib3sARB(GLuint index, GLshort x, GLshort y, GLshort z) +{ +} + +void +_mesa_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z) +{ +} + +void +_mesa_VertexAttrib3dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z) +{ +} + +void +_mesa_VertexAttrib4sARB(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w) +{ +} + +void +_mesa_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ +} + +void +_mesa_VertexAttrib4dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ +} + +void +_mesa_VertexAttrib4NubARB(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w) +{ +} + +void +_mesa_VertexAttrib1svARB(GLuint index, const GLshort *v) +{ +} + +void +_mesa_VertexAttrib1fvARB(GLuint index, const GLfloat *v) +{ +} + +void +_mesa_VertexAttrib1dvARB(GLuint index, const GLdouble *v) +{ +} + +void +_mesa_VertexAttrib2svARB(GLuint index, const GLshort *v) +{ +} + +void +_mesa_VertexAttrib2fvARB(GLuint index, const GLfloat *v) +{ +} + +void +_mesa_VertexAttrib2dvARB(GLuint index, const GLdouble *v) +{ +} + +void +_mesa_VertexAttrib3svARB(GLuint index, const GLshort *v) +{ +} + +void +_mesa_VertexAttrib3fvARB(GLuint index, const GLfloat *v) +{ +} + +void +_mesa_VertexAttrib3dvARB(GLuint index, const GLdouble *v) +{ +} + +void +_mesa_VertexAttrib4bvARB(GLuint index, const GLbyte *v) +{ +} + +void +_mesa_VertexAttrib4svARB(GLuint index, const GLshort *v) +{ +} + +void +_mesa_VertexAttrib4ivARB(GLuint index, const GLint *v) +{ +} + +void +_mesa_VertexAttrib4ubvARB(GLuint index, const GLubyte *v) +{ +} + +void +_mesa_VertexAttrib4usvARB(GLuint index, const GLushort *v) +{ +} + +void +_mesa_VertexAttrib4uivARB(GLuint index, const GLuint *v) +{ +} + +void +_mesa_VertexAttrib4fvARB(GLuint index, const GLfloat *v) +{ +} + +void +_mesa_VertexAttrib4dvARB(GLuint index, const GLdouble *v) +{ +} + +void +_mesa_VertexAttrib4NbvARB(GLuint index, const GLbyte *v) +{ +} + +void +_mesa_VertexAttrib4NsvARB(GLuint index, const GLshort *v) +{ +} + +void +_mesa_VertexAttrib4NivARB(GLuint index, const GLint *v) +{ +} + +void +_mesa_VertexAttrib4NubvARB(GLuint index, const GLubyte *v) +{ +} + +void +_mesa_VertexAttrib4NusvARB(GLuint index, const GLushort *v) +{ +} + +void +_mesa_VertexAttrib4NuivARB(GLuint index, const GLuint *v) +{ +} + + +void +_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, + GLboolean normalized, GLsizei stride, + const GLvoid *pointer) +{ +} + + +void +_mesa_EnableVertexAttribArrayARB(GLuint index) +{ +} + + +void +_mesa_DisableVertexAttribArrayARB(GLuint index) +{ +} + + +void +_mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params) +{ +} + + +void +_mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params) +{ +} + + +void +_mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params) +{ +} + + +void +_mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer) +{ +} + + +void +_mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len, + const GLvoid *string) +{ +} + + +void +_mesa_BindProgramARB(GLenum target, GLuint program) +{ +} + + +void +_mesa_DeleteProgramsARB(GLsizei n, const GLuint *programs) +{ +} + + +void +_mesa_GenProgramsARB(GLsizei n, GLuint *programs) +{ +} + + +void +_mesa_ProgramEnvParameter4dARB(GLenum target, GLuint index, + GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ +} + + +void +_mesa_ProgramEnvParameter4dvARB(GLenum target, GLuint index, + const GLdouble *params) +{ +} + + +void +_mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index, + GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ +} + + +void +_mesa_ProgramEnvParameter4fvARB(GLenum target, GLuint index, + const GLfloat *params) +{ +} + + +#if 111 + +void +_mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index, + GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (target == GL_FRAGMENT_PROGRAM_NV) { + struct fragment_program *fprog = ctx->FragmentProgram.Current; + if (!fprog) { + _mesa_error(ctx, GL_INVALID_ENUM, "glProgramLocalParameterARB"); + return; + } + if (index >= MAX_NV_FRAGMENT_PROGRAM_PARAMS) { + _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameterARB"); + return; + } + fprog->Base.LocalParams[index][0] = x; + fprog->Base.LocalParams[index][1] = y; + fprog->Base.LocalParams[index][2] = z; + fprog->Base.LocalParams[index][3] = w; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glProgramLocalParameterARB"); + return; + } +} + + +void +_mesa_ProgramLocalParameter4fvARB(GLenum target, GLuint index, + const GLfloat *params) +{ + glProgramLocalParameter4fARB(target, index, params[0], params[1], + params[2], params[3]); +} + + +void +_mesa_ProgramLocalParameter4dARB(GLenum target, GLuint index, + GLdouble x, GLdouble y, + GLdouble z, GLdouble w) +{ + glProgramLocalParameter4fARB(target, index, (GLfloat)x, (GLfloat)y, + (GLfloat)z, (GLfloat)w); +} + + +void +_mesa_ProgramLocalParameter4dvARB(GLenum target, GLuint index, + const GLdouble *params) +{ + glProgramLocalParameter4fARB(target, index, (GLfloat)params[0], + (GLfloat)params[1], (GLfloat)params[2], + (GLfloat)params[3]); +} + + +void +_mesa_GetProgramLocalParameterfvARB(GLenum target, GLuint index, + GLfloat *params) +{ + struct program *prog; + GLuint maxParams; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (target == GL_VERTEX_PROGRAM_ARB + && ctx->Extensions.ARB_vertex_program) { + prog = &(ctx->VertexProgram.Current->Base); + maxParams = ctx->Const.MaxVertexProgramParams; + } + else if ((target == GL_FRAGMENT_PROGRAM_ARB + && ctx->Extensions.ARB_fragment_program) || + (target == GL_FRAGMENT_PROGRAM_NV + && ctx->Extensions.NV_fragment_program)) { + prog = &(ctx->FragmentProgram.Current->Base); + maxParams = ctx->Const.MaxFragmentProgramParams; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetProgramLocalParameterARB(target)"); + return; + } + + if (index >= maxParams) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetProgramLocalParameterARB(index)"); + return; + } + + ASSERT(prog); + params[0] = prog->LocalParams[index][0]; + params[1] = prog->LocalParams[index][1]; + params[2] = prog->LocalParams[index][2]; + params[3] = prog->LocalParams[index][3]; +} + + +void +_mesa_GetProgramLocalParameterdvARB(GLenum target, GLuint index, + GLdouble *params) +{ + GLfloat floatParams[4]; + glGetProgramLocalParameterfvARB(target, index, floatParams); + COPY_4V(params, floatParams); +} + +#else + + +void +_mesa_ProgramLocalParameter4dARB(GLenum target, GLuint index, + GLdouble x, GLdouble y, + GLdouble z, GLdouble w) +{ +} + + +void +_mesa_ProgramLocalParameter4dvARB(GLenum target, GLuint index, + const GLdouble *params) +{ +} + + +void +_mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index, + GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ +} + + +void +_mesa_ProgramLocalParameter4fvARB(GLenum target, GLuint index, + const GLfloat *params) +{ +} + +#endif + +void +_mesa_GetProgramEnvParameterdvARB(GLenum target, GLuint index, + GLdouble *params) +{ +} + + +void +_mesa_GetProgramEnvParameterfvARB(GLenum target, GLuint index, + GLfloat *params) +{ +} + + +#if 000 +void +_mesa_GetProgramLocalParameterdvARB(GLenum target, GLuint index, + GLdouble *params) +{ +} + + +void +_mesa_GetProgramLocalParameterfvARB(GLenum target, GLuint index, + GLfloat *params) +{ +} +#endif + + + +void +_mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params) +{ + struct program *prog; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (target == GL_VERTEX_PROGRAM_ARB) { + prog = &(ctx->VertexProgram.Current->Base); + } + else if (target == GL_FRAGMENT_PROGRAM_ARB) { + prog = &(ctx->FragmentProgram.Current->Base); + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(target)"); + return; + } + + ASSERT(prog); + + switch (pname) { + case GL_PROGRAM_LENGTH_ARB: + *params = prog->String ? _mesa_strlen((char *) prog->String) : 0; + break; + case GL_PROGRAM_FORMAT_ARB: + *params = prog->Format; + break; + case GL_PROGRAM_BINDING_ARB: + *params = prog->Id; + break; + case GL_PROGRAM_INSTRUCTIONS_ARB: + *params = prog->NumInstructions; + break; + case GL_MAX_PROGRAM_INSTRUCTIONS_ARB: + case GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB: + case GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB: + case GL_PROGRAM_TEMPORARIES_ARB: + case GL_MAX_PROGRAM_TEMPORARIES_ARB: + case GL_PROGRAM_NATIVE_TEMPORARIES_ARB: + case GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB: + case GL_PROGRAM_PARAMETERS_ARB: + case GL_MAX_PROGRAM_PARAMETERS_ARB: + case GL_PROGRAM_NATIVE_PARAMETERS_ARB: + case GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB: + case GL_PROGRAM_ATTRIBS_ARB: + case GL_MAX_PROGRAM_ATTRIBS_ARB: + case GL_PROGRAM_NATIVE_ATTRIBS_ARB: + case GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB: + case GL_PROGRAM_ADDRESS_REGISTERS_ARB: + case GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB: + case GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB: + case GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB: + case GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB: + case GL_MAX_PROGRAM_ENV_PARAMETERS_ARB: + case GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB: + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(pname)"); + return; + } +} + + +void +_mesa_GetProgramStringARB(GLenum target, GLenum pname, GLvoid *string) +{ + struct program *prog; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (target == GL_VERTEX_PROGRAM_ARB) { + prog = &(ctx->VertexProgram.Current->Base); + } + else if (target == GL_FRAGMENT_PROGRAM_ARB) { + prog = &(ctx->FragmentProgram.Current->Base); + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramStringARB(target)"); + return; + } + + ASSERT(prog); + + if (pname != GL_PROGRAM_STRING_ARB) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramStringARB(pname)"); + return; + } + + MEMCPY(string, prog->String, _mesa_strlen((char *) prog->String)); +} + + +GLboolean +_mesa_IsProgramARB(GLuint program) +{ + struct program *prog; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + if (program == 0) + return GL_FALSE; + + prog = (struct program *) _mesa_HashLookup(ctx->Shared->Programs, program); + if (prog && prog->Target) + return GL_TRUE; + else + return GL_FALSE; +} diff --git a/src/mesa/main/arbprogram.h b/src/mesa/main/arbprogram.h new file mode 100644 index 00000000000..095a2106e6a --- /dev/null +++ b/src/mesa/main/arbprogram.h @@ -0,0 +1,258 @@ +/* + * Mesa 3-D graphics library + * Version: 5.1 + * + * Copyright (C) 1999-2003 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. + */ + + +#ifndef ARBPROGRAM_H +#define ARBPROGRAM_H + +extern void +_mesa_VertexAttrib1sARB(GLuint index, GLshort x); + +extern void +_mesa_VertexAttrib1fARB(GLuint index, GLfloat x); + +extern void +_mesa_VertexAttrib1dARB(GLuint index, GLdouble x); + +extern void +_mesa_VertexAttrib2sARB(GLuint index, GLshort x, GLshort y); + +extern void +_mesa_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y); + +extern void +_mesa_VertexAttrib2dARB(GLuint index, GLdouble x, GLdouble y); + +extern void +_mesa_VertexAttrib3sARB(GLuint index, GLshort x, GLshort y, GLshort z); + +extern void +_mesa_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z); + +extern void +_mesa_VertexAttrib3dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z); + +extern void +_mesa_VertexAttrib4sARB(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); + +extern void +_mesa_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + +extern void +_mesa_VertexAttrib4dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + +extern void +_mesa_VertexAttrib4NubARB(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); + +extern void +_mesa_VertexAttrib1svARB(GLuint index, const GLshort *v); + +extern void +_mesa_VertexAttrib1fvARB(GLuint index, const GLfloat *v); + +extern void +_mesa_VertexAttrib1dvARB(GLuint index, const GLdouble *v); + +extern void +_mesa_VertexAttrib2svARB(GLuint index, const GLshort *v); + +extern void +_mesa_VertexAttrib2fvARB(GLuint index, const GLfloat *v); + +extern void +_mesa_VertexAttrib2dvARB(GLuint index, const GLdouble *v); + +extern void +_mesa_VertexAttrib3svARB(GLuint index, const GLshort *v); + +extern void +_mesa_VertexAttrib3fvARB(GLuint index, const GLfloat *v); + +extern void +_mesa_VertexAttrib3dvARB(GLuint index, const GLdouble *v); + +extern void +_mesa_VertexAttrib4bvARB(GLuint index, const GLbyte *v); + +extern void +_mesa_VertexAttrib4svARB(GLuint index, const GLshort *v); + +extern void +_mesa_VertexAttrib4ivARB(GLuint index, const GLint *v); + +extern void +_mesa_VertexAttrib4ubvARB(GLuint index, const GLubyte *v); + +extern void +_mesa_VertexAttrib4usvARB(GLuint index, const GLushort *v); + +extern void +_mesa_VertexAttrib4uivARB(GLuint index, const GLuint *v); + +extern void +_mesa_VertexAttrib4fvARB(GLuint index, const GLfloat *v); + +extern void +_mesa_VertexAttrib4dvARB(GLuint index, const GLdouble *v); + +extern void +_mesa_VertexAttrib4NbvARB(GLuint index, const GLbyte *v); + +extern void +_mesa_VertexAttrib4NsvARB(GLuint index, const GLshort *v); + +extern void +_mesa_VertexAttrib4NivARB(GLuint index, const GLint *v); + +extern void +_mesa_VertexAttrib4NubvARB(GLuint index, const GLubyte *v); + +extern void +_mesa_VertexAttrib4NusvARB(GLuint index, const GLushort *v); + +extern void +_mesa_VertexAttrib4NuivARB(GLuint index, const GLuint *v); + + +extern void +_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, + GLboolean normalized, GLsizei stride, + const GLvoid *pointer); + + +extern void +_mesa_EnableVertexAttribArrayARB(GLuint index); + + +extern void +_mesa_DisableVertexAttribArrayARB(GLuint index); + + +extern void +_mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params); + + +extern void +_mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params); + + +extern void +_mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params); + + +extern void +_mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer); + + +extern void +_mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len, + const GLvoid *string); + + +extern void +_mesa_BindProgramARB(GLenum target, GLuint program); + + +extern void +_mesa_DeleteProgramsARB(GLsizei n, const GLuint *programs); + + +extern void +_mesa_GenProgramsARB(GLsizei n, GLuint *programs); + + +extern void +_mesa_ProgramEnvParameter4dARB(GLenum target, GLuint index, + GLdouble x, GLdouble y, GLdouble z, GLdouble w); + + +extern void +_mesa_ProgramEnvParameter4dvARB(GLenum target, GLuint index, + const GLdouble *params); + + +extern void +_mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index, + GLfloat x, GLfloat y, GLfloat z, GLfloat w); + + +extern void +_mesa_ProgramEnvParameter4fvARB(GLenum target, GLuint index, + const GLfloat *params); + + +extern void +_mesa_ProgramLocalParameter4dARB(GLenum target, GLuint index, + GLdouble x, GLdouble y, + GLdouble z, GLdouble w); + + +extern void +_mesa_ProgramLocalParameter4dvARB(GLenum target, GLuint index, + const GLdouble *params); + + +extern void +_mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index, + GLfloat x, GLfloat y, GLfloat z, GLfloat w); + + +extern void +_mesa_ProgramLocalParameter4fvARB(GLenum target, GLuint index, + const GLfloat *params); + + +extern void +_mesa_GetProgramEnvParameterdvARB(GLenum target, GLuint index, + GLdouble *params); + + +extern void +_mesa_GetProgramEnvParameterfvARB(GLenum target, GLuint index, + GLfloat *params); + + +extern void +_mesa_GetProgramLocalParameterdvARB(GLenum target, GLuint index, + GLdouble *params); + + +extern void +_mesa_GetProgramLocalParameterfvARB(GLenum target, GLuint index, + GLfloat *params); + + +extern void +_mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params); + + +extern void +_mesa_GetProgramStringARB(GLenum target, GLenum pname, GLvoid *string); + + +extern GLboolean +_mesa_IsProgramARB(GLuint program); + +#endif + diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index 85acb0f292f..f1f621c6b82 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -228,4 +228,9 @@ #define FEATURE_ARB_vertex_buffer_object 1 +#define FEATURE_ARB_vertex_program 1 + +#define FEATURE_ARB_fragment_program 1 + + #endif /* CONFIG_H */ diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 7189ec88a5e..6c816ebd8ba 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1,4 +1,4 @@ -/* $Id: context.c,v 1.197 2003/04/01 22:20:42 brianp Exp $ */ +/* $Id: context.c,v 1.198 2003/04/11 01:20:08 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -965,6 +965,15 @@ init_attrib_groups( GLcontext *ctx ) ctx->Const.MaxConvolutionHeight = MAX_CONVOLUTION_HEIGHT; ctx->Const.MaxClipPlanes = MAX_CLIP_PLANES; ctx->Const.MaxLights = MAX_LIGHTS; +#if FEATURE_ARB_vertex_program + ctx->Const.MaxVertexProgramParams = MAX_NV_VERTEX_PROGRAM_PARAMS; + ctx->Const.MaxVertexProgramInstructions = MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS; +#endif +#if FEATURE_ARB_fragment_program + ctx->Const.MaxFragmentProgramParams = MAX_NV_FRAGMENT_PROGRAM_PARAMS; + ctx->Const.MaxFragmentProgramInstructions = MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS; +#endif + /* Initialize matrix stacks */ init_matrix_stack(&ctx->ModelviewMatrixStack, MAX_MODELVIEW_STACK_DEPTH, diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 88616b63093..59ec4c22e40 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -1,10 +1,8 @@ -/* $Id: extensions.c,v 1.89 2003/03/29 17:01:01 brianp Exp $ */ - /* * Mesa 3-D graphics library - * Version: 4.1 + * Version: 5.1 * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2003 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"), @@ -52,6 +50,7 @@ static struct { int flag_offset; } default_extensions[] = { { OFF, "GL_ARB_depth_texture", F(ARB_depth_texture) }, + { OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) }, { OFF, "GL_ARB_imaging", F(ARB_imaging) }, { OFF, "GL_ARB_multisample", F(ARB_multisample) }, { OFF, "GL_ARB_multitexture", F(ARB_multitexture) }, @@ -68,6 +67,7 @@ static struct { { OFF, "GL_ARB_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)}, { ON, "GL_ARB_transpose_matrix", 0 }, { OFF, "GL_ARB_vertex_buffer_object", F(ARB_vertex_buffer_object) }, + { OFF, "GL_ARB_vertex_program", F(ARB_vertex_program) }, { ON, "GL_ARB_window_pos", F(ARB_window_pos) }, { OFF, "GL_ATI_texture_mirror_once", F(ATI_texture_mirror_once)}, { OFF, "GL_ATI_texture_env_combine3", F(ATI_texture_env_combine3)}, diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index bd12e772a6f..e2569f05e2e 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1236,8 +1236,15 @@ struct program GLuint Id; GLubyte *String; /* Null-terminated program text */ GLenum Target; + GLenum Format; /* String encoding format */ GLint RefCount; GLboolean Resident; + GLfloat LocalParams[MAX_NV_FRAGMENT_PROGRAM_PARAMS][4]; + GLuint NumInstructions; /* GL_ARB_vertex/fragment_program */ + GLuint NumTemporaries; + GLuint NumParameters; + GLuint NumAttributes; + GLuint NumAddressRegs; }; @@ -1260,7 +1267,6 @@ struct fragment_program GLuint InputsRead; /* Bitmask of which input regs are read */ GLuint OutputsWritten; /* Bitmask of which output regs are written to */ GLuint TexturesUsed[MAX_TEXTURE_IMAGE_UNITS]; /* TEXTURE_x_INDEX bitmask */ - GLfloat LocalParams[MAX_NV_FRAGMENT_PROGRAM_PARAMS][4]; GLuint NumParameters; struct program_parameter *Parameters; /* array [NumParameters] */ }; @@ -1391,6 +1397,12 @@ struct gl_constants { GLuint MaxConvolutionHeight; GLuint MaxClipPlanes; GLuint MaxLights; + /* GL_ARB_vertex_program */ + GLuint MaxVertexProgramParams; + GLuint MaxVertexProgramInstructions; + /* GL_ARB_fragment_program */ + GLuint MaxFragmentProgramParams; + GLuint MaxFragmentProgramInstructions; }; @@ -1405,6 +1417,7 @@ struct gl_extensions { * Not every extension needs to have such a flag, but it's encouraged. */ GLboolean ARB_depth_texture; + GLboolean ARB_fragment_program; GLboolean ARB_imaging; GLboolean ARB_multisample; GLboolean ARB_multitexture; @@ -1417,6 +1430,7 @@ struct gl_extensions { GLboolean ARB_texture_env_dot3; GLboolean ARB_texture_mirrored_repeat; GLboolean ARB_vertex_buffer_object; + GLboolean ARB_vertex_program; GLboolean ARB_window_pos; GLboolean ATI_texture_mirror_once; GLboolean ATI_texture_env_combine3; diff --git a/src/mesa/main/nvfragparse.c b/src/mesa/main/nvfragparse.c index a3e16aa8664..5846452b16a 100644 --- a/src/mesa/main/nvfragparse.c +++ b/src/mesa/main/nvfragparse.c @@ -1537,6 +1537,7 @@ _mesa_parse_nv_fragment_program(GLcontext *ctx, GLenum dstTarget, FREE(program->Base.String); } program->Base.String = programString; + program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB; if (program->Instructions) { FREE(program->Instructions); } diff --git a/src/mesa/main/nvprogram.c b/src/mesa/main/nvprogram.c index 584b5ad40f8..9e1b2ed828b 100644 --- a/src/mesa/main/nvprogram.c +++ b/src/mesa/main/nvprogram.c @@ -1085,7 +1085,7 @@ void _mesa_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte *name, const float v[]) { - glProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]); + _mesa_ProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]); } @@ -1093,8 +1093,8 @@ void _mesa_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w) { - glProgramNamedParameter4fNV(id, len, name, (GLfloat)x, (GLfloat)y, - (GLfloat)z, (GLfloat)w); + _mesa_ProgramNamedParameter4fNV(id, len, name, (GLfloat)x, (GLfloat)y, + (GLfloat)z, (GLfloat)w); } @@ -1102,8 +1102,9 @@ void _mesa_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte *name, const double v[]) { - glProgramNamedParameter4fNV(id, len, name, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3]); + _mesa_ProgramNamedParameter4fNV(id, len, name, + (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2], (GLfloat)v[3]); } @@ -1151,11 +1152,12 @@ _mesa_GetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte *name, GLdouble *params) { GLfloat floatParams[4]; - glGetProgramNamedParameterfvNV(id, len, name, floatParams); + _mesa_GetProgramNamedParameterfvNV(id, len, name, floatParams); COPY_4V(params, floatParams); } +/* XXX move into arbprogram.c */ void _mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) @@ -1173,10 +1175,10 @@ _mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index, _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameterARB"); return; } - fprog->LocalParams[index][0] = x; - fprog->LocalParams[index][1] = y; - fprog->LocalParams[index][2] = z; - fprog->LocalParams[index][3] = w; + fprog->Base.LocalParams[index][0] = x; + fprog->Base.LocalParams[index][1] = y; + fprog->Base.LocalParams[index][2] = z; + fprog->Base.LocalParams[index][3] = w; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glProgramLocalParameterARB"); @@ -1185,35 +1187,39 @@ _mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index, } +/* XXX move into arbprogram.c */ void _mesa_ProgramLocalParameter4fvARB(GLenum target, GLuint index, const GLfloat *params) { - glProgramLocalParameter4fARB(target, index, params[0], params[1], - params[2], params[3]); + _mesa_ProgramLocalParameter4fARB(target, index, params[0], params[1], + params[2], params[3]); } +/* XXX move into arbprogram.c */ void _mesa_ProgramLocalParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) { - glProgramLocalParameter4fARB(target, index, (GLfloat)x, (GLfloat)y, - (GLfloat)z, (GLfloat)w); + _mesa_ProgramLocalParameter4fARB(target, index, (GLfloat)x, (GLfloat)y, + (GLfloat)z, (GLfloat)w); } +/* XXX move into arbprogram.c */ void _mesa_ProgramLocalParameter4dvARB(GLenum target, GLuint index, const GLdouble *params) { - glProgramLocalParameter4fARB(target, index, (GLfloat)params[0], - (GLfloat)params[1], (GLfloat)params[2], - (GLfloat)params[3]); + _mesa_ProgramLocalParameter4fARB(target, index, (GLfloat)params[0], + (GLfloat)params[1], (GLfloat)params[2], + (GLfloat)params[3]); } +/* XXX move into arbprogram.c */ void _mesa_GetProgramLocalParameterfvARB(GLenum target, GLuint index, GLfloat *params) @@ -1231,10 +1237,10 @@ _mesa_GetProgramLocalParameterfvARB(GLenum target, GLuint index, _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramLocalParameterARB"); return; } - params[0] = fprog->LocalParams[index][0]; - params[1] = fprog->LocalParams[index][1]; - params[2] = fprog->LocalParams[index][2]; - params[3] = fprog->LocalParams[index][3]; + params[0] = fprog->Base.LocalParams[index][0]; + params[1] = fprog->Base.LocalParams[index][1]; + params[2] = fprog->Base.LocalParams[index][2]; + params[3] = fprog->Base.LocalParams[index][3]; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramLocalParameterARB"); @@ -1243,11 +1249,12 @@ _mesa_GetProgramLocalParameterfvARB(GLenum target, GLuint index, } +/* XXX move into arbprogram.c */ void _mesa_GetProgramLocalParameterdvARB(GLenum target, GLuint index, GLdouble *params) { GLfloat floatParams[4]; - glGetProgramLocalParameterfvARB(target, index, floatParams); + _mesa_GetProgramLocalParameterfvARB(target, index, floatParams); COPY_4V(params, floatParams); } diff --git a/src/mesa/main/nvvertparse.c b/src/mesa/main/nvvertparse.c index ed38dc65b9a..f8e1168ded3 100644 --- a/src/mesa/main/nvvertparse.c +++ b/src/mesa/main/nvvertparse.c @@ -1,4 +1,4 @@ -/* $Id: nvvertparse.c,v 1.5 2003/03/29 16:38:08 brianp Exp $ */ +/* $Id: nvvertparse.c,v 1.6 2003/04/11 01:20:12 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1283,6 +1283,7 @@ _mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum dstTarget, FREE(program->Base.String); } program->Base.String = programString; + program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB; if (program->Instructions) { FREE(program->Instructions); } diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c index 8ab65b8e324..5700b1e7846 100644 --- a/src/mesa/swrast/s_nvfragprog.c +++ b/src/mesa/swrast/s_nvfragprog.c @@ -1,4 +1,4 @@ -/* $Id: s_nvfragprog.c,v 1.14 2003/04/08 02:27:18 brianp Exp $ */ +/* $Id: s_nvfragprog.c,v 1.15 2003/04/11 01:20:15 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1107,7 +1107,7 @@ init_machine( GLcontext *ctx, struct fp_machine *machine, /* Load program local parameters */ for (j = 0; j < MAX_NV_FRAGMENT_PROGRAM_PARAMS; j++) { COPY_4V(machine->Registers[FP_PROG_REG_START + j], - program->LocalParams[j]); + program->Base.LocalParams[j]); } /* Load input registers */ |