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

texenvprogram.c File Reference

#include "glheader.h"
#include "imports.h"
#include "shader/program.h"
#include "shader/prog_parameter.h"
#include "shader/prog_cache.h"
#include "shader/prog_instruction.h"
#include "shader/prog_print.h"
#include "shader/prog_statevars.h"
#include "shader/programopt.h"
#include "texenvprogram.h"

Data Structures

struct  texenvprog_cache_item
struct  mode_opt
struct  state_key
struct  ureg
 Use uregs to represent registers internally, translate to Mesa's expected formats on emit. More...
struct  texenv_fragment_program
 State used to build the fragment program:. More...

Defines

#define MAX_INSTRUCTIONS   ((MAX_TEXTURE_COORD_UNITS * 9) + 12)
 Up to nine instructions per tex unit, plus fog, specular color.
#define DISASSEM   (MESA_VERBOSE & VERBOSE_DISASSEM)
#define FOG_LINEAR   0
#define FOG_EXP   1
#define FOG_EXP2   2
#define FOG_UNKNOWN   3
#define OPR_SRC_COLOR   0
#define OPR_ONE_MINUS_SRC_COLOR   1
#define OPR_SRC_ALPHA   2
#define OPR_ONE_MINUS_SRC_ALPHA   3
#define OPR_ZERO   4
#define OPR_ONE   5
#define OPR_UNKNOWN   7
#define SRC_TEXTURE   0
#define SRC_TEXTURE0   1
#define SRC_TEXTURE1   2
#define SRC_TEXTURE2   3
#define SRC_TEXTURE3   4
#define SRC_TEXTURE4   5
#define SRC_TEXTURE5   6
#define SRC_TEXTURE6   7
#define SRC_TEXTURE7   8
#define SRC_CONSTANT   9
#define SRC_PRIMARY_COLOR   10
#define SRC_PREVIOUS   11
#define SRC_ZERO   12
#define SRC_UNKNOWN   15
#define MODE_REPLACE   0
#define MODE_MODULATE   1
#define MODE_ADD   2
#define MODE_ADD_SIGNED   3
#define MODE_INTERPOLATE   4
#define MODE_SUBTRACT   5
#define MODE_DOT3_RGB   6
#define MODE_DOT3_RGB_EXT   7
#define MODE_DOT3_RGBA   8
#define MODE_DOT3_RGBA_EXT   9
#define MODE_MODULATE_ADD_ATI   10
#define MODE_MODULATE_SIGNED_ADD_ATI   11
#define MODE_MODULATE_SUBTRACT_ATI   12
#define MODE_ADD_PRODUCTS   13
#define MODE_ADD_PRODUCTS_SIGNED   14
#define MODE_BUMP_ENVMAP_ATI   15
#define MODE_UNKNOWN   16
#define VERT_BIT_TEX_ANY   (0xff << VERT_ATTRIB_TEX0)
#define VERT_RESULT_TEX_ANY   (0xff << VERT_RESULT_TEX0)
#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 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)

Functions

static GLboolean texenv_doing_secondary_color (GLcontext *ctx)
static GLuint translate_fog_mode (GLenum mode)
static GLuint translate_operand (GLenum operand)
static GLuint translate_source (GLenum src)
static GLuint translate_mode (GLenum envMode, GLenum mode)
 Translate GL combiner state into a MODE_x value.
static GLboolean need_saturate (GLuint mode)
 Do we need to clamp the results of the given texture env/combine mode? If the inputs to the mode are in [0,1] we don't always have to clamp the results.
static GLuint translate_tex_src_bit (GLbitfield bit)
 Translate TEXTURE_x_BIT to TEXTURE_x_INDEX.
static GLbitfield get_fp_input_mask (GLcontext *ctx)
 Identify all possible varying inputs.
static GLuint make_state_key (GLcontext *ctx, struct state_key *key)
 Examine current texture environment state and generate a unique key to identify it.
static struct ureg make_ureg (GLuint file, GLuint idx)
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 negate (struct ureg reg)
static GLboolean is_undef (struct ureg reg)
static struct ureg get_temp (struct texenv_fragment_program *p)
static struct ureg get_tex_temp (struct texenv_fragment_program *p)
static void reserve_temp (struct texenv_fragment_program *p, struct ureg r)
 Mark a temp reg as being no longer allocatable.
