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

prog_instruction.h File Reference


Detailed Description

Vertex/fragment program instruction datatypes and constants.

Author:
Brian Paul

Keith Whitwell

Ian Romanick <idr@us.ibm.com>

#include "main/mfeatures.h"

Data Structures

struct  prog_src_register
 Instruction source register. More...
struct  prog_dst_register
 Instruction destination register. More...
struct  prog_instruction
 Vertex/fragment program instruction. More...

Defines

#define MAKE_SWIZZLE4(a, b, c, d)   (((a)<<0) | ((b)<<3) | ((c)<<6) | ((d)<<9))
#define SWIZZLE_NOOP   MAKE_SWIZZLE4(0,1,2,3)
#define GET_SWZ(swz, idx)   (((swz) >> ((idx)*3)) & 0x7)
#define GET_BIT(msk, idx)   (((msk) >> (idx)) & 0x1)
#define SWIZZLE_XYZW   MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W)
#define SWIZZLE_XXXX   MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X)
#define SWIZZLE_YYYY   MAKE_SWIZZLE4(SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y)
#define SWIZZLE_ZZZZ   MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z)
#define SWIZZLE_WWWW   MAKE_SWIZZLE4(SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W)
#define INST_INDEX_BITS   10
 Number of bits for the src/dst register Index field.
#define SWIZZLE_X   0
 Swizzle indexes.
#define SWIZZLE_Y   1
#define SWIZZLE_Z   2
#define SWIZZLE_W   3
#define SWIZZLE_ZERO   4
 For SWZ instruction only.
#define SWIZZLE_ONE   5
 For SWZ instruction only.
#define SWIZZLE_NIL   7
 used during shader code gen (undefined value)
#define WRITEMASK_X   0x1
 Writemask values, 1 bit per component.
#define WRITEMASK_Y   0x2
#define WRITEMASK_XY   0x3
#define WRITEMASK_Z   0x4
#define WRITEMASK_XZ   0x5
#define WRITEMASK_YZ   0x6
#define WRITEMASK_XYZ   0x7
#define WRITEMASK_W   0x8
#define WRITEMASK_XW   0x9
#define WRITEMASK_YW   0xa
#define WRITEMASK_XYW   0xb
#define WRITEMASK_ZW   0xc
#define WRITEMASK_XZW   0xd
#define WRITEMASK_YZW   0xe
#define WRITEMASK_XYZW   0xf
#define COND_GT   1
 Condition codes.
#define COND_EQ   2
 equal to zero
#define COND_LT   3
 less than zero
#define COND_UN   4
 unordered (NaN)
#define COND_GE   5
 greater then or equal to zero
#define COND_LE   6
 less then or equal to zero
#define COND_NE   7
 not equal to zero
#define COND_TR   8
 always true
#define COND_FL   9
 always false
#define FLOAT32   0x1
 Instruction precision for GL_NV_fragment_program.
#define FLOAT16   0x2
#define FIXED12   0x4
#define SATURATE_OFF   0
 Saturation modes when storing values.
#define SATURATE_ZERO_ONE   1
#define NEGATE_X   0x1
 Per-component negation masks.
#define NEGATE_Y   0x2
#define NEGATE_Z   0x4
#define NEGATE_W   0x8
#define NEGATE_XYZ   0x7
#define NEGATE_XYZW   0xf
#define NEGATE_NONE   0x0

Typedefs

typedef enum prog_opcode gl_inst_opcode

Enumerations

