diff options
author | Dave Airlie <airliedfreedesktop.org> | 2004-12-19 03:06:59 +0000 |
---|---|---|
committer | Dave Airlie <airliedfreedesktop.org> | 2004-12-19 03:06:59 +0000 |
commit | 7f752fed993e5e9423abac200dd59141edbada56 (patch) | |
tree | 06eba28f01c81dfbd8c4a9104206765f8731528c /src/mesa/main | |
parent | a803b0c891404dcd7c376e91f6a033cd4e42abc3 (diff) |
Implement software ATI_fragment_shader
no error detection, slow, may not be 100% correct but a good start
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/config.h | 1 | ||||
-rw-r--r-- | src/mesa/main/context.c | 29 | ||||
-rw-r--r-- | src/mesa/main/dlist.c | 68 | ||||
-rw-r--r-- | src/mesa/main/enable.c | 15 | ||||
-rw-r--r-- | src/mesa/main/enums.c | 38 | ||||
-rw-r--r-- | src/mesa/main/extensions.c | 4 | ||||
-rw-r--r-- | src/mesa/main/get.c | 138 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 41 | ||||
-rw-r--r-- | src/mesa/main/state.c | 23 |
9 files changed, 354 insertions, 3 deletions
diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index 01072c397fc..cef8dd74a42 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 3116cb95a1f..98e684d3936 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 348ba495889..8ef5269cd89 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 8968c0aa838..f53ae05d171 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 3f9d91dfe74..6fb57b26579 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 76eef8afd47..43924622ffa 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) }, @@ -207,6 +208,9 @@ _mesa_enable_sw_extensions(GLcontext *ctx) 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; ctx->Extensions.EXT_blend_color = GL_TRUE; diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 646e6ac20fc..bbedf4cbd95 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 a53fb127538..bf24596c062 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 @@ -1845,6 +1879,9 @@ struct gl_shared_state #if FEATURE_ARB_fragment_program struct program *DefaultFragmentProgram; #endif +#if FEATURE_ATI_fragment_shader + struct program *DefaultFragmentShader; +#endif /*@}*/ #if FEATURE_ARB_vertex_buffer_object @@ -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 76724c0e853..64bb02cf01e 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; } |