static void release_temps (GLcontext *ctx, struct texenv_fragment_program *p)
static struct ureg register_param5 (struct texenv_fragment_program *p, GLint s0, GLint s1, GLint s2, GLint s3, GLint s4)
static GLuint frag_to_vert_attrib (GLuint attrib)
static struct ureg register_input (struct texenv_fragment_program *p, GLuint input)
static void emit_arg (struct prog_src_register *reg, struct ureg ureg)
static void emit_dst (struct prog_dst_register *dst, struct ureg ureg, GLuint mask)
static struct prog_instructionemit_op (struct texenv_fragment_program *p, enum prog_opcode op, struct ureg dest, GLuint mask, GLboolean saturate, struct ureg src0, struct ureg src1, struct ureg src2)
static struct ureg emit_arith (struct texenv_fragment_program *p, enum prog_opcode op, struct ureg dest, GLuint mask, GLboolean saturate, struct ureg src0, struct ureg src1, struct ureg src2)
static struct ureg emit_texld (struct texenv_fragment_program *p, enum prog_opcode op, struct ureg dest, GLuint destmask, GLuint tex_unit, GLuint tex_idx, GLuint tex_shadow, struct ureg coord)
static struct ureg register_const4f (struct texenv_fragment_program *p, GLfloat s0, GLfloat s1, GLfloat s2, GLfloat s3)
static struct ureg get_one (struct texenv_fragment_program *p)
static struct ureg get_half (struct texenv_fragment_program *p)
static struct ureg get_zero (struct texenv_fragment_program *p)
static void program_error (struct texenv_fragment_program *p, const char *msg)
static struct ureg get_source (struct texenv_fragment_program *p, GLuint src, GLuint unit)
static struct ureg emit_combine_source (struct texenv_fragment_program *p, GLuint mask, GLuint unit, GLuint source, GLuint operand)
static GLboolean args_match (const struct state_key *key, GLuint unit)
 Check if the RGB and Alpha sources and operands match for the given texture unit's combinder state.
static struct ureg emit_combine (struct texenv_fragment_program *p, struct ureg dest, GLuint mask, GLboolean saturate, GLuint unit, GLuint nr, GLuint mode, const struct mode_opt *opt)
static struct ureg emit_texenv (struct texenv_fragment_program *p, GLuint unit)
 Generate instructions for one texture unit's env/combiner mode.
static void load_texture (struct texenv_fragment_program *p, GLuint unit)
 Generate instruction for getting a texture source term.
static GLboolean load_texenv_source (struct texenv_fragment_program *p, GLuint src, GLuint unit)
static GLboolean load_texunit_sources (struct texenv_fragment_program *p, GLuint unit)
 Generate instructions for loading all texture source terms.
static GLboolean load_texunit_bumpmap (struct texenv_fragment_program *p, GLuint unit)
 Generate instructions for loading bump map textures.
static void create_new_program (GLcontext *ctx, struct state_key *key, struct gl_fragment_program *program)
 Generate a new fragment program which implements the context's current texture env/combine mode.
struct gl_fragment_program_mesa_get_fixed_func_fragment_program (GLcontext *ctx)
 Return a fragment program which implements the current fixed-function texture, fog and color-sum operations.

Variables

static struct ureg undef


Define Documentation

#define DISASSEM   (MESA_VERBOSE & VERBOSE_DISASSEM)

#define FOG_EXP   1

#define FOG_EXP2   2

#define FOG_LINEAR   0

#define FOG_UNKNOWN   3

#define MAX_INSTRUCTIONS   ((MAX_TEXTURE_COORD_UNITS * 9) + 12)

Up to nine instructions per tex unit, plus fog, specular color.

#define MODE_ADD   2

#define MODE_ADD_PRODUCTS   13

#define MODE_ADD_PRODUCTS_SIGNED   14

#define MODE_ADD_SIGNED   3

#define MODE_BUMP_ENVMAP_ATI   15

#define MODE_DOT3_RGB   6

#define MODE_DOT3_RGB_EXT   7

#define MODE_DOT3_RGBA   8

#define MODE_DOT3_RGBA_EXT   9

#define MODE_INTERPOLATE   4

#define MODE_MODULATE   1

#define MODE_MODULATE_ADD_ATI   10

#define MODE_MODULATE_SIGNED_ADD_ATI   11

#define MODE_MODULATE_SUBTRACT_ATI   12

#define MODE_REPLACE   0

#define MODE_SUBTRACT   5

#define MODE_UNKNOWN   16

#define OPR_ONE   5

#define OPR_ONE_MINUS_SRC_ALPHA   3

#define OPR_ONE_MINUS_SRC_COLOR   1

#define OPR_SRC_ALPHA   2

#define OPR_SRC_COLOR   0

#define OPR_UNKNOWN   7

#define OPR_ZERO   4

#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 SRC_CONSTANT   9

#define SRC_PREVIOUS   11

#define SRC_PRIMARY_COLOR   10

#define SRC_TEXTURE   0

#define SRC_TEXTURE0   1

#define SRC_TEXTURE1   2

#define SRC_TEXTURE2   3

#define SRC_TEXTURE3   4

#define SRC_TEXTURE4   5

#define SRC_TEXTURE5   6

#define SRC_TEXTURE6   7

#define SRC_TEXTURE7   8

#define SRC_UNKNOWN   15

#define SRC_ZERO   12

#define VERT_BIT_TEX_ANY   (0xff << VERT_ATTRIB_TEX0)

#define VERT_RESULT_TEX_ANY   (0xff << VERT_RESULT_TEX0)


