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

ffvertex_prog.c File Reference


Detailed Description

Create a vertex program to execute the current fixed function T&L pipeline.

Author:
Keith Whitwell

#include "main/glheader.h"
#include "main/mtypes.h"
#include "main/macros.h"
#include "main/enums.h"
#include "main/ffvertex_prog.h"
#include "shader/program.h"
#include "shader/prog_cache.h"
#include "shader/prog_instruction.h"
#include "shader/prog_parameter.h"
#include "shader/prog_print.h"
#include "shader/prog_statevars.h"

Data Structures

struct  state_key
struct  ureg
 Use uregs to represent registers internally, translate to Mesa's expected formats on emit. More...
struct  tnl_program

Defines

#define NUM_UNITS   MAX2(MAX_TEXTURE_COORD_UNITS, MAX_LIGHTS)
 Max of number of lights and texture coord units.
#define TXG_NONE   0
#define TXG_OBJ_LINEAR   1
#define TXG_EYE_LINEAR   2
#define TXG_SPHERE_MAP   3
#define TXG_REFLECTION_MAP   4
#define TXG_NORMAL_MAP   5
#define DISASSEM   0
#define X   SWIZZLE_X
#define Y   SWIZZLE_Y
#define Z   SWIZZLE_Z
#define W   SWIZZLE_W
#define register_param1(p, s0)   register_param5(p,s0,0,0,0,0)
#define register_param2(p, s0, s1)   register_param5(p,s0,s1,0,0,0)
#define register_param3(p, s0, s1, s2)   register_param5(p,s0,s1,s2,0,0)
#define register_param4(p, s0, s1, s2, s3)   register_param5(p,s0,s1,s2,s3,0)
#define register_const1f(p, s0)   register_const4f(p, s0, 0, 0, 1)
#define register_scalar_const(p, s0)   register_const4f(p, s0, s0, s0, s0)
#define register_const2f(p, s0, s1)   register_const4f(p, s0, s1, 0, 1)
#define register_const3f(p, s0, s1, s2)   register_const4f(p, s0, s1, s2, 1)
#define emit_op3(p, op, dst, mask, src0, src1, src2)   emit_op3fn(p, op, dst, mask, src0, src1, src2, __FUNCTION__, __LINE__)
#define emit_op2(p, op, dst, mask, src0, src1)   emit_op3fn(p, op, dst, mask, src0, src1, undef, __FUNCTION__, __LINE__)
#define emit_op1(p, op, dst, mask, src0)   emit_op3fn(p, op, dst, mask, src0, undef, undef, __FUNCTION__, __LINE__)
#define SCENE_COLOR_BITS(side)

Functions

static GLuint translate_texgen (GLboolean enabled, GLenum mode)
static GLboolean check_active_shininess (GLcontext *ctx, const struct state_key *key, GLuint side)
static void make_state_key (GLcontext *ctx, struct state_key *key)
static struct ureg make_ureg (GLuint file, GLint idx)
static struct ureg negate (struct ureg reg)
static struct ureg swizzle (struct ureg reg, int x, int y, int z, int w)
static struct ureg swizzle1 (struct ureg reg, int x)
static struct ureg get_temp (struct tnl_program *p)
static struct ureg reserve_temp (struct tnl_program *p)
static void release_temp (struct tnl_program *p, struct ureg reg)
static void release_temps (struct tnl_program *p)
static struct ureg register_param5 (struct tnl_program *p, GLint s0, GLint s1, GLint s2, GLint s3, GLint s4)
static struct ureg register_input (struct tnl_program *p, GLuint input)
 
Parameters:
input one of VERT_ATTRIB_x tokens.

static struct ureg register_output (struct tnl_program *p, GLuint output)
 
Parameters:
input one of VERT_RESULT_x tokens.