enum  prog_opcode {
  OPCODE_NOP = 0, OPCODE_ABS, OPCODE_ADD, OPCODE_AND,
  OPCODE_ARA, OPCODE_ARL, OPCODE_ARL_NV, OPCODE_ARR,
  OPCODE_BGNLOOP, OPCODE_BGNSUB, OPCODE_BRA, OPCODE_BRK,
  OPCODE_CAL, OPCODE_CMP, OPCODE_CONT, OPCODE_COS,
  OPCODE_DDX, OPCODE_DDY, OPCODE_DP2, OPCODE_DP2A,
  OPCODE_DP3, OPCODE_DP4, OPCODE_DPH, OPCODE_DST,
  OPCODE_ELSE, OPCODE_END, OPCODE_ENDIF, OPCODE_ENDLOOP,
  OPCODE_ENDSUB, OPCODE_EX2, OPCODE_EXP, OPCODE_FLR,
  OPCODE_FRC, OPCODE_IF, OPCODE_KIL, OPCODE_KIL_NV,
  OPCODE_LG2, OPCODE_LIT, OPCODE_LOG, OPCODE_LRP,
  OPCODE_MAD, OPCODE_MAX, OPCODE_MIN, OPCODE_MOV,
  OPCODE_MUL, OPCODE_NOISE1, OPCODE_NOISE2, OPCODE_NOISE3,
  OPCODE_NOISE4, OPCODE_NOT, OPCODE_NRM3, OPCODE_NRM4,
  OPCODE_OR, OPCODE_PK2H, OPCODE_PK2US, OPCODE_PK4B,
  OPCODE_PK4UB, OPCODE_POW, OPCODE_POPA, OPCODE_PRINT,
  OPCODE_PUSHA, OPCODE_RCC, OPCODE_RCP, OPCODE_RET,
  OPCODE_RFL, OPCODE_RSQ, OPCODE_SCS, OPCODE_SEQ,
  OPCODE_SFL, OPCODE_SGE, OPCODE_SGT, OPCODE_SIN,
  OPCODE_SLE, OPCODE_SLT, OPCODE_SNE, OPCODE_SSG,
  OPCODE_STR, OPCODE_SUB, OPCODE_SWZ, OPCODE_TEX,
  OPCODE_TXB, OPCODE_TXD, OPCODE_TXL, OPCODE_TXP,
  OPCODE_TXP_NV, OPCODE_TRUNC, OPCODE_UP2H, OPCODE_UP2US,
  OPCODE_UP4B, OPCODE_UP4UB, OPCODE_X2D, OPCODE_XOR,
  OPCODE_XPD, MAX_OPCODE
}
 Program instruction opcodes, for both vertex and fragment programs. More...

Functions

void _mesa_init_instructions (struct prog_instruction *inst, GLuint count)
 Initialize program instruction fields to defaults.
struct prog_instruction_mesa_alloc_instructions (GLuint numInst)
 Allocate an array of program instructions.
struct prog_instruction_mesa_realloc_instructions (struct prog_instruction *oldInst, GLuint numOldInst, GLuint numNewInst)
 Reallocate memory storing an array of program instructions.
struct prog_instruction_mesa_copy_instructions (struct prog_instruction *dest, const struct prog_instruction *src, GLuint n)
 Copy an array of program instructions.
void _mesa_free_instructions (struct prog_instruction *inst, GLuint count)
 Free an array of instructions.
GLuint _mesa_num_inst_src_regs (gl_inst_opcode opcode)
 Return the number of src registers for the given instruction/opcode.
GLuint _mesa_num_inst_dst_regs (gl_inst_opcode opcode)
 Return the number of dst registers for the given instruction/opcode.
GLboolean _mesa_is_tex_instruction (gl_inst_opcode opcode)
GLboolean _mesa_check_soa_dependencies (const struct prog_instruction *inst)
 Check if there's a potential src/dst register data dependency when using SOA execution.
const char * _mesa_opcode_string (gl_inst_opcode opcode)
 Return string name for given program opcode.


Define Documentation

#define COND_EQ   2

equal to zero

#define COND_FL   9

always false

#define COND_GE   5

greater then or equal to zero

#define COND_GT   1

Condition codes.

greater than zero

#define COND_LE   6

less then or equal to zero

#define COND_LT   3

less than zero

#define COND_NE   7

not equal to zero