Function Documentation

struct gl_fragment_program* _mesa_get_fixed_func_fragment_program ( GLcontext ctx  )  [read]

Return a fragment program which implements the current fixed-function texture, fog and color-sum operations.

static GLboolean args_match ( const struct state_key key,
GLuint  unit 
) [static]

Check if the RGB and Alpha sources and operands match for the given texture unit's combinder state.

When the RGB and A sources and operands match, we can emit fewer instructions.

static void create_new_program ( GLcontext ctx,
struct state_key key,
struct gl_fragment_program program 
) [static]

Generate a new fragment program which implements the context's current texture env/combine mode.

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

static struct ureg emit_arith ( struct texenv_fragment_program p,
enum prog_opcode  op,
struct ureg  dest,
GLuint  mask,
GLboolean  saturate,
struct ureg  src0,
struct ureg  src1,
struct ureg  src2 
) [static, read]

static struct ureg emit_combine ( struct texenv_fragment_program p,
struct ureg  dest,
GLuint  mask,
GLboolean  saturate,
GLuint  unit,
GLuint  nr,
GLuint  mode,
const struct mode_opt opt 
) [static, read]

static struct ureg emit_combine_source ( struct texenv_fragment_program p,
GLuint  mask,
GLuint  unit,
GLuint  source,
GLuint  operand 
) [static, read]

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

static struct prog_instruction* emit_op ( struct texenv_fragment_program p,
enum prog_opcode  op,
struct ureg  dest,
GLuint  mask,
GLboolean  saturate,
struct ureg  src0,
struct ureg  src1,
struct ureg  src2 
) [static, read]

static struct ureg emit_texenv ( struct texenv_fragment_program p,
GLuint  unit 
) [static, read]

Generate instructions for one texture unit's env/combiner mode.

static struct ureg emit_texld ( struct texenv_fragment_program p,
enum prog_opcode  op,
struct ureg  dest,
GLuint  destmask,
GLuint  tex_unit,
GLuint  tex_idx,
GLuint  tex_shadow,
struct ureg  coord 
) [static, read]

static GLuint frag_to_vert_attrib ( GLuint  attrib  )  [static]

static GLbitfield get_fp_input_mask ( GLcontext ctx  )  [static]

Identify all possible varying inputs.

The fragment program will never reference non-varying inputs, but will track them via state constants instead.

This function figures out all the inputs that the fragment program has access to. The bitmask is later reduced to just those which are actually referenced.

static struct ureg get_half ( struct texenv_fragment_program p  )  [static, read]

static struct ureg get_one ( struct texenv_fragment_program p  )  [static, read]

static struct ureg get_source ( struct texenv_fragment_program p,
GLuint  src,
GLuint  unit 
) [static, read]

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

static struct ureg get_tex_temp ( struct texenv_fragment_program p  )  [static, read]

static struct ureg get_zero ( struct texenv_fragment_program p  )  [static, read]

static GLboolean is_undef ( struct ureg  reg  )  [static]

static GLboolean load_texenv_source ( struct texenv_fragment_program p,
GLuint  src,
GLuint  unit 
) [static]

static void load_texture ( struct texenv_fragment_program p,
GLuint  unit 
) [static]

Generate instruction for getting a texture source term.

static GLboolean load_texunit_bumpmap ( struct texenv_fragment_program p,
GLuint  unit 
) [static]

Generate instructions for loading bump map textures.

static GLboolean load_texunit_sources ( struct texenv_fragment_program p,
GLuint  unit 
) [static]

Generate instructions for loading all texture source terms.

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

Examine current texture environment state and generate a unique key to identify it.

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

static GLboolean need_saturate ( GLuint  mode  )  [static]

Do we need to clamp the results of the given texture env/combine mode? If the inputs to the mode are in [0,1] we don't always have to clamp the results.

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

static void program_error ( struct texenv_fragment_program p,
const char *  msg 
) [static]

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

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

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

static void release_temps ( GLcontext ctx,
struct texenv_fragment_program p 
) [static]

static void reserve_temp ( struct texenv_fragment_program p,
struct ureg  r 
) [static]

Mark a temp reg as being no longer allocatable.

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 GLboolean texenv_doing_secondary_color ( GLcontext ctx  )  [static]

static GLuint translate_fog_mode ( GLenum  mode  )  [static]

static GLuint translate_mode ( GLenum  envMode,
GLenum  mode 
) [static]

Translate GL combiner state into a MODE_x value.

static GLuint translate_operand ( GLenum  operand  )  [static]

static GLuint translate_source ( GLenum  src  )  [static]

static GLuint translate_tex_src_bit ( GLbitfield  bit  )  [static]

Translate TEXTURE_x_BIT to TEXTURE_x_INDEX.


Variable Documentation

struct ureg undef [static]

Initial value:

 { 
   PROGRAM_UNDEFINED,
   ~0,
   0,
   0,
   0
}


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