static struct ureg register_const4f (struct tnl_program *p, GLfloat s0, GLfloat s1, GLfloat s2, GLfloat s3)
static GLboolean is_undef (struct ureg reg)
static struct ureg get_identity_param (struct tnl_program *p)
static void register_matrix_param5 (struct tnl_program *p, GLint s0, GLint s1, GLint s2, GLint s3, GLint s4, struct ureg *matrix)
static void emit_arg (struct prog_src_register *src, struct ureg reg)
static void emit_dst (struct prog_dst_register *dst, struct ureg reg, GLuint mask)
static void debug_insn (struct prog_instruction *inst, const char *fn, GLuint line)
static void emit_op3fn (struct tnl_program *p, enum prog_opcode op, struct ureg dest, GLuint mask, struct ureg src0, struct ureg src1, struct ureg src2, const char *fn, GLuint line)
static struct ureg make_temp (struct tnl_program *p, struct ureg reg)
static void emit_matrix_transform_vec4 (struct tnl_program *p, struct ureg dest, const struct ureg *mat, struct ureg src)
static void emit_transpose_matrix_transform_vec4 (struct tnl_program *p, struct ureg dest, const struct ureg *mat, struct ureg src)
static void emit_matrix_transform_vec3 (struct tnl_program *p, struct ureg dest, const struct ureg *mat, struct ureg src)
static void emit_normalize_vec3 (struct tnl_program *p, struct ureg dest, struct ureg src)
static void emit_passthrough (struct tnl_program *p, GLuint input, GLuint output)
static struct ureg get_eye_position (struct tnl_program *p)
static struct ureg get_eye_position_z (struct tnl_program *p)
static struct ureg get_eye_position_normalized (struct tnl_program *p)
static struct ureg get_transformed_normal (struct tnl_program *p)
static void build_hpos (struct tnl_program *p)
static GLuint material_attrib (GLuint side, GLuint property)
static void set_material_flags (struct tnl_program *p)
 Get a bitmask of which material values vary on a per-vertex basis.
static struct ureg get_material (struct tnl_program *p, GLuint side, GLuint property)
static struct ureg get_scenecolor (struct tnl_program *p, GLuint side)
 Either return a precalculated constant value or emit code to calculate these values dynamically in the case where material calls are present between begin/end pairs.
static struct ureg get_lightprod (struct tnl_program *p, GLuint light, GLuint side, GLuint property)
static struct ureg calculate_light_attenuation (struct tnl_program *p, GLuint i, struct ureg VPpli, struct ureg dist)
static void emit_degenerate_lit (struct tnl_program *p, struct ureg lit, struct ureg dots)
 Compute: lit.y = MAX(0, dots.x) lit.z = SLT(0, dots.x).
static void build_lighting (struct tnl_program *p)
static void build_fog (struct tnl_program *p)
static void build_reflect_texgen (struct tnl_program *p, struct ureg dest, GLuint writemask)
static void build_sphere_texgen (struct tnl_program *p, struct ureg dest, GLuint writemask)
static void build_texture_transform (struct tnl_program *p)
static void build_atten_pointsize (struct tnl_program *p)
 Point size attenuation computation.
static void build_array_pointsize (struct tnl_program *p)
 Pass-though per-vertex point size, from user's point size array.
static void build_tnl_program (struct tnl_program *p)
static void create_new_program (const struct state_key *key, struct gl_vertex_program *program, GLboolean mvp_with_dp4, GLuint max_temps)
struct gl_vertex_program_mesa_get_fixed_func_vertex_program (GLcontext *ctx)
 Return a vertex program which implements the current fixed-function transform/lighting/texgen operations.

Variables

static struct ureg undef


Define Documentation

#define DISASSEM   0

#define emit_op1 ( p,
op,
dst,
mask,
src0   )     emit_op3fn(p, op, dst, mask, src0, undef, undef, __FUNCTION__, __LINE__)

#define emit_op2 ( p,
op,
dst,
mask,
src0,
src1   )     emit_op3fn(p, op, dst, mask, src0, src1, undef, __FUNCTION__, __LINE__)

#define emit_op3 ( p,
op,
dst,
mask,
src0,
src1,
src2   )     emit_op3fn(p, op, dst, mask, src0, src1, src2, __FUNCTION__, __LINE__)

