summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-11-05 17:10:45 +0000
committerBrian Paul <[email protected]>2005-11-05 17:10:45 +0000
commit7e807510d8c3e88ee7ae6c697393201cf08f992f (patch)
treee9b016baa0c63f333efd586619568731dc3db747 /src/mesa/shader
parent73347516be1a515380af1a71cbeaec51001a46dc (diff)
Unify vertex/fragment program instuctions.
Based on patch by Ian (#4967) but also unify instruction opcodes.
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/arbfragparse.c10
-rw-r--r--src/mesa/shader/arbfragparse.h2
-rw-r--r--src/mesa/shader/arbprogparse.c171
-rw-r--r--src/mesa/shader/arbprogparse.h7
-rw-r--r--src/mesa/shader/arbprogram.c3
-rw-r--r--src/mesa/shader/arbvertparse.c24
-rw-r--r--src/mesa/shader/arbvertparse.h2
-rw-r--r--src/mesa/shader/nvfragparse.c179
-rw-r--r--src/mesa/shader/nvfragprog.h168
-rw-r--r--src/mesa/shader/nvprogram.c3
-rw-r--r--src/mesa/shader/nvvertexec.c82
-rw-r--r--src/mesa/shader/nvvertparse.c191
-rw-r--r--src/mesa/shader/nvvertparse.h2
-rw-r--r--src/mesa/shader/nvvertprog.h115
-rw-r--r--src/mesa/shader/program.c3
-rw-r--r--src/mesa/shader/program_instruction.h344
16 files changed, 675 insertions, 631 deletions
diff --git a/src/mesa/shader/arbfragparse.c b/src/mesa/shader/arbfragparse.c
index 75c7b35e400..a4470cbcb10 100644
--- a/src/mesa/shader/arbfragparse.c
+++ b/src/mesa/shader/arbfragparse.c
@@ -40,7 +40,7 @@
#include "arbfragparse.h"
void
-_mesa_debug_fp_inst(GLint num, struct fp_instruction *fp)
+_mesa_debug_fp_inst(GLint num, struct prog_instruction *fp)
{
GLint a;
@@ -190,7 +190,7 @@ _mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
{
GLuint i;
struct arb_program ap;
- struct fp_instruction *newInstructions;
+ struct prog_instruction *newInstructions;
(void) target;
/* set the program target before parsing */
@@ -205,14 +205,14 @@ _mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
* fragment_program struct.
*/
/* copy instruction buffer */
- newInstructions = (struct fp_instruction *)
- _mesa_malloc(ap.Base.NumInstructions * sizeof(struct fp_instruction));
+ newInstructions = (struct prog_instruction *)
+ _mesa_malloc(ap.Base.NumInstructions * sizeof(struct prog_instruction));
if (!newInstructions) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
return;
}
_mesa_memcpy(newInstructions, ap.FPInstructions,
- ap.Base.NumInstructions * sizeof(struct fp_instruction));
+ ap.Base.NumInstructions * sizeof(struct prog_instruction));
if (program->Instructions)
_mesa_free(program->Instructions);
program->Instructions = newInstructions;
diff --git a/src/mesa/shader/arbfragparse.h b/src/mesa/shader/arbfragparse.h
index 0d3e69fa8ef..09a01d944d6 100644
--- a/src/mesa/shader/arbfragparse.h
+++ b/src/mesa/shader/arbfragparse.h
@@ -33,7 +33,7 @@ _mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
struct fragment_program *program);
extern void
-_mesa_debug_fp_inst(GLint num, struct fp_instruction *fp);
+_mesa_debug_fp_inst(GLint num, struct prog_instruction *fp);
#endif
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index 7b56b078a11..377b9bb8623 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -37,8 +37,7 @@
#include "imports.h"
#include "macros.h"
#include "program.h"
-#include "nvvertprog.h"
-#include "nvfragprog.h"
+#include "program_instruction.h"
#include "arbprogparse.h"
#include "grammar_mesa.h"
#include "program.h"
@@ -2573,7 +2572,7 @@ static GLuint
parse_fp_vector_src_reg(GLcontext * ctx, GLubyte ** inst,
struct var_cache **vc_head,
struct arb_program *program,
- struct fp_src_register *reg)
+ struct prog_src_register *reg)
{
enum register_file file;
GLint index;
@@ -2604,7 +2603,7 @@ parse_fp_vector_src_reg(GLcontext * ctx, GLubyte ** inst,
static GLuint
parse_fp_dst_reg(GLcontext * ctx, GLubyte ** inst,
struct var_cache **vc_head, struct arb_program *Program,
- struct fp_dst_register *reg )
+ struct prog_dst_register *reg )
{
GLint mask;
GLuint idx;
@@ -2629,7 +2628,7 @@ static GLuint
parse_fp_scalar_src_reg (GLcontext * ctx, GLubyte ** inst,
struct var_cache **vc_head,
struct arb_program *Program,
- struct fp_src_register *reg )
+ struct prog_src_register *reg )
{
enum register_file File;
GLint Index;
@@ -2665,14 +2664,14 @@ parse_fp_scalar_src_reg (GLcontext * ctx, GLubyte ** inst,
static GLuint
parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
struct var_cache **vc_head, struct arb_program *Program,
- struct fp_instruction *fp)
+ struct prog_instruction *fp)
{
GLint a;
GLuint texcoord;
GLubyte instClass, type, code;
GLboolean rel;
- _mesa_init_fp_instruction(fp);
+ _mesa_init_instruction(fp);
/* Record the position in the program string for debugging */
fp->StringPos = Program->Position;
@@ -2704,31 +2703,31 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
case OP_ABS_SAT:
fp->Saturate = 1;
case OP_ABS:
- fp->Opcode = FP_OPCODE_ABS;
+ fp->Opcode = OPCODE_ABS;
break;
case OP_FLR_SAT:
fp->Saturate = 1;
case OP_FLR:
- fp->Opcode = FP_OPCODE_FLR;
+ fp->Opcode = OPCODE_FLR;
break;
case OP_FRC_SAT:
fp->Saturate = 1;
case OP_FRC:
- fp->Opcode = FP_OPCODE_FRC;
+ fp->Opcode = OPCODE_FRC;
break;
case OP_LIT_SAT:
fp->Saturate = 1;
case OP_LIT:
- fp->Opcode = FP_OPCODE_LIT;
+ fp->Opcode = OPCODE_LIT;
break;
case OP_MOV_SAT:
fp->Saturate = 1;
case OP_MOV:
- fp->Opcode = FP_OPCODE_MOV;
+ fp->Opcode = OPCODE_MOV;
break;
}
@@ -2744,44 +2743,44 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
case OP_COS_SAT:
fp->Saturate = 1;
case OP_COS:
- fp->Opcode = FP_OPCODE_COS;
+ fp->Opcode = OPCODE_COS;
break;
case OP_EX2_SAT:
fp->Saturate = 1;
case OP_EX2:
- fp->Opcode = FP_OPCODE_EX2;
+ fp->Opcode = OPCODE_EX2;
break;
case OP_LG2_SAT:
fp->Saturate = 1;
case OP_LG2:
- fp->Opcode = FP_OPCODE_LG2;
+ fp->Opcode = OPCODE_LG2;
break;
case OP_RCP_SAT:
fp->Saturate = 1;
case OP_RCP:
- fp->Opcode = FP_OPCODE_RCP;
+ fp->Opcode = OPCODE_RCP;
break;
case OP_RSQ_SAT:
fp->Saturate = 1;
case OP_RSQ:
- fp->Opcode = FP_OPCODE_RSQ;
+ fp->Opcode = OPCODE_RSQ;
break;
case OP_SIN_SAT:
fp->Saturate = 1;
case OP_SIN:
- fp->Opcode = FP_OPCODE_SIN;
+ fp->Opcode = OPCODE_SIN;
break;
case OP_SCS_SAT:
fp->Saturate = 1;
case OP_SCS:
- fp->Opcode = FP_OPCODE_SCS;
+ fp->Opcode = OPCODE_SCS;
break;
}
@@ -2797,7 +2796,7 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
case OP_POW_SAT:
fp->Saturate = 1;
case OP_POW:
- fp->Opcode = FP_OPCODE_POW;
+ fp->Opcode = OPCODE_POW;
break;
}
@@ -2816,73 +2815,73 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
case OP_ADD_SAT:
fp->Saturate = 1;
case OP_ADD:
- fp->Opcode = FP_OPCODE_ADD;
+ fp->Opcode = OPCODE_ADD;
break;
case OP_DP3_SAT:
fp->Saturate = 1;
case OP_DP3:
- fp->Opcode = FP_OPCODE_DP3;
+ fp->Opcode = OPCODE_DP3;
break;
case OP_DP4_SAT:
fp->Saturate = 1;
case OP_DP4:
- fp->Opcode = FP_OPCODE_DP4;
+ fp->Opcode = OPCODE_DP4;
break;
case OP_DPH_SAT:
fp->Saturate = 1;
case OP_DPH:
- fp->Opcode = FP_OPCODE_DPH;
+ fp->Opcode = OPCODE_DPH;
break;
case OP_DST_SAT:
fp->Saturate = 1;
case OP_DST:
- fp->Opcode = FP_OPCODE_DST;
+ fp->Opcode = OPCODE_DST;
break;
case OP_MAX_SAT:
fp->Saturate = 1;
case OP_MAX:
- fp->Opcode = FP_OPCODE_MAX;
+ fp->Opcode = OPCODE_MAX;
break;
case OP_MIN_SAT:
fp->Saturate = 1;
case OP_MIN:
- fp->Opcode = FP_OPCODE_MIN;
+ fp->Opcode = OPCODE_MIN;
break;
case OP_MUL_SAT:
fp->Saturate = 1;
case OP_MUL:
- fp->Opcode = FP_OPCODE_MUL;
+ fp->Opcode = OPCODE_MUL;
break;
case OP_SGE_SAT:
fp->Saturate = 1;
case OP_SGE:
- fp->Opcode = FP_OPCODE_SGE;
+ fp->Opcode = OPCODE_SGE;
break;
case OP_SLT_SAT:
fp->Saturate = 1;
case OP_SLT:
- fp->Opcode = FP_OPCODE_SLT;
+ fp->Opcode = OPCODE_SLT;
break;
case OP_SUB_SAT:
fp->Saturate = 1;
case OP_SUB:
- fp->Opcode = FP_OPCODE_SUB;
+ fp->Opcode = OPCODE_SUB;
break;
case OP_XPD_SAT:
fp->Saturate = 1;
case OP_XPD:
- fp->Opcode = FP_OPCODE_XPD;
+ fp->Opcode = OPCODE_XPD;
break;
}
@@ -2899,19 +2898,19 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
case OP_CMP_SAT:
fp->Saturate = 1;
case OP_CMP:
- fp->Opcode = FP_OPCODE_CMP;
+ fp->Opcode = OPCODE_CMP;
break;
case OP_LRP_SAT:
fp->Saturate = 1;
case OP_LRP:
- fp->Opcode = FP_OPCODE_LRP;
+ fp->Opcode = OPCODE_LRP;
break;
case OP_MAD_SAT:
fp->Saturate = 1;
case OP_MAD:
- fp->Opcode = FP_OPCODE_MAD;
+ fp->Opcode = OPCODE_MAD;
break;
}
@@ -2929,7 +2928,7 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
case OP_SWZ_SAT:
fp->Saturate = 1;
case OP_SWZ:
- fp->Opcode = FP_OPCODE_SWZ;
+ fp->Opcode = OPCODE_SWZ;
break;
}
if (parse_fp_dst_reg (ctx, inst, vc_head, Program, &fp->DstReg))
@@ -2959,19 +2958,19 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
case OP_TEX_SAT:
fp->Saturate = 1;
case OP_TEX:
- fp->Opcode = FP_OPCODE_TEX;
+ fp->Opcode = OPCODE_TEX;
break;
case OP_TXP_SAT:
fp->Saturate = 1;
case OP_TXP:
- fp->Opcode = FP_OPCODE_TXP;
+ fp->Opcode = OPCODE_TXP;
break;
case OP_TXB_SAT:
fp->Saturate = 1;
case OP_TXB:
- fp->Opcode = FP_OPCODE_TXB;
+ fp->Opcode = OPCODE_TXB;
break;
}
@@ -2989,19 +2988,19 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
/* texTarget */
switch (*(*inst)++) {
case TEXTARGET_1D:
- fp->TexSrcIdx = TEXTURE_1D_INDEX;
+ fp->TexSrcTarget = TEXTURE_1D_INDEX;
break;
case TEXTARGET_2D:
- fp->TexSrcIdx = TEXTURE_2D_INDEX;
+ fp->TexSrcTarget = TEXTURE_2D_INDEX;
break;
case TEXTARGET_3D:
- fp->TexSrcIdx = TEXTURE_3D_INDEX;
+ fp->TexSrcTarget = TEXTURE_3D_INDEX;
break;
case TEXTARGET_RECT:
- fp->TexSrcIdx = TEXTURE_RECT_INDEX;
+ fp->TexSrcTarget = TEXTURE_RECT_INDEX;
break;
case TEXTARGET_CUBE:
- fp->TexSrcIdx = TEXTURE_CUBE_INDEX;
+ fp->TexSrcTarget = TEXTURE_CUBE_INDEX;
break;
case TEXTARGET_SHADOW1D:
case TEXTARGET_SHADOW2D:
@@ -3009,14 +3008,14 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
/* TODO ARB_fragment_program_shadow code */
break;
}
- Program->TexturesUsed[texcoord] |= (1<<fp->TexSrcIdx);
+ Program->TexturesUsed[texcoord] |= (1<<fp->TexSrcTarget);
break;
case OP_TEX_KIL:
Program->UsesKill = 1;
if (parse_fp_vector_src_reg(ctx, inst, vc_head, Program, &fp->SrcReg[0]))
return 1;
- fp->Opcode = FP_OPCODE_KIL;
+ fp->Opcode = OPCODE_KIL;
break;
}
@@ -3026,7 +3025,7 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
static GLuint
parse_vp_dst_reg(GLcontext * ctx, GLubyte ** inst,
struct var_cache **vc_head, struct arb_program *Program,
- struct vp_dst_register *reg )
+ struct prog_dst_register *reg )
{
GLint mask;
GLuint idx;
@@ -3053,7 +3052,7 @@ static GLuint
parse_vp_address_reg (GLcontext * ctx, GLubyte ** inst,
struct var_cache **vc_head,
struct arb_program *Program,
- struct vp_dst_register *reg)
+ struct prog_dst_register *reg)
{
GLint idx;
@@ -3078,7 +3077,7 @@ static GLuint
parse_vp_vector_src_reg(GLcontext * ctx, GLubyte ** inst,
struct var_cache **vc_head,
struct arb_program *program,
- struct vp_src_register *reg )
+ struct prog_src_register *reg )
{
enum register_file file;
GLint index;
@@ -3100,7 +3099,7 @@ parse_vp_vector_src_reg(GLcontext * ctx, GLubyte ** inst,
reg->Index = index;
reg->Swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1],
swizzle[2], swizzle[3]);
- reg->Negate = negateMask;
+ reg->NegateBase = negateMask;
reg->RelAddr = isRelOffset;
return 0;
}
@@ -3110,7 +3109,7 @@ static GLuint
parse_vp_scalar_src_reg (GLcontext * ctx, GLubyte ** inst,
struct var_cache **vc_head,
struct arb_program *Program,
- struct vp_src_register *reg )
+ struct prog_src_register *reg )
{
enum register_file File;
GLint Index;
@@ -3131,7 +3130,7 @@ parse_vp_scalar_src_reg (GLcontext * ctx, GLubyte ** inst,
reg->File = File;
reg->Index = Index;
reg->Swizzle = (Swizzle[0] << 0);
- reg->Negate = Negate;
+ reg->NegateBase = Negate;
reg->RelAddr = IsRelOffset;
return 0;
}
@@ -3144,7 +3143,7 @@ parse_vp_scalar_src_reg (GLcontext * ctx, GLubyte ** inst,
static GLuint
parse_vp_instruction (GLcontext * ctx, GLubyte ** inst,
struct var_cache **vc_head, struct arb_program *Program,
- struct vp_instruction *vp)
+ struct prog_instruction *vp)
{
GLint a;
GLubyte type, code;
@@ -3155,14 +3154,14 @@ parse_vp_instruction (GLcontext * ctx, GLubyte ** inst,
/* The actual opcode name */
code = *(*inst)++;
- _mesa_init_vp_instruction(vp);
+ _mesa_init_instruction(vp);
/* Record the position in the program string for debugging */
vp->StringPos = Program->Position;
switch (type) {
/* XXX: */
case OP_ALU_ARL:
- vp->Opcode = VP_OPCODE_ARL;
+ vp->Opcode = OPCODE_ARL;
/* Remember to set SrcReg.RelAddr; */
@@ -3181,19 +3180,19 @@ parse_vp_instruction (GLcontext * ctx, GLubyte ** inst,
case OP_ALU_VECTOR:
switch (code) {
case OP_ABS:
- vp->Opcode = VP_OPCODE_ABS;
+ vp->Opcode = OPCODE_ABS;
break;
case OP_FLR:
- vp->Opcode = VP_OPCODE_FLR;
+ vp->Opcode = OPCODE_FLR;
break;
case OP_FRC:
- vp->Opcode = VP_OPCODE_FRC;
+ vp->Opcode = OPCODE_FRC;
break;
case OP_LIT:
- vp->Opcode = VP_OPCODE_LIT;
+ vp->Opcode = OPCODE_LIT;
break;
case OP_MOV:
- vp->Opcode = VP_OPCODE_MOV;
+ vp->Opcode = OPCODE_MOV;
break;
}
@@ -3207,22 +3206,22 @@ parse_vp_instruction (GLcontext * ctx, GLubyte ** inst,
case OP_ALU_SCALAR:
switch (code) {
case OP_EX2:
- vp->Opcode = VP_OPCODE_EX2;
+ vp->Opcode = OPCODE_EX2;
break;
case OP_EXP:
- vp->Opcode = VP_OPCODE_EXP;
+ vp->Opcode = OPCODE_EXP;
break;
case OP_LG2:
- vp->Opcode = VP_OPCODE_LG2;
+ vp->Opcode = OPCODE_LG2;
break;
case OP_LOG:
- vp->Opcode = VP_OPCODE_LOG;
+ vp->Opcode = OPCODE_LOG;
break;
case OP_RCP:
- vp->Opcode = VP_OPCODE_RCP;
+ vp->Opcode = OPCODE_RCP;
break;
case OP_RSQ:
- vp->Opcode = VP_OPCODE_RSQ;
+ vp->Opcode = OPCODE_RSQ;
break;
}
if (parse_vp_dst_reg(ctx, inst, vc_head, Program, &vp->DstReg))
@@ -3235,7 +3234,7 @@ parse_vp_instruction (GLcontext * ctx, GLubyte ** inst,
case OP_ALU_BINSC:
switch (code) {
case OP_POW:
- vp->Opcode = VP_OPCODE_POW;
+ vp->Opcode = OPCODE_POW;
break;
}
if (parse_vp_dst_reg(ctx, inst, vc_head, Program, &vp->DstReg))
@@ -3250,40 +3249,40 @@ parse_vp_instruction (GLcontext * ctx, GLubyte ** inst,
case OP_ALU_BIN:
switch (code) {
case OP_ADD:
- vp->Opcode = VP_OPCODE_ADD;
+ vp->Opcode = OPCODE_ADD;
break;
case OP_DP3:
- vp->Opcode = VP_OPCODE_DP3;
+ vp->Opcode = OPCODE_DP3;
break;
case OP_DP4:
- vp->Opcode = VP_OPCODE_DP4;
+ vp->Opcode = OPCODE_DP4;
break;
case OP_DPH:
- vp->Opcode = VP_OPCODE_DPH;
+ vp->Opcode = OPCODE_DPH;
break;
case OP_DST:
- vp->Opcode = VP_OPCODE_DST;
+ vp->Opcode = OPCODE_DST;
break;
case OP_MAX:
- vp->Opcode = VP_OPCODE_MAX;
+ vp->Opcode = OPCODE_MAX;
break;
case OP_MIN:
- vp->Opcode = VP_OPCODE_MIN;
+ vp->Opcode = OPCODE_MIN;
break;
case OP_MUL:
- vp->Opcode = VP_OPCODE_MUL;
+ vp->Opcode = OPCODE_MUL;
break;
case OP_SGE:
- vp->Opcode = VP_OPCODE_SGE;
+ vp->Opcode = OPCODE_SGE;
break;
case OP_SLT:
- vp->Opcode = VP_OPCODE_SLT;
+ vp->Opcode = OPCODE_SLT;
break;
case OP_SUB:
- vp->Opcode = VP_OPCODE_SUB;
+ vp->Opcode = OPCODE_SUB;
break;
case OP_XPD:
- vp->Opcode = VP_OPCODE_XPD;
+ vp->Opcode = OPCODE_XPD;
break;
}
if (parse_vp_dst_reg(ctx, inst, vc_head, Program, &vp->DstReg))
@@ -3298,7 +3297,7 @@ parse_vp_instruction (GLcontext * ctx, GLubyte ** inst,
case OP_ALU_TRI:
switch (code) {
case OP_MAD:
- vp->Opcode = VP_OPCODE_MAD;
+ vp->Opcode = OPCODE_MAD;
break;
}
@@ -3314,7 +3313,7 @@ parse_vp_instruction (GLcontext * ctx, GLubyte ** inst,
case OP_ALU_SWZ:
switch (code) {
case OP_SWZ:
- vp->Opcode = VP_OPCODE_SWZ;
+ vp->Opcode = OPCODE_SWZ;
break;
}
{
@@ -3332,7 +3331,7 @@ parse_vp_instruction (GLcontext * ctx, GLubyte ** inst,
parse_extended_swizzle_mask (inst, swizzle, &negateMask);
vp->SrcReg[0].File = file;
vp->SrcReg[0].Index = index;
- vp->SrcReg[0].Negate = negateMask;
+ vp->SrcReg[0].NegateBase = negateMask;
vp->SrcReg[0].Swizzle = MAKE_SWIZZLE4(swizzle[0],
swizzle[1],
swizzle[2],
@@ -3698,8 +3697,8 @@ parse_arb_program(GLcontext * ctx, GLubyte * inst, struct var_cache **vc_head,
/* Finally, tag on an OPCODE_END instruction */
if (Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB) {
const GLuint numInst = Program->Base.NumInstructions;
- _mesa_init_fp_instruction(Program->FPInstructions + numInst);
- Program->FPInstructions[numInst].Opcode = FP_OPCODE_END;
+ _mesa_init_instruction(Program->FPInstructions + numInst);
+ Program->FPInstructions[numInst].Opcode = OPCODE_END;
/* YYY Wrong Position in program, whatever, at least not random -> crash
Program->Position = parse_position (&inst);
*/
@@ -3707,8 +3706,8 @@ parse_arb_program(GLcontext * ctx, GLubyte * inst, struct var_cache **vc_head,
}
else {
const GLuint numInst = Program->Base.NumInstructions;
- _mesa_init_vp_instruction(Program->VPInstructions + numInst);
- Program->VPInstructions[numInst].Opcode = VP_OPCODE_END;
+ _mesa_init_instruction(Program->VPInstructions + numInst);
+ Program->VPInstructions[numInst].Opcode = OPCODE_END;
/* YYY Wrong Position in program, whatever, at least not random -> crash
Program->Position = parse_position (&inst);
*/
diff --git a/src/mesa/shader/arbprogparse.h b/src/mesa/shader/arbprogparse.h
index 59f8e3b22ed..5dbf31a2b15 100644
--- a/src/mesa/shader/arbprogparse.h
+++ b/src/mesa/shader/arbprogparse.h
@@ -28,8 +28,7 @@
#include "context.h"
#include "mtypes.h"
-#include "nvvertprog.h"
-#include "nvfragprog.h"
+#include "program_instruction.h"
#define MAX_INSTRUCTIONS 256
@@ -53,7 +52,7 @@ struct arb_program
GLuint MinorVersion;
/* ARB_vertex_program specifics */
- struct vp_instruction VPInstructions[MAX_INSTRUCTIONS];
+ struct prog_instruction VPInstructions[MAX_INSTRUCTIONS];
/* Options currently recognized by the parser */
/* ARB_fp */
@@ -64,7 +63,7 @@ struct arb_program
GLboolean HintPositionInvariant;
/* ARB_fragment_program specifics */
- struct fp_instruction FPInstructions[MAX_INSTRUCTIONS];
+ struct prog_instruction FPInstructions[MAX_INSTRUCTIONS];
GLbitfield TexturesUsed[MAX_TEXTURE_IMAGE_UNITS];
GLuint NumAluInstructions;
GLuint NumTexInstructions;
diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c
index f47f6733995..35b760bee5a 100644
--- a/src/mesa/shader/arbprogram.c
+++ b/src/mesa/shader/arbprogram.c
@@ -39,9 +39,8 @@
#include "mtypes.h"
#include "nvprogram.h"
#include "nvfragparse.h"
-#include "nvfragprog.h"
+#include "program_instruction.h"
#include "nvvertparse.h"
-#include "nvvertprog.h"
void GLAPIENTRY
diff --git a/src/mesa/shader/arbvertparse.c b/src/mesa/shader/arbvertparse.c
index 2fbfa5fe9e2..1cc2384fb58 100644
--- a/src/mesa/shader/arbvertparse.c
+++ b/src/mesa/shader/arbvertparse.c
@@ -40,7 +40,7 @@
#include "program.h"
#include "nvprogram.h"
#include "nvvertparse.h"
-#include "nvvertprog.h"
+#include "program_instruction.h"
#include "arbprogparse.h"
@@ -49,7 +49,7 @@
* XXX this is probably redundant. We've already got code like this
* in the nvvertparse.c file. Combine/clean-up someday.
*/
-void _mesa_debug_vp_inst(GLint num, struct vp_instruction *vp)
+void _mesa_debug_vp_inst(GLint num, struct prog_instruction *vp)
{
GLint a;
static const char *opcode_string[] = {
@@ -115,9 +115,9 @@ void _mesa_debug_vp_inst(GLint num, struct vp_instruction *vp)
if (vp[a].SrcReg[0].File != 0xf) {
if (vp[a].SrcReg[0].Swizzle != SWIZZLE_NOOP ||
- vp[a].SrcReg[0].Negate)
+ vp[a].SrcReg[0].NegateBase)
_mesa_printf("%s[%d].%s%c%c%c%c ", file_string[vp[a].SrcReg[0].File], vp[a].SrcReg[0].Index,
- vp[a].SrcReg[0].Negate ? "-" : "",
+ vp[a].SrcReg[0].NegateBase ? "-" : "",
swz[GET_SWZ(vp[a].SrcReg[0].Swizzle, 0)],
swz[GET_SWZ(vp[a].SrcReg[0].Swizzle, 1)],
swz[GET_SWZ(vp[a].SrcReg[0].Swizzle, 2)],
@@ -128,9 +128,9 @@ void _mesa_debug_vp_inst(GLint num, struct vp_instruction *vp)
if (vp[a].SrcReg[1].File != 0xf) {
if (vp[a].SrcReg[1].Swizzle != SWIZZLE_NOOP ||
- vp[a].SrcReg[1].Negate)
+ vp[a].SrcReg[1].NegateBase)
_mesa_printf("%s[%d].%s%c%c%c%c ", file_string[vp[a].SrcReg[1].File], vp[a].SrcReg[1].Index,
- vp[a].SrcReg[1].Negate ? "-" : "",
+ vp[a].SrcReg[1].NegateBase ? "-" : "",
swz[GET_SWZ(vp[a].SrcReg[1].Swizzle, 0)],
swz[GET_SWZ(vp[a].SrcReg[1].Swizzle, 1)],
swz[GET_SWZ(vp[a].SrcReg[1].Swizzle, 2)],
@@ -141,9 +141,9 @@ void _mesa_debug_vp_inst(GLint num, struct vp_instruction *vp)
if (vp[a].SrcReg[2].File != 0xf) {
if (vp[a].SrcReg[2].Swizzle != SWIZZLE_NOOP ||
- vp[a].SrcReg[2].Negate)
+ vp[a].SrcReg[2].NegateBase)
_mesa_printf("%s[%d].%s%c%c%c%c ", file_string[vp[a].SrcReg[2].File], vp[a].SrcReg[2].Index,
- vp[a].SrcReg[2].Negate ? "-" : "",
+ vp[a].SrcReg[2].NegateBase ? "-" : "",
swz[GET_SWZ(vp[a].SrcReg[2].Swizzle, 0)],
swz[GET_SWZ(vp[a].SrcReg[2].Swizzle, 1)],
swz[GET_SWZ(vp[a].SrcReg[2].Swizzle, 2)],
@@ -169,7 +169,7 @@ _mesa_parse_arb_vertex_program(GLcontext * ctx, GLenum target,
{
struct arb_program ap;
(void) target;
- struct vp_instruction *newInstructions;
+ struct prog_instruction *newInstructions;
/* set the program target before parsing */
ap.Base.Target = GL_VERTEX_PROGRAM_ARB;
@@ -183,14 +183,14 @@ _mesa_parse_arb_vertex_program(GLcontext * ctx, GLenum target,
* vertex_program struct.
*/
/* copy instruction buffer */
- newInstructions = (struct vp_instruction *)
- _mesa_malloc(ap.Base.NumInstructions * sizeof(struct vp_instruction));
+ newInstructions = (struct prog_instruction *)
+ _mesa_malloc(ap.Base.NumInstructions * sizeof(struct prog_instruction));
if (!newInstructions) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
return;
}
_mesa_memcpy(newInstructions, ap.VPInstructions,
- ap.Base.NumInstructions * sizeof(struct vp_instruction));
+ ap.Base.NumInstructions * sizeof(struct prog_instruction));
if (program->Instructions)
_mesa_free(program->Instructions);
program->Instructions = newInstructions;
diff --git a/src/mesa/shader/arbvertparse.h b/src/mesa/shader/arbvertparse.h
index f2ac1570be0..30ff1629132 100644
--- a/src/mesa/shader/arbvertparse.h
+++ b/src/mesa/shader/arbvertparse.h
@@ -31,6 +31,6 @@ _mesa_parse_arb_vertex_program(GLcontext * ctx, GLenum target,
struct vertex_program *program);
extern void
-_mesa_debug_vp_inst(GLint num, struct vp_instruction *vp);
+_mesa_debug_vp_inst(GLint num, struct prog_instruction *vp);
#endif
diff --git a/src/mesa/shader/nvfragparse.c b/src/mesa/shader/nvfragparse.c
index 3d72b485a29..3a480058440 100644
--- a/src/mesa/shader/nvfragparse.c
+++ b/src/mesa/shader/nvfragparse.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 6.5
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -43,7 +43,7 @@
#include "imports.h"
#include "macros.h"
#include "mtypes.h"
-#include "nvfragprog.h"
+#include "program_instruction.h"
#include "nvfragparse.h"
#include "nvprogram.h"
#include "program.h"
@@ -79,60 +79,60 @@
struct instruction_pattern {
const char *name;
- enum fp_opcode opcode;
+ enum prog_opcode opcode;
GLuint inputs;
GLuint outputs;
GLuint suffixes;
};
static const struct instruction_pattern Instructions[] = {
- { "ADD", FP_OPCODE_ADD, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
- { "COS", FP_OPCODE_COS, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
- { "DDX", FP_OPCODE_DDX, INPUT_1V, OUTPUT_V, _R | _H | _C | _S },
- { "DDY", FP_OPCODE_DDY, INPUT_1V, OUTPUT_V, _R | _H | _C | _S },
- { "DP3", FP_OPCODE_DP3, INPUT_2V, OUTPUT_S, _R | _H | _X | _C | _S },
- { "DP4", FP_OPCODE_DP4, INPUT_2V, OUTPUT_S, _R | _H | _X | _C | _S },
- { "DST", FP_OPCODE_DP4, INPUT_2V, OUTPUT_V, _R | _H | _C | _S },
- { "EX2", FP_OPCODE_DP4, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
- { "FLR", FP_OPCODE_FLR, INPUT_1V, OUTPUT_V, _R | _H | _X | _C | _S },
- { "FRC", FP_OPCODE_FRC, INPUT_1V, OUTPUT_V, _R | _H | _X | _C | _S },
- { "KIL", FP_OPCODE_KIL_NV, INPUT_CC, OUTPUT_NONE, 0 },
- { "LG2", FP_OPCODE_LG2, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
- { "LIT", FP_OPCODE_LIT, INPUT_1V, OUTPUT_V, _R | _H | _C | _S },
- { "LRP", FP_OPCODE_LRP, INPUT_3V, OUTPUT_V, _R | _H | _X | _C | _S },
- { "MAD", FP_OPCODE_MAD, INPUT_3V, OUTPUT_V, _R | _H | _X | _C | _S },
- { "MAX", FP_OPCODE_MAX, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
- { "MIN", FP_OPCODE_MIN, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
- { "MOV", FP_OPCODE_MOV, INPUT_1V, OUTPUT_V, _R | _H | _X | _C | _S },
- { "MUL", FP_OPCODE_MUL, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
- { "PK2H", FP_OPCODE_PK2H, INPUT_1V, OUTPUT_S, 0 },
- { "PK2US", FP_OPCODE_PK2US, INPUT_1V, OUTPUT_S, 0 },
- { "PK4B", FP_OPCODE_PK4B, INPUT_1V, OUTPUT_S, 0 },
- { "PK4UB", FP_OPCODE_PK4UB, INPUT_1V, OUTPUT_S, 0 },
- { "POW", FP_OPCODE_POW, INPUT_2S, OUTPUT_S, _R | _H | _C | _S },
- { "RCP", FP_OPCODE_RCP, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
- { "RFL", FP_OPCODE_RFL, INPUT_2V, OUTPUT_V, _R | _H | _C | _S },
- { "RSQ", FP_OPCODE_RSQ, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
- { "SEQ", FP_OPCODE_SEQ, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
- { "SFL", FP_OPCODE_SFL, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
- { "SGE", FP_OPCODE_SGE, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
- { "SGT", FP_OPCODE_SGT, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
- { "SIN", FP_OPCODE_SIN, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
- { "SLE", FP_OPCODE_SLE, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
- { "SLT", FP_OPCODE_SLT, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
- { "SNE", FP_OPCODE_SNE, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
- { "STR", FP_OPCODE_STR, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
- { "SUB", FP_OPCODE_SUB, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
- { "TEX", FP_OPCODE_TEX, INPUT_1V_T, OUTPUT_V, _C | _S },
- { "TXD", FP_OPCODE_TXD, INPUT_3V_T, OUTPUT_V, _C | _S },
- { "TXP", FP_OPCODE_TXP_NV, INPUT_1V_T, OUTPUT_V, _C | _S },
- { "UP2H", FP_OPCODE_UP2H, INPUT_1S, OUTPUT_V, _C | _S },
- { "UP2US", FP_OPCODE_UP2US, INPUT_1S, OUTPUT_V, _C | _S },
- { "UP4B", FP_OPCODE_UP4B, INPUT_1S, OUTPUT_V, _C | _S },
- { "UP4UB", FP_OPCODE_UP4UB, INPUT_1S, OUTPUT_V, _C | _S },
- { "X2D", FP_OPCODE_X2D, INPUT_3V, OUTPUT_V, _R | _H | _C | _S },
- { "PRINT", FP_OPCODE_PRINT, INPUT_1V_S, OUTPUT_NONE, 0 },
- { NULL, (enum fp_opcode) -1, 0, 0, 0 }
+ { "ADD", OPCODE_ADD, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "COS", OPCODE_COS, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
+ { "DDX", OPCODE_DDX, INPUT_1V, OUTPUT_V, _R | _H | _C | _S },
+ { "DDY", OPCODE_DDY, INPUT_1V, OUTPUT_V, _R | _H | _C | _S },
+ { "DP3", OPCODE_DP3, INPUT_2V, OUTPUT_S, _R | _H | _X | _C | _S },
+ { "DP4", OPCODE_DP4, INPUT_2V, OUTPUT_S, _R | _H | _X | _C | _S },
+ { "DST", OPCODE_DP4, INPUT_2V, OUTPUT_V, _R | _H | _C | _S },
+ { "EX2", OPCODE_DP4, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
+ { "FLR", OPCODE_FLR, INPUT_1V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "FRC", OPCODE_FRC, INPUT_1V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "KIL", OPCODE_KIL_NV, INPUT_CC, OUTPUT_NONE, 0 },
+ { "LG2", OPCODE_LG2, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
+ { "LIT", OPCODE_LIT, INPUT_1V, OUTPUT_V, _R | _H | _C | _S },
+ { "LRP", OPCODE_LRP, INPUT_3V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "MAD", OPCODE_MAD, INPUT_3V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "MAX", OPCODE_MAX, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "MIN", OPCODE_MIN, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "MOV", OPCODE_MOV, INPUT_1V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "MUL", OPCODE_MUL, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "PK2H", OPCODE_PK2H, INPUT_1V, OUTPUT_S, 0 },
+ { "PK2US", OPCODE_PK2US, INPUT_1V, OUTPUT_S, 0 },
+ { "PK4B", OPCODE_PK4B, INPUT_1V, OUTPUT_S, 0 },
+ { "PK4UB", OPCODE_PK4UB, INPUT_1V, OUTPUT_S, 0 },
+ { "POW", OPCODE_POW, INPUT_2S, OUTPUT_S, _R | _H | _C | _S },
+ { "RCP", OPCODE_RCP, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
+ { "RFL", OPCODE_RFL, INPUT_2V, OUTPUT_V, _R | _H | _C | _S },
+ { "RSQ", OPCODE_RSQ, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
+ { "SEQ", OPCODE_SEQ, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "SFL", OPCODE_SFL, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "SGE", OPCODE_SGE, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "SGT", OPCODE_SGT, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "SIN", OPCODE_SIN, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
+ { "SLE", OPCODE_SLE, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "SLT", OPCODE_SLT, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "SNE", OPCODE_SNE, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "STR", OPCODE_STR, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "SUB", OPCODE_SUB, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "TEX", OPCODE_TEX, INPUT_1V_T, OUTPUT_V, _C | _S },
+ { "TXD", OPCODE_TXD, INPUT_3V_T, OUTPUT_V, _C | _S },
+ { "TXP", OPCODE_TXP_NV, INPUT_1V_T, OUTPUT_V, _C | _S },
+ { "UP2H", OPCODE_UP2H, INPUT_1S, OUTPUT_V, _C | _S },
+ { "UP2US", OPCODE_UP2US, INPUT_1S, OUTPUT_V, _C | _S },
+ { "UP4B", OPCODE_UP4B, INPUT_1S, OUTPUT_V, _C | _S },
+ { "UP4UB", OPCODE_UP4UB, INPUT_1S, OUTPUT_V, _C | _S },
+ { "X2D", OPCODE_X2D, INPUT_3V, OUTPUT_V, _R | _H | _C | _S },
+ { "PRINT", OPCODE_PRINT, INPUT_1V_S, OUTPUT_NONE, 0 },
+ { NULL, (enum prog_opcode) -1, 0, 0, 0 }
};
@@ -248,7 +248,7 @@ MatchInstruction(const GLubyte *token)
return result;
}
}
- result.opcode = (enum fp_opcode) -1;
+ result.opcode = (enum prog_opcode) -1;
return result;
}
@@ -668,7 +668,7 @@ Parse_SwizzleSuffix(const GLubyte *token, GLuint swizzle[4])
static GLboolean
Parse_CondCodeMask(struct parse_state *parseState,
- struct fp_dst_register *dstReg)
+ struct prog_dst_register *dstReg)
{
if (Parse_String(parseState, "EQ"))
dstReg->CondMask = COND_EQ;
@@ -865,7 +865,7 @@ Parse_OutputReg(struct parse_state *parseState, GLint *outputRegNum)
static GLboolean
Parse_MaskedDstReg(struct parse_state *parseState,
- struct fp_dst_register *dstReg)
+ struct prog_dst_register *dstReg)
{
GLubyte token[100];
GLint idx;
@@ -964,7 +964,7 @@ Parse_MaskedDstReg(struct parse_state *parseState,
*/
static GLboolean
Parse_VectorSrc(struct parse_state *parseState,
- struct fp_src_register *srcReg)
+ struct prog_src_register *srcReg)
{
GLfloat sign = 1.0F;
GLubyte token[100];
@@ -1087,7 +1087,7 @@ Parse_VectorSrc(struct parse_state *parseState,
static GLboolean
Parse_ScalarSrcReg(struct parse_state *parseState,
- struct fp_src_register *srcReg)
+ struct prog_src_register *srcReg)
{
GLubyte token[100];
GLfloat sign = 1.0F;
@@ -1198,7 +1198,7 @@ Parse_ScalarSrcReg(struct parse_state *parseState,
static GLboolean
Parse_PrintInstruction(struct parse_state *parseState,
- struct fp_instruction *inst)
+ struct prog_instruction *inst)
{
const GLubyte *str;
GLubyte *msg;
@@ -1251,15 +1251,15 @@ Parse_PrintInstruction(struct parse_state *parseState,
static GLboolean
Parse_InstructionSequence(struct parse_state *parseState,
- struct fp_instruction program[])
+ struct prog_instruction program[])
{
while (1) {
- struct fp_instruction *inst = program + parseState->numInst;
+ struct prog_instruction *inst = program + parseState->numInst;
struct instruction_pattern instMatch;
GLubyte token[100];
/* Initialize the instruction */
- _mesa_init_fp_instruction(inst);
+ _mesa_init_instruction(inst);
/* special instructions */
if (Parse_String(parseState, "DEFINE")) {
@@ -1301,7 +1301,7 @@ Parse_InstructionSequence(struct parse_state *parseState,
(const char *) id, value);
}
else if (Parse_String(parseState, "END")) {
- inst->Opcode = FP_OPCODE_END;
+ inst->Opcode = OPCODE_END;
inst->StringPos = parseState->curLine - parseState->start;
assert(inst->StringPos >= 0);
parseState->numInst++;
@@ -1328,7 +1328,7 @@ Parse_InstructionSequence(struct parse_state *parseState,
inst->Opcode = instMatch.opcode;
inst->Precision = instMatch.suffixes & (_R | _H | _X);
inst->Saturate = (instMatch.suffixes & (_S)) ? GL_TRUE : GL_FALSE;
- inst->UpdateCondRegister = (instMatch.suffixes & (_C)) ? GL_TRUE : GL_FALSE;
+ inst->CondUpdate = (instMatch.suffixes & (_C)) ? GL_TRUE : GL_FALSE;
inst->StringPos = parseState->curLine - parseState->start;
assert(inst->StringPos >= 0);
@@ -1342,7 +1342,7 @@ Parse_InstructionSequence(struct parse_state *parseState,
RETURN_ERROR1("Expected ,");
}
else if (instMatch.outputs == OUTPUT_NONE) {
- if (instMatch.opcode == FP_OPCODE_KIL_NV) {
+ if (instMatch.opcode == OPCODE_KIL_NV) {
/* This is a little weird, the cond code info is in
* the dest register.
*/
@@ -1350,7 +1350,7 @@ Parse_InstructionSequence(struct parse_state *parseState,
RETURN_ERROR;
}
else {
- ASSERT(instMatch.opcode == FP_OPCODE_PRINT);
+ ASSERT(instMatch.opcode == OPCODE_PRINT);
}
}
@@ -1402,7 +1402,7 @@ Parse_InstructionSequence(struct parse_state *parseState,
if (!Parse_TextureImageId(parseState, &unit, &idx))
RETURN_ERROR;
inst->TexSrcUnit = unit;
- inst->TexSrcIdx = idx;
+ inst->TexSrcTarget = idx;
}
else if (instMatch.inputs == INPUT_3V_T) {
GLubyte unit, idx;
@@ -1421,7 +1421,7 @@ Parse_InstructionSequence(struct parse_state *parseState,
if (!Parse_TextureImageId(parseState, &unit, &idx))
RETURN_ERROR;
inst->TexSrcUnit = unit;
- inst->TexSrcIdx = idx;
+ inst->TexSrcTarget = idx;
}
else if (instMatch.inputs == INPUT_1V_S) {
if (!Parse_PrintInstruction(parseState, inst))
@@ -1454,8 +1454,8 @@ _mesa_parse_nv_fragment_program(GLcontext *ctx, GLenum dstTarget,
struct fragment_program *program)
{
struct parse_state parseState;
- struct fp_instruction instBuffer[MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS];
- struct fp_instruction *newInst;
+ struct prog_instruction instBuffer[MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS];
+ struct prog_instruction *newInst;
GLenum target;
GLubyte *programString;
@@ -1519,14 +1519,14 @@ _mesa_parse_nv_fragment_program(GLcontext *ctx, GLenum dstTarget,
/* copy the compiled instructions */
assert(parseState.numInst <= MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS);
- newInst = (struct fp_instruction *)
- MALLOC(parseState.numInst * sizeof(struct fp_instruction));
+ newInst = (struct prog_instruction *)
+ MALLOC(parseState.numInst * sizeof(struct prog_instruction));
if (!newInst) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
return; /* out of memory */
}
MEMCPY(newInst, instBuffer,
- parseState.numInst * sizeof(struct fp_instruction));
+ parseState.numInst * sizeof(struct prog_instruction));
/* install the program */
program->Base.Target = target;
@@ -1568,7 +1568,7 @@ _mesa_parse_nv_fragment_program(GLcontext *ctx, GLenum dstTarget,
static void
PrintSrcReg(const struct fragment_program *program,
- const struct fp_src_register *src)
+ const struct prog_src_register *src)
{
static const char comps[5] = "xyzw";
@@ -1635,10 +1635,10 @@ PrintSrcReg(const struct fragment_program *program,
}
static void
-PrintTextureSrc(const struct fp_instruction *inst)
+PrintTextureSrc(const struct prog_instruction *inst)
{
_mesa_printf("TEX%d, ", inst->TexSrcUnit);
- switch (inst->TexSrcIdx) {
+ switch (inst->TexSrcTarget) {
case TEXTURE_1D_INDEX:
_mesa_printf("1D");
break;
@@ -1660,7 +1660,7 @@ PrintTextureSrc(const struct fp_instruction *inst)
}
static void
-PrintCondCode(const struct fp_dst_register *dst)
+PrintCondCode(const struct prog_dst_register *dst)
{
static const char *comps = "xyzw";
static const char *ccString[] = {
@@ -1684,7 +1684,7 @@ PrintCondCode(const struct fp_dst_register *dst)
static void
-PrintDstReg(const struct fp_dst_register *dst)
+PrintDstReg(const struct prog_dst_register *dst)
{
if (dst->File == PROGRAM_OUTPUT) {
_mesa_printf("o[%s]", OutputRegisters[dst->Index]);
@@ -1732,9 +1732,9 @@ PrintDstReg(const struct fp_dst_register *dst)
void
_mesa_print_nv_fragment_program(const struct fragment_program *program)
{
- const struct fp_instruction *inst;
+ const struct prog_instruction *inst;
- for (inst = program->Instructions; inst->Opcode != FP_OPCODE_END; inst++) {
+ for (inst = program->Instructions; inst->Opcode != OPCODE_END; inst++) {
int i;
for (i = 0; Instructions[i].name; i++) {
if (inst->Opcode == Instructions[i].opcode) {
@@ -1744,7 +1744,7 @@ _mesa_print_nv_fragment_program(const struct fragment_program *program)
_mesa_printf("H");
else if (inst->Precision == FIXED12)
_mesa_printf("X");
- if (inst->UpdateCondRegister)
+ if (inst->CondUpdate)
_mesa_printf("C");
if (inst->Saturate)
_mesa_printf("_SAT");
@@ -1818,24 +1818,3 @@ _mesa_nv_fragment_output_register_name(GLuint i)
ASSERT(i < MAX_NV_FRAGMENT_PROGRAM_OUTPUTS);
return OutputRegisters[i];
}
-
-
-/**
- * Initialize fragment program instruction fields to defaults.
- */
-void
-_mesa_init_fp_instruction(struct fp_instruction *inst)
-{
- _mesa_bzero(inst, sizeof(struct fp_instruction));
- inst->SrcReg[0].File = PROGRAM_UNDEFINED;
- inst->SrcReg[0].Swizzle = SWIZZLE_NOOP;
- inst->SrcReg[1].File = PROGRAM_UNDEFINED;
- inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;
- inst->SrcReg[2].File = PROGRAM_UNDEFINED;
- inst->SrcReg[2].Swizzle = SWIZZLE_NOOP;
- inst->DstReg.File = PROGRAM_UNDEFINED;
- inst->DstReg.WriteMask = WRITEMASK_XYZW;
- inst->DstReg.CondSwizzle = SWIZZLE_NOOP;
- inst->Precision = FLOAT32;
- inst->DstReg.CondMask = COND_TR;
-}
diff --git a/src/mesa/shader/nvfragprog.h b/src/mesa/shader/nvfragprog.h
deleted file mode 100644
index 8596ba08e1d..00000000000
--- a/src/mesa/shader/nvfragprog.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.5
- *
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-/* Private fragment program types and constants only used by files
- * related to fragment programs.
- *
- * XXX TO-DO: Rename this file "fragprog.h" since it's not NV-specific.
- */
-
-
-#ifndef NVFRAGPROG_H
-#define NVFRAGPROG_H
-
-#include "config.h"
-#include "mtypes.h"
-
-
-
-/* condition codes */
-#define COND_GT 1 /* greater than zero */
-#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 */
-
-
-/* instruction precision */
-#define FLOAT32 0x1
-#define FLOAT16 0x2
-#define FIXED12 0x4
-
-
-/* Fragment program instruction opcodes */
-enum fp_opcode {
- FP_OPCODE_ABS, /* ARB_f_p only */
- FP_OPCODE_ADD,
- FP_OPCODE_CMP, /* ARB_f_p only */
- FP_OPCODE_COS,
- FP_OPCODE_DDX, /* NV_f_p only */
- FP_OPCODE_DDY, /* NV_f_p only */
- FP_OPCODE_DP3,
- FP_OPCODE_DP4,
- FP_OPCODE_DPH, /* ARB_f_p only */
- FP_OPCODE_DST,
- FP_OPCODE_END, /* private opcode */
- FP_OPCODE_EX2,
- FP_OPCODE_FLR,
- FP_OPCODE_FRC,
- FP_OPCODE_KIL, /* ARB_f_p only */
- FP_OPCODE_KIL_NV, /* NV_f_p only */
- FP_OPCODE_LG2,
- FP_OPCODE_LIT,
- FP_OPCODE_LRP,
- FP_OPCODE_MAD,
- FP_OPCODE_MAX,
- FP_OPCODE_MIN,
- FP_OPCODE_MOV,
- FP_OPCODE_MUL,
- FP_OPCODE_PK2H, /* NV_f_p only */
- FP_OPCODE_PK2US, /* NV_f_p only */
- FP_OPCODE_PK4B, /* NV_f_p only */
- FP_OPCODE_PK4UB, /* NV_f_p only */
- FP_OPCODE_POW,
- FP_OPCODE_PRINT, /* Mesa only */
- FP_OPCODE_RCP,
- FP_OPCODE_RFL, /* NV_f_p only */
- FP_OPCODE_RSQ,
- FP_OPCODE_SCS, /* ARB_f_p only */
- FP_OPCODE_SEQ, /* NV_f_p only */
- FP_OPCODE_SFL, /* NV_f_p only */
- FP_OPCODE_SGE, /* NV_f_p only */
- FP_OPCODE_SGT, /* NV_f_p only */
- FP_OPCODE_SIN,
- FP_OPCODE_SLE, /* NV_f_p only */
- FP_OPCODE_SLT,
- FP_OPCODE_SNE, /* NV_f_p only */
- FP_OPCODE_STR, /* NV_f_p only */
- FP_OPCODE_SUB,
- FP_OPCODE_SWZ, /* ARB_f_p only */
- FP_OPCODE_TEX,
- FP_OPCODE_TXB, /* ARB_f_p only */
- FP_OPCODE_TXD, /* NV_f_p only */
- FP_OPCODE_TXP, /* ARB_f_p only */
- FP_OPCODE_TXP_NV, /* NV_f_p only */
- FP_OPCODE_UP2H, /* NV_f_p only */
- FP_OPCODE_UP2US, /* NV_f_p only */
- FP_OPCODE_UP4B, /* NV_f_p only */
- FP_OPCODE_UP4UB, /* NV_f_p only */
- FP_OPCODE_X2D, /* NV_f_p only - 2d mat mul */
- FP_OPCODE_XPD /* ARB_f_p only - cross product */
-};
-
-
-/* Instruction source register */
-struct fp_src_register
-{
- GLuint File:4;
- GLuint Index:8;
- GLuint Swizzle:12;
- GLuint NegateBase:4; /* ARB: negate/extended negate, per component.
- NV: negate before absolute value? */
- GLuint Abs:1; /* NV: take absolute value (all components) ? */
- GLuint NegateAbs:1; /* NV: negate (all components) after absolute value? */
-};
-
-
-/* Instruction destination register */
-struct fp_dst_register
-{
- GLuint File:4;
- GLuint Index:8;
- GLuint WriteMask:4;
- GLuint CondMask:4; /* NV: enough bits? */
- GLuint CondSwizzle:12; /* NV: enough bits? */
-};
-
-
-/* Fragment program instruction */
-struct fp_instruction
-{
- GLuint Opcode:6;
- GLuint Saturate:1;
- GLuint UpdateCondRegister:1; /* NV */
- GLuint Precision:2; /* NV: unused/unneeded? */
- GLuint TexSrcUnit:4; /* texture unit for TEX, TXD, TXP instructions */
- GLuint TexSrcIdx:3; /* TEXTURE_1D,2D,3D,CUBE,RECT_INDEX source target */
-
-#if FEATURE_MESA_program_debug
- GLint StringPos:15; /* enough bits? */
-#endif
-
- void *Data; /* some arbitrary data, only used for PRINT instruction now */
- struct fp_src_register SrcReg[3];
- struct fp_dst_register DstReg;
-};
-
-
-extern void
-_mesa_init_fp_instruction(struct fp_instruction *inst);
-
-
-#endif
diff --git a/src/mesa/shader/nvprogram.c b/src/mesa/shader/nvprogram.c
index 4b893017649..c85e7c00bd0 100644
--- a/src/mesa/shader/nvprogram.c
+++ b/src/mesa/shader/nvprogram.c
@@ -44,10 +44,9 @@
#include "macros.h"
#include "mtypes.h"
#include "nvfragparse.h"
-#include "nvfragprog.h"
+#include "program_instruction.h"
#include "nvvertexec.h"
#include "nvvertparse.h"
-#include "nvvertprog.h"
#include "nvprogram.h"
#include "program.h"
diff --git a/src/mesa/shader/nvvertexec.c b/src/mesa/shader/nvvertexec.c
index 1d7c7c72a14..5bb40d881e0 100644
--- a/src/mesa/shader/nvvertexec.c
+++ b/src/mesa/shader/nvvertexec.c
@@ -34,7 +34,7 @@
#include "macros.h"
#include "mtypes.h"
#include "nvvertexec.h"
-#include "nvvertprog.h"
+#include "program_instruction.h"
#include "program.h"
#include "math/m_matrix.h"
@@ -227,7 +227,7 @@ _mesa_dump_vp_state( const struct gl_vertex_program_state *state )
* source register.
*/
static INLINE const GLfloat *
-get_register_pointer( const struct vp_src_register *source,
+get_register_pointer( const struct prog_src_register *source,
const struct gl_vertex_program_state *state )
{
if (source->RelAddr) {
@@ -277,13 +277,13 @@ get_register_pointer( const struct vp_src_register *source,
* Apply swizzling and negating as needed.
*/
static INLINE void
-fetch_vector4( const struct vp_src_register *source,
+fetch_vector4( const struct prog_src_register *source,
const struct gl_vertex_program_state *state,
GLfloat result[4] )
{
const GLfloat *src = get_register_pointer(source, state);
- if (source->Negate) {
+ if (source->NegateBase) {
result[0] = -src[GET_SWZ(source->Swizzle, 0)];
result[1] = -src[GET_SWZ(source->Swizzle, 1)];
result[2] = -src[GET_SWZ(source->Swizzle, 2)];
@@ -303,13 +303,13 @@ fetch_vector4( const struct vp_src_register *source,
* As above, but only return result[0] element.
*/
static INLINE void
-fetch_vector1( const struct vp_src_register *source,
+fetch_vector1( const struct prog_src_register *source,
const struct gl_vertex_program_state *state,
GLfloat result[4] )
{
const GLfloat *src = get_register_pointer(source, state);
- if (source->Negate) {
+ if (source->NegateBase) {
result[0] = -src[GET_SWZ(source->Swizzle, 0)];
}
else {
@@ -322,7 +322,7 @@ fetch_vector1( const struct vp_src_register *source,
* Store 4 floats into a register.
*/
static void
-store_vector4( const struct vp_dst_register *dest,
+store_vector4( const struct prog_dst_register *dest,
struct gl_vertex_program_state *state,
const GLfloat value[4] )
{
@@ -382,7 +382,7 @@ void
_mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
{
struct gl_vertex_program_state *state = &ctx->VertexProgram;
- const struct vp_instruction *inst;
+ const struct prog_instruction *inst;
ctx->_CurrentProgram = GL_VERTEX_PROGRAM_ARB; /* or NV, doesn't matter */
@@ -407,14 +407,14 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
}
switch (inst->Opcode) {
- case VP_OPCODE_MOV:
+ case OPCODE_MOV:
{
GLfloat t[4];
fetch_vector4( &inst->SrcReg[0], state, t );
store_vector4( &inst->DstReg, state, t );
}
break;
- case VP_OPCODE_LIT:
+ case OPCODE_LIT:
{
const GLfloat epsilon = 1.0F / 256.0F; /* per NV spec */
GLfloat t[4], lit[4];
@@ -429,7 +429,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, lit );
}
break;
- case VP_OPCODE_RCP:
+ case OPCODE_RCP:
{
GLfloat t[4];
fetch_vector1( &inst->SrcReg[0], state, t );
@@ -439,7 +439,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, t );
}
break;
- case VP_OPCODE_RSQ:
+ case OPCODE_RSQ:
{
GLfloat t[4];
fetch_vector1( &inst->SrcReg[0], state, t );
@@ -448,7 +448,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, t );
}
break;
- case VP_OPCODE_EXP:
+ case OPCODE_EXP:
{
GLfloat t[4], q[4], floor_t0;
fetch_vector1( &inst->SrcReg[0], state, t );
@@ -477,7 +477,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, q );
}
break;
- case VP_OPCODE_LOG:
+ case OPCODE_LOG:
{
GLfloat t[4], q[4], abs_t0;
fetch_vector1( &inst->SrcReg[0], state, t );
@@ -514,7 +514,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, q );
}
break;
- case VP_OPCODE_MUL:
+ case OPCODE_MUL:
{
GLfloat t[4], u[4], prod[4];
fetch_vector4( &inst->SrcReg[0], state, t );
@@ -526,7 +526,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, prod );
}
break;
- case VP_OPCODE_ADD:
+ case OPCODE_ADD:
{
GLfloat t[4], u[4], sum[4];
fetch_vector4( &inst->SrcReg[0], state, t );
@@ -538,7 +538,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, sum );
}
break;
- case VP_OPCODE_DP3:
+ case OPCODE_DP3:
{
GLfloat t[4], u[4], dot[4];
fetch_vector4( &inst->SrcReg[0], state, t );
@@ -548,7 +548,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, dot );
}
break;
- case VP_OPCODE_DP4:
+ case OPCODE_DP4:
{
GLfloat t[4], u[4], dot[4];
fetch_vector4( &inst->SrcReg[0], state, t );
@@ -558,7 +558,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, dot );
}
break;
- case VP_OPCODE_DST:
+ case OPCODE_DST:
{
GLfloat t[4], u[4], dst[4];
fetch_vector4( &inst->SrcReg[0], state, t );
@@ -570,7 +570,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, dst );
}
break;
- case VP_OPCODE_MIN:
+ case OPCODE_MIN:
{
GLfloat t[4], u[4], min[4];
fetch_vector4( &inst->SrcReg[0], state, t );
@@ -582,7 +582,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, min );
}
break;
- case VP_OPCODE_MAX:
+ case OPCODE_MAX:
{
GLfloat t[4], u[4], max[4];
fetch_vector4( &inst->SrcReg[0], state, t );
@@ -594,7 +594,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, max );
}
break;
- case VP_OPCODE_SLT:
+ case OPCODE_SLT:
{
GLfloat t[4], u[4], slt[4];
fetch_vector4( &inst->SrcReg[0], state, t );
@@ -606,7 +606,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, slt );
}
break;
- case VP_OPCODE_SGE:
+ case OPCODE_SGE:
{
GLfloat t[4], u[4], sge[4];
fetch_vector4( &inst->SrcReg[0], state, t );
@@ -618,7 +618,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, sge );
}
break;
- case VP_OPCODE_MAD:
+ case OPCODE_MAD:
{
GLfloat t[4], u[4], v[4], sum[4];
fetch_vector4( &inst->SrcReg[0], state, t );
@@ -631,14 +631,14 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, sum );
}
break;
- case VP_OPCODE_ARL:
+ case OPCODE_ARL:
{
GLfloat t[4];
fetch_vector4( &inst->SrcReg[0], state, t );
state->AddressReg[0] = (GLint) FLOORF(t[0]);
}
break;
- case VP_OPCODE_DPH:
+ case OPCODE_DPH:
{
GLfloat t[4], u[4], dot[4];
fetch_vector4( &inst->SrcReg[0], state, t );
@@ -648,7 +648,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, dot );
}
break;
- case VP_OPCODE_RCC:
+ case OPCODE_RCC:
{
GLfloat t[4], u;
fetch_vector1( &inst->SrcReg[0], state, t );
@@ -676,7 +676,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, t );
}
break;
- case VP_OPCODE_SUB: /* GL_NV_vertex_program1_1 */
+ case OPCODE_SUB: /* GL_NV_vertex_program1_1 */
{
GLfloat t[4], u[4], sum[4];
fetch_vector4( &inst->SrcReg[0], state, t );
@@ -688,7 +688,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, sum );
}
break;
- case VP_OPCODE_ABS: /* GL_NV_vertex_program1_1 */
+ case OPCODE_ABS: /* GL_NV_vertex_program1_1 */
{
GLfloat t[4];
fetch_vector4( &inst->SrcReg[0], state, t );
@@ -699,7 +699,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, t );
}
break;
- case VP_OPCODE_FLR: /* GL_ARB_vertex_program */
+ case OPCODE_FLR: /* GL_ARB_vertex_program */
{
GLfloat t[4];
fetch_vector4( &inst->SrcReg[0], state, t );
@@ -710,7 +710,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, t );
}
break;
- case VP_OPCODE_FRC: /* GL_ARB_vertex_program */
+ case OPCODE_FRC: /* GL_ARB_vertex_program */
{
GLfloat t[4];
fetch_vector4( &inst->SrcReg[0], state, t );
@@ -721,7 +721,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, t );
}
break;
- case VP_OPCODE_EX2: /* GL_ARB_vertex_program */
+ case OPCODE_EX2: /* GL_ARB_vertex_program */
{
GLfloat t[4];
fetch_vector1( &inst->SrcReg[0], state, t );
@@ -729,7 +729,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, t );
}
break;
- case VP_OPCODE_LG2: /* GL_ARB_vertex_program */
+ case OPCODE_LG2: /* GL_ARB_vertex_program */
{
GLfloat t[4];
fetch_vector1( &inst->SrcReg[0], state, t );
@@ -737,7 +737,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, t );
}
break;
- case VP_OPCODE_POW: /* GL_ARB_vertex_program */
+ case OPCODE_POW: /* GL_ARB_vertex_program */
{
GLfloat t[4], u[4];
fetch_vector1( &inst->SrcReg[0], state, t );
@@ -746,7 +746,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, t );
}
break;
- case VP_OPCODE_XPD: /* GL_ARB_vertex_program */
+ case OPCODE_XPD: /* GL_ARB_vertex_program */
{
GLfloat t[4], u[4], cross[4];
fetch_vector4( &inst->SrcReg[0], state, t );
@@ -757,9 +757,9 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
store_vector4( &inst->DstReg, state, cross );
}
break;
- case VP_OPCODE_SWZ: /* GL_ARB_vertex_program */
+ case OPCODE_SWZ: /* GL_ARB_vertex_program */
{
- const struct vp_src_register *source = &inst->SrcReg[0];
+ const struct prog_src_register *source = &inst->SrcReg[0];
const GLfloat *src = get_register_pointer(source, state);
GLfloat result[4];
GLuint i;
@@ -772,13 +772,13 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
result[i] = 1.0;
else
result[i] = src[GET_SWZ(source->Swizzle, i)];
- if (source->Negate & (1 << i))
+ if (source->NegateBase & (1 << i))
result[i] = -result[i];
}
store_vector4( &inst->DstReg, state, result );
}
break;
- case VP_OPCODE_PRINT:
+ case OPCODE_PRINT:
if (inst->SrcReg[0].File) {
GLfloat t[4];
fetch_vector4( &inst->SrcReg[0], state, t );
@@ -789,7 +789,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
_mesa_printf("%s\n", (char *) inst->Data);
}
break;
- case VP_OPCODE_END:
+ case OPCODE_END:
ctx->_CurrentProgram = 0;
return;
default:
@@ -818,7 +818,7 @@ masking, relative addressing, etc. when they're not needed.
For example:
-void simple_add( struct vp_instruction *inst )
+void simple_add( struct prog_instruction *inst )
{
GLfloat *sum = machine->Registers[inst->DstReg.Register];
GLfloat *a = machine->Registers[inst->SrcReg[0].Register];
diff --git a/src/mesa/shader/nvvertparse.c b/src/mesa/shader/nvvertparse.c
index c36d43dd24e..d5b08def43a 100644
--- a/src/mesa/shader/nvvertparse.c
+++ b/src/mesa/shader/nvvertparse.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.3
+ * Version: 6.5
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -45,7 +45,7 @@
#include "mtypes.h"
#include "nvprogram.h"
#include "nvvertparse.h"
-#include "nvvertprog.h"
+#include "program_instruction.h"
#include "program.h"
@@ -293,7 +293,7 @@ static const char *OutputRegisters[MAX_NV_VERTEX_PROGRAM_OUTPUTS + 1] = {
"PSIZ", "BFC0", "BFC1", NULL
};
-/* NOTE: the order here must match opcodes in nvvertprog.h */
+/* NOTE: the order here must match opcodes in program_instruction.h */
static const char *Opcodes[] = {
"MOV", "LIT", "RCP", "RSQ", "EXP", "LOG", "MUL", "ADD", "DP3", "DP4",
"DST", "MIN", "MAX", "SLT", "SGE", "MAD", "ARL", "DPH", "RCC", "SUB",
@@ -393,7 +393,7 @@ Parse_AbsParamReg(struct parse_state *parseState, GLint *regNum)
static GLboolean
-Parse_ParamReg(struct parse_state *parseState, struct vp_src_register *srcReg)
+Parse_ParamReg(struct parse_state *parseState, struct prog_src_register *srcReg)
{
GLubyte token[100];
@@ -561,7 +561,7 @@ Parse_OutputReg(struct parse_state *parseState, GLint *outputRegNum)
static GLboolean
-Parse_MaskedDstReg(struct parse_state *parseState, struct vp_dst_register *dstReg)
+Parse_MaskedDstReg(struct parse_state *parseState, struct prog_dst_register *dstReg)
{
GLubyte token[100];
GLint idx;
@@ -642,7 +642,7 @@ Parse_MaskedDstReg(struct parse_state *parseState, struct vp_dst_register *dstRe
static GLboolean
-Parse_SwizzleSrcReg(struct parse_state *parseState, struct vp_src_register *srcReg)
+Parse_SwizzleSrcReg(struct parse_state *parseState, struct prog_src_register *srcReg)
{
GLubyte token[100];
GLint idx;
@@ -654,12 +654,12 @@ Parse_SwizzleSrcReg(struct parse_state *parseState, struct vp_src_register *srcR
RETURN_ERROR;
if (token[0] == '-') {
(void) Parse_String(parseState, "-");
- srcReg->Negate = GL_TRUE;
+ srcReg->NegateBase = GL_TRUE;
if (!Peek_Token(parseState, token))
RETURN_ERROR;
}
else {
- srcReg->Negate = GL_FALSE;
+ srcReg->NegateBase = GL_FALSE;
}
/* Src reg can be R<n>, c[n], c[n +/- offset], or a named vertex attrib */
@@ -733,7 +733,7 @@ Parse_SwizzleSrcReg(struct parse_state *parseState, struct vp_src_register *srcR
static GLboolean
-Parse_ScalarSrcReg(struct parse_state *parseState, struct vp_src_register *srcReg)
+Parse_ScalarSrcReg(struct parse_state *parseState, struct prog_src_register *srcReg)
{
GLubyte token[100];
GLint idx;
@@ -744,13 +744,13 @@ Parse_ScalarSrcReg(struct parse_state *parseState, struct vp_src_register *srcRe
if (!Peek_Token(parseState, token))
RETURN_ERROR;
if (token[0] == '-') {
- srcReg->Negate = GL_TRUE;
+ srcReg->NegateBase = GL_TRUE;
(void) Parse_String(parseState, "-"); /* consume '-' */
if (!Peek_Token(parseState, token))
RETURN_ERROR;
}
else {
- srcReg->Negate = GL_FALSE;
+ srcReg->NegateBase = GL_FALSE;
}
/* Src reg can be R<n>, c[n], c[n +/- offset], or a named vertex attrib */
@@ -803,9 +803,10 @@ Parse_ScalarSrcReg(struct parse_state *parseState, struct vp_src_register *srcRe
static GLint
Parse_UnaryOpInstruction(struct parse_state *parseState,
- struct vp_instruction *inst, enum vp_opcode opcode)
+ struct prog_instruction *inst,
+ enum prog_opcode opcode)
{
- if (opcode == VP_OPCODE_ABS && !parseState->isVersion1_1)
+ if (opcode == OPCODE_ABS && !parseState->isVersion1_1)
RETURN_ERROR1("ABS illegal for vertex program 1.0");
inst->Opcode = opcode;
@@ -833,11 +834,12 @@ Parse_UnaryOpInstruction(struct parse_state *parseState,
static GLboolean
Parse_BiOpInstruction(struct parse_state *parseState,
- struct vp_instruction *inst, enum vp_opcode opcode)
+ struct prog_instruction *inst,
+ enum prog_opcode opcode)
{
- if (opcode == VP_OPCODE_DPH && !parseState->isVersion1_1)
+ if (opcode == OPCODE_DPH && !parseState->isVersion1_1)
RETURN_ERROR1("DPH illegal for vertex program 1.0");
- if (opcode == VP_OPCODE_SUB && !parseState->isVersion1_1)
+ if (opcode == OPCODE_SUB && !parseState->isVersion1_1)
RETURN_ERROR1("SUB illegal for vertex program 1.0");
inst->Opcode = opcode;
@@ -885,7 +887,8 @@ Parse_BiOpInstruction(struct parse_state *parseState,
static GLboolean
Parse_TriOpInstruction(struct parse_state *parseState,
- struct vp_instruction *inst, enum vp_opcode opcode)
+ struct prog_instruction *inst,
+ enum prog_opcode opcode)
{
inst->Opcode = opcode;
inst->StringPos = parseState->curLine - parseState->start;
@@ -952,9 +955,10 @@ Parse_TriOpInstruction(struct parse_state *parseState,
static GLboolean
Parse_ScalarInstruction(struct parse_state *parseState,
- struct vp_instruction *inst, enum vp_opcode opcode)
+ struct prog_instruction *inst,
+ enum prog_opcode opcode)
{
- if (opcode == VP_OPCODE_RCC && !parseState->isVersion1_1)
+ if (opcode == OPCODE_RCC && !parseState->isVersion1_1)
RETURN_ERROR1("RCC illegal for vertex program 1.0");
inst->Opcode = opcode;
@@ -981,9 +985,9 @@ Parse_ScalarInstruction(struct parse_state *parseState,
static GLboolean
-Parse_AddressInstruction(struct parse_state *parseState, struct vp_instruction *inst)
+Parse_AddressInstruction(struct parse_state *parseState, struct prog_instruction *inst)
{
- inst->Opcode = VP_OPCODE_ARL;
+ inst->Opcode = OPCODE_ARL;
inst->StringPos = parseState->curLine - parseState->start;
/* dest A0 reg */
@@ -1007,11 +1011,11 @@ Parse_AddressInstruction(struct parse_state *parseState, struct vp_instruction *
static GLboolean
-Parse_EndInstruction(struct parse_state *parseState, struct vp_instruction *inst)
+Parse_EndInstruction(struct parse_state *parseState, struct prog_instruction *inst)
{
GLubyte token[100];
- inst->Opcode = VP_OPCODE_END;
+ inst->Opcode = OPCODE_END;
inst->StringPos = parseState->curLine - parseState->start;
/* this should fail! */
@@ -1036,16 +1040,16 @@ Parse_EndInstruction(struct parse_state *parseState, struct vp_instruction *inst
* | "PRINT" <string literal> "," <dstReg>
*/
static GLboolean
-Parse_PrintInstruction(struct parse_state *parseState, struct vp_instruction *inst)
+Parse_PrintInstruction(struct parse_state *parseState, struct prog_instruction *inst)
{
const GLubyte *str;
GLubyte *msg;
GLuint len;
GLubyte token[100];
- struct vp_src_register *srcReg = &inst->SrcReg[0];
+ struct prog_src_register *srcReg = &inst->SrcReg[0];
GLint idx;
- inst->Opcode = VP_OPCODE_PRINT;
+ inst->Opcode = OPCODE_PRINT;
inst->StringPos = parseState->curLine - parseState->start;
/* The first argument is a literal string 'just like this' */
@@ -1070,7 +1074,7 @@ Parse_PrintInstruction(struct parse_state *parseState, struct vp_instruction *in
RETURN_ERROR;
srcReg->RelAddr = GL_FALSE;
- srcReg->Negate = GL_FALSE;
+ srcReg->NegateBase = GL_FALSE;
srcReg->Swizzle = SWIZZLE_NOOP;
/* Register can be R<n>, c[n], c[n +/- offset], a named vertex attrib,
@@ -1117,7 +1121,7 @@ Parse_PrintInstruction(struct parse_state *parseState, struct vp_instruction *in
static GLboolean
Parse_OptionSequence(struct parse_state *parseState,
- struct vp_instruction program[])
+ struct prog_instruction program[])
{
(void) program;
while (1) {
@@ -1137,92 +1141,92 @@ Parse_OptionSequence(struct parse_state *parseState,
static GLboolean
Parse_InstructionSequence(struct parse_state *parseState,
- struct vp_instruction program[])
+ struct prog_instruction program[])
{
while (1) {
- struct vp_instruction *inst = program + parseState->numInst;
+ struct prog_instruction *inst = program + parseState->numInst;
/* Initialize the instruction */
- _mesa_init_vp_instruction(inst);
+ _mesa_init_instruction(inst);
if (Parse_String(parseState, "MOV")) {
- if (!Parse_UnaryOpInstruction(parseState, inst, VP_OPCODE_MOV))
+ if (!Parse_UnaryOpInstruction(parseState, inst, OPCODE_MOV))
RETURN_ERROR;
}
else if (Parse_String(parseState, "LIT")) {
- if (!Parse_UnaryOpInstruction(parseState, inst, VP_OPCODE_LIT))
+ if (!Parse_UnaryOpInstruction(parseState, inst, OPCODE_LIT))
RETURN_ERROR;
}
else if (Parse_String(parseState, "ABS")) {
- if (!Parse_UnaryOpInstruction(parseState, inst, VP_OPCODE_ABS))
+ if (!Parse_UnaryOpInstruction(parseState, inst, OPCODE_ABS))
RETURN_ERROR;
}
else if (Parse_String(parseState, "MUL")) {
- if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_MUL))
+ if (!Parse_BiOpInstruction(parseState, inst, OPCODE_MUL))
RETURN_ERROR;
}
else if (Parse_String(parseState, "ADD")) {
- if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_ADD))
+ if (!Parse_BiOpInstruction(parseState, inst, OPCODE_ADD))
RETURN_ERROR;
}
else if (Parse_String(parseState, "DP3")) {
- if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_DP3))
+ if (!Parse_BiOpInstruction(parseState, inst, OPCODE_DP3))
RETURN_ERROR;
}
else if (Parse_String(parseState, "DP4")) {
- if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_DP4))
+ if (!Parse_BiOpInstruction(parseState, inst, OPCODE_DP4))
RETURN_ERROR;
}
else if (Parse_String(parseState, "DST")) {
- if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_DST))
+ if (!Parse_BiOpInstruction(parseState, inst, OPCODE_DST))
RETURN_ERROR;
}
else if (Parse_String(parseState, "MIN")) {
- if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_MIN))
+ if (!Parse_BiOpInstruction(parseState, inst, OPCODE_MIN))
RETURN_ERROR;
}
else if (Parse_String(parseState, "MAX")) {
- if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_MAX))
+ if (!Parse_BiOpInstruction(parseState, inst, OPCODE_MAX))
RETURN_ERROR;
}
else if (Parse_String(parseState, "SLT")) {
- if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_SLT))
+ if (!Parse_BiOpInstruction(parseState, inst, OPCODE_SLT))
RETURN_ERROR;
}
else if (Parse_String(parseState, "SGE")) {
- if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_SGE))
+ if (!Parse_BiOpInstruction(parseState, inst, OPCODE_SGE))
RETURN_ERROR;
}
else if (Parse_String(parseState, "DPH")) {
- if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_DPH))
+ if (!Parse_BiOpInstruction(parseState, inst, OPCODE_DPH))
RETURN_ERROR;
}
else if (Parse_String(parseState, "SUB")) {
- if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_SUB))
+ if (!Parse_BiOpInstruction(parseState, inst, OPCODE_SUB))
RETURN_ERROR;
}
else if (Parse_String(parseState, "MAD")) {
- if (!Parse_TriOpInstruction(parseState, inst, VP_OPCODE_MAD))
+ if (!Parse_TriOpInstruction(parseState, inst, OPCODE_MAD))
RETURN_ERROR;
}
else if (Parse_String(parseState, "RCP")) {
- if (!Parse_ScalarInstruction(parseState, inst, VP_OPCODE_RCP))
+ if (!Parse_ScalarInstruction(parseState, inst, OPCODE_RCP))
RETURN_ERROR;
}
else if (Parse_String(parseState, "RSQ")) {
- if (!Parse_ScalarInstruction(parseState, inst, VP_OPCODE_RSQ))
+ if (!Parse_ScalarInstruction(parseState, inst, OPCODE_RSQ))
RETURN_ERROR;
}
else if (Parse_String(parseState, "EXP")) {
- if (!Parse_ScalarInstruction(parseState, inst, VP_OPCODE_EXP))
+ if (!Parse_ScalarInstruction(parseState, inst, OPCODE_EXP))
RETURN_ERROR;
}
else if (Parse_String(parseState, "LOG")) {
- if (!Parse_ScalarInstruction(parseState, inst, VP_OPCODE_LOG))
+ if (!Parse_ScalarInstruction(parseState, inst, OPCODE_LOG))
RETURN_ERROR;
}
else if (Parse_String(parseState, "RCC")) {
- if (!Parse_ScalarInstruction(parseState, inst, VP_OPCODE_RCC))
+ if (!Parse_ScalarInstruction(parseState, inst, OPCODE_RCC))
RETURN_ERROR;
}
else if (Parse_String(parseState, "ARL")) {
@@ -1271,7 +1275,7 @@ Parse_InstructionSequence(struct parse_state *parseState,
static GLboolean
Parse_Program(struct parse_state *parseState,
- struct vp_instruction instBuffer[])
+ struct prog_instruction instBuffer[])
{
if (parseState->isVersion1_1) {
if (!Parse_OptionSequence(parseState, instBuffer)) {
@@ -1293,8 +1297,8 @@ _mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum dstTarget,
struct vertex_program *program)
{
struct parse_state parseState;
- struct vp_instruction instBuffer[MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS];
- struct vp_instruction *newInst;
+ struct prog_instruction instBuffer[MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS];
+ struct prog_instruction *newInst;
GLenum target;
GLubyte *programString;
@@ -1374,15 +1378,15 @@ _mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum dstTarget,
/* copy the compiled instructions */
assert(parseState.numInst <= MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS);
- newInst = (struct vp_instruction *)
- MALLOC(parseState.numInst * sizeof(struct vp_instruction));
+ newInst = (struct prog_instruction *)
+ MALLOC(parseState.numInst * sizeof(struct prog_instruction));
if (!newInst) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
FREE(programString);
return; /* out of memory */
}
MEMCPY(newInst, instBuffer,
- parseState.numInst * sizeof(struct vp_instruction));
+ parseState.numInst * sizeof(struct prog_instruction));
/* install the program */
program->Base.Target = target;
@@ -1419,10 +1423,10 @@ _mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum dstTarget,
static void
-PrintSrcReg(const struct vp_src_register *src)
+PrintSrcReg(const struct prog_src_register *src)
{
static const char comps[5] = "xyzw";
- if (src->Negate)
+ if (src->NegateBase)
_mesa_printf("-");
if (src->RelAddr) {
if (src->Index > 0)
@@ -1462,7 +1466,7 @@ PrintSrcReg(const struct vp_src_register *src)
static void
-PrintDstReg(const struct vp_dst_register *dst)
+PrintDstReg(const struct prog_dst_register *dst)
{
if (dst->File == PROGRAM_OUTPUT) {
_mesa_printf("o[%s]", OutputRegisters[dst->Index]);
@@ -1496,34 +1500,34 @@ PrintDstReg(const struct vp_dst_register *dst)
* Print a single NVIDIA vertex program instruction.
*/
void
-_mesa_print_nv_vertex_instruction(const struct vp_instruction *inst)
+_mesa_print_nv_vertex_instruction(const struct prog_instruction *inst)
{
switch (inst->Opcode) {
- case VP_OPCODE_MOV:
- case VP_OPCODE_LIT:
- case VP_OPCODE_RCP:
- case VP_OPCODE_RSQ:
- case VP_OPCODE_EXP:
- case VP_OPCODE_LOG:
- case VP_OPCODE_RCC:
- case VP_OPCODE_ABS:
+ case OPCODE_MOV:
+ case OPCODE_LIT:
+ case OPCODE_RCP:
+ case OPCODE_RSQ:
+ case OPCODE_EXP:
+ case OPCODE_LOG:
+ case OPCODE_RCC:
+ case OPCODE_ABS:
_mesa_printf("%s ", Opcodes[(int) inst->Opcode]);
PrintDstReg(&inst->DstReg);
_mesa_printf(", ");
PrintSrcReg(&inst->SrcReg[0]);
_mesa_printf(";\n");
break;
- case VP_OPCODE_MUL:
- case VP_OPCODE_ADD:
- case VP_OPCODE_DP3:
- case VP_OPCODE_DP4:
- case VP_OPCODE_DST:
- case VP_OPCODE_MIN:
- case VP_OPCODE_MAX:
- case VP_OPCODE_SLT:
- case VP_OPCODE_SGE:
- case VP_OPCODE_DPH:
- case VP_OPCODE_SUB:
+ case OPCODE_MUL:
+ case OPCODE_ADD:
+ case OPCODE_DP3:
+ case OPCODE_DP4:
+ case OPCODE_DST:
+ case OPCODE_MIN:
+ case OPCODE_MAX:
+ case OPCODE_SLT:
+ case OPCODE_SGE:
+ case OPCODE_DPH:
+ case OPCODE_SUB:
_mesa_printf("%s ", Opcodes[(int) inst->Opcode]);
PrintDstReg(&inst->DstReg);
_mesa_printf(", ");
@@ -1532,7 +1536,7 @@ _mesa_print_nv_vertex_instruction(const struct vp_instruction *inst)
PrintSrcReg(&inst->SrcReg[1]);
_mesa_printf(";\n");
break;
- case VP_OPCODE_MAD:
+ case OPCODE_MAD:
_mesa_printf("MAD ");
PrintDstReg(&inst->DstReg);
_mesa_printf(", ");
@@ -1543,12 +1547,12 @@ _mesa_print_nv_vertex_instruction(const struct vp_instruction *inst)
PrintSrcReg(&inst->SrcReg[2]);
_mesa_printf(";\n");
break;
- case VP_OPCODE_ARL:
+ case OPCODE_ARL:
_mesa_printf("ARL A0.x, ");
PrintSrcReg(&inst->SrcReg[0]);
_mesa_printf(";\n");
break;
- case VP_OPCODE_PRINT:
+ case OPCODE_PRINT:
_mesa_printf("PRINT '%s'", inst->Data);
if (inst->SrcReg[0].File) {
_mesa_printf(", ");
@@ -1559,7 +1563,7 @@ _mesa_print_nv_vertex_instruction(const struct vp_instruction *inst)
_mesa_printf("\n");
}
break;
- case VP_OPCODE_END:
+ case OPCODE_END:
_mesa_printf("END\n");
break;
default:
@@ -1574,11 +1578,11 @@ _mesa_print_nv_vertex_instruction(const struct vp_instruction *inst)
void
_mesa_print_nv_vertex_program(const struct vertex_program *program)
{
- const struct vp_instruction *inst;
+ const struct prog_instruction *inst;
for (inst = program->Instructions; ; inst++) {
_mesa_print_nv_vertex_instruction(inst);
- if (inst->Opcode == VP_OPCODE_END)
+ if (inst->Opcode == OPCODE_END)
return;
}
}
@@ -1601,19 +1605,24 @@ _mesa_nv_vertex_output_register_name(GLuint i)
/**
- * Initialize vertex program instruction fields to defaults.
+ * Initialize program instruction fields to defaults.
*/
void
-_mesa_init_vp_instruction(struct vp_instruction *inst)
+_mesa_init_instruction(struct prog_instruction *inst)
{
- _mesa_bzero(inst, sizeof(struct vp_instruction));
+ _mesa_bzero(inst, sizeof(struct prog_instruction));
+
inst->SrcReg[0].File = PROGRAM_UNDEFINED;
inst->SrcReg[0].Swizzle = SWIZZLE_NOOP;
inst->SrcReg[1].File = PROGRAM_UNDEFINED;
inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;
inst->SrcReg[2].File = PROGRAM_UNDEFINED;
inst->SrcReg[2].Swizzle = SWIZZLE_NOOP;
+
inst->DstReg.File = PROGRAM_UNDEFINED;
inst->DstReg.WriteMask = WRITEMASK_XYZW;
+ inst->DstReg.CondMask = COND_TR;
+ inst->DstReg.CondSwizzle = SWIZZLE_NOOP;
+
+ inst->Precision = FLOAT32;
}
-
diff --git a/src/mesa/shader/nvvertparse.h b/src/mesa/shader/nvvertparse.h
index 205885f45c3..d78d9fa1370 100644
--- a/src/mesa/shader/nvvertparse.h
+++ b/src/mesa/shader/nvvertparse.h
@@ -36,7 +36,7 @@ _mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum target,
struct vertex_program *program);
extern void
-_mesa_print_nv_vertex_instruction(const struct vp_instruction *inst);
+_mesa_print_nv_vertex_instruction(const struct prog_instruction *inst);
extern void
_mesa_print_nv_vertex_program(const struct vertex_program *program);
diff --git a/src/mesa/shader/nvvertprog.h b/src/mesa/shader/nvvertprog.h
deleted file mode 100644
index 994a324f8fc..00000000000
--- a/src/mesa/shader/nvvertprog.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.3.1
- *
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-/* Private vertex program types and constants only used by files
- * related to vertex programs.
- *
- * XXX TO-DO: Rename this file "vertprog.h" since it's not NV-specific.
- */
-
-
-#ifndef NVVERTPROG_H
-#define NVVERTPROG_H
-
-
-/* Vertex program opcodes */
-enum vp_opcode
-{
- VP_OPCODE_ABS,
- VP_OPCODE_ADD,
- VP_OPCODE_ARL,
- VP_OPCODE_DP3,
- VP_OPCODE_DP4,
- VP_OPCODE_DPH,
- VP_OPCODE_DST,
- VP_OPCODE_END, /* Placeholder */
- VP_OPCODE_EX2, /* ARB only */
- VP_OPCODE_EXP,
- VP_OPCODE_FLR, /* ARB */
- VP_OPCODE_FRC, /* ARB */
- VP_OPCODE_LG2, /* ARB only */
- VP_OPCODE_LIT,
- VP_OPCODE_LOG,
- VP_OPCODE_MAD,
- VP_OPCODE_MAX,
- VP_OPCODE_MIN,
- VP_OPCODE_MOV,
- VP_OPCODE_MUL,
- VP_OPCODE_POW, /* ARB only */
- VP_OPCODE_PRINT, /* Mesa only */
- VP_OPCODE_RCC,
- VP_OPCODE_RCP,
- VP_OPCODE_RSQ,
- VP_OPCODE_SGE,
- VP_OPCODE_SLT,
- VP_OPCODE_SUB,
- VP_OPCODE_SWZ, /* ARB only */
- VP_OPCODE_XPD, /* ARB only */
-
- VP_MAX_OPCODE
-};
-
-
-
-/* Instruction source register */
-struct vp_src_register
-{
- GLuint File:4; /* one of the PROGRAM_* register file values */
- GLint Index:9; /* may be negative for relative addressing */
- GLuint Swizzle:12;
- GLuint Negate:4; /* ARB requires component-wise negation. */
- GLuint RelAddr:1;
- GLuint pad:2;
-};
-
-
-/* Instruction destination register */
-struct vp_dst_register
-{
- GLuint File:4; /* one of the PROGRAM_* register file values */
- GLuint Index:8;
- GLuint WriteMask:4;
- GLuint pad:16;
-};
-
-
-/* Vertex program instruction */
-struct vp_instruction
-{
- GLshort Opcode;
-#if FEATURE_MESA_program_debug
- GLshort StringPos;
-#endif
- void *Data; /* some arbitrary data, only used for PRINT instruction now */
- struct vp_src_register SrcReg[3];
- struct vp_dst_register DstReg;
-};
-
-
-extern void
-_mesa_init_vp_instruction(struct vp_instruction *inst);
-
-
-#endif /* VERTPROG_H */
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c
index b4ac8f51d45..4b8817876df 100644
--- a/src/mesa/shader/program.c
+++ b/src/mesa/shader/program.c
@@ -37,9 +37,8 @@
#include "mtypes.h"
#include "program.h"
#include "nvfragparse.h"
-#include "nvfragprog.h"
+#include "program_instruction.h"
#include "nvvertparse.h"
-#include "nvvertprog.h"
#include "atifragshader.h"
diff --git a/src/mesa/shader/program_instruction.h b/src/mesa/shader/program_instruction.h
new file mode 100644
index 00000000000..80dbd16a90d
--- /dev/null
+++ b/src/mesa/shader/program_instruction.h
@@ -0,0 +1,344 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file prog_instruction.h
+ *
+ * Private vertex program types and constants only used by files
+ * related to vertex programs.
+ *
+ * \author Brian Paul
+ * \author Keith Whitwell
+ * \author Ian Romanick <[email protected]>
+ */
+
+
+#ifndef PROG_INSTRUCTION_H
+#define PROG_INSTRUCTION_H
+
+/**
+ * Condition codes for GL_NV_fragment_program
+ */
+/*@{*/
+#define COND_GT 1 /* greater than zero */
+#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 */
+/*@}*/
+
+
+/*
+ * Instruction precision for GL_NV_fragment_program
+ */
+/*@{*/
+#define FLOAT32 0x1
+#define FLOAT16 0x2
+#define FIXED12 0x4
+/*@}*/
+
+
+/**
+ * Program instruction opcodes, for both vertex and fragment programs.
+ * \note changes to this opcode list must be reflected in t_vb_arbprogram.c
+ */
+ /* ARB_vp ARB_fp NV_vp NV_fp */
+enum prog_opcode { /*---------------------------------*/
+ OPCODE_ABS, /* X 1.1 */
+ OPCODE_ADD, /* X X X X */
+ OPCODE_ARL, /* X X */
+ OPCODE_CMP, /* X */
+ OPCODE_COS, /* X 2 */
+ OPCODE_DDX, /* X */
+ OPCODE_DDY, /* X */
+ OPCODE_DP3, /* X X X X */
+ OPCODE_DP4, /* X X X X */
+ OPCODE_DPH, /* X X 1.1 */
+ OPCODE_DST, /* X X X */
+ OPCODE_END, /* X X X X */
+ OPCODE_EX2, /* X X 2 X */
+ OPCODE_EXP, /* X X */
+ OPCODE_FLR, /* X X 2 X */
+ OPCODE_FRC, /* X X 2 X */
+ OPCODE_KIL, /* X */
+ OPCODE_KIL_NV, /* X */
+ OPCODE_LG2, /* X X 2 X */
+ OPCODE_LIT, /* X X X X */
+ OPCODE_LOG, /* X X X */
+ OPCODE_LRP, /* X X */
+ OPCODE_MAD, /* X X X X */
+ OPCODE_MAX, /* X X X X */
+ OPCODE_MIN, /* X X X X */
+ OPCODE_MOV, /* X X X X */
+ OPCODE_MUL, /* X X X X */
+ OPCODE_PK2H, /* X */
+ OPCODE_PK2US, /* X */
+ OPCODE_PK4B, /* X */
+ OPCODE_PK4UB, /* X */
+ OPCODE_POW, /* X X X */
+ OPCODE_PRINT, /* X X */
+ OPCODE_RCC, /* 1.1 */
+ OPCODE_RCP, /* X X X X */
+ OPCODE_RFL, /* X X */
+ OPCODE_RSQ, /* X X X X */
+ OPCODE_SCS, /* X */
+ OPCODE_SEQ, /* 2 X */
+ OPCODE_SFL, /* 2 X */
+ OPCODE_SGE, /* X X X X */
+ OPCODE_SGT, /* 2 X */
+ OPCODE_SIN, /* X 2 X */
+ OPCODE_SLE, /* 2 X */
+ OPCODE_SLT, /* X X X X */
+ OPCODE_SNE, /* 2 X */
+ OPCODE_STR, /* X 2 X */
+ OPCODE_SUB, /* X X 1.1 X */
+ OPCODE_SWZ, /* X X */
+ OPCODE_TEX, /* X X */
+ OPCODE_TXB, /* X */
+ OPCODE_TXD, /* X X */
+ OPCODE_TXP, /* X */
+ OPCODE_TXP_NV, /* X */
+ OPCODE_UP2H, /* X */
+ OPCODE_UP2US, /* X */
+ OPCODE_UP4B, /* X */
+ OPCODE_UP4UB, /* X */
+ OPCODE_X2D, /* X */
+ OPCODE_XPD, /* X X */
+#if 0
+ OPCODE_ARA, /* NV_vertex_program2 */
+ OPCODE_ARL_NV, /* NV_vertex_program2 */
+ OPCODE_ARR, /* NV_vertex_program2 */
+
+ OPCODE_SEQ, /* NV_vertex_program2 */
+ OPCODE_SFL, /* NV_vertex_program2 */
+ OPCODE_SGT, /* NV_vertex_program2 */
+ OPCODE_SLE, /* NV_vertex_program2 */
+ OPCODE_SNE, /* NV_vertex_program2 */
+ OPCODE_STR, /* NV_vertex_program2 */
+
+ OPCODE_SSG, /* NV_vertex_program2 */
+ OPCODE_COS, /* NV_vertex_program2 */
+ OPCODE_SIN, /* NV_vertex_program2 */
+
+ OPCODE_BRA, /* NV_vertex_program2 */
+ OPCODE_CAL, /* NV_vertex_program2 */
+ OPCODE_RET, /* NV_vertex_program2 */
+
+ OPCODE_PUSHA, /* NV_vertex_program3 */
+ OPCODE_POPA, /* NV_vertex_program3 */
+
+ OPCODE_TEX, /* NV_vertex_program3 */
+ OPCODE_TXB, /* NV_vertex_program3 */
+ OPCODE_TXL, /* NV_vertex_program3 */
+ OPCODE_TXP, /* NV_vertex_program3 */
+#endif
+ MAX_OPCODE
+};
+
+
+/**
+ * Instruction source register.
+ */
+struct prog_src_register
+{
+ GLuint File:4; /**< One of the PROGRAM_* register file values. */
+ GLint Index:9; /**< May be negative for relative addressing. */
+ GLuint Swizzle:12;
+ GLuint RelAddr:1;
+
+ /**
+ * \name Source register "sign" control.
+ *
+ * The ARB and NV extensions allow varrying degrees of control over the
+ * sign of the source vector components. These values allow enough control
+ * for all flavors of the extensions.
+ */
+ /*@{*/
+ /**
+ * Per-component negation for the SWZ instruction.
+ *
+ * \since
+ * ARB_vertex_program, ARB_fragment_program
+ */
+ GLuint NegateBase:4;
+
+ /**
+ * Take the component-wise absolute value.
+ *
+ * \since
+ * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2,
+ * NV_vertex_program2_option.
+ */
+ GLuint Abs:1;
+
+ /**
+ * Take the component-wise negation. The negation occurs \b after the
+ * (optional) absolute value operation.
+ */
+ GLuint NegateAbs:1;
+ /*@}*/
+};
+
+
+/**
+ * Instruction destination register.
+ */
+struct prog_dst_register
+{
+ /**
+ * One of the PROGRAM_* register file values.
+ */
+ GLuint File:4;
+
+ GLuint Index:8;
+ GLuint WriteMask:4;
+
+ /**
+ * \name Conditional destination update control.
+ *
+ * \since
+ * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2,
+ * NV_vertex_program2_option.
+ */
+ /*@{*/
+ /**
+ * Takes one of the 9 possible condition values (EQ, FL, GT, GE, LE, LT,
+ * NE, TR, or UN). Destination update is enabled if the matching
+ * (swizzled) condition code value passes. When a conditional update mask
+ * is not specified, this will be \c COND_TR.
+ */
+ GLuint CondMask:4;
+
+ /**
+ * Condition code swizzle value.
+ */
+ GLuint CondSwizzle:12;
+
+ /**
+ * Selects the condition code register to use for conditional destination
+ * update masking. In NV_fragmnet_program or NV_vertex_program2 mode, only
+ * condition code register 0 is available. In NV_vertex_program3 mode,
+ * condition code registers 0 and 1 are available.
+ */
+ GLuint CondSrc:1;
+ /*@}*/
+
+ GLuint pad:31;
+};
+
+
+/**
+ * Vertex/fragment program instruction.
+ */
+struct prog_instruction
+{
+ enum prog_opcode Opcode;
+#if FEATURE_MESA_program_debug
+ GLshort StringPos;
+#endif
+ /**
+ * Arbitrary data. Used for the PRINT, CAL, and BRA instructions.
+ */
+ void *Data;
+
+ struct prog_src_register SrcReg[3];
+ struct prog_dst_register DstReg;
+
+ /**
+ * Indicates that the instruction should update the condition code
+ * register.
+ *
+ * \since
+ * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2,
+ * NV_vertex_program2_option.
+ */
+ GLuint CondUpdate:1;
+
+ /**
+ * If prog_instruction::cc_update is \c GL_TRUE, this value selects the
+ * condition code register that is to be updated.
+ *
+ * In GL_NV_fragment_program or GL_NV_vertex_program2 mode, only condition
+ * code register 0 is available. In GL_NV_vertex_program3 mode, condition code registers
+ * 0 and 1 are available.
+ *
+ * \since
+ * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2,
+ * NV_vertex_program2_option.
+ */
+ GLuint CondDst:1;
+
+ /**
+ * Saturate each value of the vectored result to the range [0,1] or the
+ * range [-1,1]. \c SSAT mode (i.e., saturation to the range [-1,1]) is
+ * only available in NV_fragment_program2 mode.
+ *
+ * \since
+ * NV_fragment_program, NV_fragment_program_option, NV_vertex_program3.
+ */
+ GLuint Saturate:2;
+
+ /**
+ * Per-instruction selectable precision.
+ *
+ * \since
+ * NV_fragment_program, NV_fragment_program_option.
+ */
+ GLuint Precision:3;
+
+ /**
+ * \name Texture source controls.
+ *
+ * The texture source controls are only used with the \c TEX, \c TXD,
+ * \c TXL, and \c TXP instructions.
+ *
+ * \since
+ * ARB_fragment_program, NV_fragment_program, NV_vertex_program3.
+ */
+ /*@{*/
+ /**
+ * Source texture unit. OpenGL supports a maximum of 32 texture
+ * units.
+ */
+ GLuint TexSrcUnit:5;
+
+ /**
+ * Source texture target (e.g., GL_TEXTURE_1D, GL_TEXTURE_2D,
+ * GL_TEXTURE_3D, GL_TEXTURE_CUBE, GL_TEXTURE_RECTANGLE_ARB).
+ */
+ GLuint TexSrcTarget:3;
+ /*@}*/
+};
+
+
+extern void
+_mesa_init_instruction(struct prog_instruction *inst);
+
+
+#endif /* PROG_INSTRUCTION_H */