st_cb_program.c File Reference

Include dependency graph for st_cb_program.c:

Go to the source code of this file.

Functions

static void st_bind_program (GLcontext *ctx, GLenum target, struct gl_program *prog)
 Called via ctx->Driver.BindProgram() to bind an ARB vertex or fragment program.
static void st_use_program (GLcontext *ctx, GLuint program)
 Called via ctx->Driver.UseProgram() to bind a linked GLSL program (vertex shader + fragment shader).
static struct gl_program * st_new_program (GLcontext *ctx, GLenum target, GLuint id)
 Called via ctx->Driver.NewProgram() to allocate a new vertex or fragment program.
void st_delete_program (GLcontext *ctx, struct gl_program *prog)
static GLboolean st_is_program_native (GLcontext *ctx, GLenum target, struct gl_program *prog)
static void st_program_string_notify (GLcontext *ctx, GLenum target, struct gl_program *prog)
void st_init_program_functions (struct dd_function_table *functions)

Variables

static GLuint SerialNo = 1


Function Documentation

static void st_bind_program ( GLcontext *  ctx,
GLenum  target,
struct gl_program *  prog 
) [static]

Called via ctx->Driver.BindProgram() to bind an ARB vertex or fragment program.

Definition at line 58 of file st_cb_program.c.

References st_context::dirty, st_state_flags::st, st_context(), ST_NEW_FRAGMENT_PROGRAM, and ST_NEW_VERTEX_PROGRAM.

00061 {
00062    struct st_context *st = st_context(ctx);
00063 
00064    switch (target) {
00065    case GL_VERTEX_PROGRAM_ARB: 
00066       st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
00067       break;
00068    case GL_FRAGMENT_PROGRAM_ARB:
00069       st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
00070       break;
00071    }
00072 }

void st_delete_program ( GLcontext *  ctx,
struct gl_program *  prog 
)

Definition at line 132 of file st_cb_program.c.

References assert, st_fragment_program::Base, st_fragment_program::bitmap_program, st_context::cso_context, cso_delete_fragment_shader(), cso_delete_vertex_shader(), st_context::draw, draw_delete_vertex_shader(), st_vertex_program::draw_shader, st_fragment_program::driver_shader, st_vertex_program::driver_shader, FREE, st_context(), st_free_translated_vertex_programs(), st_fragment_program::state, st_vertex_program::state, pipe_shader_state::tokens, and st_fragment_program::vertex_programs.

00133 {
00134    struct st_context *st = st_context(ctx);
00135 
00136    switch( prog->Target ) {
00137    case GL_VERTEX_PROGRAM_ARB:
00138       {
00139          struct st_vertex_program *stvp = (struct st_vertex_program *) prog;
00140 
00141          if (stvp->driver_shader) {
00142             cso_delete_vertex_shader(st->cso_context, stvp->driver_shader);
00143             stvp->driver_shader = NULL;
00144          }
00145 
00146          if (stvp->draw_shader) {
00147 #if FEATURE_feedback || FEATURE_drawpix
00148             /* this would only have been allocated for the RasterPos path */
00149             draw_delete_vertex_shader(st->draw, stvp->draw_shader);
00150             stvp->draw_shader = NULL;
00151 #endif
00152          }
00153 
00154          if (stvp->state.tokens) {
00155             FREE((void *) stvp->state.tokens);
00156             stvp->state.tokens = NULL;
00157          }
00158       }
00159       break;
00160    case GL_FRAGMENT_PROGRAM_ARB:
00161       {
00162          struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
00163 
00164          if (stfp->driver_shader) {
00165             cso_delete_fragment_shader(st->cso_context, stfp->driver_shader);
00166             stfp->driver_shader = NULL;
00167          }
00168          
00169          if (stfp->state.tokens) {
00170             FREE((void *) stfp->state.tokens);
00171             stfp->state.tokens = NULL;
00172          }
00173 
00174          if (stfp->bitmap_program) {
00175             struct gl_program *prg = &stfp->bitmap_program->Base.Base;
00176             _mesa_reference_program(ctx, &prg, NULL);
00177             stfp->bitmap_program = NULL;
00178          }
00179 
00180          st_free_translated_vertex_programs(st, stfp->vertex_programs);
00181       }
00182       break;
00183    default:
00184       assert(0); /* problem */
00185    }
00186 
00187    /* delete base class */
00188    _mesa_delete_program( ctx, prog );
00189 }

void st_init_program_functions ( struct dd_function_table *  functions  ) 

Definition at line 258 of file st_cb_program.c.

References st_bind_program(), st_delete_program(), st_is_program_native(), st_new_program(), st_program_string_notify(), and st_use_program().

00259 {
00260    functions->BindProgram = st_bind_program;
00261    functions->UseProgram = st_use_program;
00262    functions->NewProgram = st_new_program;
00263    functions->DeleteProgram = st_delete_program;
00264    functions->IsProgramNative = st_is_program_native;
00265    functions->ProgramStringNotify = st_program_string_notify;
00266 }

static GLboolean st_is_program_native ( GLcontext *  ctx,
GLenum  target,
struct gl_program *  prog 
) [static]