#define NUM_UNITS   MAX2(MAX_TEXTURE_COORD_UNITS, MAX_LIGHTS)

Max of number of lights and texture coord units.

#define register_const1f ( p,
s0   )     register_const4f(p, s0, 0, 0, 1)

#define register_const2f ( p,
s0,
s1   )     register_const4f(p, s0, s1, 0, 1)

#define register_const3f ( p,
s0,
s1,
s2   )     register_const4f(p, s0, s1, s2, 1)

#define register_param1 ( p,
s0   )     register_param5(p,s0,0,0,0,0)

#define register_param2 ( p,
s0,
s1   )     register_param5(p,s0,s1,0,0,0)

#define register_param3 ( p,
s0,
s1,
s2   )     register_param5(p,s0,s1,s2,0,0)

#define register_param4 ( p,
s0,
s1,
s2,
s3   )     register_param5(p,s0,s1,s2,s3,0)

#define register_scalar_const ( p,
s0   )     register_const4f(p, s0, s0, s0, s0)

#define SCENE_COLOR_BITS ( side   ) 

Value:

#define TXG_EYE_LINEAR   2

#define TXG_NONE   0

#define TXG_NORMAL_MAP   5

#define TXG_OBJ_LINEAR   1

#define TXG_REFLECTION_MAP   4

#define TXG_SPHERE_MAP   3

#define W   SWIZZLE_W

#define X   SWIZZLE_X

#define Y   SWIZZLE_Y

#define Z   SWIZZLE_Z


Function Documentation

struct gl_vertex_program* _mesa_get_fixed_func_vertex_program ( GLcontext ctx  )  [read]

Return a vertex program which implements the current fixed-function transform/lighting/texgen operations.

XXX move this into core mesa (main/)

static void build_array_pointsize ( struct tnl_program p  )  [static]

Pass-though per-vertex point size, from user's point size array.

static void build_atten_pointsize ( struct tnl_program p  )  [static]

Point size attenuation computation.

static void build_fog ( struct tnl_program p  )  [static]

static void build_hpos ( struct tnl_program p  )  [static]

static void build_lighting ( struct tnl_program p  )  [static]

static void build_reflect_texgen ( struct tnl_program p,
struct ureg  dest,
GLuint  writemask 
) [static]

static void build_sphere_texgen ( struct tnl_program p,
struct ureg  dest,
GLuint  writemask 
) [static]

static void build_texture_transform ( struct tnl_program p  )  [static]

static void build_tnl_program ( struct tnl_program p  )  [static]

static struct ureg calculate_light_attenuation ( struct tnl_program p,
GLuint  i,
struct ureg  VPpli,
struct ureg  dist 
) [static, read]

static GLboolean check_active_shininess ( GLcontext ctx,
const struct state_key key,
GLuint  side 
) [static]

static void create_new_program ( const struct state_key key,
struct gl_vertex_program program,
GLboolean  mvp_with_dp4,
GLuint  max_temps 
) [static]

static void debug_insn ( struct prog_instruction inst,
const char *  fn,
GLuint  line 
) [static]

static void emit_arg ( struct prog_src_register src,
struct ureg  reg 
) [static]

static void emit_degenerate_lit ( struct tnl_program p,
struct ureg  lit,
struct ureg  dots 
) [static]

Compute: lit.y = MAX(0, dots.x) lit.z = SLT(0, dots.x).

static void emit_dst ( struct prog_dst_register dst,
struct ureg  reg,
GLuint  mask 
) [static]

static void emit_matrix_transform_vec3 ( struct tnl_program p,
struct ureg  dest,
const struct ureg mat,
struct ureg  src 
) [static]

static void emit_matrix_transform_vec4 ( struct tnl_program p,
struct ureg  dest,
const struct ureg mat,
struct ureg  src 
) [static]

static void emit_normalize_vec3 ( struct tnl_program p,
struct ureg  dest,
struct ureg  src 
) [static]