#define COND_TR   8

always true

#define COND_UN   4

unordered (NaN)

#define FIXED12   0x4

#define FLOAT16   0x2

#define FLOAT32   0x1

Instruction precision for GL_NV_fragment_program.

#define GET_BIT ( msk,
idx   )     (((msk) >> (idx)) & 0x1)

#define GET_SWZ ( swz,
idx   )     (((swz) >> ((idx)*3)) & 0x7)

#define INST_INDEX_BITS   10

Number of bits for the src/dst register Index field.

This limits the size of temp/uniform register files.

#define MAKE_SWIZZLE4 ( a,
b,
c,
 )     (((a)<<0) | ((b)<<3) | ((c)<<6) | ((d)<<9))

#define NEGATE_NONE   0x0

#define NEGATE_W   0x8

#define NEGATE_X   0x1

Per-component negation masks.

#define NEGATE_XYZ   0x7

#define NEGATE_XYZW   0xf

#define NEGATE_Y   0x2

#define NEGATE_Z   0x4

#define SATURATE_OFF   0

Saturation modes when storing values.

#define SATURATE_ZERO_ONE   1

#define SWIZZLE_NIL   7

used during shader code gen (undefined value)

#define SWIZZLE_NOOP   MAKE_SWIZZLE4(0,1,2,3)

#define SWIZZLE_ONE   5

For SWZ instruction only.

#define SWIZZLE_W   3

#define SWIZZLE_WWWW   MAKE_SWIZZLE4(SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W)

#define SWIZZLE_X   0

Swizzle indexes.

Do not change!

#define SWIZZLE_XXXX   MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X)

#define SWIZZLE_XYZW   MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W)

#define SWIZZLE_Y   1

#define SWIZZLE_YYYY   MAKE_SWIZZLE4(SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y)

#define SWIZZLE_Z   2

#define SWIZZLE_ZERO   4

For SWZ instruction only.

#define SWIZZLE_ZZZZ   MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z)

#define WRITEMASK_W   0x8

#define WRITEMASK_X   0x1

Writemask values, 1 bit per component.

#define WRITEMASK_XW   0x9

#define WRITEMASK_XY   0x3

#define WRITEMASK_XYW   0xb

#define WRITEMASK_XYZ   0x7

#define WRITEMASK_XYZW   0xf

#define WRITEMASK_XZ   0x5

#define WRITEMASK_XZW   0xd

#define WRITEMASK_Y   0x2

#define WRITEMASK_YW   0xa

#define WRITEMASK_YZ   0x6

#define WRITEMASK_YZW   0xe

#define WRITEMASK_Z   0x4

#define WRITEMASK_ZW   0xc


Typedef Documentation

typedef enum prog_opcode gl_inst_opcode


Enumeration Type Documentation

enum prog_opcode

Program instruction opcodes, for both vertex and fragment programs.

