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/shader/program.c | |
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/shader/program.c')
-rw-r--r-- | src/mesa/shader/program.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 307736f79ca..e258f67ec1c 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 } @@ -106,6 +113,13 @@ _mesa_free_program_data(GLcontext *ctx) 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); } |