7 #include "r300_context.h"
8 #include "r300_fragprog.h"
11 r300BindProgram(GLcontext
*ctx
, GLenum target
, struct gl_program
*prog
)
14 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
15 struct r300_vertex_program_cont
*vp
=(void *)prog
;
19 case GL_VERTEX_PROGRAM_ARB
:
20 //rmesa->curr_vp = (struct gl_vertex_program *)vp;
23 if((vp
->ref_count
% 1500) == 0) {
24 fprintf(stderr
, "id %p, ref_count %d\n", vp
, vp
->ref_count
);
25 _mesa_print_program(&vp
->mesa_program
.Base
);
29 case GL_FRAGMENT_PROGRAM_ARB
:
32 WARN_ONCE("Target not supported yet!\n");
37 static struct gl_program
*
38 r300NewProgram(GLcontext
*ctx
, GLenum target
, GLuint id
)
40 struct r300_vertex_program_cont
*vp
;
41 struct r300_fragment_program
*fp
;
44 case GL_VERTEX_STATE_PROGRAM_NV
:
45 case GL_VERTEX_PROGRAM_ARB
:
46 vp
=CALLOC_STRUCT(r300_vertex_program_cont
);
47 return _mesa_init_vertex_program(ctx
, &vp
->mesa_program
, target
, id
);
48 case GL_FRAGMENT_PROGRAM_ARB
:
49 fp
=CALLOC_STRUCT(r300_fragment_program
);
51 return _mesa_init_fragment_program(ctx
, &fp
->mesa_program
, target
, id
);
52 case GL_FRAGMENT_PROGRAM_NV
:
53 fp
=CALLOC_STRUCT(r300_fragment_program
);
54 return _mesa_init_fragment_program(ctx
, &fp
->mesa_program
, target
, id
);
56 _mesa_problem(ctx
, "Bad target in r300NewProgram");
64 r300DeleteProgram(GLcontext
*ctx
, struct gl_program
*prog
)
67 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
68 struct r300_vertex_program
*vp
=(void *)prog
;
70 if(rmesa
->curr_vp
== vp
)
71 rmesa
->curr_vp
= NULL
;
74 _mesa_delete_program(ctx
, prog
);
78 r300ProgramStringNotify(GLcontext
*ctx
, GLenum target
, struct gl_program
*prog
)
80 struct r300_vertex_program_cont
*vp
=(void *)prog
;
81 struct r300_fragment_program
*fp
= (struct r300_fragment_program
*) prog
;
84 case GL_VERTEX_PROGRAM_ARB
:
86 /*vp->translated = GL_FALSE;
87 memset(&vp->translated, 0, sizeof(struct r300_vertex_program) - sizeof(struct gl_vertex_program));*/
88 /*r300_translate_vertex_shader(vp);*/
90 case GL_FRAGMENT_PROGRAM_ARB
:
91 fp
->translated
= GL_FALSE
;
94 /* need this for tcl fallbacks */
95 _tnl_program_string(ctx
, target
, prog
);
99 r300IsProgramNative(GLcontext
*ctx
, GLenum target
, struct gl_program
*prog
)
101 //struct r300_vertex_program *vp=(void *)prog;
102 //r300ContextPtr rmesa = R300_CONTEXT(ctx);
107 void r300InitShaderFuncs(struct dd_function_table
*functions
)
109 functions
->NewProgram
=r300NewProgram
;
110 functions
->BindProgram
=r300BindProgram
;
111 functions
->DeleteProgram
=r300DeleteProgram
;
112 functions
->ProgramStringNotify
=r300ProgramStringNotify
;
113 functions
->IsProgramNative
=r300IsProgramNative
;