static void emit_op3fn ( struct tnl_program p,
enum prog_opcode  op,
struct ureg  dest,
GLuint  mask,
struct ureg  src0,
struct ureg  src1,
struct ureg  src2,
const char *  fn,
GLuint  line 
) [static]

static void emit_passthrough ( struct tnl_program p,
GLuint  input,
GLuint  output 
) [static]

static void emit_transpose_matrix_transform_vec4 ( struct tnl_program p,
struct ureg  dest,
const struct ureg mat,
struct ureg  src 
) [static]

static struct ureg get_eye_position ( struct tnl_program p  )  [static, read]

static struct ureg get_eye_position_normalized ( struct tnl_program p  )  [static, read]

static struct ureg get_eye_position_z ( struct tnl_program p  )  [static, read]

static struct ureg get_identity_param ( struct tnl_program p  )  [static, read]

static struct ureg get_lightprod ( struct tnl_program p,
GLuint  light,
GLuint  side,
GLuint  property 
) [static, read]

static struct ureg get_material ( struct tnl_program p,
GLuint  side,
GLuint  property 
) [static, read]

static struct ureg get_scenecolor ( struct tnl_program p,
GLuint  side 
) [static, read]

Either return a precalculated constant value or emit code to calculate these values dynamically in the case where material calls are present between begin/end pairs.

Probably want to shift this to the program compilation phase - if we always emitted the calculation here, a smart compiler could detect that it was constant (given a certain set of inputs), and lift it out of the main loop. That way the programs created here would be independent of the vertex_buffer details.

static struct ureg get_temp ( struct tnl_program p  )  [static, read]

static struct ureg get_transformed_normal ( struct tnl_program p  )  [static, read]

static GLboolean is_undef ( struct ureg  reg  )  [static]

static void make_state_key ( GLcontext ctx,
struct state_key key 
) [static]

static struct ureg make_temp ( struct tnl_program p,
struct ureg  reg 
) [static, read]

static struct ureg make_ureg ( GLuint  file,
GLint  idx 
) [static, read]

static GLuint material_attrib ( GLuint  side,
GLuint  property 
) [static]

static struct ureg negate ( struct ureg  reg  )  [static, read]

static struct ureg register_const4f ( struct tnl_program p,
GLfloat  s0,
GLfloat  s1,
GLfloat  s2,
GLfloat  s3 
) [static, read]

static struct ureg register_input ( struct tnl_program p,
GLuint  input 
) [static, read]

Parameters:
input one of VERT_ATTRIB_x tokens.

static void register_matrix_param5 ( struct tnl_program p,
GLint  s0,
GLint  s1,
GLint  s2,
GLint  s3,
GLint  s4,
struct ureg matrix 
) [static]

static struct ureg register_output ( struct tnl_program p,
GLuint  output 
) [static, read]

Parameters:
input one of VERT_RESULT_x tokens.

static struct ureg register_param5 ( struct tnl_program p,
GLint  s0,
GLint  s1,
GLint  s2,
GLint  s3,
GLint  s4 
) [static, read]

static void release_temp ( struct tnl_program p,
struct ureg  reg 
) [static]

static void release_temps ( struct tnl_program p  )  [static]

static struct ureg reserve_temp ( struct tnl_program p  )  [static, read]

static void set_material_flags ( struct tnl_program p  )  [static]

Get a bitmask of which material values vary on a per-vertex basis.

static struct ureg swizzle ( struct ureg  reg,
int  x,
int  y,
int  z,
int  w 
) [static, read]

static struct ureg swizzle1 ( struct ureg  reg,
int  x 
) [static, read]

static GLuint translate_texgen ( GLboolean  enabled,
GLenum  mode 
) [static]


Variable Documentation

struct ureg undef [static]

Initial value:

 {
   PROGRAM_UNDEFINED,
   0,
   0,
   0,
   0
}


Generated on Sun Sep 27 06:47:45 2009 for Mesa Main by  doxygen 1.5.4