core | glapi | vbo | math | shader | swrast | swrast_setup | tnl | tnl_dd

programopt.c File Reference


Detailed Description

Vertex/Fragment program optimizations and transformations for program options, etc.

Author:
Brian Paul

#include "main/glheader.h"
#include "main/context.h"
#include "prog_parameter.h"
#include "prog_statevars.h"
#include "program.h"
#include "programopt.h"
#include "prog_instruction.h"

Functions

static void _mesa_insert_mvp_dp4_code (GLcontext *ctx, struct gl_vertex_program *vprog)
 This function inserts instructions for coordinate modelview * projection into a vertex program.
static void _mesa_insert_mvp_mad_code (GLcontext *ctx, struct gl_vertex_program *vprog)
void _mesa_insert_mvp_code (GLcontext *ctx, struct gl_vertex_program *vprog)
void _mesa_append_fog_code (GLcontext *ctx, struct gl_fragment_program *fprog)
 Append extra instructions onto the given fragment program to implement the fog mode specified by fprog->FogOption.
static GLboolean is_texture_instruction (const struct prog_instruction *inst)
void _mesa_count_texture_indirections (struct gl_program *prog)
 Count the number of texure indirections in the given program.
void _mesa_count_texture_instructions (struct gl_program *prog)
 Count number of texture instructions in given program and update the program's NumTexInstructions field.
void _mesa_remove_output_reads (struct gl_program *prog, gl_register_file type)
 Scan/rewrite program to remove reads of custom (output) registers.


Function Documentation

void _mesa_append_fog_code ( GLcontext ctx,
struct gl_fragment_program fprog 
)

Append extra instructions onto the given fragment program to implement the fog mode specified by fprog->FogOption.

The fragment.fogcoord input is used to compute the fog blend factor.

XXX with a little work, this function could be adapted to add fog code to vertex programs too.

void _mesa_count_texture_indirections ( struct gl_program prog  ) 

Count the number of texure indirections in the given program.

The program's NumTexIndirections field will be updated. See the GL_ARB_fragment_program spec (issue 24) for details. XXX we count texture indirections in texenvprogram.c (maybe use this code instead and elsewhere).

void _mesa_count_texture_instructions ( struct gl_program prog  ) 

Count number of texture instructions in given program and update the program's NumTexInstructions field.

void _mesa_insert_mvp_code ( GLcontext ctx,
struct gl_vertex_program vprog 
)

static void _mesa_insert_mvp_dp4_code ( GLcontext ctx,
struct gl_vertex_program vprog 
) [static]

This function inserts instructions for coordinate modelview * projection into a vertex program.

May be used to implement the position_invariant option.

static void _mesa_insert_mvp_mad_code ( GLcontext ctx,
struct gl_vertex_program vprog 
) [static]

void _mesa_remove_output_reads ( struct gl_program prog,
gl_register_file  type 
)

Scan/rewrite program to remove reads of custom (output) registers.

The passed type has to be either PROGRAM_OUTPUT or PROGRAM_VARYING (for vertex shaders). In GLSL shaders, varying vars can be read and written. On some hardware, trying to read an output register causes trouble. So, rewrite the program to use a temporary register in this case.

static GLboolean is_texture_instruction ( const struct prog_instruction inst  )  [static]


Generated on Sun Sep 27 06:48:02 2009 for Mesa Vertex and Fragment Program code by  doxygen 1.5.4