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

nvvertparse.c File Reference


Detailed Description

NVIDIA vertex program parser.

Author:
Brian Paul

#include "main/glheader.h"
#include "main/context.h"
#include "main/imports.h"
#include "main/macros.h"
#include "nvprogram.h"
#include "nvvertparse.h"
#include "prog_instruction.h"
#include "prog_parameter.h"
#include "prog_print.h"
#include "program.h"

Data Structures

struct  parse_state
 Current parsing state. More...

Defines

#define RETURN_ERROR
#define RETURN_ERROR1(msg)
#define RETURN_ERROR2(msg1, msg2)

Functions

static void record_error (struct parse_state *parseState, const char *msg, int lineNo)
static GLboolean IsLetter (GLubyte b)
static GLboolean IsDigit (GLubyte b)
static GLboolean IsWhitespace (GLubyte b)
static GLint GetToken (struct parse_state *parseState, GLubyte *token)
 Starting at 'str' find the next token.
static GLboolean Parse_Token (struct parse_state *parseState, GLubyte *token)
 Get next token from input stream and increment stream pointer past token.
static GLboolean Peek_Token (struct parse_state *parseState, GLubyte *token)
 Get next token from input stream but don't increment stream pointer.
static GLboolean Parse_String (struct parse_state *parseState, const char *pattern)
 Try to match 'pattern' as the next token after any whitespace/comments.
static GLboolean Parse_TempReg (struct parse_state *parseState, GLint *tempRegNum)
 Parse a temporary register: Rnn.
static GLboolean Parse_AddrReg (struct parse_state *parseState)
 Parse address register "A0.x".
static GLboolean Parse_AbsParamReg (struct parse_state *parseState, GLint *regNum)
 Parse absolute program parameter register "c[##]".
static GLboolean Parse_ParamReg (struct parse_state *parseState, struct prog_src_register *srcReg)
static GLboolean Parse_AttribReg (struct parse_state *parseState, GLint *tempRegNum)
 Parse v[#] or v[<name>].
static GLboolean Parse_OutputReg (struct parse_state *parseState, GLint *outputRegNum)
static GLboolean Parse_MaskedDstReg (struct parse_state *parseState, struct prog_dst_register *dstReg)
static GLboolean Parse_SwizzleSrcReg (struct parse_state *parseState, struct prog_src_register *srcReg)
static GLboolean Parse_ScalarSrcReg (struct parse_state *parseState, struct prog_src_register *srcReg)
static GLint Parse_UnaryOpInstruction (struct parse_state *parseState, struct prog_instruction *inst, enum prog_opcode opcode)
static GLboolean Parse_BiOpInstruction (struct parse_state *parseState, struct prog_instruction *inst, enum prog_opcode opcode)
static GLboolean Parse_TriOpInstruction (struct parse_state *parseState, struct prog_instruction *inst, enum prog_opcode opcode)
static GLboolean Parse_ScalarInstruction (struct parse_state *parseState, struct prog_instruction *inst, enum prog_opcode opcode)
static GLboolean Parse_AddressInstruction (struct parse_state *parseState, struct prog_instruction *inst)
static GLboolean Parse_EndInstruction (struct parse_state *parseState, struct prog_instruction *inst)
static GLboolean Parse_PrintInstruction (struct parse_state *parseState, struct prog_instruction *inst)
 The PRINT instruction is Mesa-specific and is meant as a debugging aid for the vertex program developer.
static GLboolean Parse_OptionSequence (struct parse_state *parseState, struct prog_instruction program[])
static GLboolean Parse_InstructionSequence (struct parse_state *parseState, struct prog_instruction program[])
static GLboolean Parse_Program (struct parse_state *parseState, struct prog_instruction instBuffer[])
void _mesa_parse_nv_vertex_program (GLcontext *ctx, GLenum dstTarget, const GLubyte *str, GLsizei len, struct gl_vertex_program *program)
 Parse/compile the 'str' returning the compiled 'program'.
const char * _mesa_nv_vertex_input_register_name (GLuint i)
const char * _mesa_nv_vertex_output_register_name (GLuint i)

Variables

static const char * InputRegisters [MAX_NV_VERTEX_PROGRAM_INPUTS+1]
static const char * OutputRegisters [MAX_NV_VERTEX_PROGRAM_OUTPUTS+1]


Define Documentation

#define RETURN_ERROR

Value:

do {                                                                    \
   record_error(parseState, "Unexpected end of input.", __LINE__);      \
   return GL_FALSE;                                                     \
} while(0)

#define RETURN_ERROR1 ( msg   ) 

Value:

do {                                                                    \
   record_error(parseState, msg, __LINE__);                             \
   return GL_FALSE;                                                     \
} while(0)

#define RETURN_ERROR2 ( msg1,
msg2   ) 

Value:

do {                                                                    \
   char err[1000];                                                      \
   _mesa_sprintf(err, "%s %s", msg1, msg2);                             \
   record_error(parseState, err, __LINE__);                             \
   return GL_FALSE;                                                     \
} while(0)


Function Documentation

const char* _mesa_nv_vertex_input_register_name ( GLuint  i  ) 

const char* _mesa_nv_vertex_output_register_name ( GLuint  i  ) 

