From 7f752fed993e5e9423abac200dd59141edbada56 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 19 Dec 2004 03:06:59 +0000 Subject: Implement software ATI_fragment_shader no error detection, slow, may not be 100% correct but a good start --- src/mesa/glapi/gl_API.xml | 113 +++++++ src/mesa/glapi/glapioffsets.h | 14 + src/mesa/glapi/glapitable.h | 14 + src/mesa/glapi/glapitemp.h | 84 +++++ src/mesa/glapi/glprocs.h | 384 ++++++++++++----------- src/mesa/main/config.h | 1 + src/mesa/main/context.c | 29 ++ src/mesa/main/dlist.c | 68 ++++- src/mesa/main/enable.c | 15 +- src/mesa/main/enums.c | 38 +++ src/mesa/main/extensions.c | 4 + src/mesa/main/get.c | 138 +++++++++ src/mesa/main/mtypes.h | 41 ++- src/mesa/main/state.c | 23 ++ src/mesa/shader/atifragshader.c | 419 +++++++++++++++++++++++++ src/mesa/shader/atifragshader.h | 105 +++++++ src/mesa/shader/program.c | 38 +++ src/mesa/sources | 2 + src/mesa/swrast/s_atifragshader.c | 624 ++++++++++++++++++++++++++++++++++++++ src/mesa/swrast/s_atifragshader.h | 37 +++ src/mesa/swrast/s_context.c | 4 + src/mesa/swrast/s_context.h | 1 + src/mesa/swrast/s_span.c | 7 +- src/mesa/x86/glapi_x86.S | 14 + 24 files changed, 2035 insertions(+), 182 deletions(-) create mode 100644 src/mesa/shader/atifragshader.c create mode 100644 src/mesa/shader/atifragshader.h create mode 100644 src/mesa/swrast/s_atifragshader.c create mode 100644 src/mesa/swrast/s_atifragshader.h (limited to 'src/mesa') diff --git a/src/mesa/glapi/gl_API.xml b/src/mesa/glapi/gl_API.xml index fc51c63ee6..668913f0ac 100644 --- a/src/mesa/glapi/gl_API.xml +++ b/src/mesa/glapi/gl_API.xml @@ -9300,6 +9300,119 @@ glx: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mesa/glapi/glapioffsets.h b/src/mesa/glapi/glapioffsets.h index f80c14cd60..2bd36e4110 100644 --- a/src/mesa/glapi/glapioffsets.h +++ b/src/mesa/glapi/glapioffsets.h @@ -811,5 +811,19 @@ #define _gloffset_VertexAttrib4svNV 779 #define _gloffset_VertexAttrib4ubNV 780 #define _gloffset_VertexAttrib4ubvNV 781 +#define _gloffset_GenFragmentShadersATI 782 +#define _gloffset_BindFragmentShaderATI 783 +#define _gloffset_DeleteFragmentShaderATI 784 +#define _gloffset_BeginFragmentShaderATI 785 +#define _gloffset_EndFragmentShaderATI 786 +#define _gloffset_PassTexCoordATI 787 +#define _gloffset_SampleMapATI 788 +#define _gloffset_ColorFragmentOp1ATI 789 +#define _gloffset_ColorFragmentOp2ATI 790 +#define _gloffset_ColorFragmentOp3ATI 791 +#define _gloffset_AlphaFragmentOp1ATI 792 +#define _gloffset_AlphaFragmentOp2ATI 793 +#define _gloffset_AlphaFragmentOp3ATI 794 +#define _gloffset_SetFragmentShaderConstantATI 795 #endif diff --git a/src/mesa/glapi/glapitable.h b/src/mesa/glapi/glapitable.h index 50f513567d..cc63407a40 100644 --- a/src/mesa/glapi/glapitable.h +++ b/src/mesa/glapi/glapitable.h @@ -817,6 +817,20 @@ struct _glapi_table void (GLAPIENTRYP VertexAttrib4svNV)(GLuint index, const GLshort * v); /* 779 */ void (GLAPIENTRYP VertexAttrib4ubNV)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); /* 780 */ void (GLAPIENTRYP VertexAttrib4ubvNV)(GLuint index, const GLubyte * v); /* 781 */ + GLuint (GLAPIENTRYP GenFragmentShadersATI)(GLuint range); /* 782 */ + void (GLAPIENTRYP BindFragmentShaderATI)(GLuint id); /* 783 */ + void (GLAPIENTRYP DeleteFragmentShaderATI)(GLuint id); /* 784 */ + void (GLAPIENTRYP BeginFragmentShaderATI)(void); /* 785 */ + void (GLAPIENTRYP EndFragmentShaderATI)(void); /* 786 */ + void (GLAPIENTRYP PassTexCoordATI)(GLuint dst, GLuint coord, GLenum swizzle); /* 787 */ + void (GLAPIENTRYP SampleMapATI)(GLuint dst, GLuint interp, GLenum swizzle); /* 788 */ + void (GLAPIENTRYP ColorFragmentOp1ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); /* 789 */ + void (GLAPIENTRYP ColorFragmentOp2ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); /* 790 */ + void (GLAPIENTRYP ColorFragmentOp3ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); /* 791 */ + void (GLAPIENTRYP AlphaFragmentOp1ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); /* 792 */ + void (GLAPIENTRYP AlphaFragmentOp2ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); /* 793 */ + void (GLAPIENTRYP AlphaFragmentOp3ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); /* 794 */ + void (GLAPIENTRYP SetFragmentShaderConstantATI)(GLuint dst, const GLfloat * value); /* 795 */ }; #endif diff --git a/src/mesa/glapi/glapitemp.h b/src/mesa/glapi/glapitemp.h index fbf8fa5911..d6da59cd81 100644 --- a/src/mesa/glapi/glapitemp.h +++ b/src/mesa/glapi/glapitemp.h @@ -3980,6 +3980,76 @@ KEYWORD1 void KEYWORD2 NAME(VertexAttrib4ubvNV)(GLuint index, const GLubyte * v) DISPATCH(VertexAttrib4ubvNV, (index, v), (F, "glVertexAttrib4ubvNV(%d, %p);\n", index, (const void *) v)); } +KEYWORD1 GLuint KEYWORD2 NAME(GenFragmentShadersATI)(GLuint range) +{ + RETURN_DISPATCH(GenFragmentShadersATI, (range), (F, "glGenFragmentShadersATI(%d);\n", range)); +} + +KEYWORD1 void KEYWORD2 NAME(BindFragmentShaderATI)(GLuint id) +{ + DISPATCH(BindFragmentShaderATI, (id), (F, "glBindFragmentShaderATI(%d);\n", id)); +} + +KEYWORD1 void KEYWORD2 NAME(DeleteFragmentShaderATI)(GLuint id) +{ + DISPATCH(DeleteFragmentShaderATI, (id), (F, "glDeleteFragmentShaderATI(%d);\n", id)); +} + +KEYWORD1 void KEYWORD2 NAME(BeginFragmentShaderATI)(void) +{ + DISPATCH(BeginFragmentShaderATI, (), (F, "glBeginFragmentShaderATI();\n")); +} + +KEYWORD1 void KEYWORD2 NAME(EndFragmentShaderATI)(void) +{ + DISPATCH(EndFragmentShaderATI, (), (F, "glEndFragmentShaderATI();\n")); +} + +KEYWORD1 void KEYWORD2 NAME(PassTexCoordATI)(GLuint dst, GLuint coord, GLenum swizzle) +{ + DISPATCH(PassTexCoordATI, (dst, coord, swizzle), (F, "glPassTexCoordATI(%d, %d, 0x%x);\n", dst, coord, swizzle)); +} + +KEYWORD1 void KEYWORD2 NAME(SampleMapATI)(GLuint dst, GLuint interp, GLenum swizzle) +{ + DISPATCH(SampleMapATI, (dst, interp, swizzle), (F, "glSampleMapATI(%d, %d, 0x%x);\n", dst, interp, swizzle)); +} + +KEYWORD1 void KEYWORD2 NAME(ColorFragmentOp1ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod) +{ + DISPATCH(ColorFragmentOp1ATI, (op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod), (F, "glColorFragmentOp1ATI(0x%x, %d, %d, %d, %d, %d, %d);\n", op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod)); +} + +KEYWORD1 void KEYWORD2 NAME(ColorFragmentOp2ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod) +{ + DISPATCH(ColorFragmentOp2ATI, (op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod), (F, "glColorFragmentOp2ATI(0x%x, %d, %d, %d, %d, %d, %d, %d, %d, %d);\n", op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod)); +} + +KEYWORD1 void KEYWORD2 NAME(ColorFragmentOp3ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod) +{ + DISPATCH(ColorFragmentOp3ATI, (op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, arg3Rep, arg3Mod), (F, "glColorFragmentOp3ATI(0x%x, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d);\n", op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, arg3Rep, arg3Mod)); +} + +KEYWORD1 void KEYWORD2 NAME(AlphaFragmentOp1ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod) +{ + DISPATCH(AlphaFragmentOp1ATI, (op, dst, dstMod, arg1, arg1Rep, arg1Mod), (F, "glAlphaFragmentOp1ATI(0x%x, %d, %d, %d, %d, %d);\n", op, dst, dstMod, arg1, arg1Rep, arg1Mod)); +} + +KEYWORD1 void KEYWORD2 NAME(AlphaFragmentOp2ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod) +{ + DISPATCH(AlphaFragmentOp2ATI, (op, dst, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod), (F, "glAlphaFragmentOp2ATI(0x%x, %d, %d, %d, %d, %d, %d, %d, %d);\n", op, dst, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod)); +} + +KEYWORD1 void KEYWORD2 NAME(AlphaFragmentOp3ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod) +{ + DISPATCH(AlphaFragmentOp3ATI, (op, dst, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, arg3Rep, arg3Mod), (F, "glAlphaFragmentOp3ATI(0x%x, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d);\n", op, dst, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, arg3Rep, arg3Mod)); +} + +KEYWORD1 void KEYWORD2 NAME(SetFragmentShaderConstantATI)(GLuint dst, const GLfloat * value) +{ + DISPATCH(SetFragmentShaderConstantATI, (dst, value), (F, "glSetFragmentShaderConstantATI(%d, %p);\n", dst, (const void *) value)); +} + KEYWORD1 void KEYWORD2 NAME(ActiveTexture)(GLenum texture) { DISPATCH(ActiveTextureARB, (texture), (F, "glActiveTexture(0x%x);\n", texture)); @@ -5666,6 +5736,20 @@ static _glapi_proc DISPATCH_TABLE_NAME[] = { TABLE_ENTRY(VertexAttrib4svNV), TABLE_ENTRY(VertexAttrib4ubNV), TABLE_ENTRY(VertexAttrib4ubvNV), + TABLE_ENTRY(GenFragmentShadersATI), + TABLE_ENTRY(BindFragmentShaderATI), + TABLE_ENTRY(DeleteFragmentShaderATI), + TABLE_ENTRY(BeginFragmentShaderATI), + TABLE_ENTRY(EndFragmentShaderATI), + TABLE_ENTRY(PassTexCoordATI), + TABLE_ENTRY(SampleMapATI), + TABLE_ENTRY(ColorFragmentOp1ATI), + TABLE_ENTRY(ColorFragmentOp2ATI), + TABLE_ENTRY(ColorFragmentOp3ATI), + TABLE_ENTRY(AlphaFragmentOp1ATI), + TABLE_ENTRY(AlphaFragmentOp2ATI), + TABLE_ENTRY(AlphaFragmentOp3ATI), + TABLE_ENTRY(SetFragmentShaderConstantATI), /* A whole bunch of no-op functions. These might be called * when someone tries to call a dynamically-registered * extension function without a current rendering context. diff --git a/src/mesa/glapi/glprocs.h b/src/mesa/glapi/glprocs.h index 9e510d2695..bdf9339cc1 100644 --- a/src/mesa/glapi/glprocs.h +++ b/src/mesa/glapi/glprocs.h @@ -828,6 +828,20 @@ static const char gl_string_table[] = "glVertexAttrib4svNV\0" "glVertexAttrib4ubNV\0" "glVertexAttrib4ubvNV\0" + "glGenFragmentShadersATI\0" + "glBindFragmentShaderATI\0" + "glDeleteFragmentShaderATI\0" + "glBeginFragmentShaderATI\0" + "glEndFragmentShaderATI\0" + "glPassTexCoordATI\0" + "glSampleMapATI\0" + "glColorFragmentOp1ATI\0" + "glColorFragmentOp2ATI\0" + "glColorFragmentOp3ATI\0" + "glAlphaFragmentOp1ATI\0" + "glAlphaFragmentOp2ATI\0" + "glAlphaFragmentOp3ATI\0" + "glSetFragmentShaderConstantATI\0" "glActiveTexture\0" "glClientActiveTexture\0" "glMultiTexCoord1d\0" @@ -1791,184 +1805,198 @@ static const glprocs_table_t static_functions[] = { NAME_FUNC_OFFSET( 13801, glVertexAttrib4svNV, _gloffset_VertexAttrib4svNV ), NAME_FUNC_OFFSET( 13821, glVertexAttrib4ubNV, _gloffset_VertexAttrib4ubNV ), NAME_FUNC_OFFSET( 13841, glVertexAttrib4ubvNV, _gloffset_VertexAttrib4ubvNV ), - NAME_FUNC_OFFSET( 13862, glActiveTexture, _gloffset_ActiveTextureARB ), - NAME_FUNC_OFFSET( 13878, glClientActiveTexture, _gloffset_ClientActiveTextureARB ), - NAME_FUNC_OFFSET( 13900, glMultiTexCoord1d, _gloffset_MultiTexCoord1dARB ), - NAME_FUNC_OFFSET( 13918, glMultiTexCoord1dv, _gloffset_MultiTexCoord1dvARB ), - NAME_FUNC_OFFSET( 13937, glMultiTexCoord1f, _gloffset_MultiTexCoord1fARB ), - NAME_FUNC_OFFSET( 13955, glMultiTexCoord1fv, _gloffset_MultiTexCoord1fvARB ), - NAME_FUNC_OFFSET( 13974, glMultiTexCoord1i, _gloffset_MultiTexCoord1iARB ), - NAME_FUNC_OFFSET( 13992, glMultiTexCoord1iv, _gloffset_MultiTexCoord1ivARB ), - NAME_FUNC_OFFSET( 14011, glMultiTexCoord1s, _gloffset_MultiTexCoord1sARB ), - NAME_FUNC_OFFSET( 14029, glMultiTexCoord1sv, _gloffset_MultiTexCoord1svARB ), - NAME_FUNC_OFFSET( 14048, glMultiTexCoord2d, _gloffset_MultiTexCoord2dARB ), - NAME_FUNC_OFFSET( 14066, glMultiTexCoord2dv, _gloffset_MultiTexCoord2dvARB ), - NAME_FUNC_OFFSET( 14085, glMultiTexCoord2f, _gloffset_MultiTexCoord2fARB ), - NAME_FUNC_OFFSET( 14103, glMultiTexCoord2fv, _gloffset_MultiTexCoord2fvARB ), - NAME_FUNC_OFFSET( 14122, glMultiTexCoord2i, _gloffset_MultiTexCoord2iARB ), - NAME_FUNC_OFFSET( 14140, glMultiTexCoord2iv, _gloffset_MultiTexCoord2ivARB ), - NAME_FUNC_OFFSET( 14159, glMultiTexCoord2s, _gloffset_MultiTexCoord2sARB ), - NAME_FUNC_OFFSET( 14177, glMultiTexCoord2sv, _gloffset_MultiTexCoord2svARB ), - NAME_FUNC_OFFSET( 14196, glMultiTexCoord3d, _gloffset_MultiTexCoord3dARB ), - NAME_FUNC_OFFSET( 14214, glMultiTexCoord3dv, _gloffset_MultiTexCoord3dvARB ), - NAME_FUNC_OFFSET( 14233, glMultiTexCoord3f, _gloffset_MultiTexCoord3fARB ), - NAME_FUNC_OFFSET( 14251, glMultiTexCoord3fv, _gloffset_MultiTexCoord3fvARB ), - NAME_FUNC_OFFSET( 14270, glMultiTexCoord3i, _gloffset_MultiTexCoord3iARB ), - NAME_FUNC_OFFSET( 14288, glMultiTexCoord3iv, _gloffset_MultiTexCoord3ivARB ), - NAME_FUNC_OFFSET( 14307, glMultiTexCoord3s, _gloffset_MultiTexCoord3sARB ), - NAME_FUNC_OFFSET( 14325, glMultiTexCoord3sv, _gloffset_MultiTexCoord3svARB ), - NAME_FUNC_OFFSET( 14344, glMultiTexCoord4d, _gloffset_MultiTexCoord4dARB ), - NAME_FUNC_OFFSET( 14362, glMultiTexCoord4dv, _gloffset_MultiTexCoord4dvARB ), - NAME_FUNC_OFFSET( 14381, glMultiTexCoord4f, _gloffset_MultiTexCoord4fARB ), - NAME_FUNC_OFFSET( 14399, glMultiTexCoord4fv, _gloffset_MultiTexCoord4fvARB ), - NAME_FUNC_OFFSET( 14418, glMultiTexCoord4i, _gloffset_MultiTexCoord4iARB ), - NAME_FUNC_OFFSET( 14436, glMultiTexCoord4iv, _gloffset_MultiTexCoord4ivARB ), - NAME_FUNC_OFFSET( 14455, glMultiTexCoord4s, _gloffset_MultiTexCoord4sARB ), - NAME_FUNC_OFFSET( 14473, glMultiTexCoord4sv, _gloffset_MultiTexCoord4svARB ), - NAME_FUNC_OFFSET( 14492, glLoadTransposeMatrixf, _gloffset_LoadTransposeMatrixfARB ), - NAME_FUNC_OFFSET( 14515, glLoadTransposeMatrixd, _gloffset_LoadTransposeMatrixdARB ), - NAME_FUNC_OFFSET( 14538, glMultTransposeMatrixf, _gloffset_MultTransposeMatrixfARB ), - NAME_FUNC_OFFSET( 14561, glMultTransposeMatrixd, _gloffset_MultTransposeMatrixdARB ), - NAME_FUNC_OFFSET( 14584, glSampleCoverage, _gloffset_SampleCoverageARB ), - NAME_FUNC_OFFSET( 14601, glCompressedTexImage3D, _gloffset_CompressedTexImage3DARB ), - NAME_FUNC_OFFSET( 14624, glCompressedTexImage2D, _gloffset_CompressedTexImage2DARB ), - NAME_FUNC_OFFSET( 14647, glCompressedTexImage1D, _gloffset_CompressedTexImage1DARB ), - NAME_FUNC_OFFSET( 14670, glCompressedTexSubImage3D, _gloffset_CompressedTexSubImage3DARB ), - NAME_FUNC_OFFSET( 14696, glCompressedTexSubImage2D, _gloffset_CompressedTexSubImage2DARB ), - NAME_FUNC_OFFSET( 14722, glCompressedTexSubImage1D, _gloffset_CompressedTexSubImage1DARB ), - NAME_FUNC_OFFSET( 14748, glGetCompressedTexImage, _gloffset_GetCompressedTexImageARB ), - NAME_FUNC_OFFSET( 14772, glBlendFuncSeparate, _gloffset_BlendFuncSeparateEXT ), - NAME_FUNC_OFFSET( 14792, glFogCoordf, _gloffset_FogCoordfEXT ), - NAME_FUNC_OFFSET( 14804, glFogCoordfv, _gloffset_FogCoordfvEXT ), - NAME_FUNC_OFFSET( 14817, glFogCoordd, _gloffset_FogCoorddEXT ), - NAME_FUNC_OFFSET( 14829, glFogCoorddv, _gloffset_FogCoorddvEXT ), - NAME_FUNC_OFFSET( 14842, glFogCoordPointer, _gloffset_FogCoordPointerEXT ), - NAME_FUNC_OFFSET( 14860, glMultiDrawArrays, _gloffset_MultiDrawArraysEXT ), - NAME_FUNC_OFFSET( 14878, glMultiDrawElements, _gloffset_MultiDrawElementsEXT ), - NAME_FUNC_OFFSET( 14898, glPointParameterf, _gloffset_PointParameterfEXT ), - NAME_FUNC_OFFSET( 14916, glPointParameterfv, _gloffset_PointParameterfvEXT ), - NAME_FUNC_OFFSET( 14935, glPointParameteri, _gloffset_PointParameteriNV ), - NAME_FUNC_OFFSET( 14953, glPointParameteriv, _gloffset_PointParameterivNV ), - NAME_FUNC_OFFSET( 14972, glSecondaryColor3b, _gloffset_SecondaryColor3bEXT ), - NAME_FUNC_OFFSET( 14991, glSecondaryColor3bv, _gloffset_SecondaryColor3bvEXT ), - NAME_FUNC_OFFSET( 15011, glSecondaryColor3d, _gloffset_SecondaryColor3dEXT ), - NAME_FUNC_OFFSET( 15030, glSecondaryColor3dv, _gloffset_SecondaryColor3dvEXT ), - NAME_FUNC_OFFSET( 15050, glSecondaryColor3f, _gloffset_SecondaryColor3fEXT ), - NAME_FUNC_OFFSET( 15069, glSecondaryColor3fv, _gloffset_SecondaryColor3fvEXT ), - NAME_FUNC_OFFSET( 15089, glSecondaryColor3i, _gloffset_SecondaryColor3iEXT ), - NAME_FUNC_OFFSET( 15108, glSecondaryColor3iv, _gloffset_SecondaryColor3ivEXT ), - NAME_FUNC_OFFSET( 15128, glSecondaryColor3s, _gloffset_SecondaryColor3sEXT ), - NAME_FUNC_OFFSET( 15147, glSecondaryColor3sv, _gloffset_SecondaryColor3svEXT ), - NAME_FUNC_OFFSET( 15167, glSecondaryColor3ub, _gloffset_SecondaryColor3ubEXT ), - NAME_FUNC_OFFSET( 15187, glSecondaryColor3ubv, _gloffset_SecondaryColor3ubvEXT ), - NAME_FUNC_OFFSET( 15208, glSecondaryColor3ui, _gloffset_SecondaryColor3uiEXT ), - NAME_FUNC_OFFSET( 15228, glSecondaryColor3uiv, _gloffset_SecondaryColor3uivEXT ), - NAME_FUNC_OFFSET( 15249, glSecondaryColor3us, _gloffset_SecondaryColor3usEXT ), - NAME_FUNC_OFFSET( 15269, glSecondaryColor3usv, _gloffset_SecondaryColor3usvEXT ), - NAME_FUNC_OFFSET( 15290, glSecondaryColorPointer, _gloffset_SecondaryColorPointerEXT ), - NAME_FUNC_OFFSET( 15314, glWindowPos2d, _gloffset_WindowPos2dMESA ), - NAME_FUNC_OFFSET( 15328, glWindowPos2dv, _gloffset_WindowPos2dvMESA ), - NAME_FUNC_OFFSET( 15343, glWindowPos2f, _gloffset_WindowPos2fMESA ), - NAME_FUNC_OFFSET( 15357, glWindowPos2fv, _gloffset_WindowPos2fvMESA ), - NAME_FUNC_OFFSET( 15372, glWindowPos2i, _gloffset_WindowPos2iMESA ), - NAME_FUNC_OFFSET( 15386, glWindowPos2iv, _gloffset_WindowPos2ivMESA ), - NAME_FUNC_OFFSET( 15401, glWindowPos2s, _gloffset_WindowPos2sMESA ), - NAME_FUNC_OFFSET( 15415, glWindowPos2sv, _gloffset_WindowPos2svMESA ), - NAME_FUNC_OFFSET( 15430, glWindowPos3d, _gloffset_WindowPos3dMESA ), - NAME_FUNC_OFFSET( 15444, glWindowPos3dv, _gloffset_WindowPos3dvMESA ), - NAME_FUNC_OFFSET( 15459, glWindowPos3f, _gloffset_WindowPos3fMESA ), - NAME_FUNC_OFFSET( 15473, glWindowPos3fv, _gloffset_WindowPos3fvMESA ), - NAME_FUNC_OFFSET( 15488, glWindowPos3i, _gloffset_WindowPos3iMESA ), - NAME_FUNC_OFFSET( 15502, glWindowPos3iv, _gloffset_WindowPos3ivMESA ), - NAME_FUNC_OFFSET( 15517, glWindowPos3s, _gloffset_WindowPos3sMESA ), - NAME_FUNC_OFFSET( 15531, glWindowPos3sv, _gloffset_WindowPos3svMESA ), - NAME_FUNC_OFFSET( 15546, glBindBuffer, _gloffset_BindBufferARB ), - NAME_FUNC_OFFSET( 15559, glBufferData, _gloffset_BufferDataARB ), - NAME_FUNC_OFFSET( 15572, glBufferSubData, _gloffset_BufferSubDataARB ), - NAME_FUNC_OFFSET( 15588, glDeleteBuffers, _gloffset_DeleteBuffersARB ), - NAME_FUNC_OFFSET( 15604, glGenBuffers, _gloffset_GenBuffersARB ), - NAME_FUNC_OFFSET( 15617, glGetBufferParameteriv, _gloffset_GetBufferParameterivARB ), - NAME_FUNC_OFFSET( 15640, glGetBufferPointerv, _gloffset_GetBufferPointervARB ), - NAME_FUNC_OFFSET( 15660, glGetBufferSubData, _gloffset_GetBufferSubDataARB ), - NAME_FUNC_OFFSET( 15679, glIsBuffer, _gloffset_IsBufferARB ), - NAME_FUNC_OFFSET( 15690, glMapBuffer, _gloffset_MapBufferARB ), - NAME_FUNC_OFFSET( 15702, glUnmapBuffer, _gloffset_UnmapBufferARB ), - NAME_FUNC_OFFSET( 15716, glGenQueries, _gloffset_GenQueriesARB ), - NAME_FUNC_OFFSET( 15729, glDeleteQueries, _gloffset_DeleteQueriesARB ), - NAME_FUNC_OFFSET( 15745, glIsQuery, _gloffset_IsQueryARB ), - NAME_FUNC_OFFSET( 15755, glBeginQuery, _gloffset_BeginQueryARB ), - NAME_FUNC_OFFSET( 15768, glEndQuery, _gloffset_EndQueryARB ), - NAME_FUNC_OFFSET( 15779, glGetQueryiv, _gloffset_GetQueryivARB ), - NAME_FUNC_OFFSET( 15792, glGetQueryObjectiv, _gloffset_GetQueryObjectivARB ), - NAME_FUNC_OFFSET( 15811, glGetQueryObjectuiv, _gloffset_GetQueryObjectuivARB ), - NAME_FUNC_OFFSET( 15831, glPointParameterfARB, _gloffset_PointParameterfEXT ), - NAME_FUNC_OFFSET( 15852, glPointParameterfvARB, _gloffset_PointParameterfvEXT ), - NAME_FUNC_OFFSET( 15874, glWindowPos2dARB, _gloffset_WindowPos2dMESA ), - NAME_FUNC_OFFSET( 15891, glWindowPos2fARB, _gloffset_WindowPos2fMESA ), - NAME_FUNC_OFFSET( 15908, glWindowPos2iARB, _gloffset_WindowPos2iMESA ), - NAME_FUNC_OFFSET( 15925, glWindowPos2sARB, _gloffset_WindowPos2sMESA ), - NAME_FUNC_OFFSET( 15942, glWindowPos2dvARB, _gloffset_WindowPos2dvMESA ), - NAME_FUNC_OFFSET( 15960, glWindowPos2fvARB, _gloffset_WindowPos2fvMESA ), - NAME_FUNC_OFFSET( 15978, glWindowPos2ivARB, _gloffset_WindowPos2ivMESA ), - NAME_FUNC_OFFSET( 15996, glWindowPos2svARB, _gloffset_WindowPos2svMESA ), - NAME_FUNC_OFFSET( 16014, glWindowPos3dARB, _gloffset_WindowPos3dMESA ), - NAME_FUNC_OFFSET( 16031, glWindowPos3fARB, _gloffset_WindowPos3fMESA ), - NAME_FUNC_OFFSET( 16048, glWindowPos3iARB, _gloffset_WindowPos3iMESA ), - NAME_FUNC_OFFSET( 16065, glWindowPos3sARB, _gloffset_WindowPos3sMESA ), - NAME_FUNC_OFFSET( 16082, glWindowPos3dvARB, _gloffset_WindowPos3dvMESA ), - NAME_FUNC_OFFSET( 16100, glWindowPos3fvARB, _gloffset_WindowPos3fvMESA ), - NAME_FUNC_OFFSET( 16118, glWindowPos3ivARB, _gloffset_WindowPos3ivMESA ), - NAME_FUNC_OFFSET( 16136, glWindowPos3svARB, _gloffset_WindowPos3svMESA ), - NAME_FUNC_OFFSET( 16154, glBindProgramARB, _gloffset_BindProgramNV ), - NAME_FUNC_OFFSET( 16171, glDeleteProgramsARB, _gloffset_DeleteProgramsNV ), - NAME_FUNC_OFFSET( 16191, glGenProgramsARB, _gloffset_GenProgramsNV ), - NAME_FUNC_OFFSET( 16208, glIsProgramARB, _gloffset_IsProgramNV ), - NAME_FUNC_OFFSET( 16223, glGetVertexAttribPointervARB, _gloffset_GetVertexAttribPointervNV ), - NAME_FUNC_OFFSET( 16252, glBlendColorEXT, _gloffset_BlendColor ), - NAME_FUNC_OFFSET( 16268, glTexImage3DEXT, _gloffset_TexImage3D ), - NAME_FUNC_OFFSET( 16284, glTexSubImage3DEXT, _gloffset_TexSubImage3D ), - NAME_FUNC_OFFSET( 16303, glTexSubImage1DEXT, _gloffset_TexSubImage1D ), - NAME_FUNC_OFFSET( 16322, glTexSubImage2DEXT, _gloffset_TexSubImage2D ), - NAME_FUNC_OFFSET( 16341, glCopyTexImage1DEXT, _gloffset_CopyTexImage1D ), - NAME_FUNC_OFFSET( 16361, glCopyTexImage2DEXT, _gloffset_CopyTexImage2D ), - NAME_FUNC_OFFSET( 16381, glCopyTexSubImage1DEXT, _gloffset_CopyTexSubImage1D ), - NAME_FUNC_OFFSET( 16404, glCopyTexSubImage2DEXT, _gloffset_CopyTexSubImage2D ), - NAME_FUNC_OFFSET( 16427, glCopyTexSubImage3DEXT, _gloffset_CopyTexSubImage3D ), - NAME_FUNC_OFFSET( 16450, glHistogramEXT, _gloffset_Histogram ), - NAME_FUNC_OFFSET( 16465, glMinmaxEXT, _gloffset_Minmax ), - NAME_FUNC_OFFSET( 16477, glResetHistogramEXT, _gloffset_ResetHistogram ), - NAME_FUNC_OFFSET( 16497, glResetMinmaxEXT, _gloffset_ResetMinmax ), - NAME_FUNC_OFFSET( 16514, glConvolutionFilter1DEXT, _gloffset_ConvolutionFilter1D ), - NAME_FUNC_OFFSET( 16539, glConvolutionFilter2DEXT, _gloffset_ConvolutionFilter2D ), - NAME_FUNC_OFFSET( 16564, glConvolutionParameterfEXT, _gloffset_ConvolutionParameterf ), - NAME_FUNC_OFFSET( 16591, glConvolutionParameterfvEXT, _gloffset_ConvolutionParameterfv ), - NAME_FUNC_OFFSET( 16619, glConvolutionParameteriEXT, _gloffset_ConvolutionParameteri ), - NAME_FUNC_OFFSET( 16646, glConvolutionParameterivEXT, _gloffset_ConvolutionParameteriv ), - NAME_FUNC_OFFSET( 16674, glCopyConvolutionFilter1DEXT, _gloffset_CopyConvolutionFilter1D ), - NAME_FUNC_OFFSET( 16703, glCopyConvolutionFilter2DEXT, _gloffset_CopyConvolutionFilter2D ), - NAME_FUNC_OFFSET( 16732, glSeparableFilter2DEXT, _gloffset_SeparableFilter2D ), - NAME_FUNC_OFFSET( 16755, glColorTableSGI, _gloffset_ColorTable ), - NAME_FUNC_OFFSET( 16771, glColorTableParameterfvSGI, _gloffset_ColorTableParameterfv ), - NAME_FUNC_OFFSET( 16798, glColorTableParameterivSGI, _gloffset_ColorTableParameteriv ), - NAME_FUNC_OFFSET( 16825, glCopyColorTableSGI, _gloffset_CopyColorTable ), - NAME_FUNC_OFFSET( 16845, glBindTextureEXT, _gloffset_BindTexture ), - NAME_FUNC_OFFSET( 16862, glDeleteTexturesEXT, _gloffset_DeleteTextures ), - NAME_FUNC_OFFSET( 16882, glPrioritizeTexturesEXT, _gloffset_PrioritizeTextures ), - NAME_FUNC_OFFSET( 16906, glArrayElementEXT, _gloffset_ArrayElement ), - NAME_FUNC_OFFSET( 16924, glDrawArraysEXT, _gloffset_DrawArrays ), - NAME_FUNC_OFFSET( 16940, glGetPointervEXT, _gloffset_GetPointerv ), - NAME_FUNC_OFFSET( 16957, glBlendEquationEXT, _gloffset_BlendEquation ), - NAME_FUNC_OFFSET( 16976, glColorSubTableEXT, _gloffset_ColorSubTable ), - NAME_FUNC_OFFSET( 16995, glCopyColorSubTableEXT, _gloffset_CopyColorSubTable ), - NAME_FUNC_OFFSET( 17018, glColorTableEXT, _gloffset_ColorTable ), - NAME_FUNC_OFFSET( 17034, glDrawRangeElementsEXT, _gloffset_DrawRangeElements ), - NAME_FUNC_OFFSET( 17057, glSampleMaskEXT, _gloffset_SampleMaskSGIS ), - NAME_FUNC_OFFSET( 17073, glSamplePatternEXT, _gloffset_SamplePatternSGIS ), - NAME_FUNC_OFFSET( 17092, glDrawBuffersATI, _gloffset_DrawBuffersARB ), - NAME_FUNC_OFFSET( 17109, glBlendEquationSeparateATI, _gloffset_BlendEquationSeparateEXT ), - NAME_FUNC_OFFSET( 17136, glBlendFuncSeparateINGR, _gloffset_BlendFuncSeparateEXT ), - NAME_FUNC_OFFSET( 17160, glPointParameterfSGIS, _gloffset_PointParameterfEXT ), - NAME_FUNC_OFFSET( 17182, glPointParameterfvSGIS, _gloffset_PointParameterfvEXT ), + NAME_FUNC_OFFSET( 13862, glGenFragmentShadersATI, _gloffset_GenFragmentShadersATI ), + NAME_FUNC_OFFSET( 13886, glBindFragmentShaderATI, _gloffset_BindFragmentShaderATI ), + NAME_FUNC_OFFSET( 13910, glDeleteFragmentShaderATI, _gloffset_DeleteFragmentShaderATI ), + NAME_FUNC_OFFSET( 13936, glBeginFragmentShaderATI, _gloffset_BeginFragmentShaderATI ), + NAME_FUNC_OFFSET( 13961, glEndFragmentShaderATI, _gloffset_EndFragmentShaderATI ), + NAME_FUNC_OFFSET( 13984, glPassTexCoordATI, _gloffset_PassTexCoordATI ), + NAME_FUNC_OFFSET( 14002, glSampleMapATI, _gloffset_SampleMapATI ), + NAME_FUNC_OFFSET( 14017, glColorFragmentOp1ATI, _gloffset_ColorFragmentOp1ATI ), + NAME_FUNC_OFFSET( 14039, glColorFragmentOp2ATI, _gloffset_ColorFragmentOp2ATI ), + NAME_FUNC_OFFSET( 14061, glColorFragmentOp3ATI, _gloffset_ColorFragmentOp3ATI ), + NAME_FUNC_OFFSET( 14083, glAlphaFragmentOp1ATI, _gloffset_AlphaFragmentOp1ATI ), + NAME_FUNC_OFFSET( 14105, glAlphaFragmentOp2ATI, _gloffset_AlphaFragmentOp2ATI ), + NAME_FUNC_OFFSET( 14127, glAlphaFragmentOp3ATI, _gloffset_AlphaFragmentOp3ATI ), + NAME_FUNC_OFFSET( 14149, glSetFragmentShaderConstantATI, _gloffset_SetFragmentShaderConstantATI ), + NAME_FUNC_OFFSET( 14180, glActiveTexture, _gloffset_ActiveTextureARB ), + NAME_FUNC_OFFSET( 14196, glClientActiveTexture, _gloffset_ClientActiveTextureARB ), + NAME_FUNC_OFFSET( 14218, glMultiTexCoord1d, _gloffset_MultiTexCoord1dARB ), + NAME_FUNC_OFFSET( 14236, glMultiTexCoord1dv, _gloffset_MultiTexCoord1dvARB ), + NAME_FUNC_OFFSET( 14255, glMultiTexCoord1f, _gloffset_MultiTexCoord1fARB ), + NAME_FUNC_OFFSET( 14273, glMultiTexCoord1fv, _gloffset_MultiTexCoord1fvARB ), + NAME_FUNC_OFFSET( 14292, glMultiTexCoord1i, _gloffset_MultiTexCoord1iARB ), + NAME_FUNC_OFFSET( 14310, glMultiTexCoord1iv, _gloffset_MultiTexCoord1ivARB ), + NAME_FUNC_OFFSET( 14329, glMultiTexCoord1s, _gloffset_MultiTexCoord1sARB ), + NAME_FUNC_OFFSET( 14347, glMultiTexCoord1sv, _gloffset_MultiTexCoord1svARB ), + NAME_FUNC_OFFSET( 14366, glMultiTexCoord2d, _gloffset_MultiTexCoord2dARB ), + NAME_FUNC_OFFSET( 14384, glMultiTexCoord2dv, _gloffset_MultiTexCoord2dvARB ), + NAME_FUNC_OFFSET( 14403, glMultiTexCoord2f, _gloffset_MultiTexCoord2fARB ), + NAME_FUNC_OFFSET( 14421, glMultiTexCoord2fv, _gloffset_MultiTexCoord2fvARB ), + NAME_FUNC_OFFSET( 14440, glMultiTexCoord2i, _gloffset_MultiTexCoord2iARB ), + NAME_FUNC_OFFSET( 14458, glMultiTexCoord2iv, _gloffset_MultiTexCoord2ivARB ), + NAME_FUNC_OFFSET( 14477, glMultiTexCoord2s, _gloffset_MultiTexCoord2sARB ), + NAME_FUNC_OFFSET( 14495, glMultiTexCoord2sv, _gloffset_MultiTexCoord2svARB ), + NAME_FUNC_OFFSET( 14514, glMultiTexCoord3d, _gloffset_MultiTexCoord3dARB ), + NAME_FUNC_OFFSET( 14532, glMultiTexCoord3dv, _gloffset_MultiTexCoord3dvARB ), + NAME_FUNC_OFFSET( 14551, glMultiTexCoord3f, _gloffset_MultiTexCoord3fARB ), + NAME_FUNC_OFFSET( 14569, glMultiTexCoord3fv, _gloffset_MultiTexCoord3fvARB ), + NAME_FUNC_OFFSET( 14588, glMultiTexCoord3i, _gloffset_MultiTexCoord3iARB ), + NAME_FUNC_OFFSET( 14606, glMultiTexCoord3iv, _gloffset_MultiTexCoord3ivARB ), + NAME_FUNC_OFFSET( 14625, glMultiTexCoord3s, _gloffset_MultiTexCoord3sARB ), + NAME_FUNC_OFFSET( 14643, glMultiTexCoord3sv, _gloffset_MultiTexCoord3svARB ), + NAME_FUNC_OFFSET( 14662, glMultiTexCoord4d, _gloffset_MultiTexCoord4dARB ), + NAME_FUNC_OFFSET( 14680, glMultiTexCoord4dv, _gloffset_MultiTexCoord4dvARB ), + NAME_FUNC_OFFSET( 14699, glMultiTexCoord4f, _gloffset_MultiTexCoord4fARB ), + NAME_FUNC_OFFSET( 14717, glMultiTexCoord4fv, _gloffset_MultiTexCoord4fvARB ), + NAME_FUNC_OFFSET( 14736, glMultiTexCoord4i, _gloffset_MultiTexCoord4iARB ), + NAME_FUNC_OFFSET( 14754, glMultiTexCoord4iv, _gloffset_MultiTexCoord4ivARB ), + NAME_FUNC_OFFSET( 14773, glMultiTexCoord4s, _gloffset_MultiTexCoord4sARB ), + NAME_FUNC_OFFSET( 14791, glMultiTexCoord4sv, _gloffset_MultiTexCoord4svARB ), + NAME_FUNC_OFFSET( 14810, glLoadTransposeMatrixf, _gloffset_LoadTransposeMatrixfARB ), + NAME_FUNC_OFFSET( 14833, glLoadTransposeMatrixd, _gloffset_LoadTransposeMatrixdARB ), + NAME_FUNC_OFFSET( 14856, glMultTransposeMatrixf, _gloffset_MultTransposeMatrixfARB ), + NAME_FUNC_OFFSET( 14879, glMultTransposeMatrixd, _gloffset_MultTransposeMatrixdARB ), + NAME_FUNC_OFFSET( 14902, glSampleCoverage, _gloffset_SampleCoverageARB ), + NAME_FUNC_OFFSET( 14919, glCompressedTexImage3D, _gloffset_CompressedTexImage3DARB ), + NAME_FUNC_OFFSET( 14942, glCompressedTexImage2D, _gloffset_CompressedTexImage2DARB ), + NAME_FUNC_OFFSET( 14965, glCompressedTexImage1D, _gloffset_CompressedTexImage1DARB ), + NAME_FUNC_OFFSET( 14988, glCompressedTexSubImage3D, _gloffset_CompressedTexSubImage3DARB ), + NAME_FUNC_OFFSET( 15014, glCompressedTexSubImage2D, _gloffset_CompressedTexSubImage2DARB ), + NAME_FUNC_OFFSET( 15040, glCompressedTexSubImage1D, _gloffset_CompressedTexSubImage1DARB ), + NAME_FUNC_OFFSET( 15066, glGetCompressedTexImage, _gloffset_GetCompressedTexImageARB ), + NAME_FUNC_OFFSET( 15090, glBlendFuncSeparate, _gloffset_BlendFuncSeparateEXT ), + NAME_FUNC_OFFSET( 15110, glFogCoordf, _gloffset_FogCoordfEXT ), + NAME_FUNC_OFFSET( 15122, glFogCoordfv, _gloffset_FogCoordfvEXT ), + NAME_FUNC_OFFSET( 15135, glFogCoordd, _gloffset_FogCoorddEXT ), + NAME_FUNC_OFFSET( 15147, glFogCoorddv, _gloffset_FogCoorddvEXT ), + NAME_FUNC_OFFSET( 15160, glFogCoordPointer, _gloffset_FogCoordPointerEXT ), + NAME_FUNC_OFFSET( 15178, glMultiDrawArrays, _gloffset_MultiDrawArraysEXT ), + NAME_FUNC_OFFSET( 15196, glMultiDrawElements, _gloffset_MultiDrawElementsEXT ), + NAME_FUNC_OFFSET( 15216, glPointParameterf, _gloffset_PointParameterfEXT ), + NAME_FUNC_OFFSET( 15234, glPointParameterfv, _gloffset_PointParameterfvEXT ), + NAME_FUNC_OFFSET( 15253, glPointParameteri, _gloffset_PointParameteriNV ), + NAME_FUNC_OFFSET( 15271, glPointParameteriv, _gloffset_PointParameterivNV ), + NAME_FUNC_OFFSET( 15290, glSecondaryColor3b, _gloffset_SecondaryColor3bEXT ), + NAME_FUNC_OFFSET( 15309, glSecondaryColor3bv, _gloffset_SecondaryColor3bvEXT ), + NAME_FUNC_OFFSET( 15329, glSecondaryColor3d, _gloffset_SecondaryColor3dEXT ), + NAME_FUNC_OFFSET( 15348, glSecondaryColor3dv, _gloffset_SecondaryColor3dvEXT ), + NAME_FUNC_OFFSET( 15368, glSecondaryColor3f, _gloffset_SecondaryColor3fEXT ), + NAME_FUNC_OFFSET( 15387, glSecondaryColor3fv, _gloffset_SecondaryColor3fvEXT ), + NAME_FUNC_OFFSET( 15407, glSecondaryColor3i, _gloffset_SecondaryColor3iEXT ), + NAME_FUNC_OFFSET( 15426, glSecondaryColor3iv, _gloffset_SecondaryColor3ivEXT ), + NAME_FUNC_OFFSET( 15446, glSecondaryColor3s, _gloffset_SecondaryColor3sEXT ), + NAME_FUNC_OFFSET( 15465, glSecondaryColor3sv, _gloffset_SecondaryColor3svEXT ), + NAME_FUNC_OFFSET( 15485, glSecondaryColor3ub, _gloffset_SecondaryColor3ubEXT ), + NAME_FUNC_OFFSET( 15505, glSecondaryColor3ubv, _gloffset_SecondaryColor3ubvEXT ), + NAME_FUNC_OFFSET( 15526, glSecondaryColor3ui, _gloffset_SecondaryColor3uiEXT ), + NAME_FUNC_OFFSET( 15546, glSecondaryColor3uiv, _gloffset_SecondaryColor3uivEXT ), + NAME_FUNC_OFFSET( 15567, glSecondaryColor3us, _gloffset_SecondaryColor3usEXT ), + NAME_FUNC_OFFSET( 15587, glSecondaryColor3usv, _gloffset_SecondaryColor3usvEXT ), + NAME_FUNC_OFFSET( 15608, glSecondaryColorPointer, _gloffset_SecondaryColorPointerEXT ), + NAME_FUNC_OFFSET( 15632, glWindowPos2d, _gloffset_WindowPos2dMESA ), + NAME_FUNC_OFFSET( 15646, glWindowPos2dv, _gloffset_WindowPos2dvMESA ), + NAME_FUNC_OFFSET( 15661, glWindowPos2f, _gloffset_WindowPos2fMESA ), + NAME_FUNC_OFFSET( 15675, glWindowPos2fv, _gloffset_WindowPos2fvMESA ), + NAME_FUNC_OFFSET( 15690, glWindowPos2i, _gloffset_WindowPos2iMESA ), + NAME_FUNC_OFFSET( 15704, glWindowPos2iv, _gloffset_WindowPos2ivMESA ), + NAME_FUNC_OFFSET( 15719, glWindowPos2s, _gloffset_WindowPos2sMESA ), + NAME_FUNC_OFFSET( 15733, glWindowPos2sv, _gloffset_WindowPos2svMESA ), + NAME_FUNC_OFFSET( 15748, glWindowPos3d, _gloffset_WindowPos3dMESA ), + NAME_FUNC_OFFSET( 15762, glWindowPos3dv, _gloffset_WindowPos3dvMESA ), + NAME_FUNC_OFFSET( 15777, glWindowPos3f, _gloffset_WindowPos3fMESA ), + NAME_FUNC_OFFSET( 15791, glWindowPos3fv, _gloffset_WindowPos3fvMESA ), + NAME_FUNC_OFFSET( 15806, glWindowPos3i, _gloffset_WindowPos3iMESA ), + NAME_FUNC_OFFSET( 15820, glWindowPos3iv, _gloffset_WindowPos3ivMESA ), + NAME_FUNC_OFFSET( 15835, glWindowPos3s, _gloffset_WindowPos3sMESA ), + NAME_FUNC_OFFSET( 15849, glWindowPos3sv, _gloffset_WindowPos3svMESA ), + NAME_FUNC_OFFSET( 15864, glBindBuffer, _gloffset_BindBufferARB ), + NAME_FUNC_OFFSET( 15877, glBufferData, _gloffset_BufferDataARB ), + NAME_FUNC_OFFSET( 15890, glBufferSubData, _gloffset_BufferSubDataARB ), + NAME_FUNC_OFFSET( 15906, glDeleteBuffers, _gloffset_DeleteBuffersARB ), + NAME_FUNC_OFFSET( 15922, glGenBuffers, _gloffset_GenBuffersARB ), + NAME_FUNC_OFFSET( 15935, glGetBufferParameteriv, _gloffset_GetBufferParameterivARB ), + NAME_FUNC_OFFSET( 15958, glGetBufferPointerv, _gloffset_GetBufferPointervARB ), + NAME_FUNC_OFFSET( 15978, glGetBufferSubData, _gloffset_GetBufferSubDataARB ), + NAME_FUNC_OFFSET( 15997, glIsBuffer, _gloffset_IsBufferARB ), + NAME_FUNC_OFFSET( 16008, glMapBuffer, _gloffset_MapBufferARB ), + NAME_FUNC_OFFSET( 16020, glUnmapBuffer, _gloffset_UnmapBufferARB ), + NAME_FUNC_OFFSET( 16034, glGenQueries, _gloffset_GenQueriesARB ), + NAME_FUNC_OFFSET( 16047, glDeleteQueries, _gloffset_DeleteQueriesARB ), + NAME_FUNC_OFFSET( 16063, glIsQuery, _gloffset_IsQueryARB ), + NAME_FUNC_OFFSET( 16073, glBeginQuery, _gloffset_BeginQueryARB ), + NAME_FUNC_OFFSET( 16086, glEndQuery, _gloffset_EndQueryARB ), + NAME_FUNC_OFFSET( 16097, glGetQueryiv, _gloffset_GetQueryivARB ), + NAME_FUNC_OFFSET( 16110, glGetQueryObjectiv, _gloffset_GetQueryObjectivARB ), + NAME_FUNC_OFFSET( 16129, glGetQueryObjectuiv, _gloffset_GetQueryObjectuivARB ), + NAME_FUNC_OFFSET( 16149, glPointParameterfARB, _gloffset_PointParameterfEXT ), + NAME_FUNC_OFFSET( 16170, glPointParameterfvARB, _gloffset_PointParameterfvEXT ), + NAME_FUNC_OFFSET( 16192, glWindowPos2dARB, _gloffset_WindowPos2dMESA ), + NAME_FUNC_OFFSET( 16209, glWindowPos2fARB, _gloffset_WindowPos2fMESA ), + NAME_FUNC_OFFSET( 16226, glWindowPos2iARB, _gloffset_WindowPos2iMESA ), + NAME_FUNC_OFFSET( 16243, glWindowPos2sARB, _gloffset_WindowPos2sMESA ), + NAME_FUNC_OFFSET( 16260, glWindowPos2dvARB, _gloffset_WindowPos2dvMESA ), + NAME_FUNC_OFFSET( 16278, glWindowPos2fvARB, _gloffset_WindowPos2fvMESA ), + NAME_FUNC_OFFSET( 16296, glWindowPos2ivARB, _gloffset_WindowPos2ivMESA ), + NAME_FUNC_OFFSET( 16314, glWindowPos2svARB, _gloffset_WindowPos2svMESA ), + NAME_FUNC_OFFSET( 16332, glWindowPos3dARB, _gloffset_WindowPos3dMESA ), + NAME_FUNC_OFFSET( 16349, glWindowPos3fARB, _gloffset_WindowPos3fMESA ), + NAME_FUNC_OFFSET( 16366, glWindowPos3iARB, _gloffset_WindowPos3iMESA ), + NAME_FUNC_OFFSET( 16383, glWindowPos3sARB, _gloffset_WindowPos3sMESA ), + NAME_FUNC_OFFSET( 16400, glWindowPos3dvARB, _gloffset_WindowPos3dvMESA ), + NAME_FUNC_OFFSET( 16418, glWindowPos3fvARB, _gloffset_WindowPos3fvMESA ), + NAME_FUNC_OFFSET( 16436, glWindowPos3ivARB, _gloffset_WindowPos3ivMESA ), + NAME_FUNC_OFFSET( 16454, glWindowPos3svARB, _gloffset_WindowPos3svMESA ), + NAME_FUNC_OFFSET( 16472, glBindProgramARB, _gloffset_BindProgramNV ), + NAME_FUNC_OFFSET( 16489, glDeleteProgramsARB, _gloffset_DeleteProgramsNV ), + NAME_FUNC_OFFSET( 16509, glGenProgramsARB, _gloffset_GenProgramsNV ), + NAME_FUNC_OFFSET( 16526, glIsProgramARB, _gloffset_IsProgramNV ), + NAME_FUNC_OFFSET( 16541, glGetVertexAttribPointervARB, _gloffset_GetVertexAttribPointervNV ), + NAME_FUNC_OFFSET( 16570, glBlendColorEXT, _gloffset_BlendColor ), + NAME_FUNC_OFFSET( 16586, glTexImage3DEXT, _gloffset_TexImage3D ), + NAME_FUNC_OFFSET( 16602, glTexSubImage3DEXT, _gloffset_TexSubImage3D ), + NAME_FUNC_OFFSET( 16621, glTexSubImage1DEXT, _gloffset_TexSubImage1D ), + NAME_FUNC_OFFSET( 16640, glTexSubImage2DEXT, _gloffset_TexSubImage2D ), + NAME_FUNC_OFFSET( 16659, glCopyTexImage1DEXT, _gloffset_CopyTexImage1D ), + NAME_FUNC_OFFSET( 16679, glCopyTexImage2DEXT, _gloffset_CopyTexImage2D ), + NAME_FUNC_OFFSET( 16699, glCopyTexSubImage1DEXT, _gloffset_CopyTexSubImage1D ), + NAME_FUNC_OFFSET( 16722, glCopyTexSubImage2DEXT, _gloffset_CopyTexSubImage2D ), + NAME_FUNC_OFFSET( 16745, glCopyTexSubImage3DEXT, _gloffset_CopyTexSubImage3D ), + NAME_FUNC_OFFSET( 16768, glHistogramEXT, _gloffset_Histogram ), + NAME_FUNC_OFFSET( 16783, glMinmaxEXT, _gloffset_Minmax ), + NAME_FUNC_OFFSET( 16795, glResetHistogramEXT, _gloffset_ResetHistogram ), + NAME_FUNC_OFFSET( 16815, glResetMinmaxEXT, _gloffset_ResetMinmax ), + NAME_FUNC_OFFSET( 16832, glConvolutionFilter1DEXT, _gloffset_ConvolutionFilter1D ), + NAME_FUNC_OFFSET( 16857, glConvolutionFilter2DEXT, _gloffset_ConvolutionFilter2D ), + NAME_FUNC_OFFSET( 16882, glConvolutionParameterfEXT, _gloffset_ConvolutionParameterf ), + NAME_FUNC_OFFSET( 16909, glConvolutionParameterfvEXT, _gloffset_ConvolutionParameterfv ), + NAME_FUNC_OFFSET( 16937, glConvolutionParameteriEXT, _gloffset_ConvolutionParameteri ), + NAME_FUNC_OFFSET( 16964, glConvolutionParameterivEXT, _gloffset_ConvolutionParameteriv ), + NAME_FUNC_OFFSET( 16992, glCopyConvolutionFilter1DEXT, _gloffset_CopyConvolutionFilter1D ), + NAME_FUNC_OFFSET( 17021, glCopyConvolutionFilter2DEXT, _gloffset_CopyConvolutionFilter2D ), + NAME_FUNC_OFFSET( 17050, glSeparableFilter2DEXT, _gloffset_SeparableFilter2D ), + NAME_FUNC_OFFSET( 17073, glColorTableSGI, _gloffset_ColorTable ), + NAME_FUNC_OFFSET( 17089, glColorTableParameterfvSGI, _gloffset_ColorTableParameterfv ), + NAME_FUNC_OFFSET( 17116, glColorTableParameterivSGI, _gloffset_ColorTableParameteriv ), + NAME_FUNC_OFFSET( 17143, glCopyColorTableSGI, _gloffset_CopyColorTable ), + NAME_FUNC_OFFSET( 17163, glBindTextureEXT, _gloffset_BindTexture ), + NAME_FUNC_OFFSET( 17180, glDeleteTexturesEXT, _gloffset_DeleteTextures ), + NAME_FUNC_OFFSET( 17200, glPrioritizeTexturesEXT, _gloffset_PrioritizeTextures ), + NAME_FUNC_OFFSET( 17224, glArrayElementEXT, _gloffset_ArrayElement ), + NAME_FUNC_OFFSET( 17242, glDrawArraysEXT, _gloffset_DrawArrays ), + NAME_FUNC_OFFSET( 17258, glGetPointervEXT, _gloffset_GetPointerv ), + NAME_FUNC_OFFSET( 17275, glBlendEquationEXT, _gloffset_BlendEquation ), + NAME_FUNC_OFFSET( 17294, glColorSubTableEXT, _gloffset_ColorSubTable ), + NAME_FUNC_OFFSET( 17313, glCopyColorSubTableEXT, _gloffset_CopyColorSubTable ), + NAME_FUNC_OFFSET( 17336, glColorTableEXT, _gloffset_ColorTable ), + NAME_FUNC_OFFSET( 17352, glDrawRangeElementsEXT, _gloffset_DrawRangeElements ), + NAME_FUNC_OFFSET( 17375, glSampleMaskEXT, _gloffset_SampleMaskSGIS ), + NAME_FUNC_OFFSET( 17391, glSamplePatternEXT, _gloffset_SamplePatternSGIS ), + NAME_FUNC_OFFSET( 17410, glDrawBuffersATI, _gloffset_DrawBuffersARB ), + NAME_FUNC_OFFSET( 17427, glBlendEquationSeparateATI, _gloffset_BlendEquationSeparateEXT ), + NAME_FUNC_OFFSET( 17454, glBlendFuncSeparateINGR, _gloffset_BlendFuncSeparateEXT ), + NAME_FUNC_OFFSET( 17478, glPointParameterfSGIS, _gloffset_PointParameterfEXT ), + NAME_FUNC_OFFSET( 17500, glPointParameterfvSGIS, _gloffset_PointParameterfvEXT ), NAME_FUNC_OFFSET( -1, NULL, 0 ) }; diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index 01072c397f..cef8dd74a4 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -289,6 +289,7 @@ #define FEATURE_ARB_vertex_shader _HAVE_FULL_GL #define FEATURE_ARB_fragment_shader _HAVE_FULL_GL #define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader) +#define FEATURE_ATI_fragment_shader _HAVE_FULL_GL /*@}*/ diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 3116cb95a1..98e684d393 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -859,6 +859,11 @@ alloc_shared_state( GLcontext *ctx ) if (!ss->DefaultFragmentProgram) goto cleanup; #endif +#if FEATURE_ATI_fragment_shader + ss->DefaultFragmentShader = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_SHADER_ATI, 0); + if (!ss->DefaultFragmentShader) + goto cleanup; +#endif ss->BufferObjects = _mesa_NewHashTable(); @@ -909,6 +914,10 @@ alloc_shared_state( GLcontext *ctx ) if (ss->DefaultFragmentProgram) ctx->Driver.DeleteProgram(ctx, ss->DefaultFragmentProgram); #endif +#if FEATURE_ATI_fragment_shader + if (ss->DefaultFragmentShader) + ctx->Driver.DeleteProgram(ctx, ss->DefaultFragmentShader); +#endif #if FEATURE_ARB_vertex_buffer_object if (ss->BufferObjects) _mesa_DeleteHashTable(ss->BufferObjects); @@ -1003,6 +1012,9 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) #if FEATURE_ARB_fragment_program _mesa_delete_program(ctx, ss->DefaultFragmentProgram); #endif +#if FEATURE_ATI_fragment_shader + _mesa_delete_program(ctx, ss->DefaultFragmentShader); +#endif #if FEATURE_ARB_vertex_buffer_object _mesa_DeleteHashTable(ss->BufferObjects); @@ -1100,6 +1112,7 @@ _mesa_init_constants( GLcontext *ctx ) ctx->Const.MaxFragmentProgramTexInstructions = MAX_FRAGMENT_PROGRAM_TEX_INSTRUCTIONS; ctx->Const.MaxFragmentProgramTexIndirections = MAX_FRAGMENT_PROGRAM_TEX_INDIRECTIONS; #endif + ctx->Const.MaxProgramMatrices = MAX_PROGRAM_MATRICES; ctx->Const.MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH; @@ -1385,6 +1398,22 @@ add_newer_entrypoints(void) { "glActiveStencilFaceEXT", _gloffset_ActiveStencilFaceEXT }, /* GL_ARB_draw_buffers */ { "glDrawBuffersARB", _gloffset_DrawBuffersARB }, +#if FEATURE_ATI_fragment_shader + { "glGenFragmentShadersATI", _gloffset_GenFragmentShadersATI }, + { "glBindFragmentShaderATI", _gloffset_BindFragmentShaderATI }, + { "glDeleteFragmentShaderATI", _gloffset_DeleteFragmentShaderATI }, + { "glBeginFragmentShaderATI", _gloffset_BeginFragmentShaderATI }, + { "glEndFragmentShaderATI", _gloffset_EndFragmentShaderATI }, + { "glPassTexCoordATI", _gloffset_PassTexCoordATI }, + { "glSampleMapATI", _gloffset_SampleMapATI }, + { "glColorFragmentOp1ATI", _gloffset_ColorFragmentOp1ATI }, + { "glColorFragmentOp2ATI", _gloffset_ColorFragmentOp2ATI }, + { "glColorFragmentOp3ATI", _gloffset_ColorFragmentOp3ATI }, + { "glAlphaFragmentOp1ATI", _gloffset_AlphaFragmentOp1ATI }, + { "glAlphaFragmentOp2ATI", _gloffset_AlphaFragmentOp2ATI }, + { "glAlphaFragmentOp3ATI", _gloffset_AlphaFragmentOp3ATI }, + { "glSetFragmentShaderConstantATI", _gloffset_SetFragmentShaderConstantATI }, +#endif }; for (i = 0; i < Elements(newer_entrypoints); i++ ) { diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 348ba49588..8ef5269cd8 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -79,6 +79,9 @@ #include "nvprogram.h" #include "program.h" #endif +#if FEATURE_ATI_fragment_shader +#include "atifragshader.h" +#endif #include "math/m_matrix.h" #include "math/m_xform.h" @@ -316,7 +319,10 @@ typedef enum { OPCODE_END_QUERY_ARB, /* GL_ARB_draw_buffers */ OPCODE_DRAW_BUFFERS_ARB, - + /* GL_ATI_fragment_shader */ + OPCODE_BIND_FRAGMENT_SHADER_ATI, + OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, + /* Vertex attributes -- fallback for when optimized display * list build isn't active. */ @@ -789,6 +795,10 @@ _mesa_init_lists( void ) InstSize[OPCODE_END_QUERY_ARB] = 2; #endif InstSize[OPCODE_DRAW_BUFFERS_ARB] = 2 + MAX_DRAW_BUFFERS; +#if FEATURE_ATI_fragment_shader + InstSize[OPCODE_BIND_FRAGMENT_SHADER_ATI] = 2; + InstSize[OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI] = 6; +#endif InstSize[OPCODE_ATTR_1F_NV] = 3; InstSize[OPCODE_ATTR_2F_NV] = 4; InstSize[OPCODE_ATTR_3F_NV] = 5; @@ -4715,6 +4725,41 @@ save_DrawBuffersARB(GLsizei count, const GLenum *buffers) } } +#if FEATURE_ATI_fragment_shader +static void GLAPIENTRY +save_BindFragmentShaderATI(GLuint id) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + n = ALLOC_INSTRUCTION( ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1); + if (n) { + n[1].ui = id; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->BindFragmentShaderATI)(id); + } +} + +static void GLAPIENTRY +save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + n = ALLOC_INSTRUCTION( ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5); + if (n) { + n[1].ui = dst; + n[2].f = value[0]; + n[3].f = value[1]; + n[4].f = value[2]; + n[5].f = value[3]; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->SetFragmentShaderConstantATI)(dst, value); + } +} +#endif static void save_Attr1fNV( GLenum attr, GLfloat x ) { @@ -6246,6 +6291,21 @@ execute_list( GLcontext *ctx, GLuint list ) ctx->Exec->DrawBuffersARB(n[1].i, buffers); } break; +#if FEATURE_ATI_fragment_shader + case OPCODE_BIND_FRAGMENT_SHADER_ATI: + ctx->Exec->BindFragmentShaderATI(n[1].i); + break; + case OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI: + { + GLfloat values[4]; + GLuint i, dst = n[1].ui; + + for (i = 0; i < 4; i++) + values[i] = n[1+i].f; + ctx->Exec->SetFragmentShaderConstantATI(dst, values); + } + break; +#endif case OPCODE_ATTR_1F_NV: (*ctx->Exec->VertexAttrib1fNV)(n[1].e, n[2].f); break; @@ -7753,6 +7813,12 @@ _mesa_init_dlist_table( struct _glapi_table *table ) table->VertexAttribPointerNV = _mesa_VertexAttribPointerNV; #endif + /* 245. GL_ATI_fragment_shader */ +#if FEATURE_ATI_fragment_shader + table->BindFragmentShaderATI = save_BindFragmentShaderATI; + table->SetFragmentShaderConstantATI = save_SetFragmentShaderConstantATI; +#endif + /* 282. GL_NV_fragment_program */ #if FEATURE_NV_fragment_program table->ProgramNamedParameter4fNV = save_ProgramNamedParameter4fNV; diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 8968c0aa83..f53ae05d17 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -993,6 +993,15 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) ctx->VertexProgram.CallbackEnabled = state; break; +#if FEATURE_ATI_fragment_shader + case GL_FRAGMENT_SHADER_ATI: + CHECK_EXTENSION(ATI_fragment_shader, cap); + if (ctx->ATIFragmentShader.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + ctx->ATIFragmentShader.Enabled = state; + break; +#endif default: _mesa_error(ctx, GL_INVALID_ENUM, "%s(0x%x)", state ? "glEnable" : "glDisable", cap); @@ -1430,7 +1439,11 @@ _mesa_IsEnabled( GLenum cap ) case GL_VERTEX_PROGRAM_CALLBACK_MESA: CHECK_EXTENSION(MESA_program_debug); return ctx->VertexProgram.CallbackEnabled; - +#if FEATURE_ATI_fragment_shader + case GL_FRAGMENT_SHADER_ATI: + CHECK_EXTENSION(ATI_fragment_shader); + return ctx->ATIFragmentShader.Enabled; +#endif /* FEATURE_ATI_fragment_shader */ default: _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap); return GL_FALSE; diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c index 3f9d91dfe7..6fb57b2657 100644 --- a/src/mesa/main/enums.c +++ b/src/mesa/main/enums.c @@ -765,6 +765,8 @@ static enum_elt all_enums[] = { "GL_TEXTURE1_ARB", 0x84C1 }, { "GL_TEXTURE2_ARB", 0x84C2 }, { "GL_TEXTURE3_ARB", 0x84C3 }, + { "GL_TEXTURE4_ARB", 0x84C4 }, + { "GL_TEXTURE5_ARB", 0x84C5 }, { "GL_ACTIVE_TEXTURE_ARB", 0x84E0 }, { "GL_CLIENT_ACTIVE_TEXTURE_ARB", 0x84E1 }, { "GL_MAX_TEXTURE_UNITS_ARB", 0x84E2 }, @@ -887,6 +889,42 @@ static enum_elt all_enums[] = /* GL_3DFX_texture_compression_FXT1 */ { "GL_COMPRESSED_RGB_FXT1_3DFX", 0x86B0 }, { "GL_COMPRESSED_RGBA_FXT1_3DFX", 0x86B1 }, + + /* GL_ATI_fragment_shader */ + { "GL_REG_0_ATI", 0x8921 }, + { "GL_REG_1_ATI", 0x8922 }, + { "GL_REG_2_ATI", 0x8923 }, + { "GL_REG_3_ATI", 0x8924 }, + { "GL_REG_4_ATI", 0x8925 }, + { "GL_REG_5_ATI", 0x8926 }, + + { "GL_CON_0_ATI", 0x8941 }, + { "GL_CON_1_ATI", 0x8942 }, + { "GL_CON_2_ATI", 0x8943 }, + { "GL_CON_3_ATI", 0x8944 }, + { "GL_CON_4_ATI", 0x8945 }, + { "GL_CON_5_ATI", 0x8946 }, + { "GL_CON_6_ATI", 0x8947 }, + { "GL_CON_7_ATI", 0x8948 }, + + { "GL_MOV_ATI", 0x8961 }, + { "GL_ADD_ATI", 0x8963 }, + { "GL_MUL_ATI", 0x8964 }, + { "GL_SUB_ATI", 0x8965 }, + { "GL_DOT3_ATI", 0x8966 }, + { "GL_DOT4_ATI", 0x8967 }, + + { "GL_MAD_ATI", 0x8968 }, + { "GL_LERP_ATI", 0x8969 }, + { "GL_CND_ATI", 0x896A }, + { "GL_CND0_ATI", 0x896B }, + { "GL_DOT2_ADD_ATI", 0x896C }, + { "GL_SECONDARY_INTERPOLATER_ATI", 0x896D }, + + { "SWIZZLE_STR_ATI", 0x8976 }, + { "SWIZZLE_STQ_ATI", 0x8977 }, + { "SWIZZLE_STR_DR_ATI", 0x8978 }, + { "SWIZZLE_STQ_DQ_ATI", 0x8979 }, }; #define Elements(x) sizeof(x)/sizeof(*x) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 76eef8afd4..43924622ff 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -126,6 +126,7 @@ static const struct { { OFF, "GL_ATI_blend_equation_separate", F(EXT_blend_equation_separate) }, { OFF, "GL_ATI_texture_env_combine3", F(ATI_texture_env_combine3)}, { OFF, "GL_ATI_texture_mirror_once", F(ATI_texture_mirror_once)}, + { OFF, "GL_ATI_fragment_shader", F(ATI_fragment_shader)}, { OFF, "GL_HP_occlusion_test", F(HP_occlusion_test) }, { OFF, "GL_IBM_multimode_draw_arrays", F(IBM_multimode_draw_arrays) }, { ON, "GL_IBM_rasterpos_clip", F(IBM_rasterpos_clip) }, @@ -206,6 +207,9 @@ _mesa_enable_sw_extensions(GLcontext *ctx) #if FEATURE_ARB_vertex_shader ctx->Extensions.ARB_vertex_shader = GL_FALSE; /*GL_TRUE;*/ #endif +#endif +#if FEATURE_ATI_fragment_shader + ctx->Extensions.ATI_fragment_shader = GL_TRUE; #endif ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE; ctx->Extensions.ATI_texture_mirror_once = GL_TRUE; diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 646e6ac20f..bbedf4cbd9 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1730,6 +1730,40 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) *params = INT_TO_BOOL(ctx->Const.ColorReadFormat); return; +#if FEATURE_ATI_fragment_shader + case GL_NUM_FRAGMENT_REGISTERS_ATI: + CHECK_EXTENSION_B(ATI_fragment_shader, pname); + *params = INT_TO_BOOL(6); + break; + case GL_NUM_FRAGMENT_CONSTANTS_ATI: + CHECK_EXTENSION_B(ATI_fragment_shader, pname); + *params = INT_TO_BOOL(8); + break; + case GL_NUM_PASSES_ATI: + CHECK_EXTENSION_B(ATI_fragment_shader, pname); + *params = INT_TO_BOOL(2); + break; + case GL_NUM_INSTRUCTIONS_PER_PASS_ATI: + CHECK_EXTENSION_B(ATI_fragment_shader, pname); + *params = INT_TO_BOOL(8); + break; + case GL_NUM_INSTRUCTIONS_TOTAL_ATI: + CHECK_EXTENSION_B(ATI_fragment_shader, pname); + *params = INT_TO_BOOL(16); + break; + case GL_COLOR_ALPHA_PAIRING_ATI: + CHECK_EXTENSION_B(ATI_fragment_shader, pname); + *params = GL_TRUE; + break; + case GL_NUM_LOOPBACK_COMPONENTS_ATI: + CHECK_EXTENSION_B(ATI_fragment_shader, pname); + *params = INT_TO_BOOL(3); + break; + case GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI: + CHECK_EXTENSION_B(ATI_fragment_shader, pname); + *params = INT_TO_BOOL(3); + break; +#endif default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv(pname=0x%x)", pname); } @@ -3331,6 +3365,42 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) *params = (GLdouble) ctx->Const.ColorReadFormat; return; + +#if FEATURE_ATI_fragment_shader + case GL_NUM_FRAGMENT_REGISTERS_ATI: + CHECK_EXTENSION_D(ATI_fragment_shader, pname); + *params = 6; + break; + case GL_NUM_FRAGMENT_CONSTANTS_ATI: + CHECK_EXTENSION_D(ATI_fragment_shader, pname); + *params = 8; + break; + case GL_NUM_PASSES_ATI: + CHECK_EXTENSION_D(ATI_fragment_shader, pname); + *params = 2; + break; + case GL_NUM_INSTRUCTIONS_PER_PASS_ATI: + CHECK_EXTENSION_D(ATI_fragment_shader, pname); + *params = 8; + break; + case GL_NUM_INSTRUCTIONS_TOTAL_ATI: + CHECK_EXTENSION_D(ATI_fragment_shader, pname); + *params = 16; + break; + case GL_COLOR_ALPHA_PAIRING_ATI: + CHECK_EXTENSION_D(ATI_fragment_shader, pname); + *params = GL_TRUE; + break; + case GL_NUM_LOOPBACK_COMPONENTS_ATI: + CHECK_EXTENSION_D(ATI_fragment_shader, pname); + *params = 3; + break; + case GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI: + CHECK_EXTENSION_D(ATI_fragment_shader, pname); + *params = 3; + break; +#endif + default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetDoublev(pname=0x%x)", pname); } @@ -4908,6 +4978,40 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) *params = (GLfloat) ctx->Const.ColorReadFormat; return; +#if FEATURE_ATI_fragment_shader + case GL_NUM_FRAGMENT_REGISTERS_ATI: + CHECK_EXTENSION_F(ATI_fragment_shader, pname); + *params = 6; + break; + case GL_NUM_FRAGMENT_CONSTANTS_ATI: + CHECK_EXTENSION_F(ATI_fragment_shader, pname); + *params = 8; + break; + case GL_NUM_PASSES_ATI: + CHECK_EXTENSION_F(ATI_fragment_shader, pname); + *params = 2; + break; + case GL_NUM_INSTRUCTIONS_PER_PASS_ATI: + CHECK_EXTENSION_F(ATI_fragment_shader, pname); + *params = 8; + break; + case GL_NUM_INSTRUCTIONS_TOTAL_ATI: + CHECK_EXTENSION_F(ATI_fragment_shader, pname); + *params = 16; + break; + case GL_COLOR_ALPHA_PAIRING_ATI: + CHECK_EXTENSION_F(ATI_fragment_shader, pname); + *params = GL_TRUE; + break; + case GL_NUM_LOOPBACK_COMPONENTS_ATI: + CHECK_EXTENSION_F(ATI_fragment_shader, pname); + *params = 3; + break; + case GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI: + CHECK_EXTENSION_F(ATI_fragment_shader, pname); + *params = 3; + break; +#endif default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv(0x%x)", pname); } @@ -6523,6 +6627,40 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) *params = ctx->Const.ColorReadFormat; return; +#if FEATURE_ATI_fragment_shader + case GL_NUM_FRAGMENT_REGISTERS_ATI: + CHECK_EXTENSION_I(ATI_fragment_shader, pname); + *params = 6; + break; + case GL_NUM_FRAGMENT_CONSTANTS_ATI: + CHECK_EXTENSION_I(ATI_fragment_shader, pname); + *params = 8; + break; + case GL_NUM_PASSES_ATI: + CHECK_EXTENSION_I(ATI_fragment_shader, pname); + *params = 2; + break; + case GL_NUM_INSTRUCTIONS_PER_PASS_ATI: + CHECK_EXTENSION_I(ATI_fragment_shader, pname); + *params = 8; + break; + case GL_NUM_INSTRUCTIONS_TOTAL_ATI: + CHECK_EXTENSION_I(ATI_fragment_shader, pname); + *params = 16; + break; + case GL_COLOR_ALPHA_PAIRING_ATI: + CHECK_EXTENSION_I(ATI_fragment_shader, pname); + *params = GL_TRUE; + break; + case GL_NUM_LOOPBACK_COMPONENTS_ATI: + CHECK_EXTENSION_I(ATI_fragment_shader, pname); + *params = 3; + break; + case GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI: + CHECK_EXTENSION_I(ATI_fragment_shader, pname); + *params = 3; + break; +#endif default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv(pname=0x%x)", pname); } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a53fb12753..bf24596c06 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -625,6 +625,7 @@ struct gl_enable_attrib GLboolean VertexProgramTwoSide; /* GL_ARB_point_sprite / GL_NV_point_sprite */ GLboolean PointSprite; + GLboolean FragmentShaderATI; }; @@ -1659,6 +1660,21 @@ struct fp_machine GLuint CondCodes[4]; }; +/** + * ATI_fragment_shader runtime state + */ +#define ATI_FS_INPUT_PRIMARY 0 +#define ATI_FS_INPUT_SECONDARY 1 + +/* 6 register sets - 2 inputs (primary, secondary) */ +struct atifs_machine +{ + GLfloat Registers[6][4]; + GLfloat PrevPassRegisters[6][4]; + GLfloat Inputs[2][4]; + GLuint pass; +}; + /** * Names of the various vertex/fragment register files @@ -1680,7 +1696,7 @@ enum register_file /** Vertex and fragment instructions */ struct vp_instruction; struct fp_instruction; - +struct atifs_instruction; struct program_parameter_list; @@ -1738,6 +1754,13 @@ struct fragment_program #endif }; +struct ati_fragment_shader +{ + struct program Base; + struct atifs_instruction *Instructions; + GLfloat Constants[8][4]; + GLint cur_pass; +}; /** * State common to vertex and fragment programs. @@ -1799,6 +1822,17 @@ struct gl_fragment_program_state #endif }; +/* + * State for GL_fragment_shader + */ +struct gl_ati_fragment_shader_state +{ + GLboolean Enabled; + GLboolean _Enabled; + GLboolean Compiling; + struct atifs_machine Machine; /* machine state */ + struct ati_fragment_shader *Current; +}; /* * State for GL_ARB_occlusion_query @@ -1844,6 +1878,9 @@ struct gl_shared_state #endif #if FEATURE_ARB_fragment_program struct program *DefaultFragmentProgram; +#endif +#if FEATURE_ATI_fragment_shader + struct program *DefaultFragmentShader; #endif /*@}*/ @@ -2064,6 +2101,7 @@ struct gl_extensions GLboolean APPLE_packed_pixels; GLboolean ATI_texture_mirror_once; GLboolean ATI_texture_env_combine3; + GLboolean ATI_fragment_shader; GLboolean HP_occlusion_test; GLboolean IBM_rasterpos_clip; GLboolean IBM_multimode_draw_arrays; @@ -2476,6 +2514,7 @@ struct __GLcontextRec struct gl_program_state Program; /**< for vertex or fragment progs */ struct gl_vertex_program_state VertexProgram; /**< GL_NV_vertex_program */ struct gl_fragment_program_state FragmentProgram; /**< GL_NV_fragment_program */ + struct gl_ati_fragment_shader_state ATIFragmentShader; /**< GL_ATI_fragment_shader */ struct gl_occlusion_state Occlusion; /**< GL_ARB_occlusion_query */ /*@}*/ diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 76724c0e85..64bb02cf01 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -37,6 +37,9 @@ #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program #include "arbprogram.h" #endif +#if FEATURE_ATI_fragment_shader +#include "atifragshader.h" +#endif #include "attrib.h" #include "blend.h" #if FEATURE_ARB_vertex_buffer_object @@ -745,6 +748,24 @@ _mesa_init_exec_table(struct _glapi_table *exec) exec->GetAttribLocationARB = _mesa_GetAttribLocationARB; #endif #endif /* FEATURE_ARB_shader_objects */ + + /* GL_ATI_fragment_shader */ +#if FEATURE_ATI_fragment_shader + exec->GenFragmentShadersATI = _mesa_GenFragmentShadersATI; + exec->BindFragmentShaderATI = _mesa_BindFragmentShaderATI; + exec->DeleteFragmentShaderATI = _mesa_DeleteFragmentShaderATI; + exec->BeginFragmentShaderATI = _mesa_BeginFragmentShaderATI; + exec->EndFragmentShaderATI = _mesa_EndFragmentShaderATI; + exec->PassTexCoordATI = _mesa_PassTexCoordATI; + exec->SampleMapATI = _mesa_SampleMapATI; + exec->ColorFragmentOp1ATI = _mesa_ColorFragmentOp1ATI; + exec->ColorFragmentOp2ATI = _mesa_ColorFragmentOp2ATI; + exec->ColorFragmentOp3ATI = _mesa_ColorFragmentOp3ATI; + exec->AlphaFragmentOp1ATI = _mesa_AlphaFragmentOp1ATI; + exec->AlphaFragmentOp2ATI = _mesa_AlphaFragmentOp2ATI; + exec->AlphaFragmentOp3ATI = _mesa_AlphaFragmentOp3ATI; + exec->SetFragmentShaderConstantATI = _mesa_SetFragmentShaderConstantATI; +#endif } @@ -881,6 +902,8 @@ update_program(GLcontext *ctx) && ctx->VertexProgram.Current->Instructions; ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled && ctx->FragmentProgram.Current->Instructions; + ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled + && ctx->ATIFragmentShader.Current->Instructions; } diff --git a/src/mesa/shader/atifragshader.c b/src/mesa/shader/atifragshader.c new file mode 100644 index 0000000000..dbffa37f4f --- /dev/null +++ b/src/mesa/shader/atifragshader.c @@ -0,0 +1,419 @@ +/** + * \file atifragshader.c + * \author David Airlie + * Copyright (C) 2004 David Airlie 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 + * DAVID AIRLIE 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. + */ + +#include "glheader.h" +#include "context.h" +#include "hash.h" +#include "imports.h" +#include "macros.h" +#include "enums.h" +#include "mtypes.h" +#include "atifragshader.h" + +#define MESA_DEBUG_ATI_FS 0 + +extern struct program _mesa_DummyProgram; + +static void +new_inst(struct ati_fragment_shader *prog) +{ + prog->Base.NumInstructions++; +} + +#if MESA_DEBUG_ATI_FS +static char * +create_dst_mod_str(GLuint mod) +{ + static char ret_str[1024]; + + _mesa_memset(ret_str, 0, 1024); + if (mod & GL_2X_BIT_ATI) + _mesa_strncat(ret_str, "|2X", 1024); + + if (mod & GL_4X_BIT_ATI) + _mesa_strncat(ret_str, "|4X", 1024); + + if (mod & GL_8X_BIT_ATI) + _mesa_strncat(ret_str, "|8X", 1024); + if (mod & GL_HALF_BIT_ATI) + _mesa_strncat(ret_str, "|HA", 1024); + if (mod & GL_QUARTER_BIT_ATI) + _mesa_strncat(ret_str, "|QU", 1024); + if (mod & GL_EIGHTH_BIT_ATI) + _mesa_strncat(ret_str, "|EI", 1024); + + if (mod & GL_SATURATE_BIT_ATI) + _mesa_strncat(ret_str, "|SAT", 1024); + + if (_mesa_strlen(ret_str) == 0) + _mesa_strncat(ret_str, "NONE", 1024); + return ret_str; +} + +static char *atifs_ops[] = {"ColorFragmentOp1ATI", "ColorFragmentOp2ATI", "ColorFragmentOp3ATI", + "AlphaFragmentOp1ATI", "AlphaFragmentOp2ATI", "AlphaFragmentOp3ATI" }; + +static void debug_op(GLint optype, GLuint arg_count, GLenum op, GLuint dst, + GLuint dstMask, GLuint dstMod, GLuint arg1, + GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, + GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, + GLuint arg3Rep, GLuint arg3Mod) +{ + char *op_name; + + op_name = atifs_ops[(arg_count-1)+(optype?3:0)]; + + fprintf(stderr, "%s(%s, %s", op_name, _mesa_lookup_enum_by_nr(op), + _mesa_lookup_enum_by_nr(dst)); + if (!optype) + fprintf(stderr, ", %d", dstMask); + + fprintf(stderr, ", %s", create_dst_mod_str(dstMod)); + + fprintf(stderr, ", %s, %s, %d", _mesa_lookup_enum_by_nr(arg1), + _mesa_lookup_enum_by_nr(arg1Rep), arg1Mod); + if (arg_count>1) + fprintf(stderr, ", %s, %s, %d", _mesa_lookup_enum_by_nr(arg2), + _mesa_lookup_enum_by_nr(arg2Rep), arg2Mod); + if (arg_count>2) + fprintf(stderr, ", %s, %s, %d", _mesa_lookup_enum_by_nr(arg3), + _mesa_lookup_enum_by_nr(arg3Rep), arg3Mod); + + fprintf(stderr,")\n"); + +} +#endif + +GLuint GLAPIENTRY +_mesa_GenFragmentShadersATI(GLuint range) +{ + GLuint first; + GLuint i; + GET_CURRENT_CONTEXT(ctx); + + first = _mesa_HashFindFreeKeyBlock(ctx->Shared->Programs, range); + for (i = 0; i < range; i++) { + _mesa_HashInsert(ctx->Shared->Programs, first + i, &_mesa_DummyProgram); + } + + return first; +} + +void GLAPIENTRY +_mesa_BindFragmentShaderATI(GLuint id) +{ + struct program *prog; + GET_CURRENT_CONTEXT(ctx); + struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; + + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + + if (curProg->Base.Id == id) { + return; + } + + if (curProg->Base.Id != 0) { + curProg->Base.RefCount--; + if (curProg->Base.RefCount <= 0) { + _mesa_HashRemove(ctx->Shared->Programs, id); + } + } + + /* Go bind */ + if (id == 0) { + prog = ctx->Shared->DefaultFragmentShader; + } + else { + prog = (struct program *) _mesa_HashLookup(ctx->Shared->Programs, id); + if (!prog || prog == &_mesa_DummyProgram) { + /* allocate a new program now */ + prog = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_SHADER_ATI, id); + if (!prog) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindFragmentShaderATI"); + return; + } + _mesa_HashInsert(ctx->Shared->Programs, id, prog); + } + + } + + /* do actual bind */ + ctx->ATIFragmentShader.Current = (struct ati_fragment_shader *) prog; + + ASSERT(ctx->ATIFragmentShader.Current); + if (prog) + prog->RefCount++; + + /*if (ctx->Driver.BindProgram) + ctx->Driver.BindProgram(ctx, target, prog); */ +} + +void GLAPIENTRY +_mesa_DeleteFragmentShaderATI(GLuint id) +{ + GET_CURRENT_CONTEXT(ctx); + + if (id != 0) { + struct program *prog = (struct program *) + _mesa_HashLookup(ctx->Shared->Programs, id); + if (prog == &_mesa_DummyProgram) { + _mesa_HashRemove(ctx->Shared->Programs, id); + } + else if (prog) { + if (ctx->ATIFragmentShader.Current && + ctx->ATIFragmentShader.Current->Base.Id == id) { + _mesa_BindFragmentShaderATI(0); + } + } + if (!prog->DeletePending) { + prog->DeletePending = GL_TRUE; + prog->RefCount--; + } + if (prog->RefCount <= 0) { + _mesa_HashRemove(ctx->Shared->Programs, id); + ctx->Driver.DeleteProgram(ctx, prog); + } + } +} + +void GLAPIENTRY +_mesa_BeginFragmentShaderATI(void) +{ + GET_CURRENT_CONTEXT(ctx); + + /* malloc the instructions here - not sure if the best place but its + a start */ + ctx->ATIFragmentShader.Current->Instructions = + (struct atifs_instruction *) + _mesa_calloc(sizeof(struct atifs_instruction) * MAX_NUM_PASSES_ATI * + MAX_NUM_INSTRUCTIONS_PER_PASS_ATI * 2); + + ctx->ATIFragmentShader.Current->cur_pass = 0; + ctx->ATIFragmentShader.Compiling = 1; +} + +void GLAPIENTRY +_mesa_EndFragmentShaderATI(void) +{ + GET_CURRENT_CONTEXT(ctx); +#if MESA_DEBUG_ATI_FS + struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; + GLint i; +#endif + + ctx->ATIFragmentShader.Compiling = 0; + +#if MESA_DEBUG_ATI_FS + for (i = 0; i < curProg->Base.NumInstructions; i++) { + GLuint op0 = curProg->Instructions[i].Opcode[0]; + GLuint op1 = curProg->Instructions[i].Opcode[1]; + const char *op0_enum = op0 > 5 ? _mesa_lookup_enum_by_nr(op0) : "0"; + const char *op1_enum = op1 > 5 ? _mesa_lookup_enum_by_nr(op1) : "0"; + GLuint count0 = curProg->Instructions[i].ArgCount[0]; + GLuint count1 = curProg->Instructions[i].ArgCount[1]; + + fprintf(stderr, "%2d %04X %s %d %04X %s %d\n", i, op0, op0_enum, count0, + op1, op1_enum, count1); + } +#endif +} + +void GLAPIENTRY +_mesa_PassTexCoordATI(GLuint dst, GLuint coord, GLenum swizzle) +{ + GET_CURRENT_CONTEXT(ctx); + struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; + GLint ci; + struct atifs_instruction *curI; + + new_inst(curProg); + ci = curProg->Base.NumInstructions - 1; + /* some validation + if ((swizzle != GL_SWIZZLE_STR_ATI) || + (swizzle != GL_SWIZZLE_STQ_ATI) || + (swizzle != GL_SWIZZLE_STR_DR_ATI) || + (swizzle != GL_SWIZZLE_STQ_DQ_ATI)) + */ + + /* add the instructions */ + curI = &curProg->Instructions[ci]; + + curI->Opcode[0] = ATI_FRAGMENT_SHADER_PASS_OP; + curI->DstReg[0].Index = dst; + curI->SrcReg[0][0].Index = coord; + curI->DstReg[0].Swizzle = swizzle; + +#if MESA_DEBUG_ATI_FS + _mesa_debug(ctx, "%s(%s, %s, %s)\n", __FUNCTION__, + _mesa_lookup_enum_by_nr(dst), _mesa_lookup_enum_by_nr(coord), + _mesa_lookup_enum_by_nr(swizzle)); +#endif +} + +void GLAPIENTRY +_mesa_SampleMapATI(GLuint dst, GLuint interp, GLenum swizzle) +{ + GET_CURRENT_CONTEXT(ctx); + struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; + GLint ci; + struct atifs_instruction *curI; + + new_inst(curProg); + + ci = curProg->Base.NumInstructions - 1; + /* add the instructions */ + curI = &curProg->Instructions[ci]; + + curI->Opcode[0] = ATI_FRAGMENT_SHADER_SAMPLE_OP; + curI->DstReg[0].Index = dst; + curI->DstReg[0].Swizzle = swizzle; + + curI->SrcReg[0][0].Index = interp; + +#if MESA_DEBUG_ATI_FS + _mesa_debug(ctx, "%s(%s, %s, %s)\n", __FUNCTION__, + _mesa_lookup_enum_by_nr(dst), _mesa_lookup_enum_by_nr(interp), + _mesa_lookup_enum_by_nr(swizzle)); +#endif +} + +static void +_mesa_FragmentOpXATI(GLint optype, GLuint arg_count, GLenum op, GLuint dst, + GLuint dstMask, GLuint dstMod, GLuint arg1, + GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, + GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, + GLuint arg3Rep, GLuint arg3Mod) +{ + GET_CURRENT_CONTEXT(ctx); + struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; + GLint ci; + struct atifs_instruction *curI; + + /* decide whether this is a new instruction or not ... all color instructions are new */ + if (optype == 0) + new_inst(curProg); + + ci = curProg->Base.NumInstructions - 1; + + /* add the instructions */ + curI = &curProg->Instructions[ci]; + + curI->Opcode[optype] = op; + + curI->SrcReg[optype][0].Index = arg1; + curI->SrcReg[optype][0].argRep = arg1Rep; + curI->SrcReg[optype][0].argMod = arg1Mod; + curI->ArgCount[optype] = arg_count; + + if (arg2) { + curI->SrcReg[optype][1].Index = arg2; + curI->SrcReg[optype][1].argRep = arg2Rep; + curI->SrcReg[optype][1].argMod = arg2Mod; + } + + if (arg3) { + curI->SrcReg[optype][2].Index = arg3; + curI->SrcReg[optype][2].argRep = arg3Rep; + curI->SrcReg[optype][2].argMod = arg3Mod; + } + + curI->DstReg[optype].Index = dst; + curI->DstReg[optype].dstMod = dstMod; + curI->DstReg[optype].dstMask = dstMask; + +#if MESA_DEBUG_ATI_FS + debug_op(optype, arg_count, op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, arg3Rep, arg3Mod); +#endif + +} + +void GLAPIENTRY +_mesa_ColorFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMask, + GLuint dstMod, GLuint arg1, GLuint arg1Rep, + GLuint arg1Mod) +{ + _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_COLOR_OP, 1, op, dst, dstMask, + dstMod, arg1, arg1Rep, arg1Mod, 0, 0, 0, 0, 0, 0); +} + +void GLAPIENTRY +_mesa_ColorFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMask, + GLuint dstMod, GLuint arg1, GLuint arg1Rep, + GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, + GLuint arg2Mod) +{ + _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_COLOR_OP, 2, op, dst, dstMask, + dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, + arg2Mod, 0, 0, 0); +} + +void GLAPIENTRY +_mesa_ColorFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMask, + GLuint dstMod, GLuint arg1, GLuint arg1Rep, + GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, + GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, + GLuint arg3Mod) +{ + _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_COLOR_OP, 3, op, dst, dstMask, + dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, + arg2Mod, arg3, arg3Rep, arg3Mod); +} + +void GLAPIENTRY +_mesa_AlphaFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, + GLuint arg1Rep, GLuint arg1Mod) +{ + _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_ALPHA_OP, 1, op, dst, 0, dstMod, + arg1, arg1Rep, arg1Mod, 0, 0, 0, 0, 0, 0); +} + +void GLAPIENTRY +_mesa_AlphaFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, + GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, + GLuint arg2Rep, GLuint arg2Mod) +{ + _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_ALPHA_OP, 2, op, dst, 0, dstMod, + arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, 0, 0, + 0); +} + +void GLAPIENTRY +_mesa_AlphaFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, + GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, + GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, + GLuint arg3Rep, GLuint arg3Mod) +{ + _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_ALPHA_OP, 3, op, dst, 0, dstMod, + arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, + arg3Rep, arg3Mod); +} + +void GLAPIENTRY +_mesa_SetFragmentShaderConstantATI(GLuint dst, const GLfloat * value) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint dstindex = dst - GL_CON_0_ATI; + struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; + + COPY_4V(curProg->Constants[dstindex], value); +} diff --git a/src/mesa/shader/atifragshader.h b/src/mesa/shader/atifragshader.h new file mode 100644 index 0000000000..82ac4746b6 --- /dev/null +++ b/src/mesa/shader/atifragshader.h @@ -0,0 +1,105 @@ +/* + * Mesa 3-D graphics library ATI Fragment Shader + * + * Copyright (C) 2004 David Airlie All Rights Reserved. + * + */ + +#ifndef ATIFRAGSHADER_H +#define ATIFRAGSHADER_H + +#define MAX_NUM_INSTRUCTIONS_PER_PASS_ATI 8 +#define MAX_NUM_PASSES_ATI 2 +#define MAX_NUM_FRAGMENT_REGISTERS_ATI 6 + +struct ati_fs_opcode_st +{ + GLenum opcode; + GLint num_src_args; +}; + +extern struct ati_fs_opcode_st ati_fs_opcodes[]; + +struct atifragshader_src_register +{ + GLuint Index; + GLuint argRep; + GLuint argMod; +}; + +struct atifragshader_dst_register +{ + GLuint Index; + GLuint dstMod; + GLuint dstMask; + GLuint Swizzle; +}; + +#define ATI_FRAGMENT_SHADER_COLOR_OP 0 +#define ATI_FRAGMENT_SHADER_ALPHA_OP 1 +#define ATI_FRAGMENT_SHADER_PASS_OP 2 +#define ATI_FRAGMENT_SHADER_SAMPLE_OP 3 + +/* two opcodes - one for color/one for alpha - also pass/sample */ +/* up to three source registers for most ops */ +struct atifs_instruction +{ + GLenum Opcode[2]; + GLuint ArgCount[2]; + struct atifragshader_src_register SrcReg[2][3]; + struct atifragshader_dst_register DstReg[2]; +}; + +extern GLuint GLAPIENTRY _mesa_GenFragmentShadersATI(GLuint range); + +extern void GLAPIENTRY _mesa_BindFragmentShaderATI(GLuint id); + +extern void GLAPIENTRY _mesa_DeleteFragmentShaderATI(GLuint id); + +extern void GLAPIENTRY _mesa_BeginFragmentShaderATI(void); + +extern void GLAPIENTRY _mesa_EndFragmentShaderATI(void); + +extern void GLAPIENTRY +_mesa_PassTexCoordATI(GLuint dst, GLuint coord, GLenum swizzle); + +extern void GLAPIENTRY +_mesa_SampleMapATI(GLuint dst, GLuint interp, GLenum swizzle); + +extern void GLAPIENTRY +_mesa_ColorFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMask, + GLuint dstMod, GLuint arg1, GLuint arg1Rep, + GLuint arg1Mod); + +extern void GLAPIENTRY +_mesa_ColorFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMask, + GLuint dstMod, GLuint arg1, GLuint arg1Rep, + GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, + GLuint arg2Mod); + +extern void GLAPIENTRY +_mesa_ColorFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMask, + GLuint dstMod, GLuint arg1, GLuint arg1Rep, + GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, + GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, + GLuint arg3Mod); + +extern void GLAPIENTRY +_mesa_AlphaFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, + GLuint arg1Rep, GLuint arg1Mod); + +extern void GLAPIENTRY +_mesa_AlphaFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, + GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, + GLuint arg2Rep, GLuint arg2Mod); + +extern void GLAPIENTRY +_mesa_AlphaFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, + GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, + GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, + GLuint arg3Rep, GLuint arg3Mod); + +extern void GLAPIENTRY +_mesa_SetFragmentShaderConstantATI(GLuint dst, const GLfloat * value); + +#endif diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 307736f79c..e258f67ec1 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -83,6 +83,13 @@ _mesa_init_program(GLcontext *ctx) assert(ctx->FragmentProgram.Current); ctx->FragmentProgram.Current->Base.RefCount++; #endif + +#if FEATURE_ATI_fragment_shader + ctx->ATIFragmentShader.Enabled = GL_FALSE; + ctx->ATIFragmentShader.Current = (struct ati_fragment_shader *) ctx->Shared->DefaultFragmentShader; + assert(ctx->ATIFragmentShader.Current); + ctx->ATIFragmentShader.Current->Base.RefCount++; +#endif } @@ -105,6 +112,13 @@ _mesa_free_program_data(GLcontext *ctx) if (ctx->FragmentProgram.Current->Base.RefCount <= 0) ctx->Driver.DeleteProgram(ctx, &(ctx->FragmentProgram.Current->Base)); } +#endif +#if FEATURE_ATI_fragment_shader + if (ctx->ATIFragmentShader.Current) { + ctx->ATIFragmentShader.Current->Base.RefCount--; + if (ctx->ATIFragmentShader.Current->Base.RefCount <= 0) + ctx->Driver.DeleteProgram(ctx, &(ctx->ATIFragmentShader.Current->Base)); + } #endif _mesa_free((void *) ctx->Program.ErrorString); } @@ -216,6 +230,20 @@ _mesa_init_vertex_program( GLcontext *ctx, struct vertex_program *prog, return NULL; } +/** + * Initialize a new ATI fragment shader object. + */ +struct program * +_mesa_init_ati_fragment_shader( GLcontext *ctx, struct ati_fragment_shader *prog, + GLenum target, GLuint id) +{ + if (prog) + return _mesa_init_program_struct( ctx, &prog->Base, target, id ); + else + return NULL; +} + + /** * Allocate and initialize a new fragment/vertex program object but @@ -240,6 +268,10 @@ _mesa_new_program(GLcontext *ctx, GLenum target, GLuint id) case GL_FRAGMENT_PROGRAM_ARB: return _mesa_init_fragment_program( ctx, CALLOC_STRUCT(fragment_program), target, id ); + case GL_FRAGMENT_SHADER_ATI: + return _mesa_init_ati_fragment_shader( ctx, CALLOC_STRUCT(ati_fragment_shader), + target, id ); + default: _mesa_problem(ctx, "bad target in _mesa_new_program"); return NULL; @@ -289,6 +321,12 @@ _mesa_delete_program(GLcontext *ctx, struct program *prog) if (fprog->Parameters) _mesa_free_parameter_list(fprog->Parameters); } + else if (prog->Target == GL_FRAGMENT_SHADER_ATI) { + struct ati_fragment_shader *atifs = (struct ati_fragment_shader *)prog; + if (atifs->Instructions) + _mesa_free(atifs->Instructions); + } + _mesa_free(prog); } diff --git a/src/mesa/sources b/src/mesa/sources index 404249d047..b3301b218c 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -77,6 +77,7 @@ SWRAST_SOURCES = \ swrast/s_accum.c \ swrast/s_alpha.c \ swrast/s_alphabuf.c \ + swrast/s_atifragshader.c \ swrast/s_auxbuffer.c \ swrast/s_bitmap.c \ swrast/s_blend.c \ @@ -138,6 +139,7 @@ SHADER_SOURCES = \ shader/arbprogparse.c \ shader/arbprogram.c \ shader/arbvertparse.c \ + shader/atifragshader.c \ shader/grammar_mesa.c \ shader/nvfragparse.c \ shader/nvprogram.c \ diff --git a/src/mesa/swrast/s_atifragshader.c b/src/mesa/swrast/s_atifragshader.c new file mode 100644 index 0000000000..da5064324d --- /dev/null +++ b/src/mesa/swrast/s_atifragshader.c @@ -0,0 +1,624 @@ +/* + * + * Copyright (C) 2004 David Airlie 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 + * DAVID AIRLIE 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. + */ + +#include "glheader.h" +#include "colormac.h" +#include "context.h" +#include "atifragshader.h" +#include "macros.h" +#include "program.h" + +#include "s_nvfragprog.h" +#include "s_span.h" +#include "s_texture.h" + +/** + * Fetch a texel. + */ +static void +fetch_texel(GLcontext * ctx, const GLfloat texcoord[4], GLfloat lambda, + GLuint unit, GLfloat color[4]) +{ + GLchan rgba[4]; + SWcontext *swrast = SWRAST_CONTEXT(ctx); + + /* XXX use a float-valued TextureSample routine here!!! */ + swrast->TextureSample[unit] (ctx, unit, ctx->Texture.Unit[unit]._Current, + 1, (const GLfloat(*)[4]) texcoord, + &lambda, &rgba); + color[0] = CHAN_TO_FLOAT(rgba[0]); + color[1] = CHAN_TO_FLOAT(rgba[1]); + color[2] = CHAN_TO_FLOAT(rgba[2]); + color[3] = CHAN_TO_FLOAT(rgba[3]); +} + +static void +apply_swizzle(struct atifs_machine *machine, GLuint reg, GLuint swizzle) +{ + GLfloat s, t, r, q; + + s = machine->Registers[reg][0]; + t = machine->Registers[reg][1]; + r = machine->Registers[reg][2]; + q = machine->Registers[reg][3]; + + switch (swizzle) { + case GL_SWIZZLE_STR_ATI: + machine->Registers[reg][0] = s; + machine->Registers[reg][1] = t; + machine->Registers[reg][2] = r; + break; + case GL_SWIZZLE_STQ_ATI: + machine->Registers[reg][0] = s; + machine->Registers[reg][1] = t; + machine->Registers[reg][2] = q; + break; + case GL_SWIZZLE_STR_DR_ATI: + machine->Registers[reg][0] = s / r; + machine->Registers[reg][1] = t / r; + machine->Registers[reg][2] = 1 / r; + break; + case GL_SWIZZLE_STQ_DQ_ATI: + machine->Registers[reg][0] = s / q; + machine->Registers[reg][1] = t / q; + machine->Registers[reg][2] = 1 / q; + break; + } + machine->Registers[reg][3] = 0.0; +} + +static void +apply_src_rep(GLint optype, GLuint rep, GLfloat * val) +{ + GLint i; + GLint start, end; + if (!rep) + return; + + start = optype ? 3 : 0; + end = optype ? 4 : 3; + + for (i = start; i < end; i++) { + switch (rep) { + case GL_RED: + val[i] = val[0]; + break; + case GL_GREEN: + val[i] = val[1]; + break; + case GL_BLUE: + val[i] = val[2]; + break; + case GL_ALPHA: + val[i] = val[3]; + break; + } + } +} + +static void +apply_src_mod(GLint optype, GLuint mod, GLfloat * val) +{ + GLint i; + GLint start, end; + + if (!mod) + return; + + start = optype ? 3 : 0; + end = optype ? 4 : 3; + + for (i = start; i < end; i++) { + if (mod & GL_COMP_BIT_ATI) + val[i] = 1 - val[i]; + + if (mod & GL_BIAS_BIT_ATI) + val[i] = val[i] - 0.5; + + if (mod & GL_2X_BIT_ATI) + val[i] = 2 * val[i]; + + if (mod & GL_NEGATE_BIT_ATI) + val[i] = -val[i]; + } +} + +static void +apply_dst_mod(GLuint optype, GLuint mod, GLfloat * val) +{ + GLint i; + GLint has_sat = mod & GL_SATURATE_BIT_ATI; + GLint start, end; + + mod &= ~GL_SATURATE_BIT_ATI; + + start = optype ? 3 : 0; + end = optype ? 4 : 3; + + for (i = start; i < end; i++) { + switch (mod) { + case GL_2X_BIT_ATI: + val[i] = 2 * val[i]; + break; + case GL_4X_BIT_ATI: + val[i] = 4 * val[i]; + break; + case GL_8X_BIT_ATI: + val[i] = 8 * val[i]; + break; + case GL_HALF_BIT_ATI: + val[i] = val[i] * 0.5; + break; + case GL_QUARTER_BIT_ATI: + val[i] = val[i] * 0.25; + break; + case GL_EIGHTH_BIT_ATI: + val[i] = val[i] * 0.125; + break; + } + + if (has_sat) { + if (val[i] < 0.0) + val[i] = 0; + else if (val[i] > 1.0) + val[i] = 1.0; + } + else { + if (val[i] < -8.0) + val[i] = -8.0; + else if (val[i] > 8.0) + val[i] = 8.0; + } + } +} + + +static void +write_dst_addr(GLuint optype, GLuint mod, GLuint mask, GLfloat * src, + GLfloat * dst) +{ + GLint i; + apply_dst_mod(optype, mod, src); + + if (optype == ATI_FRAGMENT_SHADER_COLOR_OP) { + if (mask) { + if (mask & GL_RED_BIT_ATI) + dst[0] = src[0]; + + if (mask & GL_GREEN_BIT_ATI) + dst[1] = src[1]; + + if (mask & GL_BLUE_BIT_ATI) + dst[2] = src[2]; + } + else { + for (i = 0; i < 3; i++) + dst[i] = src[i]; + } + } + else + dst[3] = src[3]; +} + +void +finish_pass(struct atifs_machine *machine) +{ + GLint i; + + for (i = 0; i < 6; i++) { + COPY_4V(machine->PrevPassRegisters[i], machine->Registers[i]); + } +} + +/** + * Execute the given fragment shader + * NOTE: we do everything in single-precision floating point; we don't + * currently observe the single/half/fixed-precision qualifiers. + * \param ctx - rendering context + * \param program - the fragment program to execute + * \param machine - machine state (register file) + * \param maxInst - max number of instructions to execute + * \return GL_TRUE if program completed or GL_FALSE if program executed KIL. + */ + +struct ati_fs_opcode_st ati_fs_opcodes[] = { + {GL_ADD_ATI, 2}, + {GL_SUB_ATI, 2}, + {GL_MUL_ATI, 2}, + {GL_MAD_ATI, 3}, + {GL_LERP_ATI, 3}, + {GL_MOV_ATI, 1}, + {GL_CND_ATI, 3}, + {GL_CND0_ATI, 3}, + {GL_DOT2_ADD_ATI, 3}, + {GL_DOT3_ATI, 2}, + {GL_DOT4_ATI, 2} +}; + + + +static void +handle_pass_op(struct atifs_machine *machine, struct atifs_instruction *inst, + const struct sw_span *span, GLuint column) +{ + GLuint idx = inst->DstReg[0].Index - GL_REG_0_ATI; + GLuint swizzle = inst->DstReg[0].Swizzle; + GLuint pass_tex = inst->SrcReg[0][0].Index; + + /* if we get here after passing pass one then we are starting pass two - backup the registers */ + if (machine->pass == 1) { + finish_pass(machine); + machine->pass = 2; + } + if (pass_tex >= GL_TEXTURE0_ARB && pass_tex <= GL_TEXTURE7_ARB) { + pass_tex -= GL_TEXTURE0_ARB; + COPY_4V(machine->Registers[idx], + span->array->texcoords[pass_tex][column]); + } + else if (pass_tex >= GL_REG_0_ATI && pass_tex <= GL_REG_5_ATI + && machine->pass == 2) { + pass_tex -= GL_REG_0_ATI; + COPY_4V(machine->Registers[idx], machine->PrevPassRegisters[pass_tex]); + } + apply_swizzle(machine, idx, swizzle); + +} + +static void +handle_sample_op(GLcontext * ctx, struct atifs_machine *machine, + struct atifs_instruction *inst, const struct sw_span *span, + GLuint column) +{ + GLuint idx = inst->DstReg[0].Index - GL_REG_0_ATI; + GLuint swizzle = inst->DstReg[0].Swizzle; + GLuint sample_tex = inst->SrcReg[0][0].Index; + + /* if we get here after passing pass one then we are starting pass two - backup the registers */ + if (machine->pass == 1) { + finish_pass(machine); + machine->pass = 2; + } + + if (sample_tex >= GL_TEXTURE0_ARB && sample_tex <= GL_TEXTURE7_ARB) { + sample_tex -= GL_TEXTURE0_ARB; + fetch_texel(ctx, span->array->texcoords[sample_tex][column], 0.0F, + sample_tex, machine->Registers[idx]); + } + else if (sample_tex >= GL_REG_0_ATI && sample_tex <= GL_REG_5_ATI) { + /* this is wrong... */ + sample_tex -= GL_REG_0_ATI; + fetch_texel(ctx, machine->Registers[sample_tex], 0, sample_tex, + machine->Registers[idx]); + } + + apply_swizzle(machine, idx, swizzle); +} + +#define SETUP_SRC_REG(optype, i, x) do { \ + if (optype) \ + src[optype][i][3] = x[3]; \ + else \ + COPY_3V(src[optype][i], x); \ + } while (0) + +static GLboolean +execute_shader(GLcontext * ctx, + const struct ati_fragment_shader *shader, GLuint maxInst, + struct atifs_machine *machine, const struct sw_span *span, + GLuint column) +{ + GLuint pc; + struct atifs_instruction *inst; + GLint optype; + GLint i; + GLint dstreg; + GLfloat src[2][3][4]; + GLfloat zeros[4] = { 0.0, 0.0, 0.0, 0.0 }; + GLfloat ones[4] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat dst[2][4], *dstp; + + for (pc = 0; pc < shader->Base.NumInstructions; pc++) { + inst = &shader->Instructions[pc]; + + if (inst->Opcode[0] == ATI_FRAGMENT_SHADER_PASS_OP) + handle_pass_op(machine, inst, span, column); + else if (inst->Opcode[0] == ATI_FRAGMENT_SHADER_SAMPLE_OP) + handle_sample_op(ctx, machine, inst, span, column); + else { + if (machine->pass == 0) + machine->pass = 1; + + /* setup the source registers for color and alpha ops */ + for (optype = 0; optype < 2; optype++) { + for (i = 0; i < inst->ArgCount[optype]; i++) { + GLint index = inst->SrcReg[optype][i].Index; + + if (index >= GL_REG_0_ATI && index <= GL_REG_5_ATI) + SETUP_SRC_REG(optype, i, + machine->Registers[index - GL_REG_0_ATI]); + else if (index >= GL_CON_0_ATI && index <= GL_CON_7_ATI) + SETUP_SRC_REG(optype, i, + shader->Constants[index - GL_CON_0_ATI]); + else if (index == GL_ONE) + SETUP_SRC_REG(optype, i, ones); + else if (index == GL_ZERO) + SETUP_SRC_REG(optype, i, zeros); + else if (index == GL_PRIMARY_COLOR_EXT) + SETUP_SRC_REG(optype, i, + machine->Inputs[ATI_FS_INPUT_PRIMARY]); + else if (index == GL_SECONDARY_INTERPOLATOR_ATI) + SETUP_SRC_REG(optype, i, + machine->Inputs[ATI_FS_INPUT_SECONDARY]); + + apply_src_rep(optype, inst->SrcReg[optype][i].argRep, + src[optype][i]); + apply_src_mod(optype, inst->SrcReg[optype][i].argMod, + src[optype][i]); + } + } + + /* Execute the operations - color then alpha */ + for (optype = 0; optype < 2; optype++) { + if (inst->Opcode[optype]) { + switch (inst->Opcode[optype]) { + case GL_ADD_ATI: + if (!optype) + for (i = 0; i < 3; i++) { + dst[optype][i] = + src[optype][0][i] + src[optype][1][i]; + } + else + dst[optype][3] = src[optype][0][3] + src[optype][1][3]; + break; + case GL_SUB_ATI: + if (!optype) + for (i = 0; i < 3; i++) { + dst[optype][i] = + src[optype][0][i] - src[optype][1][i]; + } + else + dst[optype][3] = src[optype][0][3] - src[optype][1][3]; + break; + case GL_MUL_ATI: + if (!optype) + for (i = 0; i < 3; i++) { + dst[optype][i] = + src[optype][0][i] * src[optype][1][i]; + } + else + dst[optype][3] = src[optype][0][3] * src[optype][1][3]; + break; + case GL_MAD_ATI: + if (!optype) + for (i = 0; i < 3; i++) { + dst[optype][i] = + src[optype][0][i] * src[optype][1][i] + + src[optype][2][i]; + } + else + dst[optype][3] = + src[optype][0][3] * src[optype][1][3] + + src[optype][2][3]; + break; + case GL_LERP_ATI: + if (!optype) + for (i = 0; i < 3; i++) { + dst[optype][i] = + src[optype][0][i] * src[optype][1][i] + (1 - + src + [optype] + [0][i]) * + src[optype][2][i]; + } + else + dst[optype][3] = + src[optype][0][3] * src[optype][1][3] + (1 - + src[optype] + [0][3]) * + src[optype][2][3]; + break; + + case GL_MOV_ATI: + if (!optype) + for (i = 0; i < 3; i++) { + dst[optype][i] = src[optype][0][i]; + } + else + dst[optype][3] = src[optype][0][3]; + break; + case GL_CND_ATI: + if (!optype) { + for (i = 0; i < 3; i++) { + dst[optype][i] = + (src[optype][2][i] > + 0.5) ? src[optype][0][i] : src[optype][1][i]; + } + } + else { + dst[optype][3] = + (src[optype][2][3] > + 0.5) ? src[optype][0][3] : src[optype][1][3]; + } + break; + + case GL_CND0_ATI: + if (!optype) + for (i = 0; i < 3; i++) { + dst[optype][i] = + (src[optype][2][i] >= + 0) ? src[optype][0][i] : src[optype][1][i]; + } + else { + dst[optype][3] = + (src[optype][2][3] >= + 0) ? src[optype][0][3] : src[optype][1][3]; + } + break; + case GL_DOT2_ADD_ATI: + { + GLfloat result; + + /* DOT 2 always uses the source from the color op */ + result = src[0][0][0] * src[0][1][0] + + src[0][0][1] * src[0][1][1] + src[0][2][2]; + if (!optype) { + for (i = 0; i < 3; i++) { + dst[optype][i] = result; + } + } + else + dst[optype][3] = result; + + } + break; + case GL_DOT3_ATI: + { + GLfloat result; + + /* DOT 3 always uses the source from the color op */ + result = src[0][0][0] * src[0][1][0] + + src[0][0][1] * src[0][1][1] + + src[0][0][2] * src[0][1][2]; + + if (!optype) { + for (i = 0; i < 3; i++) { + dst[optype][i] = result; + } + } + else + dst[optype][3] = result; + } + break; + case GL_DOT4_ATI: + { + GLfloat result; + + /* DOT 4 always uses the source from the color op */ + result = src[optype][0][0] * src[0][1][0] + + src[0][0][1] * src[0][1][1] + + src[0][0][2] * src[0][1][2] + + src[0][0][3] * src[0][1][3]; + if (!optype) { + for (i = 0; i < 3; i++) { + dst[optype][i] = result; + } + } + else + dst[optype][3] = result; + } + break; + + } + } + } + + /* write out the destination registers */ + for (optype = 0; optype < 2; optype++) { + if (inst->Opcode[optype]) { + dstreg = inst->DstReg[optype].Index; + dstp = machine->Registers[dstreg - GL_REG_0_ATI]; + + write_dst_addr(optype, inst->DstReg[optype].dstMod, + inst->DstReg[optype].dstMask, dst[optype], + dstp); + } + } + } + } + return GL_TRUE; +} + +static void +init_machine(GLcontext * ctx, struct atifs_machine *machine, + const struct ati_fragment_shader *shader, + const struct sw_span *span, GLuint col) +{ + GLint i, j; + + for (i = 0; i < 6; i++) { + for (j = 0; j < 4; j++) + ctx->ATIFragmentShader.Machine.Registers[i][j] = 0.0; + + } + + ctx->ATIFragmentShader.Machine.Inputs[ATI_FS_INPUT_PRIMARY][0] = + CHAN_TO_FLOAT(span->array->rgba[col][0]); + ctx->ATIFragmentShader.Machine.Inputs[ATI_FS_INPUT_PRIMARY][1] = + CHAN_TO_FLOAT(span->array->rgba[col][1]); + ctx->ATIFragmentShader.Machine.Inputs[ATI_FS_INPUT_PRIMARY][2] = + CHAN_TO_FLOAT(span->array->rgba[col][2]); + ctx->ATIFragmentShader.Machine.Inputs[ATI_FS_INPUT_PRIMARY][3] = + CHAN_TO_FLOAT(span->array->rgba[col][3]); + + ctx->ATIFragmentShader.Machine.Inputs[ATI_FS_INPUT_SECONDARY][0] = + CHAN_TO_FLOAT(span->array->spec[col][0]); + ctx->ATIFragmentShader.Machine.Inputs[ATI_FS_INPUT_SECONDARY][1] = + CHAN_TO_FLOAT(span->array->spec[col][1]); + ctx->ATIFragmentShader.Machine.Inputs[ATI_FS_INPUT_SECONDARY][2] = + CHAN_TO_FLOAT(span->array->spec[col][2]); + ctx->ATIFragmentShader.Machine.Inputs[ATI_FS_INPUT_SECONDARY][3] = + CHAN_TO_FLOAT(span->array->spec[col][3]); + + ctx->ATIFragmentShader.Machine.pass = 0; +} + + + +/** + * Execute the current fragment program, operating on the given span. + */ +void +_swrast_exec_fragment_shader(GLcontext * ctx, struct sw_span *span) +{ + const struct ati_fragment_shader *shader = ctx->ATIFragmentShader.Current; + GLuint i; + + ctx->_CurrentProgram = GL_FRAGMENT_SHADER_ATI; + + for (i = 0; i < span->end; i++) { + if (span->array->mask[i]) { + init_machine(ctx, &ctx->ATIFragmentShader.Machine, + ctx->ATIFragmentShader.Current, span, i); + + if (execute_shader(ctx, shader, ~0, + &ctx->ATIFragmentShader.Machine, span, i)) { + span->array->mask[i] = GL_FALSE; + } + + { + const GLfloat *colOut = + ctx->ATIFragmentShader.Machine.Registers[0]; + + /*fprintf(stderr,"outputs %f %f %f %f\n", colOut[0], colOut[1], colOut[2], colOut[3]); */ + UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][RCOMP], colOut[0]); + UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][GCOMP], colOut[1]); + UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][BCOMP], colOut[2]); + UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][ACOMP], colOut[3]); + } + } + + } + + + ctx->_CurrentProgram = 0; + +} diff --git a/src/mesa/swrast/s_atifragshader.h b/src/mesa/swrast/s_atifragshader.h new file mode 100644 index 0000000000..269be1f2e4 --- /dev/null +++ b/src/mesa/swrast/s_atifragshader.h @@ -0,0 +1,37 @@ +/* + * Mesa 3-D graphics library + * Version: 6.1 + * + * Copyright (C) 1999-2003 David Airlie 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 + * DAVID AIRLIE 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 S_ATIFRAGSHADER_H +#define S_ATIFRAGSHADER_H + + +#include "s_context.h" + + +extern void +_swrast_exec_fragment_shader( GLcontext *ctx, struct sw_span *span ); + + +#endif diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index f81fc11835..b923f0a673 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -108,6 +108,10 @@ _swrast_update_rasterflags( GLcontext *ctx ) rasterMask |= FRAGPROG_BIT; } + if (ctx->ATIFragmentShader._Enabled) { + rasterMask |= ATIFRAGSHADER_BIT; + } + SWRAST_CONTEXT(ctx)->_RasterMask = rasterMask; } diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h index aba32755d1..6eac3232b0 100644 --- a/src/mesa/swrast/s_context.h +++ b/src/mesa/swrast/s_context.h @@ -246,6 +246,7 @@ typedef void (*swrast_tri_func)( GLcontext *ctx, const SWvertex *, #define OCCLUSION_BIT 0x800 /**< GL_HP_occlusion_test enabled */ #define TEXTURE_BIT 0x1000 /**< Texturing really enabled */ #define FRAGPROG_BIT 0x2000 /**< Fragment program enabled */ +#define ATIFRAGSHADER_BIT 0x4000 /**< ATI Fragment shader enabled */ /*@}*/ #define _SWRAST_NEW_RASTERMASK (_NEW_BUFFERS| \ diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 8441530956..449ae837dc 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -36,6 +36,7 @@ #include "macros.h" #include "imports.h" +#include "s_atifragshader.h" #include "s_alpha.h" #include "s_alphabuf.h" #include "s_blend.h" @@ -127,7 +128,7 @@ _swrast_span_default_texcoords( GLcontext *ctx, struct sw_span *span ) GLuint i; for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { const GLfloat *tc = ctx->Current.RasterTexCoords[i]; - if (ctx->FragmentProgram._Enabled) { + if (ctx->FragmentProgram._Enabled || ctx->ATIFragmentShader._Enabled) { COPY_4V(span->tex[i], tc); } else if (tc[3] > 0.0F) { @@ -1153,6 +1154,8 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span) if (ctx->FragmentProgram._Enabled) /* XXX interpolate depth values here??? */ _swrast_exec_fragment_program( ctx, span ); + else if (ctx->ATIFragmentShader._Enabled) + _swrast_exec_fragment_shader( ctx, span ); else if (ctx->Texture._EnabledUnits) _swrast_texture_span( ctx, span ); @@ -1225,6 +1228,8 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span) if (ctx->FragmentProgram._Enabled) _swrast_exec_fragment_program( ctx, span ); + else if (ctx->ATIFragmentShader._Enabled) + _swrast_exec_fragment_shader( ctx, span ); else if (ctx->Texture._EnabledUnits) _swrast_texture_span( ctx, span ); } diff --git a/src/mesa/x86/glapi_x86.S b/src/mesa/x86/glapi_x86.S index fb64025500..5b1802203f 100644 --- a/src/mesa/x86/glapi_x86.S +++ b/src/mesa/x86/glapi_x86.S @@ -898,6 +898,20 @@ GLNAME(gl_dispatch_functions_start): GL_STUB(VertexAttrib4svNV, _gloffset_VertexAttrib4svNV, VertexAttrib4svNV@8) GL_STUB(VertexAttrib4ubNV, _gloffset_VertexAttrib4ubNV, VertexAttrib4ubNV@20) GL_STUB(VertexAttrib4ubvNV, _gloffset_VertexAttrib4ubvNV, VertexAttrib4ubvNV@8) + GL_STUB(GenFragmentShadersATI, _gloffset_GenFragmentShadersATI, GenFragmentShadersATI@4) + GL_STUB(BindFragmentShaderATI, _gloffset_BindFragmentShaderATI, BindFragmentShaderATI@4) + GL_STUB(DeleteFragmentShaderATI, _gloffset_DeleteFragmentShaderATI, DeleteFragmentShaderATI@4) + GL_STUB(BeginFragmentShaderATI, _gloffset_BeginFragmentShaderATI, BeginFragmentShaderATI@0) + GL_STUB(EndFragmentShaderATI, _gloffset_EndFragmentShaderATI, EndFragmentShaderATI@0) + GL_STUB(PassTexCoordATI, _gloffset_PassTexCoordATI, PassTexCoordATI@12) + GL_STUB(SampleMapATI, _gloffset_SampleMapATI, SampleMapATI@12) + GL_STUB(ColorFragmentOp1ATI, _gloffset_ColorFragmentOp1ATI, ColorFragmentOp1ATI@28) + GL_STUB(ColorFragmentOp2ATI, _gloffset_ColorFragmentOp2ATI, ColorFragmentOp2ATI@40) + GL_STUB(ColorFragmentOp3ATI, _gloffset_ColorFragmentOp3ATI, ColorFragmentOp3ATI@52) + GL_STUB(AlphaFragmentOp1ATI, _gloffset_AlphaFragmentOp1ATI, AlphaFragmentOp1ATI@24) + GL_STUB(AlphaFragmentOp2ATI, _gloffset_AlphaFragmentOp2ATI, AlphaFragmentOp2ATI@36) + GL_STUB(AlphaFragmentOp3ATI, _gloffset_AlphaFragmentOp3ATI, AlphaFragmentOp3ATI@48) + GL_STUB(SetFragmentShaderConstantATI, _gloffset_SetFragmentShaderConstantATI, SetFragmentShaderConstantATI@8) GL_STUB(ActiveTexture, _gloffset_ActiveTextureARB, ActiveTexture@4) GL_STUB(ClientActiveTexture, _gloffset_ClientActiveTextureARB, ClientActiveTexture@4) GL_STUB(MultiTexCoord1d, _gloffset_MultiTexCoord1dARB, MultiTexCoord1d@12) -- cgit v1.2.3