Note:
changes to this opcode list must be reflected in t_vb_arbprogram.c
Enumerator:
OPCODE_NOP 
OPCODE_ABS 
OPCODE_ADD 
OPCODE_AND 
OPCODE_ARA 
OPCODE_ARL 
OPCODE_ARL_NV 
OPCODE_ARR 
OPCODE_BGNLOOP 
OPCODE_BGNSUB 
OPCODE_BRA 
OPCODE_BRK 
OPCODE_CAL 
OPCODE_CMP 
OPCODE_CONT 
OPCODE_COS 
OPCODE_DDX 
OPCODE_DDY 
OPCODE_DP2 
OPCODE_DP2A 
OPCODE_DP3 
OPCODE_DP4 
OPCODE_DPH 
OPCODE_DST 
OPCODE_ELSE 
OPCODE_END 
OPCODE_ENDIF 
OPCODE_ENDLOOP 
OPCODE_ENDSUB 
OPCODE_EX2 
OPCODE_EXP 
OPCODE_FLR 
OPCODE_FRC 
OPCODE_IF 
OPCODE_KIL 
OPCODE_KIL_NV 
OPCODE_LG2 
OPCODE_LIT 
OPCODE_LOG 
OPCODE_LRP 
OPCODE_MAD 
OPCODE_MAX 
OPCODE_MIN 
OPCODE_MOV 
OPCODE_MUL 
OPCODE_NOISE1 
OPCODE_NOISE2 
OPCODE_NOISE3 
OPCODE_NOISE4 
OPCODE_NOT 
OPCODE_NRM3 
OPCODE_NRM4 
OPCODE_OR 
OPCODE_PK2H 
OPCODE_PK2US 
OPCODE_PK4B 
OPCODE_PK4UB 
OPCODE_POW 
OPCODE_POPA 
OPCODE_PRINT 
OPCODE_PUSHA 
OPCODE_RCC 
OPCODE_RCP 
OPCODE_RET 
OPCODE_RFL 
OPCODE_RSQ 
OPCODE_SCS 
OPCODE_SEQ 
OPCODE_SFL 
OPCODE_SGE 
OPCODE_SGT 
OPCODE_SIN 
OPCODE_SLE 
OPCODE_SLT 
OPCODE_SNE 
OPCODE_SSG 
OPCODE_STR 
OPCODE_SUB 
OPCODE_SWZ 
OPCODE_TEX 
OPCODE_TXB 
OPCODE_TXD 
OPCODE_TXL 
OPCODE_TXP 
OPCODE_TXP_NV 
OPCODE_TRUNC 
OPCODE_UP2H 
OPCODE_UP2US 
OPCODE_UP4B 
OPCODE_UP4UB 
OPCODE_X2D 
OPCODE_XOR 
OPCODE_XPD 
MAX_OPCODE 


Function Documentation

struct prog_instruction* _mesa_alloc_instructions ( GLuint  numInst  )  [read]

Allocate an array of program instructions.

Parameters:
numInst number of instructions
Returns:
pointer to instruction memory

GLboolean _mesa_check_soa_dependencies ( const struct prog_instruction inst  ) 

Check if there's a potential src/dst register data dependency when using SOA execution.

Example: MOV T, T.yxwz; This would expand into: MOV t0, t1; MOV t1, t0; MOV t2, t3; MOV t3, t2; The second instruction will have the wrong value for t0 if executed as-is.

struct prog_instruction* _mesa_copy_instructions ( struct prog_instruction dest,
const struct prog_instruction src,
GLuint  n 
) [read]

Copy an array of program instructions.

Parameters:
dest pointer to destination.
src pointer to source.
n number of instructions to copy.
Returns:
pointer to destination.

void _mesa_free_instructions ( struct prog_instruction inst,
GLuint  count 
)

Free an array of instructions.

void _mesa_init_instructions ( struct prog_instruction inst,
GLuint  count 
)

Initialize program instruction fields to defaults.

Parameters:
inst first instruction to initialize
count number of instructions to initialize

GLboolean _mesa_is_tex_instruction ( gl_inst_opcode  opcode  ) 

GLuint _mesa_num_inst_dst_regs ( gl_inst_opcode  opcode  ) 

Return the number of dst registers for the given instruction/opcode.

GLuint _mesa_num_inst_src_regs ( gl_inst_opcode  opcode  ) 

Return the number of src registers for the given instruction/opcode.

const char* _mesa_opcode_string ( gl_inst_opcode  opcode  ) 

Return string name for given program opcode.

struct prog_instruction* _mesa_realloc_instructions ( struct prog_instruction oldInst,
GLuint  numOldInst,
GLuint  numNewInst 
) [read]

Reallocate memory storing an array of program instructions.

This is used when we need to append additional instructions onto an program.

Parameters:
oldInst pointer to first of old/src instructions
numOldInst number of instructions at <oldInst>
numNewInst desired size of new instruction array.
Returns:
pointer to start of new instruction array.


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