void _mesa_parse_nv_vertex_program ( GLcontext ctx,
GLenum  dstTarget,
const GLubyte *  str,
GLsizei  len,
struct gl_vertex_program program 
)

Parse/compile the 'str' returning the compiled 'program'.

ctx->Program.ErrorPos will be -1 if successful. Otherwise, ErrorPos indicates the position of the error in 'str'.

static GLint GetToken ( struct parse_state parseState,
GLubyte *  token 
) [static]

Starting at 'str' find the next token.

A token can be an integer, an identifier or punctuation symbol.

Returns:
<= 0 we found an error, else, return number of characters parsed.

static GLboolean IsDigit ( GLubyte  b  )  [static]

static GLboolean IsLetter ( GLubyte  b  )  [static]

static GLboolean IsWhitespace ( GLubyte  b  )  [static]

static GLboolean Parse_AbsParamReg ( struct parse_state parseState,
GLint *  regNum 
) [static]

Parse absolute program parameter register "c[##]".

static GLboolean Parse_AddressInstruction ( struct parse_state parseState,
struct prog_instruction inst 
) [static]

static GLboolean Parse_AddrReg ( struct parse_state parseState  )  [static]

Parse address register "A0.x".

static GLboolean Parse_AttribReg ( struct parse_state parseState,
GLint *  tempRegNum 
) [static]

Parse v[#] or v[<name>].

static GLboolean Parse_BiOpInstruction ( struct parse_state parseState,
struct prog_instruction inst,
enum prog_opcode  opcode 
) [static]

static GLboolean Parse_EndInstruction ( struct parse_state parseState,
struct prog_instruction inst 
) [static]

static GLboolean Parse_InstructionSequence ( struct parse_state parseState,
struct prog_instruction  program[] 
) [static]

static GLboolean Parse_MaskedDstReg ( struct parse_state parseState,
struct prog_dst_register dstReg 
) [static]

static GLboolean Parse_OptionSequence ( struct parse_state parseState,
struct prog_instruction  program[] 
) [static]

static GLboolean Parse_OutputReg ( struct parse_state parseState,
GLint *  outputRegNum 
) [static]

static GLboolean Parse_ParamReg ( struct parse_state parseState,
struct prog_src_register srcReg 
) [static]

static GLboolean Parse_PrintInstruction ( struct parse_state parseState,
struct prog_instruction inst 
) [static]

The PRINT instruction is Mesa-specific and is meant as a debugging aid for the vertex program developer.

The NV_vertex_program extension grammar is modified as follows:

<instruction> ::= <ARL-instruction> | ... | <PRINT-instruction>

<PRINT-instruction> ::= "PRINT" <string literal>=""> | "PRINT" <string literal>=""> "," <srcReg> | "PRINT" <string literal>=""> "," <dstReg>

static GLboolean Parse_Program ( struct parse_state parseState,
struct prog_instruction  instBuffer[] 
) [static]

static GLboolean Parse_ScalarInstruction ( struct parse_state parseState,
struct prog_instruction inst,
enum prog_opcode  opcode 
) [static]

static GLboolean Parse_ScalarSrcReg ( struct parse_state parseState,
struct prog_src_register srcReg 
) [static]

static GLboolean Parse_String ( struct parse_state parseState,
const char *  pattern 
) [static]

Try to match 'pattern' as the next token after any whitespace/comments.

Advance the current parsing position only if we match the pattern.

Returns:
GL_TRUE if pattern is matched, GL_FALSE otherwise.

static GLboolean Parse_SwizzleSrcReg ( struct parse_state parseState,
struct prog_src_register srcReg 
) [static]

static GLboolean Parse_TempReg ( struct parse_state parseState,
GLint *  tempRegNum 
) [static]

Parse a temporary register: Rnn.

static GLboolean Parse_Token ( struct parse_state parseState,
GLubyte *  token 
) [static]

Get next token from input stream and increment stream pointer past token.

static GLboolean Parse_TriOpInstruction ( struct parse_state parseState,
struct prog_instruction inst,
enum prog_opcode  opcode 
) [static]

static GLint Parse_UnaryOpInstruction ( struct parse_state parseState,
struct prog_instruction inst,
enum prog_opcode  opcode 
) [static]

static GLboolean Peek_Token ( struct parse_state parseState,
GLubyte *  token 
) [static]

Get next token from input stream but don't increment stream pointer.

static void record_error ( struct parse_state parseState,
const char *  msg,
int  lineNo 
) [static]


Variable Documentation

const char* InputRegisters[MAX_NV_VERTEX_PROGRAM_INPUTS+1] [static]

Initial value:

 {
   "OPOS", "WGHT", "NRML", "COL0", "COL1", "FOGC", "6", "7",
   "TEX0", "TEX1", "TEX2", "TEX3", "TEX4", "TEX5", "TEX6", "TEX7", NULL
}

const char* OutputRegisters[MAX_NV_VERTEX_PROGRAM_OUTPUTS+1] [static]

Initial value:

 {
   "HPOS", "COL0", "COL1", "FOGC", 
   "TEX0", "TEX1", "TEX2", "TEX3", "TEX4", "TEX5", "TEX6", "TEX7", 
   "PSIZ", "BFC0", "BFC1", NULL
}


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