Definition at line 192 of file st_cb_program.c.

00195 {
00196    return GL_TRUE;
00197 }

static struct gl_program* st_new_program ( GLcontext *  ctx,
GLenum  target,
GLuint  id 
) [static, read]

Called via ctx->Driver.NewProgram() to allocate a new vertex or fragment program.

Definition at line 96 of file st_cb_program.c.

References assert, st_fragment_program::Base, st_vertex_program::Base, CALLOC_STRUCT, st_fragment_program::serialNo, SerialNo, and st_vertex_program::serialNo.

00099 {
00100    switch (target) {
00101    case GL_VERTEX_PROGRAM_ARB: {
00102       struct st_vertex_program *prog = CALLOC_STRUCT(st_vertex_program);
00103 
00104       prog->serialNo = SerialNo++;
00105 
00106       return _mesa_init_vertex_program( ctx, 
00107                                         &prog->Base,
00108                                         target, 
00109                                         id );
00110    }
00111 
00112    case GL_FRAGMENT_PROGRAM_ARB:
00113    case GL_FRAGMENT_PROGRAM_NV: {
00114       struct st_fragment_program *prog = CALLOC_STRUCT(st_fragment_program);
00115 
00116       prog->serialNo = SerialNo++;
00117 
00118       return _mesa_init_fragment_program( ctx, 
00119                                           &prog->Base,
00120                                           target, 
00121                                           id );
00122    }
00123 
00124    default:
00125       assert(0);
00126       return NULL;
00127    }
00128 }

static void st_program_string_notify ( GLcontext *  ctx,
GLenum  target,
struct gl_program *  prog 
) [static]

Definition at line 200 of file st_cb_program.c.

References st_vertex_program::Base, st_fragment_program::Base, st_context::cso_context, cso_delete_fragment_shader(), cso_delete_vertex_shader(), st_context::dirty, st_context::draw, draw_delete_vertex_shader(), st_vertex_program::draw_shader, st_vertex_program::driver_shader, st_fragment_program::driver_shader, st_context::fp, FREE, st_vertex_program::param_state, st_fragment_program::param_state, st_vertex_program::serialNo, st_fragment_program::serialNo, st_state_flags::st, st_context(), ST_NEW_FRAGMENT_PROGRAM, ST_NEW_VERTEX_PROGRAM, st_vertex_program::state, st_fragment_program::state, pipe_shader_state::tokens, and st_context::vp.

00203 {
00204    struct st_context *st = st_context(ctx);
00205 
00206    if (target == GL_FRAGMENT_PROGRAM_ARB) {
00207       struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
00208 
00209       stfp->serialNo++;
00210 
00211       if (stfp->driver_shader) {
00212          cso_delete_fragment_shader(st->cso_context, stfp->driver_shader);
00213          stfp->driver_shader = NULL;
00214       }
00215 
00216       if (stfp->state.tokens) {
00217          FREE((void *) stfp->state.tokens);
00218          stfp->state.tokens = NULL;
00219       }
00220 
00221       stfp->param_state = stfp->Base.Base.Parameters->StateFlags;
00222 
00223       if (st->fp == stfp)
00224          st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
00225    }
00226    else if (target == GL_VERTEX_PROGRAM_ARB) {
00227       struct st_vertex_program *stvp = (struct st_vertex_program *) prog;
00228 
00229       stvp->serialNo++;
00230 
00231       if (stvp->driver_shader) {
00232          cso_delete_vertex_shader(st->cso_context, stvp->driver_shader);
00233          stvp->driver_shader = NULL;
00234       }
00235 
00236       if (stvp->draw_shader) {
00237 #if FEATURE_feedback || FEATURE_drawpix
00238          /* this would only have been allocated for the RasterPos path */
00239          draw_delete_vertex_shader(st->draw, stvp->draw_shader);
00240          stvp->draw_shader = NULL;
00241 #endif
00242       }
00243 
00244       if (stvp->state.tokens) {
00245          FREE((void *) stvp->state.tokens);
00246          stvp->state.tokens = NULL;
00247       }
00248 
00249       stvp->param_state = stvp->Base.Base.Parameters->StateFlags;
00250 
00251       if (st->vp == stvp)
00252          st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
00253    }
00254 }

static void st_use_program ( GLcontext *  ctx,
GLuint  program 
) [static]

Called via ctx->Driver.UseProgram() to bind a linked GLSL program (vertex shader + fragment shader).

Definition at line 79 of file st_cb_program.c.

References st_context::dirty, st_state_flags::st, st_context(), ST_NEW_FRAGMENT_PROGRAM, and ST_NEW_VERTEX_PROGRAM.

00081 {
00082    struct st_context *st = st_context(ctx);
00083 
00084    st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
00085    st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
00086 
00087    _mesa_use_program(ctx, program);
00088 }


Variable Documentation

GLuint SerialNo = 1 [static]

Definition at line 51 of file st_cb_program.c.


Generated on Tue Sep 29 06:25:53 2009 for Gallium3D by  doxygen 1.5.4